babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457
  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. private _extensions;
  7722. private _textureMatrix;
  7723. private _format;
  7724. private _createPolynomials;
  7725. /** @hidden */
  7726. _prefiltered: boolean;
  7727. /**
  7728. * Creates a cube texture from an array of image urls
  7729. * @param files defines an array of image urls
  7730. * @param scene defines the hosting scene
  7731. * @param noMipmap specifies if mip maps are not used
  7732. * @returns a cube texture
  7733. */
  7734. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7735. /**
  7736. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7737. * @param url defines the url of the prefiltered texture
  7738. * @param scene defines the scene the texture is attached to
  7739. * @param forcedExtension defines the extension of the file if different from the url
  7740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7741. * @return the prefiltered texture
  7742. */
  7743. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7744. /**
  7745. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7746. * as prefiltered data.
  7747. * @param rootUrl defines the url of the texture or the root name of the six images
  7748. * @param scene defines the scene the texture is attached to
  7749. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7750. * @param noMipmap defines if mipmaps should be created or not
  7751. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7752. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7753. * @param onError defines a callback triggered in case of error during load
  7754. * @param format defines the internal format to use for the texture once loaded
  7755. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7756. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7757. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7758. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7759. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7760. * @return the cube texture
  7761. */
  7762. 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);
  7763. /**
  7764. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7765. */
  7766. readonly isPrefiltered: boolean;
  7767. /**
  7768. * Get the current class name of the texture useful for serialization or dynamic coding.
  7769. * @returns "CubeTexture"
  7770. */
  7771. getClassName(): string;
  7772. /**
  7773. * Update the url (and optional buffer) of this texture if url was null during construction.
  7774. * @param url the url of the texture
  7775. * @param forcedExtension defines the extension to use
  7776. * @param onLoad callback called when the texture is loaded (defaults to null)
  7777. */
  7778. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7779. /**
  7780. * Delays loading of the cube texture
  7781. * @param forcedExtension defines the extension to use
  7782. */
  7783. delayLoad(forcedExtension?: string): void;
  7784. /**
  7785. * Returns the reflection texture matrix
  7786. * @returns the reflection texture matrix
  7787. */
  7788. getReflectionTextureMatrix(): Matrix;
  7789. /**
  7790. * Sets the reflection texture matrix
  7791. * @param value Reflection texture matrix
  7792. */
  7793. setReflectionTextureMatrix(value: Matrix): void;
  7794. /**
  7795. * Parses text to create a cube texture
  7796. * @param parsedTexture define the serialized text to read from
  7797. * @param scene defines the hosting scene
  7798. * @param rootUrl defines the root url of the cube texture
  7799. * @returns a cube texture
  7800. */
  7801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7802. /**
  7803. * Makes a clone, or deep copy, of the cube texture
  7804. * @returns a new cube texture
  7805. */
  7806. clone(): CubeTexture;
  7807. }
  7808. }
  7809. declare module "babylonjs/Materials/materialDefines" {
  7810. /**
  7811. * Manages the defines for the Material
  7812. */
  7813. export class MaterialDefines {
  7814. /** @hidden */
  7815. protected _keys: string[];
  7816. private _isDirty;
  7817. /** @hidden */
  7818. _renderId: number;
  7819. /** @hidden */
  7820. _areLightsDirty: boolean;
  7821. /** @hidden */
  7822. _areLightsDisposed: boolean;
  7823. /** @hidden */
  7824. _areAttributesDirty: boolean;
  7825. /** @hidden */
  7826. _areTexturesDirty: boolean;
  7827. /** @hidden */
  7828. _areFresnelDirty: boolean;
  7829. /** @hidden */
  7830. _areMiscDirty: boolean;
  7831. /** @hidden */
  7832. _areImageProcessingDirty: boolean;
  7833. /** @hidden */
  7834. _normals: boolean;
  7835. /** @hidden */
  7836. _uvs: boolean;
  7837. /** @hidden */
  7838. _needNormals: boolean;
  7839. /** @hidden */
  7840. _needUVs: boolean;
  7841. [id: string]: any;
  7842. /**
  7843. * Specifies if the material needs to be re-calculated
  7844. */
  7845. readonly isDirty: boolean;
  7846. /**
  7847. * Marks the material to indicate that it has been re-calculated
  7848. */
  7849. markAsProcessed(): void;
  7850. /**
  7851. * Marks the material to indicate that it needs to be re-calculated
  7852. */
  7853. markAsUnprocessed(): void;
  7854. /**
  7855. * Marks the material to indicate all of its defines need to be re-calculated
  7856. */
  7857. markAllAsDirty(): void;
  7858. /**
  7859. * Marks the material to indicate that image processing needs to be re-calculated
  7860. */
  7861. markAsImageProcessingDirty(): void;
  7862. /**
  7863. * Marks the material to indicate the lights need to be re-calculated
  7864. * @param disposed Defines whether the light is dirty due to dispose or not
  7865. */
  7866. markAsLightDirty(disposed?: boolean): void;
  7867. /**
  7868. * Marks the attribute state as changed
  7869. */
  7870. markAsAttributesDirty(): void;
  7871. /**
  7872. * Marks the texture state as changed
  7873. */
  7874. markAsTexturesDirty(): void;
  7875. /**
  7876. * Marks the fresnel state as changed
  7877. */
  7878. markAsFresnelDirty(): void;
  7879. /**
  7880. * Marks the misc state as changed
  7881. */
  7882. markAsMiscDirty(): void;
  7883. /**
  7884. * Rebuilds the material defines
  7885. */
  7886. rebuild(): void;
  7887. /**
  7888. * Specifies if two material defines are equal
  7889. * @param other - A material define instance to compare to
  7890. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7891. */
  7892. isEqual(other: MaterialDefines): boolean;
  7893. /**
  7894. * Clones this instance's defines to another instance
  7895. * @param other - material defines to clone values to
  7896. */
  7897. cloneTo(other: MaterialDefines): void;
  7898. /**
  7899. * Resets the material define values
  7900. */
  7901. reset(): void;
  7902. /**
  7903. * Converts the material define values to a string
  7904. * @returns - String of material define information
  7905. */
  7906. toString(): string;
  7907. }
  7908. }
  7909. declare module "babylonjs/Materials/colorCurves" {
  7910. import { Effect } from "babylonjs/Materials/effect";
  7911. /**
  7912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7914. * 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;
  7915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7916. */
  7917. export class ColorCurves {
  7918. private _dirty;
  7919. private _tempColor;
  7920. private _globalCurve;
  7921. private _highlightsCurve;
  7922. private _midtonesCurve;
  7923. private _shadowsCurve;
  7924. private _positiveCurve;
  7925. private _negativeCurve;
  7926. private _globalHue;
  7927. private _globalDensity;
  7928. private _globalSaturation;
  7929. private _globalExposure;
  7930. /**
  7931. * Gets the global Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the global Hue value.
  7936. * 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).
  7937. */
  7938. globalHue: number;
  7939. /**
  7940. * Gets the global Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the global Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. globalDensity: number;
  7950. /**
  7951. * Gets the global Saturation value.
  7952. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7953. */
  7954. /**
  7955. * Sets the global Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. globalSaturation: number;
  7959. /**
  7960. * Gets the global Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the global Exposure value.
  7965. * 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.
  7966. */
  7967. globalExposure: number;
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights Hue value.
  7974. * 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).
  7975. */
  7976. /**
  7977. * Sets the highlights Hue value.
  7978. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7979. */
  7980. highlightsHue: number;
  7981. /**
  7982. * Gets the highlights Density value.
  7983. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the highlights Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. highlightsDensity: number;
  7992. /**
  7993. * Gets the highlights Saturation value.
  7994. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7995. */
  7996. /**
  7997. * Sets the highlights Saturation value.
  7998. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7999. */
  8000. highlightsSaturation: number;
  8001. /**
  8002. * Gets the highlights Exposure value.
  8003. * 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.
  8004. */
  8005. /**
  8006. * Sets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. highlightsExposure: number;
  8010. private _midtonesHue;
  8011. private _midtonesDensity;
  8012. private _midtonesSaturation;
  8013. private _midtonesExposure;
  8014. /**
  8015. * Gets the midtones Hue value.
  8016. * 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).
  8017. */
  8018. /**
  8019. * Sets the midtones Hue value.
  8020. * 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).
  8021. */
  8022. midtonesHue: number;
  8023. /**
  8024. * Gets the midtones Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. /**
  8029. * Sets the midtones Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. midtonesDensity: number;
  8034. /**
  8035. * Gets the midtones Saturation value.
  8036. * 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.
  8037. */
  8038. /**
  8039. * Sets the midtones Saturation value.
  8040. * 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.
  8041. */
  8042. midtonesSaturation: number;
  8043. /**
  8044. * Gets the midtones Exposure value.
  8045. * 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.
  8046. */
  8047. /**
  8048. * Sets the midtones Exposure value.
  8049. * 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.
  8050. */
  8051. midtonesExposure: number;
  8052. private _shadowsHue;
  8053. private _shadowsDensity;
  8054. private _shadowsSaturation;
  8055. private _shadowsExposure;
  8056. /**
  8057. * Gets the shadows Hue value.
  8058. * 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).
  8059. */
  8060. /**
  8061. * Sets the shadows Hue value.
  8062. * 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).
  8063. */
  8064. shadowsHue: number;
  8065. /**
  8066. * Gets the shadows Density value.
  8067. * 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.
  8068. * Values less than zero provide a filter of opposite hue.
  8069. */
  8070. /**
  8071. * Sets the shadows Density value.
  8072. * 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.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. shadowsDensity: number;
  8076. /**
  8077. * Gets the shadows Saturation value.
  8078. * 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.
  8079. */
  8080. /**
  8081. * Sets the shadows Saturation value.
  8082. * 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.
  8083. */
  8084. shadowsSaturation: number;
  8085. /**
  8086. * Gets the shadows Exposure value.
  8087. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8088. */
  8089. /**
  8090. * Sets the shadows Exposure value.
  8091. * 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.
  8092. */
  8093. shadowsExposure: number;
  8094. /**
  8095. * Returns the class name
  8096. * @returns The class name
  8097. */
  8098. getClassName(): string;
  8099. /**
  8100. * Binds the color curves to the shader.
  8101. * @param colorCurves The color curve to bind
  8102. * @param effect The effect to bind to
  8103. * @param positiveUniform The positive uniform shader parameter
  8104. * @param neutralUniform The neutral uniform shader parameter
  8105. * @param negativeUniform The negative uniform shader parameter
  8106. */
  8107. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8108. /**
  8109. * Prepare the list of uniforms associated with the ColorCurves effects.
  8110. * @param uniformsList The list of uniforms used in the effect
  8111. */
  8112. static PrepareUniforms(uniformsList: string[]): void;
  8113. /**
  8114. * Returns color grading data based on a hue, density, saturation and exposure value.
  8115. * @param filterHue The hue of the color filter.
  8116. * @param filterDensity The density of the color filter.
  8117. * @param saturation The saturation.
  8118. * @param exposure The exposure.
  8119. * @param result The result data container.
  8120. */
  8121. private getColorGradingDataToRef;
  8122. /**
  8123. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8124. * @param value The input slider value in range [-100,100].
  8125. * @returns Adjusted value.
  8126. */
  8127. private static applyColorGradingSliderNonlinear;
  8128. /**
  8129. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8130. * @param hue The hue (H) input.
  8131. * @param saturation The saturation (S) input.
  8132. * @param brightness The brightness (B) input.
  8133. * @result An RGBA color represented as Vector4.
  8134. */
  8135. private static fromHSBToRef;
  8136. /**
  8137. * Returns a value clamped between min and max
  8138. * @param value The value to clamp
  8139. * @param min The minimum of value
  8140. * @param max The maximum of value
  8141. * @returns The clamped value.
  8142. */
  8143. private static clamp;
  8144. /**
  8145. * Clones the current color curve instance.
  8146. * @return The cloned curves
  8147. */
  8148. clone(): ColorCurves;
  8149. /**
  8150. * Serializes the current color curve instance to a json representation.
  8151. * @return a JSON representation
  8152. */
  8153. serialize(): any;
  8154. /**
  8155. * Parses the color curve from a json representation.
  8156. * @param source the JSON source to parse
  8157. * @return The parsed curves
  8158. */
  8159. static Parse(source: any): ColorCurves;
  8160. }
  8161. }
  8162. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8163. import { Observable } from "babylonjs/Misc/observable";
  8164. import { Nullable } from "babylonjs/types";
  8165. import { Color4 } from "babylonjs/Maths/math.color";
  8166. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8167. import { Effect } from "babylonjs/Materials/effect";
  8168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8169. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8170. /**
  8171. * Interface to follow in your material defines to integrate easily the
  8172. * Image proccessing functions.
  8173. * @hidden
  8174. */
  8175. export interface IImageProcessingConfigurationDefines {
  8176. IMAGEPROCESSING: boolean;
  8177. VIGNETTE: boolean;
  8178. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8179. VIGNETTEBLENDMODEOPAQUE: boolean;
  8180. TONEMAPPING: boolean;
  8181. TONEMAPPING_ACES: boolean;
  8182. CONTRAST: boolean;
  8183. EXPOSURE: boolean;
  8184. COLORCURVES: boolean;
  8185. COLORGRADING: boolean;
  8186. COLORGRADING3D: boolean;
  8187. SAMPLER3DGREENDEPTH: boolean;
  8188. SAMPLER3DBGRMAP: boolean;
  8189. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8190. }
  8191. /**
  8192. * @hidden
  8193. */
  8194. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8195. IMAGEPROCESSING: boolean;
  8196. VIGNETTE: boolean;
  8197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8198. VIGNETTEBLENDMODEOPAQUE: boolean;
  8199. TONEMAPPING: boolean;
  8200. TONEMAPPING_ACES: boolean;
  8201. CONTRAST: boolean;
  8202. COLORCURVES: boolean;
  8203. COLORGRADING: boolean;
  8204. COLORGRADING3D: boolean;
  8205. SAMPLER3DGREENDEPTH: boolean;
  8206. SAMPLER3DBGRMAP: boolean;
  8207. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8208. EXPOSURE: boolean;
  8209. constructor();
  8210. }
  8211. /**
  8212. * This groups together the common properties used for image processing either in direct forward pass
  8213. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8214. * or not.
  8215. */
  8216. export class ImageProcessingConfiguration {
  8217. /**
  8218. * Default tone mapping applied in BabylonJS.
  8219. */
  8220. static readonly TONEMAPPING_STANDARD: number;
  8221. /**
  8222. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8223. * to other engines rendering to increase portability.
  8224. */
  8225. static readonly TONEMAPPING_ACES: number;
  8226. /**
  8227. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8228. */
  8229. colorCurves: Nullable<ColorCurves>;
  8230. private _colorCurvesEnabled;
  8231. /**
  8232. * Gets wether the color curves effect is enabled.
  8233. */
  8234. /**
  8235. * Sets wether the color curves effect is enabled.
  8236. */
  8237. colorCurvesEnabled: boolean;
  8238. private _colorGradingTexture;
  8239. /**
  8240. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8241. */
  8242. /**
  8243. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8244. */
  8245. colorGradingTexture: Nullable<BaseTexture>;
  8246. private _colorGradingEnabled;
  8247. /**
  8248. * Gets wether the color grading effect is enabled.
  8249. */
  8250. /**
  8251. * Sets wether the color grading effect is enabled.
  8252. */
  8253. colorGradingEnabled: boolean;
  8254. private _colorGradingWithGreenDepth;
  8255. /**
  8256. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8257. */
  8258. /**
  8259. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8260. */
  8261. colorGradingWithGreenDepth: boolean;
  8262. private _colorGradingBGR;
  8263. /**
  8264. * Gets wether the color grading texture contains BGR values.
  8265. */
  8266. /**
  8267. * Sets wether the color grading texture contains BGR values.
  8268. */
  8269. colorGradingBGR: boolean;
  8270. /** @hidden */
  8271. _exposure: number;
  8272. /**
  8273. * Gets the Exposure used in the effect.
  8274. */
  8275. /**
  8276. * Sets the Exposure used in the effect.
  8277. */
  8278. exposure: number;
  8279. private _toneMappingEnabled;
  8280. /**
  8281. * Gets wether the tone mapping effect is enabled.
  8282. */
  8283. /**
  8284. * Sets wether the tone mapping effect is enabled.
  8285. */
  8286. toneMappingEnabled: boolean;
  8287. private _toneMappingType;
  8288. /**
  8289. * Gets the type of tone mapping effect.
  8290. */
  8291. /**
  8292. * Sets the type of tone mapping effect used in BabylonJS.
  8293. */
  8294. toneMappingType: number;
  8295. protected _contrast: number;
  8296. /**
  8297. * Gets the contrast used in the effect.
  8298. */
  8299. /**
  8300. * Sets the contrast used in the effect.
  8301. */
  8302. contrast: number;
  8303. /**
  8304. * Vignette stretch size.
  8305. */
  8306. vignetteStretch: number;
  8307. /**
  8308. * Vignette centre X Offset.
  8309. */
  8310. vignetteCentreX: number;
  8311. /**
  8312. * Vignette centre Y Offset.
  8313. */
  8314. vignetteCentreY: number;
  8315. /**
  8316. * Vignette weight or intensity of the vignette effect.
  8317. */
  8318. vignetteWeight: number;
  8319. /**
  8320. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8321. * if vignetteEnabled is set to true.
  8322. */
  8323. vignetteColor: Color4;
  8324. /**
  8325. * Camera field of view used by the Vignette effect.
  8326. */
  8327. vignetteCameraFov: number;
  8328. private _vignetteBlendMode;
  8329. /**
  8330. * Gets the vignette blend mode allowing different kind of effect.
  8331. */
  8332. /**
  8333. * Sets the vignette blend mode allowing different kind of effect.
  8334. */
  8335. vignetteBlendMode: number;
  8336. private _vignetteEnabled;
  8337. /**
  8338. * Gets wether the vignette effect is enabled.
  8339. */
  8340. /**
  8341. * Sets wether the vignette effect is enabled.
  8342. */
  8343. vignetteEnabled: boolean;
  8344. private _applyByPostProcess;
  8345. /**
  8346. * Gets wether the image processing is applied through a post process or not.
  8347. */
  8348. /**
  8349. * Sets wether the image processing is applied through a post process or not.
  8350. */
  8351. applyByPostProcess: boolean;
  8352. private _isEnabled;
  8353. /**
  8354. * Gets wether the image processing is enabled or not.
  8355. */
  8356. /**
  8357. * Sets wether the image processing is enabled or not.
  8358. */
  8359. isEnabled: boolean;
  8360. /**
  8361. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8362. */
  8363. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8364. /**
  8365. * Method called each time the image processing information changes requires to recompile the effect.
  8366. */
  8367. protected _updateParameters(): void;
  8368. /**
  8369. * Gets the current class name.
  8370. * @return "ImageProcessingConfiguration"
  8371. */
  8372. getClassName(): string;
  8373. /**
  8374. * Prepare the list of uniforms associated with the Image Processing effects.
  8375. * @param uniforms The list of uniforms used in the effect
  8376. * @param defines the list of defines currently in use
  8377. */
  8378. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8379. /**
  8380. * Prepare the list of samplers associated with the Image Processing effects.
  8381. * @param samplersList The list of uniforms used in the effect
  8382. * @param defines the list of defines currently in use
  8383. */
  8384. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8385. /**
  8386. * Prepare the list of defines associated to the shader.
  8387. * @param defines the list of defines to complete
  8388. * @param forPostProcess Define if we are currently in post process mode or not
  8389. */
  8390. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8391. /**
  8392. * Returns true if all the image processing information are ready.
  8393. * @returns True if ready, otherwise, false
  8394. */
  8395. isReady(): boolean;
  8396. /**
  8397. * Binds the image processing to the shader.
  8398. * @param effect The effect to bind to
  8399. * @param aspectRatio Define the current aspect ratio of the effect
  8400. */
  8401. bind(effect: Effect, aspectRatio?: number): void;
  8402. /**
  8403. * Clones the current image processing instance.
  8404. * @return The cloned image processing
  8405. */
  8406. clone(): ImageProcessingConfiguration;
  8407. /**
  8408. * Serializes the current image processing instance to a json representation.
  8409. * @return a JSON representation
  8410. */
  8411. serialize(): any;
  8412. /**
  8413. * Parses the image processing from a json representation.
  8414. * @param source the JSON source to parse
  8415. * @return The parsed image processing
  8416. */
  8417. static Parse(source: any): ImageProcessingConfiguration;
  8418. private static _VIGNETTEMODE_MULTIPLY;
  8419. private static _VIGNETTEMODE_OPAQUE;
  8420. /**
  8421. * Used to apply the vignette as a mix with the pixel color.
  8422. */
  8423. static readonly VIGNETTEMODE_MULTIPLY: number;
  8424. /**
  8425. * Used to apply the vignette as a replacement of the pixel color.
  8426. */
  8427. static readonly VIGNETTEMODE_OPAQUE: number;
  8428. }
  8429. }
  8430. declare module "babylonjs/Shaders/postprocess.vertex" {
  8431. /** @hidden */
  8432. export var postprocessVertexShader: {
  8433. name: string;
  8434. shader: string;
  8435. };
  8436. }
  8437. declare module "babylonjs/Maths/math.axis" {
  8438. import { Vector3 } from "babylonjs/Maths/math.vector";
  8439. /** Defines supported spaces */
  8440. export enum Space {
  8441. /** Local (object) space */
  8442. LOCAL = 0,
  8443. /** World space */
  8444. WORLD = 1,
  8445. /** Bone space */
  8446. BONE = 2
  8447. }
  8448. /** Defines the 3 main axes */
  8449. export class Axis {
  8450. /** X axis */
  8451. static X: Vector3;
  8452. /** Y axis */
  8453. static Y: Vector3;
  8454. /** Z axis */
  8455. static Z: Vector3;
  8456. }
  8457. }
  8458. declare module "babylonjs/Cameras/targetCamera" {
  8459. import { Nullable } from "babylonjs/types";
  8460. import { Camera } from "babylonjs/Cameras/camera";
  8461. import { Scene } from "babylonjs/scene";
  8462. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8463. /**
  8464. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8465. * This is the base of the follow, arc rotate cameras and Free camera
  8466. * @see http://doc.babylonjs.com/features/cameras
  8467. */
  8468. export class TargetCamera extends Camera {
  8469. private static _RigCamTransformMatrix;
  8470. private static _TargetTransformMatrix;
  8471. private static _TargetFocalPoint;
  8472. /**
  8473. * Define the current direction the camera is moving to
  8474. */
  8475. cameraDirection: Vector3;
  8476. /**
  8477. * Define the current rotation the camera is rotating to
  8478. */
  8479. cameraRotation: Vector2;
  8480. /**
  8481. * When set, the up vector of the camera will be updated by the rotation of the camera
  8482. */
  8483. updateUpVectorFromRotation: boolean;
  8484. private _tmpQuaternion;
  8485. /**
  8486. * Define the current rotation of the camera
  8487. */
  8488. rotation: Vector3;
  8489. /**
  8490. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8491. */
  8492. rotationQuaternion: Quaternion;
  8493. /**
  8494. * Define the current speed of the camera
  8495. */
  8496. speed: number;
  8497. /**
  8498. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8499. * around all axis.
  8500. */
  8501. noRotationConstraint: boolean;
  8502. /**
  8503. * Define the current target of the camera as an object or a position.
  8504. */
  8505. lockedTarget: any;
  8506. /** @hidden */
  8507. _currentTarget: Vector3;
  8508. /** @hidden */
  8509. _initialFocalDistance: number;
  8510. /** @hidden */
  8511. _viewMatrix: Matrix;
  8512. /** @hidden */
  8513. _camMatrix: Matrix;
  8514. /** @hidden */
  8515. _cameraTransformMatrix: Matrix;
  8516. /** @hidden */
  8517. _cameraRotationMatrix: Matrix;
  8518. /** @hidden */
  8519. _referencePoint: Vector3;
  8520. /** @hidden */
  8521. _transformedReferencePoint: Vector3;
  8522. protected _globalCurrentTarget: Vector3;
  8523. protected _globalCurrentUpVector: Vector3;
  8524. /** @hidden */
  8525. _reset: () => void;
  8526. private _defaultUp;
  8527. /**
  8528. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. * @param name Defines the name of the camera in the scene
  8532. * @param position Defines the start position of the camera in the scene
  8533. * @param scene Defines the scene the camera belongs to
  8534. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8535. */
  8536. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8537. /**
  8538. * Gets the position in front of the camera at a given distance.
  8539. * @param distance The distance from the camera we want the position to be
  8540. * @returns the position
  8541. */
  8542. getFrontPosition(distance: number): Vector3;
  8543. /** @hidden */
  8544. _getLockedTargetPosition(): Nullable<Vector3>;
  8545. private _storedPosition;
  8546. private _storedRotation;
  8547. private _storedRotationQuaternion;
  8548. /**
  8549. * Store current camera state of the camera (fov, position, rotation, etc..)
  8550. * @returns the camera
  8551. */
  8552. storeState(): Camera;
  8553. /**
  8554. * Restored camera state. You must call storeState() first
  8555. * @returns whether it was successful or not
  8556. * @hidden
  8557. */
  8558. _restoreStateValues(): boolean;
  8559. /** @hidden */
  8560. _initCache(): void;
  8561. /** @hidden */
  8562. _updateCache(ignoreParentClass?: boolean): void;
  8563. /** @hidden */
  8564. _isSynchronizedViewMatrix(): boolean;
  8565. /** @hidden */
  8566. _computeLocalCameraSpeed(): number;
  8567. /**
  8568. * Defines the target the camera should look at.
  8569. * @param target Defines the new target as a Vector or a mesh
  8570. */
  8571. setTarget(target: Vector3): void;
  8572. /**
  8573. * Return the current target position of the camera. This value is expressed in local space.
  8574. * @returns the target position
  8575. */
  8576. getTarget(): Vector3;
  8577. /** @hidden */
  8578. _decideIfNeedsToMove(): boolean;
  8579. /** @hidden */
  8580. _updatePosition(): void;
  8581. /** @hidden */
  8582. _checkInputs(): void;
  8583. protected _updateCameraRotationMatrix(): void;
  8584. /**
  8585. * 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)
  8586. * @returns the current camera
  8587. */
  8588. private _rotateUpVectorWithCameraRotationMatrix;
  8589. private _cachedRotationZ;
  8590. private _cachedQuaternionRotationZ;
  8591. /** @hidden */
  8592. _getViewMatrix(): Matrix;
  8593. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8594. /**
  8595. * @hidden
  8596. */
  8597. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8598. /**
  8599. * @hidden
  8600. */
  8601. _updateRigCameras(): void;
  8602. private _getRigCamPositionAndTarget;
  8603. /**
  8604. * Gets the current object class name.
  8605. * @return the class name
  8606. */
  8607. getClassName(): string;
  8608. }
  8609. }
  8610. declare module "babylonjs/Events/keyboardEvents" {
  8611. /**
  8612. * Gather the list of keyboard event types as constants.
  8613. */
  8614. export class KeyboardEventTypes {
  8615. /**
  8616. * The keydown event is fired when a key becomes active (pressed).
  8617. */
  8618. static readonly KEYDOWN: number;
  8619. /**
  8620. * The keyup event is fired when a key has been released.
  8621. */
  8622. static readonly KEYUP: number;
  8623. }
  8624. /**
  8625. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8626. */
  8627. export class KeyboardInfo {
  8628. /**
  8629. * Defines the type of event (KeyboardEventTypes)
  8630. */
  8631. type: number;
  8632. /**
  8633. * Defines the related dom event
  8634. */
  8635. event: KeyboardEvent;
  8636. /**
  8637. * Instantiates a new keyboard info.
  8638. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8639. * @param type Defines the type of event (KeyboardEventTypes)
  8640. * @param event Defines the related dom event
  8641. */
  8642. constructor(
  8643. /**
  8644. * Defines the type of event (KeyboardEventTypes)
  8645. */
  8646. type: number,
  8647. /**
  8648. * Defines the related dom event
  8649. */
  8650. event: KeyboardEvent);
  8651. }
  8652. /**
  8653. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8654. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8655. */
  8656. export class KeyboardInfoPre extends KeyboardInfo {
  8657. /**
  8658. * Defines the type of event (KeyboardEventTypes)
  8659. */
  8660. type: number;
  8661. /**
  8662. * Defines the related dom event
  8663. */
  8664. event: KeyboardEvent;
  8665. /**
  8666. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8667. */
  8668. skipOnPointerObservable: boolean;
  8669. /**
  8670. * Instantiates a new keyboard pre info.
  8671. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8672. * @param type Defines the type of event (KeyboardEventTypes)
  8673. * @param event Defines the related dom event
  8674. */
  8675. constructor(
  8676. /**
  8677. * Defines the type of event (KeyboardEventTypes)
  8678. */
  8679. type: number,
  8680. /**
  8681. * Defines the related dom event
  8682. */
  8683. event: KeyboardEvent);
  8684. }
  8685. }
  8686. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8687. import { Nullable } from "babylonjs/types";
  8688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8689. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8690. /**
  8691. * Manage the keyboard inputs to control the movement of a free camera.
  8692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8693. */
  8694. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8695. /**
  8696. * Defines the camera the input is attached to.
  8697. */
  8698. camera: FreeCamera;
  8699. /**
  8700. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8701. */
  8702. keysUp: number[];
  8703. /**
  8704. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8705. */
  8706. keysDown: number[];
  8707. /**
  8708. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8709. */
  8710. keysLeft: number[];
  8711. /**
  8712. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8713. */
  8714. keysRight: number[];
  8715. private _keys;
  8716. private _onCanvasBlurObserver;
  8717. private _onKeyboardObserver;
  8718. private _engine;
  8719. private _scene;
  8720. /**
  8721. * Attach the input controls to a specific dom element to get the input from.
  8722. * @param element Defines the element the controls should be listened from
  8723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8724. */
  8725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8726. /**
  8727. * Detach the current controls from the specified dom element.
  8728. * @param element Defines the element to stop listening the inputs from
  8729. */
  8730. detachControl(element: Nullable<HTMLElement>): void;
  8731. /**
  8732. * Update the current camera state depending on the inputs that have been used this frame.
  8733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8734. */
  8735. checkInputs(): void;
  8736. /**
  8737. * Gets the class name of the current intput.
  8738. * @returns the class name
  8739. */
  8740. getClassName(): string;
  8741. /** @hidden */
  8742. _onLostFocus(): void;
  8743. /**
  8744. * Get the friendly name associated with the input class.
  8745. * @returns the input friendly name
  8746. */
  8747. getSimpleName(): string;
  8748. }
  8749. }
  8750. declare module "babylonjs/Lights/shadowLight" {
  8751. import { Camera } from "babylonjs/Cameras/camera";
  8752. import { Scene } from "babylonjs/scene";
  8753. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8755. import { Light } from "babylonjs/Lights/light";
  8756. /**
  8757. * Interface describing all the common properties and methods a shadow light needs to implement.
  8758. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8759. * as well as binding the different shadow properties to the effects.
  8760. */
  8761. export interface IShadowLight extends Light {
  8762. /**
  8763. * The light id in the scene (used in scene.findLighById for instance)
  8764. */
  8765. id: string;
  8766. /**
  8767. * The position the shdow will be casted from.
  8768. */
  8769. position: Vector3;
  8770. /**
  8771. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8772. */
  8773. direction: Vector3;
  8774. /**
  8775. * The transformed position. Position of the light in world space taking parenting in account.
  8776. */
  8777. transformedPosition: Vector3;
  8778. /**
  8779. * The transformed direction. Direction of the light in world space taking parenting in account.
  8780. */
  8781. transformedDirection: Vector3;
  8782. /**
  8783. * The friendly name of the light in the scene.
  8784. */
  8785. name: string;
  8786. /**
  8787. * Defines the shadow projection clipping minimum z value.
  8788. */
  8789. shadowMinZ: number;
  8790. /**
  8791. * Defines the shadow projection clipping maximum z value.
  8792. */
  8793. shadowMaxZ: number;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Gets the scene the light belongs to.
  8801. * @returns The scene
  8802. */
  8803. getScene(): Scene;
  8804. /**
  8805. * Callback defining a custom Projection Matrix Builder.
  8806. * This can be used to override the default projection matrix computation.
  8807. */
  8808. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8809. /**
  8810. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8811. * @param matrix The materix to updated with the projection information
  8812. * @param viewMatrix The transform matrix of the light
  8813. * @param renderList The list of mesh to render in the map
  8814. * @returns The current light
  8815. */
  8816. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8817. /**
  8818. * Gets the current depth scale used in ESM.
  8819. * @returns The scale
  8820. */
  8821. getDepthScale(): number;
  8822. /**
  8823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8824. * @returns true if a cube texture needs to be use
  8825. */
  8826. needCube(): boolean;
  8827. /**
  8828. * Detects if the projection matrix requires to be recomputed this frame.
  8829. * @returns true if it requires to be recomputed otherwise, false.
  8830. */
  8831. needProjectionMatrixCompute(): boolean;
  8832. /**
  8833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8834. */
  8835. forceProjectionMatrixCompute(): void;
  8836. /**
  8837. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8840. */
  8841. getShadowDirection(faceIndex?: number): Vector3;
  8842. /**
  8843. * Gets the minZ used for shadow according to both the scene and the light.
  8844. * @param activeCamera The camera we are returning the min for
  8845. * @returns the depth min z
  8846. */
  8847. getDepthMinZ(activeCamera: Camera): number;
  8848. /**
  8849. * Gets the maxZ used for shadow according to both the scene and the light.
  8850. * @param activeCamera The camera we are returning the max for
  8851. * @returns the depth max z
  8852. */
  8853. getDepthMaxZ(activeCamera: Camera): number;
  8854. }
  8855. /**
  8856. * Base implementation IShadowLight
  8857. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8858. */
  8859. export abstract class ShadowLight extends Light implements IShadowLight {
  8860. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8861. protected _position: Vector3;
  8862. protected _setPosition(value: Vector3): void;
  8863. /**
  8864. * Sets the position the shadow will be casted from. Also use as the light position for both
  8865. * point and spot lights.
  8866. */
  8867. /**
  8868. * Sets the position the shadow will be casted from. Also use as the light position for both
  8869. * point and spot lights.
  8870. */
  8871. position: Vector3;
  8872. protected _direction: Vector3;
  8873. protected _setDirection(value: Vector3): void;
  8874. /**
  8875. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8876. * Also use as the light direction on spot and directional lights.
  8877. */
  8878. /**
  8879. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8880. * Also use as the light direction on spot and directional lights.
  8881. */
  8882. direction: Vector3;
  8883. private _shadowMinZ;
  8884. /**
  8885. * Gets the shadow projection clipping minimum z value.
  8886. */
  8887. /**
  8888. * Sets the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. private _shadowMaxZ;
  8892. /**
  8893. * Sets the shadow projection clipping maximum z value.
  8894. */
  8895. /**
  8896. * Gets the shadow projection clipping maximum z value.
  8897. */
  8898. shadowMaxZ: number;
  8899. /**
  8900. * Callback defining a custom Projection Matrix Builder.
  8901. * This can be used to override the default projection matrix computation.
  8902. */
  8903. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8904. /**
  8905. * The transformed position. Position of the light in world space taking parenting in account.
  8906. */
  8907. transformedPosition: Vector3;
  8908. /**
  8909. * The transformed direction. Direction of the light in world space taking parenting in account.
  8910. */
  8911. transformedDirection: Vector3;
  8912. private _needProjectionMatrixCompute;
  8913. /**
  8914. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8915. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8916. */
  8917. computeTransformedInformation(): boolean;
  8918. /**
  8919. * Return the depth scale used for the shadow map.
  8920. * @returns the depth scale.
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8925. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8926. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8927. */
  8928. getShadowDirection(faceIndex?: number): Vector3;
  8929. /**
  8930. * Returns the ShadowLight absolute position in the World.
  8931. * @returns the position vector in world space
  8932. */
  8933. getAbsolutePosition(): Vector3;
  8934. /**
  8935. * Sets the ShadowLight direction toward the passed target.
  8936. * @param target The point to target in local space
  8937. * @returns the updated ShadowLight direction
  8938. */
  8939. setDirectionToTarget(target: Vector3): Vector3;
  8940. /**
  8941. * Returns the light rotation in euler definition.
  8942. * @returns the x y z rotation in local space.
  8943. */
  8944. getRotation(): Vector3;
  8945. /**
  8946. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8947. * @returns true if a cube texture needs to be use
  8948. */
  8949. needCube(): boolean;
  8950. /**
  8951. * Detects if the projection matrix requires to be recomputed this frame.
  8952. * @returns true if it requires to be recomputed otherwise, false.
  8953. */
  8954. needProjectionMatrixCompute(): boolean;
  8955. /**
  8956. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8957. */
  8958. forceProjectionMatrixCompute(): void;
  8959. /** @hidden */
  8960. _initCache(): void;
  8961. /** @hidden */
  8962. _isSynchronized(): boolean;
  8963. /**
  8964. * Computes the world matrix of the node
  8965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8966. * @returns the world matrix
  8967. */
  8968. computeWorldMatrix(force?: boolean): Matrix;
  8969. /**
  8970. * Gets the minZ used for shadow according to both the scene and the light.
  8971. * @param activeCamera The camera we are returning the min for
  8972. * @returns the depth min z
  8973. */
  8974. getDepthMinZ(activeCamera: Camera): number;
  8975. /**
  8976. * Gets the maxZ used for shadow according to both the scene and the light.
  8977. * @param activeCamera The camera we are returning the max for
  8978. * @returns the depth max z
  8979. */
  8980. getDepthMaxZ(activeCamera: Camera): number;
  8981. /**
  8982. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8983. * @param matrix The materix to updated with the projection information
  8984. * @param viewMatrix The transform matrix of the light
  8985. * @param renderList The list of mesh to render in the map
  8986. * @returns The current light
  8987. */
  8988. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8989. }
  8990. }
  8991. declare module "babylonjs/Materials/effectFallbacks" {
  8992. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8993. import { Effect } from "babylonjs/Materials/effect";
  8994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8995. /**
  8996. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8997. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8998. */
  8999. export class EffectFallbacks implements IEffectFallbacks {
  9000. private _defines;
  9001. private _currentRank;
  9002. private _maxRank;
  9003. private _mesh;
  9004. /**
  9005. * Removes the fallback from the bound mesh.
  9006. */
  9007. unBindMesh(): void;
  9008. /**
  9009. * Adds a fallback on the specified property.
  9010. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9011. * @param define The name of the define in the shader
  9012. */
  9013. addFallback(rank: number, define: string): void;
  9014. /**
  9015. * Sets the mesh to use CPU skinning when needing to fallback.
  9016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9017. * @param mesh The mesh to use the fallbacks.
  9018. */
  9019. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9020. /**
  9021. * Checks to see if more fallbacks are still availible.
  9022. */
  9023. readonly hasMoreFallbacks: boolean;
  9024. /**
  9025. * Removes the defines that should be removed when falling back.
  9026. * @param currentDefines defines the current define statements for the shader.
  9027. * @param effect defines the current effect we try to compile
  9028. * @returns The resulting defines with defines of the current rank removed.
  9029. */
  9030. reduce(currentDefines: string, effect: Effect): string;
  9031. }
  9032. }
  9033. declare module "babylonjs/Materials/materialHelper" {
  9034. import { Nullable } from "babylonjs/types";
  9035. import { Scene } from "babylonjs/scene";
  9036. import { Engine } from "babylonjs/Engines/engine";
  9037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9038. import { Light } from "babylonjs/Lights/light";
  9039. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9040. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9042. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9043. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9044. /**
  9045. * "Static Class" containing the most commonly used helper while dealing with material for
  9046. * rendering purpose.
  9047. *
  9048. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9049. *
  9050. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9051. */
  9052. export class MaterialHelper {
  9053. /**
  9054. * Bind the current view position to an effect.
  9055. * @param effect The effect to be bound
  9056. * @param scene The scene the eyes position is used from
  9057. */
  9058. static BindEyePosition(effect: Effect, scene: Scene): void;
  9059. /**
  9060. * Helps preparing the defines values about the UVs in used in the effect.
  9061. * UVs are shared as much as we can accross channels in the shaders.
  9062. * @param texture The texture we are preparing the UVs for
  9063. * @param defines The defines to update
  9064. * @param key The channel key "diffuse", "specular"... used in the shader
  9065. */
  9066. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9067. /**
  9068. * Binds a texture matrix value to its corrsponding uniform
  9069. * @param texture The texture to bind the matrix for
  9070. * @param uniformBuffer The uniform buffer receivin the data
  9071. * @param key The channel key "diffuse", "specular"... used in the shader
  9072. */
  9073. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9074. /**
  9075. * Gets the current status of the fog (should it be enabled?)
  9076. * @param mesh defines the mesh to evaluate for fog support
  9077. * @param scene defines the hosting scene
  9078. * @returns true if fog must be enabled
  9079. */
  9080. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9081. /**
  9082. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9083. * @param mesh defines the current mesh
  9084. * @param scene defines the current scene
  9085. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9086. * @param pointsCloud defines if point cloud rendering has to be turned on
  9087. * @param fogEnabled defines if fog has to be turned on
  9088. * @param alphaTest defines if alpha testing has to be turned on
  9089. * @param defines defines the current list of defines
  9090. */
  9091. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9092. /**
  9093. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9094. * @param scene defines the current scene
  9095. * @param engine defines the current engine
  9096. * @param defines specifies the list of active defines
  9097. * @param useInstances defines if instances have to be turned on
  9098. * @param useClipPlane defines if clip plane have to be turned on
  9099. */
  9100. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9101. /**
  9102. * Prepares the defines for bones
  9103. * @param mesh The mesh containing the geometry data we will draw
  9104. * @param defines The defines to update
  9105. */
  9106. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9107. /**
  9108. * Prepares the defines for morph targets
  9109. * @param mesh The mesh containing the geometry data we will draw
  9110. * @param defines The defines to update
  9111. */
  9112. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9113. /**
  9114. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9115. * @param mesh The mesh containing the geometry data we will draw
  9116. * @param defines The defines to update
  9117. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9118. * @param useBones Precise whether bones should be used or not (override mesh info)
  9119. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9120. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9121. * @returns false if defines are considered not dirty and have not been checked
  9122. */
  9123. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9124. /**
  9125. * Prepares the defines related to multiview
  9126. * @param scene The scene we are intending to draw
  9127. * @param defines The defines to update
  9128. */
  9129. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9130. /**
  9131. * Prepares the defines related to the light information passed in parameter
  9132. * @param scene The scene we are intending to draw
  9133. * @param mesh The mesh the effect is compiling for
  9134. * @param light The light the effect is compiling for
  9135. * @param lightIndex The index of the light
  9136. * @param defines The defines to update
  9137. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9138. * @param state Defines the current state regarding what is needed (normals, etc...)
  9139. */
  9140. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9141. needNormals: boolean;
  9142. needRebuild: boolean;
  9143. shadowEnabled: boolean;
  9144. specularEnabled: boolean;
  9145. lightmapMode: boolean;
  9146. }): void;
  9147. /**
  9148. * Prepares the defines related to the light information passed in parameter
  9149. * @param scene The scene we are intending to draw
  9150. * @param mesh The mesh the effect is compiling for
  9151. * @param defines The defines to update
  9152. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9153. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9154. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9155. * @returns true if normals will be required for the rest of the effect
  9156. */
  9157. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9158. /**
  9159. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9160. * @param lightIndex defines the light index
  9161. * @param uniformsList The uniform list
  9162. * @param samplersList The sampler list
  9163. * @param projectedLightTexture defines if projected texture must be used
  9164. * @param uniformBuffersList defines an optional list of uniform buffers
  9165. */
  9166. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9167. /**
  9168. * Prepares the uniforms and samplers list to be used in the effect
  9169. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9170. * @param samplersList The sampler list
  9171. * @param defines The defines helping in the list generation
  9172. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9173. */
  9174. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9175. /**
  9176. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9177. * @param defines The defines to update while falling back
  9178. * @param fallbacks The authorized effect fallbacks
  9179. * @param maxSimultaneousLights The maximum number of lights allowed
  9180. * @param rank the current rank of the Effect
  9181. * @returns The newly affected rank
  9182. */
  9183. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9184. private static _TmpMorphInfluencers;
  9185. /**
  9186. * Prepares the list of attributes required for morph targets according to the effect defines.
  9187. * @param attribs The current list of supported attribs
  9188. * @param mesh The mesh to prepare the morph targets attributes for
  9189. * @param influencers The number of influencers
  9190. */
  9191. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9192. /**
  9193. * Prepares the list of attributes required for morph targets according to the effect defines.
  9194. * @param attribs The current list of supported attribs
  9195. * @param mesh The mesh to prepare the morph targets attributes for
  9196. * @param defines The current Defines of the effect
  9197. */
  9198. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9199. /**
  9200. * Prepares the list of attributes required for bones according to the effect defines.
  9201. * @param attribs The current list of supported attribs
  9202. * @param mesh The mesh to prepare the bones attributes for
  9203. * @param defines The current Defines of the effect
  9204. * @param fallbacks The current efffect fallback strategy
  9205. */
  9206. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9207. /**
  9208. * Check and prepare the list of attributes required for instances according to the effect defines.
  9209. * @param attribs The current list of supported attribs
  9210. * @param defines The current MaterialDefines of the effect
  9211. */
  9212. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9213. /**
  9214. * Add the list of attributes required for instances to the attribs array.
  9215. * @param attribs The current list of supported attribs
  9216. */
  9217. static PushAttributesForInstances(attribs: string[]): void;
  9218. /**
  9219. * Binds the light shadow information to the effect for the given mesh.
  9220. * @param light The light containing the generator
  9221. * @param scene The scene the lights belongs to
  9222. * @param mesh The mesh we are binding the information to render
  9223. * @param lightIndex The light index in the effect used to render the mesh
  9224. * @param effect The effect we are binding the data to
  9225. */
  9226. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9227. /**
  9228. * Binds the light information to the effect.
  9229. * @param light The light containing the generator
  9230. * @param effect The effect we are binding the data to
  9231. * @param lightIndex The light index in the effect used to render
  9232. */
  9233. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9234. /**
  9235. * Binds the lights information from the scene to the effect for the given mesh.
  9236. * @param light Light to bind
  9237. * @param lightIndex Light index
  9238. * @param scene The scene where the light belongs to
  9239. * @param mesh The mesh we are binding the information to render
  9240. * @param effect The effect we are binding the data to
  9241. * @param useSpecular Defines if specular is supported
  9242. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9243. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9244. */
  9245. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9246. /**
  9247. * Binds the lights information from the scene to the effect for the given mesh.
  9248. * @param scene The scene the lights belongs to
  9249. * @param mesh The mesh we are binding the information to render
  9250. * @param effect The effect we are binding the data to
  9251. * @param defines The generated defines for the effect
  9252. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9253. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9254. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9255. */
  9256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9257. private static _tempFogColor;
  9258. /**
  9259. * Binds the fog information from the scene to the effect for the given mesh.
  9260. * @param scene The scene the lights belongs to
  9261. * @param mesh The mesh we are binding the information to render
  9262. * @param effect The effect we are binding the data to
  9263. * @param linearSpace Defines if the fog effect is applied in linear space
  9264. */
  9265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9266. /**
  9267. * Binds the bones information from the mesh to the effect.
  9268. * @param mesh The mesh we are binding the information to render
  9269. * @param effect The effect we are binding the data to
  9270. */
  9271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9272. /**
  9273. * Binds the morph targets information from the mesh to the effect.
  9274. * @param abstractMesh The mesh we are binding the information to render
  9275. * @param effect The effect we are binding the data to
  9276. */
  9277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9278. /**
  9279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9280. * @param defines The generated defines used in the effect
  9281. * @param effect The effect we are binding the data to
  9282. * @param scene The scene we are willing to render with logarithmic scale for
  9283. */
  9284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9285. /**
  9286. * Binds the clip plane information from the scene to the effect.
  9287. * @param scene The scene the clip plane information are extracted from
  9288. * @param effect The effect we are binding the data to
  9289. */
  9290. static BindClipPlane(effect: Effect, scene: Scene): void;
  9291. }
  9292. }
  9293. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9294. /** @hidden */
  9295. export var packingFunctions: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9301. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9302. /** @hidden */
  9303. export var shadowMapPixelShader: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9309. /** @hidden */
  9310. export var bonesDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9316. /** @hidden */
  9317. export var morphTargetsVertexGlobalDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9323. /** @hidden */
  9324. export var morphTargetsVertexDeclaration: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9330. /** @hidden */
  9331. export var instancesDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9337. /** @hidden */
  9338. export var helperFunctions: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9344. /** @hidden */
  9345. export var morphTargetsVertex: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9351. /** @hidden */
  9352. export var instancesVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9358. /** @hidden */
  9359. export var bonesVertex: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9365. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9371. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9372. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9373. /** @hidden */
  9374. export var shadowMapVertexShader: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9380. /** @hidden */
  9381. export var depthBoxBlurPixelShader: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9387. import { Nullable } from "babylonjs/types";
  9388. import { Scene } from "babylonjs/scene";
  9389. import { Matrix } from "babylonjs/Maths/math.vector";
  9390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9392. import { Mesh } from "babylonjs/Meshes/mesh";
  9393. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9394. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9395. import { Effect } from "babylonjs/Materials/effect";
  9396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9397. import "babylonjs/Shaders/shadowMap.fragment";
  9398. import "babylonjs/Shaders/shadowMap.vertex";
  9399. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9400. import { Observable } from "babylonjs/Misc/observable";
  9401. /**
  9402. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9403. */
  9404. export interface ICustomShaderOptions {
  9405. /**
  9406. * Gets or sets the custom shader name to use
  9407. */
  9408. shaderName: string;
  9409. /**
  9410. * The list of attribute names used in the shader
  9411. */
  9412. attributes?: string[];
  9413. /**
  9414. * The list of unifrom names used in the shader
  9415. */
  9416. uniforms?: string[];
  9417. /**
  9418. * The list of sampler names used in the shader
  9419. */
  9420. samplers?: string[];
  9421. /**
  9422. * The list of defines used in the shader
  9423. */
  9424. defines?: string[];
  9425. }
  9426. /**
  9427. * Interface to implement to create a shadow generator compatible with BJS.
  9428. */
  9429. export interface IShadowGenerator {
  9430. /**
  9431. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9432. * @returns The render target texture if present otherwise, null
  9433. */
  9434. getShadowMap(): Nullable<RenderTargetTexture>;
  9435. /**
  9436. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9437. * @returns The render target texture if the shadow map is present otherwise, null
  9438. */
  9439. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9440. /**
  9441. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9442. * @param subMesh The submesh we want to render in the shadow map
  9443. * @param useInstances Defines wether will draw in the map using instances
  9444. * @returns true if ready otherwise, false
  9445. */
  9446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9447. /**
  9448. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9449. * @param defines Defines of the material we want to update
  9450. * @param lightIndex Index of the light in the enabled light list of the material
  9451. */
  9452. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9453. /**
  9454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9455. * defined in the generator but impacting the effect).
  9456. * It implies the unifroms available on the materials are the standard BJS ones.
  9457. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9458. * @param effect The effect we are binfing the information for
  9459. */
  9460. bindShadowLight(lightIndex: string, effect: Effect): void;
  9461. /**
  9462. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9463. * (eq to shadow prjection matrix * light transform matrix)
  9464. * @returns The transform matrix used to create the shadow map
  9465. */
  9466. getTransformMatrix(): Matrix;
  9467. /**
  9468. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9469. * Cube and 2D textures for instance.
  9470. */
  9471. recreateShadowMap(): void;
  9472. /**
  9473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9474. * @param onCompiled Callback triggered at the and of the effects compilation
  9475. * @param options Sets of optional options forcing the compilation with different modes
  9476. */
  9477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9478. useInstances: boolean;
  9479. }>): void;
  9480. /**
  9481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9482. * @param options Sets of optional options forcing the compilation with different modes
  9483. * @returns A promise that resolves when the compilation completes
  9484. */
  9485. forceCompilationAsync(options?: Partial<{
  9486. useInstances: boolean;
  9487. }>): Promise<void>;
  9488. /**
  9489. * Serializes the shadow generator setup to a json object.
  9490. * @returns The serialized JSON object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Disposes the Shadow map and related Textures and effects.
  9495. */
  9496. dispose(): void;
  9497. }
  9498. /**
  9499. * Default implementation IShadowGenerator.
  9500. * This is the main object responsible of generating shadows in the framework.
  9501. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9502. */
  9503. export class ShadowGenerator implements IShadowGenerator {
  9504. /**
  9505. * Shadow generator mode None: no filtering applied.
  9506. */
  9507. static readonly FILTER_NONE: number;
  9508. /**
  9509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9511. */
  9512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9513. /**
  9514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9516. */
  9517. static readonly FILTER_POISSONSAMPLING: number;
  9518. /**
  9519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9521. */
  9522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9523. /**
  9524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9525. * edge artifacts on steep falloff.
  9526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9527. */
  9528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9529. /**
  9530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9531. * edge artifacts on steep falloff.
  9532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9533. */
  9534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9535. /**
  9536. * Shadow generator mode PCF: Percentage Closer Filtering
  9537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9539. */
  9540. static readonly FILTER_PCF: number;
  9541. /**
  9542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9544. * Contact Hardening
  9545. */
  9546. static readonly FILTER_PCSS: number;
  9547. /**
  9548. * Reserved for PCF and PCSS
  9549. * Highest Quality.
  9550. *
  9551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9552. *
  9553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9554. */
  9555. static readonly QUALITY_HIGH: number;
  9556. /**
  9557. * Reserved for PCF and PCSS
  9558. * Good tradeoff for quality/perf cross devices
  9559. *
  9560. * Execute PCF on a 3*3 kernel.
  9561. *
  9562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9563. */
  9564. static readonly QUALITY_MEDIUM: number;
  9565. /**
  9566. * Reserved for PCF and PCSS
  9567. * The lowest quality but the fastest.
  9568. *
  9569. * Execute PCF on a 1*1 kernel.
  9570. *
  9571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9572. */
  9573. static readonly QUALITY_LOW: number;
  9574. /** Gets or sets the custom shader name to use */
  9575. customShaderOptions: ICustomShaderOptions;
  9576. /**
  9577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9578. */
  9579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9580. /**
  9581. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9582. */
  9583. onAfterShadowMapRenderObservable: Observable<Effect>;
  9584. /**
  9585. * Observable triggered before a mesh is rendered in the shadow map.
  9586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9587. */
  9588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9589. /**
  9590. * Observable triggered after a mesh is rendered in the shadow map.
  9591. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9592. */
  9593. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9594. private _bias;
  9595. /**
  9596. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9597. */
  9598. /**
  9599. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9600. */
  9601. bias: number;
  9602. private _normalBias;
  9603. /**
  9604. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9605. */
  9606. /**
  9607. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9608. */
  9609. normalBias: number;
  9610. private _blurBoxOffset;
  9611. /**
  9612. * Gets the blur box offset: offset applied during the blur pass.
  9613. * Only useful if useKernelBlur = false
  9614. */
  9615. /**
  9616. * Sets the blur box offset: offset applied during the blur pass.
  9617. * Only useful if useKernelBlur = false
  9618. */
  9619. blurBoxOffset: number;
  9620. private _blurScale;
  9621. /**
  9622. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9623. * 2 means half of the size.
  9624. */
  9625. /**
  9626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9627. * 2 means half of the size.
  9628. */
  9629. blurScale: number;
  9630. private _blurKernel;
  9631. /**
  9632. * Gets the blur kernel: kernel size of the blur pass.
  9633. * Only useful if useKernelBlur = true
  9634. */
  9635. /**
  9636. * Sets the blur kernel: kernel size of the blur pass.
  9637. * Only useful if useKernelBlur = true
  9638. */
  9639. blurKernel: number;
  9640. private _useKernelBlur;
  9641. /**
  9642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9644. */
  9645. /**
  9646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9648. */
  9649. useKernelBlur: boolean;
  9650. private _depthScale;
  9651. /**
  9652. * Gets the depth scale used in ESM mode.
  9653. */
  9654. /**
  9655. * Sets the depth scale used in ESM mode.
  9656. * This can override the scale stored on the light.
  9657. */
  9658. depthScale: number;
  9659. private _filter;
  9660. /**
  9661. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9662. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9663. */
  9664. /**
  9665. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9667. */
  9668. filter: number;
  9669. /**
  9670. * Gets if the current filter is set to Poisson Sampling.
  9671. */
  9672. /**
  9673. * Sets the current filter to Poisson Sampling.
  9674. */
  9675. usePoissonSampling: boolean;
  9676. /**
  9677. * Gets if the current filter is set to ESM.
  9678. */
  9679. /**
  9680. * Sets the current filter is to ESM.
  9681. */
  9682. useExponentialShadowMap: boolean;
  9683. /**
  9684. * Gets if the current filter is set to filtered ESM.
  9685. */
  9686. /**
  9687. * Gets if the current filter is set to filtered ESM.
  9688. */
  9689. useBlurExponentialShadowMap: boolean;
  9690. /**
  9691. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9692. * exponential to prevent steep falloff artifacts).
  9693. */
  9694. /**
  9695. * Sets the current filter to "close ESM" (using the inverse of the
  9696. * exponential to prevent steep falloff artifacts).
  9697. */
  9698. useCloseExponentialShadowMap: boolean;
  9699. /**
  9700. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9701. * exponential to prevent steep falloff artifacts).
  9702. */
  9703. /**
  9704. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9705. * exponential to prevent steep falloff artifacts).
  9706. */
  9707. useBlurCloseExponentialShadowMap: boolean;
  9708. /**
  9709. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9710. */
  9711. /**
  9712. * Sets the current filter to "PCF" (percentage closer filtering).
  9713. */
  9714. usePercentageCloserFiltering: boolean;
  9715. private _filteringQuality;
  9716. /**
  9717. * Gets the PCF or PCSS Quality.
  9718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9719. */
  9720. /**
  9721. * Sets the PCF or PCSS Quality.
  9722. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9723. */
  9724. filteringQuality: number;
  9725. /**
  9726. * Gets if the current filter is set to "PCSS" (contact hardening).
  9727. */
  9728. /**
  9729. * Sets the current filter to "PCSS" (contact hardening).
  9730. */
  9731. useContactHardeningShadow: boolean;
  9732. private _contactHardeningLightSizeUVRatio;
  9733. /**
  9734. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9735. * Using a ratio helps keeping shape stability independently of the map size.
  9736. *
  9737. * It does not account for the light projection as it was having too much
  9738. * instability during the light setup or during light position changes.
  9739. *
  9740. * Only valid if useContactHardeningShadow is true.
  9741. */
  9742. /**
  9743. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9744. * Using a ratio helps keeping shape stability independently of the map size.
  9745. *
  9746. * It does not account for the light projection as it was having too much
  9747. * instability during the light setup or during light position changes.
  9748. *
  9749. * Only valid if useContactHardeningShadow is true.
  9750. */
  9751. contactHardeningLightSizeUVRatio: number;
  9752. private _darkness;
  9753. /** Gets or sets the actual darkness of a shadow */
  9754. darkness: number;
  9755. /**
  9756. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9757. * 0 means strongest and 1 would means no shadow.
  9758. * @returns the darkness.
  9759. */
  9760. getDarkness(): number;
  9761. /**
  9762. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9763. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9764. * @returns the shadow generator allowing fluent coding.
  9765. */
  9766. setDarkness(darkness: number): ShadowGenerator;
  9767. private _transparencyShadow;
  9768. /** Gets or sets the ability to have transparent shadow */
  9769. transparencyShadow: boolean;
  9770. /**
  9771. * Sets the ability to have transparent shadow (boolean).
  9772. * @param transparent True if transparent else False
  9773. * @returns the shadow generator allowing fluent coding
  9774. */
  9775. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9776. private _shadowMap;
  9777. private _shadowMap2;
  9778. /**
  9779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9780. * @returns The render target texture if present otherwise, null
  9781. */
  9782. getShadowMap(): Nullable<RenderTargetTexture>;
  9783. /**
  9784. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9785. * @returns The render target texture if the shadow map is present otherwise, null
  9786. */
  9787. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9788. /**
  9789. * Gets the class name of that object
  9790. * @returns "ShadowGenerator"
  9791. */
  9792. getClassName(): string;
  9793. /**
  9794. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9795. * @param mesh Mesh to add
  9796. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9797. * @returns the Shadow Generator itself
  9798. */
  9799. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9800. /**
  9801. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9802. * @param mesh Mesh to remove
  9803. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9804. * @returns the Shadow Generator itself
  9805. */
  9806. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9807. /**
  9808. * Controls the extent to which the shadows fade out at the edge of the frustum
  9809. * Used only by directionals and spots
  9810. */
  9811. frustumEdgeFalloff: number;
  9812. private _light;
  9813. /**
  9814. * Returns the associated light object.
  9815. * @returns the light generating the shadow
  9816. */
  9817. getLight(): IShadowLight;
  9818. /**
  9819. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9820. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9821. * It might on the other hand introduce peter panning.
  9822. */
  9823. forceBackFacesOnly: boolean;
  9824. private _scene;
  9825. private _lightDirection;
  9826. private _effect;
  9827. private _viewMatrix;
  9828. private _projectionMatrix;
  9829. private _transformMatrix;
  9830. private _cachedPosition;
  9831. private _cachedDirection;
  9832. private _cachedDefines;
  9833. private _currentRenderID;
  9834. private _boxBlurPostprocess;
  9835. private _kernelBlurXPostprocess;
  9836. private _kernelBlurYPostprocess;
  9837. private _blurPostProcesses;
  9838. private _mapSize;
  9839. private _currentFaceIndex;
  9840. private _currentFaceIndexCache;
  9841. private _textureType;
  9842. private _defaultTextureMatrix;
  9843. /** @hidden */
  9844. static _SceneComponentInitialization: (scene: Scene) => void;
  9845. /**
  9846. * Creates a ShadowGenerator object.
  9847. * A ShadowGenerator is the required tool to use the shadows.
  9848. * Each light casting shadows needs to use its own ShadowGenerator.
  9849. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9850. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9851. * @param light The light object generating the shadows.
  9852. * @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.
  9853. */
  9854. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9855. private _initializeGenerator;
  9856. private _initializeShadowMap;
  9857. private _initializeBlurRTTAndPostProcesses;
  9858. private _renderForShadowMap;
  9859. private _renderSubMeshForShadowMap;
  9860. private _applyFilterValues;
  9861. /**
  9862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9863. * @param onCompiled Callback triggered at the and of the effects compilation
  9864. * @param options Sets of optional options forcing the compilation with different modes
  9865. */
  9866. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9867. useInstances: boolean;
  9868. }>): void;
  9869. /**
  9870. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9871. * @param options Sets of optional options forcing the compilation with different modes
  9872. * @returns A promise that resolves when the compilation completes
  9873. */
  9874. forceCompilationAsync(options?: Partial<{
  9875. useInstances: boolean;
  9876. }>): Promise<void>;
  9877. /**
  9878. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9879. * @param subMesh The submesh we want to render in the shadow map
  9880. * @param useInstances Defines wether will draw in the map using instances
  9881. * @returns true if ready otherwise, false
  9882. */
  9883. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9884. /**
  9885. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9886. * @param defines Defines of the material we want to update
  9887. * @param lightIndex Index of the light in the enabled light list of the material
  9888. */
  9889. prepareDefines(defines: any, lightIndex: number): void;
  9890. /**
  9891. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9892. * defined in the generator but impacting the effect).
  9893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9894. * @param effect The effect we are binfing the information for
  9895. */
  9896. bindShadowLight(lightIndex: string, effect: Effect): void;
  9897. /**
  9898. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9899. * (eq to shadow prjection matrix * light transform matrix)
  9900. * @returns The transform matrix used to create the shadow map
  9901. */
  9902. getTransformMatrix(): Matrix;
  9903. /**
  9904. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9905. * Cube and 2D textures for instance.
  9906. */
  9907. recreateShadowMap(): void;
  9908. private _disposeBlurPostProcesses;
  9909. private _disposeRTTandPostProcesses;
  9910. /**
  9911. * Disposes the ShadowGenerator.
  9912. * Returns nothing.
  9913. */
  9914. dispose(): void;
  9915. /**
  9916. * Serializes the shadow generator setup to a json object.
  9917. * @returns The serialized JSON object
  9918. */
  9919. serialize(): any;
  9920. /**
  9921. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9922. * @param parsedShadowGenerator The JSON object to parse
  9923. * @param scene The scene to create the shadow map for
  9924. * @returns The parsed shadow generator
  9925. */
  9926. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9927. }
  9928. }
  9929. declare module "babylonjs/Lights/light" {
  9930. import { Nullable } from "babylonjs/types";
  9931. import { Scene } from "babylonjs/scene";
  9932. import { Vector3 } from "babylonjs/Maths/math.vector";
  9933. import { Color3 } from "babylonjs/Maths/math.color";
  9934. import { Node } from "babylonjs/node";
  9935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9936. import { Effect } from "babylonjs/Materials/effect";
  9937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9938. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9939. /**
  9940. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9941. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9942. * 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.
  9943. */
  9944. export abstract class Light extends Node {
  9945. /**
  9946. * Falloff Default: light is falling off following the material specification:
  9947. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9948. */
  9949. static readonly FALLOFF_DEFAULT: number;
  9950. /**
  9951. * Falloff Physical: light is falling off following the inverse squared distance law.
  9952. */
  9953. static readonly FALLOFF_PHYSICAL: number;
  9954. /**
  9955. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9956. * to enhance interoperability with other engines.
  9957. */
  9958. static readonly FALLOFF_GLTF: number;
  9959. /**
  9960. * Falloff Standard: light is falling off like in the standard material
  9961. * to enhance interoperability with other materials.
  9962. */
  9963. static readonly FALLOFF_STANDARD: number;
  9964. /**
  9965. * If every light affecting the material is in this lightmapMode,
  9966. * material.lightmapTexture adds or multiplies
  9967. * (depends on material.useLightmapAsShadowmap)
  9968. * after every other light calculations.
  9969. */
  9970. static readonly LIGHTMAP_DEFAULT: number;
  9971. /**
  9972. * material.lightmapTexture as only diffuse lighting from this light
  9973. * adds only specular lighting from this light
  9974. * adds dynamic shadows
  9975. */
  9976. static readonly LIGHTMAP_SPECULAR: number;
  9977. /**
  9978. * material.lightmapTexture as only lighting
  9979. * no light calculation from this light
  9980. * only adds dynamic shadows from this light
  9981. */
  9982. static readonly LIGHTMAP_SHADOWSONLY: number;
  9983. /**
  9984. * Each light type uses the default quantity according to its type:
  9985. * point/spot lights use luminous intensity
  9986. * directional lights use illuminance
  9987. */
  9988. static readonly INTENSITYMODE_AUTOMATIC: number;
  9989. /**
  9990. * lumen (lm)
  9991. */
  9992. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9993. /**
  9994. * candela (lm/sr)
  9995. */
  9996. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9997. /**
  9998. * lux (lm/m^2)
  9999. */
  10000. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10001. /**
  10002. * nit (cd/m^2)
  10003. */
  10004. static readonly INTENSITYMODE_LUMINANCE: number;
  10005. /**
  10006. * Light type const id of the point light.
  10007. */
  10008. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10009. /**
  10010. * Light type const id of the directional light.
  10011. */
  10012. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10013. /**
  10014. * Light type const id of the spot light.
  10015. */
  10016. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10017. /**
  10018. * Light type const id of the hemispheric light.
  10019. */
  10020. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10021. /**
  10022. * Diffuse gives the basic color to an object.
  10023. */
  10024. diffuse: Color3;
  10025. /**
  10026. * Specular produces a highlight color on an object.
  10027. * Note: This is note affecting PBR materials.
  10028. */
  10029. specular: Color3;
  10030. /**
  10031. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10032. * falling off base on range or angle.
  10033. * This can be set to any values in Light.FALLOFF_x.
  10034. *
  10035. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10036. * other types of materials.
  10037. */
  10038. falloffType: number;
  10039. /**
  10040. * Strength of the light.
  10041. * Note: By default it is define in the framework own unit.
  10042. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10043. */
  10044. intensity: number;
  10045. private _range;
  10046. protected _inverseSquaredRange: number;
  10047. /**
  10048. * Defines how far from the source the light is impacting in scene units.
  10049. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10050. */
  10051. /**
  10052. * Defines how far from the source the light is impacting in scene units.
  10053. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10054. */
  10055. range: number;
  10056. /**
  10057. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10058. * of light.
  10059. */
  10060. private _photometricScale;
  10061. private _intensityMode;
  10062. /**
  10063. * Gets the photometric scale used to interpret the intensity.
  10064. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10065. */
  10066. /**
  10067. * Sets the photometric scale used to interpret the intensity.
  10068. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10069. */
  10070. intensityMode: number;
  10071. private _radius;
  10072. /**
  10073. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10074. */
  10075. /**
  10076. * sets the light radius used by PBR Materials to simulate soft area lights.
  10077. */
  10078. radius: number;
  10079. private _renderPriority;
  10080. /**
  10081. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10082. * exceeding the number allowed of the materials.
  10083. */
  10084. renderPriority: number;
  10085. private _shadowEnabled;
  10086. /**
  10087. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10088. * the current shadow generator.
  10089. */
  10090. /**
  10091. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10092. * the current shadow generator.
  10093. */
  10094. shadowEnabled: boolean;
  10095. private _includedOnlyMeshes;
  10096. /**
  10097. * Gets the only meshes impacted by this light.
  10098. */
  10099. /**
  10100. * Sets the only meshes impacted by this light.
  10101. */
  10102. includedOnlyMeshes: AbstractMesh[];
  10103. private _excludedMeshes;
  10104. /**
  10105. * Gets the meshes not impacted by this light.
  10106. */
  10107. /**
  10108. * Sets the meshes not impacted by this light.
  10109. */
  10110. excludedMeshes: AbstractMesh[];
  10111. private _excludeWithLayerMask;
  10112. /**
  10113. * Gets the layer id use to find what meshes are not impacted by the light.
  10114. * Inactive if 0
  10115. */
  10116. /**
  10117. * Sets the layer id use to find what meshes are not impacted by the light.
  10118. * Inactive if 0
  10119. */
  10120. excludeWithLayerMask: number;
  10121. private _includeOnlyWithLayerMask;
  10122. /**
  10123. * Gets the layer id use to find what meshes are impacted by the light.
  10124. * Inactive if 0
  10125. */
  10126. /**
  10127. * Sets the layer id use to find what meshes are impacted by the light.
  10128. * Inactive if 0
  10129. */
  10130. includeOnlyWithLayerMask: number;
  10131. private _lightmapMode;
  10132. /**
  10133. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10134. */
  10135. /**
  10136. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10137. */
  10138. lightmapMode: number;
  10139. /**
  10140. * Shadow generator associted to the light.
  10141. * @hidden Internal use only.
  10142. */
  10143. _shadowGenerator: Nullable<IShadowGenerator>;
  10144. /**
  10145. * @hidden Internal use only.
  10146. */
  10147. _excludedMeshesIds: string[];
  10148. /**
  10149. * @hidden Internal use only.
  10150. */
  10151. _includedOnlyMeshesIds: string[];
  10152. /**
  10153. * The current light unifom buffer.
  10154. * @hidden Internal use only.
  10155. */
  10156. _uniformBuffer: UniformBuffer;
  10157. /**
  10158. * Creates a Light object in the scene.
  10159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10160. * @param name The firendly name of the light
  10161. * @param scene The scene the light belongs too
  10162. */
  10163. constructor(name: string, scene: Scene);
  10164. protected abstract _buildUniformLayout(): void;
  10165. /**
  10166. * Sets the passed Effect "effect" with the Light information.
  10167. * @param effect The effect to update
  10168. * @param lightIndex The index of the light in the effect to update
  10169. * @returns The light
  10170. */
  10171. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10172. /**
  10173. * Sets the passed Effect "effect" with the Light information.
  10174. * @param effect The effect to update
  10175. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10176. * @returns The light
  10177. */
  10178. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10179. /**
  10180. * Returns the string "Light".
  10181. * @returns the class name
  10182. */
  10183. getClassName(): string;
  10184. /** @hidden */
  10185. readonly _isLight: boolean;
  10186. /**
  10187. * Converts the light information to a readable string for debug purpose.
  10188. * @param fullDetails Supports for multiple levels of logging within scene loading
  10189. * @returns the human readable light info
  10190. */
  10191. toString(fullDetails?: boolean): string;
  10192. /** @hidden */
  10193. protected _syncParentEnabledState(): void;
  10194. /**
  10195. * Set the enabled state of this node.
  10196. * @param value - the new enabled state
  10197. */
  10198. setEnabled(value: boolean): void;
  10199. /**
  10200. * Returns the Light associated shadow generator if any.
  10201. * @return the associated shadow generator.
  10202. */
  10203. getShadowGenerator(): Nullable<IShadowGenerator>;
  10204. /**
  10205. * Returns a Vector3, the absolute light position in the World.
  10206. * @returns the world space position of the light
  10207. */
  10208. getAbsolutePosition(): Vector3;
  10209. /**
  10210. * Specifies if the light will affect the passed mesh.
  10211. * @param mesh The mesh to test against the light
  10212. * @return true the mesh is affected otherwise, false.
  10213. */
  10214. canAffectMesh(mesh: AbstractMesh): boolean;
  10215. /**
  10216. * Sort function to order lights for rendering.
  10217. * @param a First Light object to compare to second.
  10218. * @param b Second Light object to compare first.
  10219. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10220. */
  10221. static CompareLightsPriority(a: Light, b: Light): number;
  10222. /**
  10223. * Releases resources associated with this node.
  10224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10226. */
  10227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10228. /**
  10229. * Returns the light type ID (integer).
  10230. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10231. */
  10232. getTypeID(): number;
  10233. /**
  10234. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10235. * @returns the scaled intensity in intensity mode unit
  10236. */
  10237. getScaledIntensity(): number;
  10238. /**
  10239. * Returns a new Light object, named "name", from the current one.
  10240. * @param name The name of the cloned light
  10241. * @returns the new created light
  10242. */
  10243. clone(name: string): Nullable<Light>;
  10244. /**
  10245. * Serializes the current light into a Serialization object.
  10246. * @returns the serialized object.
  10247. */
  10248. serialize(): any;
  10249. /**
  10250. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10251. * This new light is named "name" and added to the passed scene.
  10252. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10253. * @param name The friendly name of the light
  10254. * @param scene The scene the new light will belong to
  10255. * @returns the constructor function
  10256. */
  10257. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10258. /**
  10259. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10260. * @param parsedLight The JSON representation of the light
  10261. * @param scene The scene to create the parsed light in
  10262. * @returns the created light after parsing
  10263. */
  10264. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10265. private _hookArrayForExcluded;
  10266. private _hookArrayForIncludedOnly;
  10267. private _resyncMeshes;
  10268. /**
  10269. * Forces the meshes to update their light related information in their rendering used effects
  10270. * @hidden Internal Use Only
  10271. */
  10272. _markMeshesAsLightDirty(): void;
  10273. /**
  10274. * Recomputes the cached photometric scale if needed.
  10275. */
  10276. private _computePhotometricScale;
  10277. /**
  10278. * Returns the Photometric Scale according to the light type and intensity mode.
  10279. */
  10280. private _getPhotometricScale;
  10281. /**
  10282. * Reorder the light in the scene according to their defined priority.
  10283. * @hidden Internal Use Only
  10284. */
  10285. _reorderLightsInScene(): void;
  10286. /**
  10287. * Prepares the list of defines specific to the light type.
  10288. * @param defines the list of defines
  10289. * @param lightIndex defines the index of the light for the effect
  10290. */
  10291. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10292. }
  10293. }
  10294. declare module "babylonjs/Actions/action" {
  10295. import { Observable } from "babylonjs/Misc/observable";
  10296. import { Condition } from "babylonjs/Actions/condition";
  10297. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10298. import { ActionManager } from "babylonjs/Actions/actionManager";
  10299. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10300. /**
  10301. * Interface used to define Action
  10302. */
  10303. export interface IAction {
  10304. /**
  10305. * Trigger for the action
  10306. */
  10307. trigger: number;
  10308. /** Options of the trigger */
  10309. triggerOptions: any;
  10310. /**
  10311. * Gets the trigger parameters
  10312. * @returns the trigger parameters
  10313. */
  10314. getTriggerParameter(): any;
  10315. /**
  10316. * Internal only - executes current action event
  10317. * @hidden
  10318. */
  10319. _executeCurrent(evt?: ActionEvent): void;
  10320. /**
  10321. * Serialize placeholder for child classes
  10322. * @param parent of child
  10323. * @returns the serialized object
  10324. */
  10325. serialize(parent: any): any;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _prepare(): void;
  10331. /**
  10332. * Internal only - manager for action
  10333. * @hidden
  10334. */
  10335. _actionManager: AbstractActionManager;
  10336. /**
  10337. * Adds action to chain of actions, may be a DoNothingAction
  10338. * @param action defines the next action to execute
  10339. * @returns The action passed in
  10340. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10341. */
  10342. then(action: IAction): IAction;
  10343. }
  10344. /**
  10345. * The action to be carried out following a trigger
  10346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10347. */
  10348. export class Action implements IAction {
  10349. /** the trigger, with or without parameters, for the action */
  10350. triggerOptions: any;
  10351. /**
  10352. * Trigger for the action
  10353. */
  10354. trigger: number;
  10355. /**
  10356. * Internal only - manager for action
  10357. * @hidden
  10358. */
  10359. _actionManager: ActionManager;
  10360. private _nextActiveAction;
  10361. private _child;
  10362. private _condition?;
  10363. private _triggerParameter;
  10364. /**
  10365. * An event triggered prior to action being executed.
  10366. */
  10367. onBeforeExecuteObservable: Observable<Action>;
  10368. /**
  10369. * Creates a new Action
  10370. * @param triggerOptions the trigger, with or without parameters, for the action
  10371. * @param condition an optional determinant of action
  10372. */
  10373. constructor(
  10374. /** the trigger, with or without parameters, for the action */
  10375. triggerOptions: any, condition?: Condition);
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. _prepare(): void;
  10381. /**
  10382. * Gets the trigger parameters
  10383. * @returns the trigger parameters
  10384. */
  10385. getTriggerParameter(): any;
  10386. /**
  10387. * Internal only - executes current action event
  10388. * @hidden
  10389. */
  10390. _executeCurrent(evt?: ActionEvent): void;
  10391. /**
  10392. * Execute placeholder for child classes
  10393. * @param evt optional action event
  10394. */
  10395. execute(evt?: ActionEvent): void;
  10396. /**
  10397. * Skips to next active action
  10398. */
  10399. skipToNextActiveAction(): void;
  10400. /**
  10401. * Adds action to chain of actions, may be a DoNothingAction
  10402. * @param action defines the next action to execute
  10403. * @returns The action passed in
  10404. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10405. */
  10406. then(action: Action): Action;
  10407. /**
  10408. * Internal only
  10409. * @hidden
  10410. */
  10411. _getProperty(propertyPath: string): string;
  10412. /**
  10413. * Internal only
  10414. * @hidden
  10415. */
  10416. _getEffectiveTarget(target: any, propertyPath: string): any;
  10417. /**
  10418. * Serialize placeholder for child classes
  10419. * @param parent of child
  10420. * @returns the serialized object
  10421. */
  10422. serialize(parent: any): any;
  10423. /**
  10424. * Internal only called by serialize
  10425. * @hidden
  10426. */
  10427. protected _serialize(serializedAction: any, parent?: any): any;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. static _SerializeValueAsString: (value: any) => string;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10438. name: string;
  10439. targetType: string;
  10440. value: string;
  10441. };
  10442. }
  10443. }
  10444. declare module "babylonjs/Actions/condition" {
  10445. import { ActionManager } from "babylonjs/Actions/actionManager";
  10446. /**
  10447. * A Condition applied to an Action
  10448. */
  10449. export class Condition {
  10450. /**
  10451. * Internal only - manager for action
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _evaluationId: number;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _currentResult: boolean;
  10465. /**
  10466. * Creates a new Condition
  10467. * @param actionManager the manager of the action the condition is applied to
  10468. */
  10469. constructor(actionManager: ActionManager);
  10470. /**
  10471. * Check if the current condition is valid
  10472. * @returns a boolean
  10473. */
  10474. isValid(): boolean;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. _getProperty(propertyPath: string): string;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. _getEffectiveTarget(target: any, propertyPath: string): any;
  10485. /**
  10486. * Serialize placeholder for child classes
  10487. * @returns the serialized object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. protected _serialize(serializedCondition: any): any;
  10495. }
  10496. /**
  10497. * Defines specific conditional operators as extensions of Condition
  10498. */
  10499. export class ValueCondition extends Condition {
  10500. /** path to specify the property of the target the conditional operator uses */
  10501. propertyPath: string;
  10502. /** the value compared by the conditional operator against the current value of the property */
  10503. value: any;
  10504. /** the conditional operator, default ValueCondition.IsEqual */
  10505. operator: number;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private static _IsEqual;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. private static _IsDifferent;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. private static _IsGreater;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. private static _IsLesser;
  10526. /**
  10527. * returns the number for IsEqual
  10528. */
  10529. static readonly IsEqual: number;
  10530. /**
  10531. * Returns the number for IsDifferent
  10532. */
  10533. static readonly IsDifferent: number;
  10534. /**
  10535. * Returns the number for IsGreater
  10536. */
  10537. static readonly IsGreater: number;
  10538. /**
  10539. * Returns the number for IsLesser
  10540. */
  10541. static readonly IsLesser: number;
  10542. /**
  10543. * Internal only The action manager for the condition
  10544. * @hidden
  10545. */
  10546. _actionManager: ActionManager;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private _target;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private _effectiveTarget;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private _property;
  10562. /**
  10563. * Creates a new ValueCondition
  10564. * @param actionManager manager for the action the condition applies to
  10565. * @param target for the action
  10566. * @param propertyPath path to specify the property of the target the conditional operator uses
  10567. * @param value the value compared by the conditional operator against the current value of the property
  10568. * @param operator the conditional operator, default ValueCondition.IsEqual
  10569. */
  10570. constructor(actionManager: ActionManager, target: any,
  10571. /** path to specify the property of the target the conditional operator uses */
  10572. propertyPath: string,
  10573. /** the value compared by the conditional operator against the current value of the property */
  10574. value: any,
  10575. /** the conditional operator, default ValueCondition.IsEqual */
  10576. operator?: number);
  10577. /**
  10578. * Compares the given value with the property value for the specified conditional operator
  10579. * @returns the result of the comparison
  10580. */
  10581. isValid(): boolean;
  10582. /**
  10583. * Serialize the ValueCondition into a JSON compatible object
  10584. * @returns serialization object
  10585. */
  10586. serialize(): any;
  10587. /**
  10588. * Gets the name of the conditional operator for the ValueCondition
  10589. * @param operator the conditional operator
  10590. * @returns the name
  10591. */
  10592. static GetOperatorName(operator: number): string;
  10593. }
  10594. /**
  10595. * Defines a predicate condition as an extension of Condition
  10596. */
  10597. export class PredicateCondition extends Condition {
  10598. /** defines the predicate function used to validate the condition */
  10599. predicate: () => boolean;
  10600. /**
  10601. * Internal only - manager for action
  10602. * @hidden
  10603. */
  10604. _actionManager: ActionManager;
  10605. /**
  10606. * Creates a new PredicateCondition
  10607. * @param actionManager manager for the action the condition applies to
  10608. * @param predicate defines the predicate function used to validate the condition
  10609. */
  10610. constructor(actionManager: ActionManager,
  10611. /** defines the predicate function used to validate the condition */
  10612. predicate: () => boolean);
  10613. /**
  10614. * @returns the validity of the predicate condition
  10615. */
  10616. isValid(): boolean;
  10617. }
  10618. /**
  10619. * Defines a state condition as an extension of Condition
  10620. */
  10621. export class StateCondition extends Condition {
  10622. /** Value to compare with target state */
  10623. value: string;
  10624. /**
  10625. * Internal only - manager for action
  10626. * @hidden
  10627. */
  10628. _actionManager: ActionManager;
  10629. /**
  10630. * Internal only
  10631. * @hidden
  10632. */
  10633. private _target;
  10634. /**
  10635. * Creates a new StateCondition
  10636. * @param actionManager manager for the action the condition applies to
  10637. * @param target of the condition
  10638. * @param value to compare with target state
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** Value to compare with target state */
  10642. value: string);
  10643. /**
  10644. * Gets a boolean indicating if the current condition is met
  10645. * @returns the validity of the state
  10646. */
  10647. isValid(): boolean;
  10648. /**
  10649. * Serialize the StateCondition into a JSON compatible object
  10650. * @returns serialization object
  10651. */
  10652. serialize(): any;
  10653. }
  10654. }
  10655. declare module "babylonjs/Actions/directActions" {
  10656. import { Action } from "babylonjs/Actions/action";
  10657. import { Condition } from "babylonjs/Actions/condition";
  10658. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10659. /**
  10660. * This defines an action responsible to toggle a boolean once triggered.
  10661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10662. */
  10663. export class SwitchBooleanAction extends Action {
  10664. /**
  10665. * The path to the boolean property in the target object
  10666. */
  10667. propertyPath: string;
  10668. private _target;
  10669. private _effectiveTarget;
  10670. private _property;
  10671. /**
  10672. * Instantiate the action
  10673. * @param triggerOptions defines the trigger options
  10674. * @param target defines the object containing the boolean
  10675. * @param propertyPath defines the path to the boolean property in the target object
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action toggle the boolean value.
  10683. */
  10684. execute(): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to set a the state field of the target
  10694. * to a desired value once triggered.
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10696. */
  10697. export class SetStateAction extends Action {
  10698. /**
  10699. * The value to store in the state field.
  10700. */
  10701. value: string;
  10702. private _target;
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param target defines the object containing the state property
  10707. * @param value defines the value to store in the state field
  10708. * @param condition defines the trigger related conditions
  10709. */
  10710. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10711. /**
  10712. * Execute the action and store the value on the target state property.
  10713. */
  10714. execute(): void;
  10715. /**
  10716. * Serializes the actions and its related information.
  10717. * @param parent defines the object to serialize in
  10718. * @returns the serialized object
  10719. */
  10720. serialize(parent: any): any;
  10721. }
  10722. /**
  10723. * This defines an action responsible to set a property of the target
  10724. * to a desired value once triggered.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class SetValueAction extends Action {
  10728. /**
  10729. * The path of the property to set in the target.
  10730. */
  10731. propertyPath: string;
  10732. /**
  10733. * The value to set in the property
  10734. */
  10735. value: any;
  10736. private _target;
  10737. private _effectiveTarget;
  10738. private _property;
  10739. /**
  10740. * Instantiate the action
  10741. * @param triggerOptions defines the trigger options
  10742. * @param target defines the object containing the property
  10743. * @param propertyPath defines the path of the property to set in the target
  10744. * @param value defines the value to set in the property
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10748. /** @hidden */
  10749. _prepare(): void;
  10750. /**
  10751. * Execute the action and set the targetted property to the desired value.
  10752. */
  10753. execute(): void;
  10754. /**
  10755. * Serializes the actions and its related information.
  10756. * @param parent defines the object to serialize in
  10757. * @returns the serialized object
  10758. */
  10759. serialize(parent: any): any;
  10760. }
  10761. /**
  10762. * This defines an action responsible to increment the target value
  10763. * to a desired value once triggered.
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10765. */
  10766. export class IncrementValueAction extends Action {
  10767. /**
  10768. * The path of the property to increment in the target.
  10769. */
  10770. propertyPath: string;
  10771. /**
  10772. * The value we should increment the property by.
  10773. */
  10774. value: any;
  10775. private _target;
  10776. private _effectiveTarget;
  10777. private _property;
  10778. /**
  10779. * Instantiate the action
  10780. * @param triggerOptions defines the trigger options
  10781. * @param target defines the object containing the property
  10782. * @param propertyPath defines the path of the property to increment in the target
  10783. * @param value defines the value value we should increment the property by
  10784. * @param condition defines the trigger related conditions
  10785. */
  10786. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10787. /** @hidden */
  10788. _prepare(): void;
  10789. /**
  10790. * Execute the action and increment the target of the value amount.
  10791. */
  10792. execute(): void;
  10793. /**
  10794. * Serializes the actions and its related information.
  10795. * @param parent defines the object to serialize in
  10796. * @returns the serialized object
  10797. */
  10798. serialize(parent: any): any;
  10799. }
  10800. /**
  10801. * This defines an action responsible to start an animation once triggered.
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10803. */
  10804. export class PlayAnimationAction extends Action {
  10805. /**
  10806. * Where the animation should start (animation frame)
  10807. */
  10808. from: number;
  10809. /**
  10810. * Where the animation should stop (animation frame)
  10811. */
  10812. to: number;
  10813. /**
  10814. * Define if the animation should loop or stop after the first play.
  10815. */
  10816. loop?: boolean;
  10817. private _target;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the target animation or animation name
  10822. * @param from defines from where the animation should start (animation frame)
  10823. * @param end defines where the animation should stop (animation frame)
  10824. * @param loop defines if the animation should loop or stop after the first play
  10825. * @param condition defines the trigger related conditions
  10826. */
  10827. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10828. /** @hidden */
  10829. _prepare(): void;
  10830. /**
  10831. * Execute the action and play the animation.
  10832. */
  10833. execute(): void;
  10834. /**
  10835. * Serializes the actions and its related information.
  10836. * @param parent defines the object to serialize in
  10837. * @returns the serialized object
  10838. */
  10839. serialize(parent: any): any;
  10840. }
  10841. /**
  10842. * This defines an action responsible to stop an animation once triggered.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class StopAnimationAction extends Action {
  10846. private _target;
  10847. /**
  10848. * Instantiate the action
  10849. * @param triggerOptions defines the trigger options
  10850. * @param target defines the target animation or animation name
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and stop the animation.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. /**
  10868. * This defines an action responsible that does nothing once triggered.
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10870. */
  10871. export class DoNothingAction extends Action {
  10872. /**
  10873. * Instantiate the action
  10874. * @param triggerOptions defines the trigger options
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions?: any, condition?: Condition);
  10878. /**
  10879. * Execute the action and do nothing.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to trigger several actions once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class CombineAction extends Action {
  10894. /**
  10895. * The list of aggregated animations to run.
  10896. */
  10897. children: Action[];
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param children defines the list of aggregated animations to run
  10902. * @param condition defines the trigger related conditions
  10903. */
  10904. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10905. /** @hidden */
  10906. _prepare(): void;
  10907. /**
  10908. * Execute the action and executes all the aggregated actions.
  10909. */
  10910. execute(evt: ActionEvent): void;
  10911. /**
  10912. * Serializes the actions and its related information.
  10913. * @param parent defines the object to serialize in
  10914. * @returns the serialized object
  10915. */
  10916. serialize(parent: any): any;
  10917. }
  10918. /**
  10919. * This defines an action responsible to run code (external event) once triggered.
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10921. */
  10922. export class ExecuteCodeAction extends Action {
  10923. /**
  10924. * The callback function to run.
  10925. */
  10926. func: (evt: ActionEvent) => void;
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param func defines the callback function to run
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10934. /**
  10935. * Execute the action and run the attached code.
  10936. */
  10937. execute(evt: ActionEvent): void;
  10938. }
  10939. /**
  10940. * This defines an action responsible to set the parent property of the target once triggered.
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10942. */
  10943. export class SetParentAction extends Action {
  10944. private _parent;
  10945. private _target;
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param target defines the target containing the parent property
  10950. * @param parent defines from where the animation should start (animation frame)
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10954. /** @hidden */
  10955. _prepare(): void;
  10956. /**
  10957. * Execute the action and set the parent property.
  10958. */
  10959. execute(): void;
  10960. /**
  10961. * Serializes the actions and its related information.
  10962. * @param parent defines the object to serialize in
  10963. * @returns the serialized object
  10964. */
  10965. serialize(parent: any): any;
  10966. }
  10967. }
  10968. declare module "babylonjs/Actions/actionManager" {
  10969. import { Nullable } from "babylonjs/types";
  10970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10971. import { Scene } from "babylonjs/scene";
  10972. import { IAction } from "babylonjs/Actions/action";
  10973. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10974. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10975. /**
  10976. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10977. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10979. */
  10980. export class ActionManager extends AbstractActionManager {
  10981. /**
  10982. * Nothing
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly NothingTrigger: number;
  10986. /**
  10987. * On pick
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnPickTrigger: number;
  10991. /**
  10992. * On left pick
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnLeftPickTrigger: number;
  10996. /**
  10997. * On right pick
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnRightPickTrigger: number;
  11001. /**
  11002. * On center pick
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnCenterPickTrigger: number;
  11006. /**
  11007. * On pick down
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnPickDownTrigger: number;
  11011. /**
  11012. * On double pick
  11013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11014. */
  11015. static readonly OnDoublePickTrigger: number;
  11016. /**
  11017. * On pick up
  11018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11019. */
  11020. static readonly OnPickUpTrigger: number;
  11021. /**
  11022. * On pick out.
  11023. * This trigger will only be raised if you also declared a OnPickDown
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnPickOutTrigger: number;
  11027. /**
  11028. * On long press
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnLongPressTrigger: number;
  11032. /**
  11033. * On pointer over
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPointerOverTrigger: number;
  11037. /**
  11038. * On pointer out
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly OnPointerOutTrigger: number;
  11042. /**
  11043. * On every frame
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnEveryFrameTrigger: number;
  11047. /**
  11048. * On intersection enter
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11050. */
  11051. static readonly OnIntersectionEnterTrigger: number;
  11052. /**
  11053. * On intersection exit
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly OnIntersectionExitTrigger: number;
  11057. /**
  11058. * On key down
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnKeyDownTrigger: number;
  11062. /**
  11063. * On key up
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnKeyUpTrigger: number;
  11067. private _scene;
  11068. /**
  11069. * Creates a new action manager
  11070. * @param scene defines the hosting scene
  11071. */
  11072. constructor(scene: Scene);
  11073. /**
  11074. * Releases all associated resources
  11075. */
  11076. dispose(): void;
  11077. /**
  11078. * Gets hosting scene
  11079. * @returns the hosting scene
  11080. */
  11081. getScene(): Scene;
  11082. /**
  11083. * Does this action manager handles actions of any of the given triggers
  11084. * @param triggers defines the triggers to be tested
  11085. * @return a boolean indicating whether one (or more) of the triggers is handled
  11086. */
  11087. hasSpecificTriggers(triggers: number[]): boolean;
  11088. /**
  11089. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11090. * speed.
  11091. * @param triggerA defines the trigger to be tested
  11092. * @param triggerB defines the trigger to be tested
  11093. * @return a boolean indicating whether one (or more) of the triggers is handled
  11094. */
  11095. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11096. /**
  11097. * Does this action manager handles actions of a given trigger
  11098. * @param trigger defines the trigger to be tested
  11099. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11100. * @return whether the trigger is handled
  11101. */
  11102. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11103. /**
  11104. * Does this action manager has pointer triggers
  11105. */
  11106. readonly hasPointerTriggers: boolean;
  11107. /**
  11108. * Does this action manager has pick triggers
  11109. */
  11110. readonly hasPickTriggers: boolean;
  11111. /**
  11112. * Registers an action to this action manager
  11113. * @param action defines the action to be registered
  11114. * @return the action amended (prepared) after registration
  11115. */
  11116. registerAction(action: IAction): Nullable<IAction>;
  11117. /**
  11118. * Unregisters an action to this action manager
  11119. * @param action defines the action to be unregistered
  11120. * @return a boolean indicating whether the action has been unregistered
  11121. */
  11122. unregisterAction(action: IAction): Boolean;
  11123. /**
  11124. * Process a specific trigger
  11125. * @param trigger defines the trigger to process
  11126. * @param evt defines the event details to be processed
  11127. */
  11128. processTrigger(trigger: number, evt?: IActionEvent): void;
  11129. /** @hidden */
  11130. _getEffectiveTarget(target: any, propertyPath: string): any;
  11131. /** @hidden */
  11132. _getProperty(propertyPath: string): string;
  11133. /**
  11134. * Serialize this manager to a JSON object
  11135. * @param name defines the property name to store this manager
  11136. * @returns a JSON representation of this manager
  11137. */
  11138. serialize(name: string): any;
  11139. /**
  11140. * Creates a new ActionManager from a JSON data
  11141. * @param parsedActions defines the JSON data to read from
  11142. * @param object defines the hosting mesh
  11143. * @param scene defines the hosting scene
  11144. */
  11145. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11146. /**
  11147. * Get a trigger name by index
  11148. * @param trigger defines the trigger index
  11149. * @returns a trigger name
  11150. */
  11151. static GetTriggerName(trigger: number): string;
  11152. }
  11153. }
  11154. declare module "babylonjs/Culling/ray" {
  11155. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11156. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11158. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11159. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11160. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11161. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11162. import { Plane } from "babylonjs/Maths/math.plane";
  11163. /**
  11164. * Class representing a ray with position and direction
  11165. */
  11166. export class Ray {
  11167. /** origin point */
  11168. origin: Vector3;
  11169. /** direction */
  11170. direction: Vector3;
  11171. /** length of the ray */
  11172. length: number;
  11173. private static readonly TmpVector3;
  11174. private _tmpRay;
  11175. /**
  11176. * Creates a new ray
  11177. * @param origin origin point
  11178. * @param direction direction
  11179. * @param length length of the ray
  11180. */
  11181. constructor(
  11182. /** origin point */
  11183. origin: Vector3,
  11184. /** direction */
  11185. direction: Vector3,
  11186. /** length of the ray */
  11187. length?: number);
  11188. /**
  11189. * Checks if the ray intersects a box
  11190. * @param minimum bound of the box
  11191. * @param maximum bound of the box
  11192. * @param intersectionTreshold extra extend to be added to the box in all direction
  11193. * @returns if the box was hit
  11194. */
  11195. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11196. /**
  11197. * Checks if the ray intersects a box
  11198. * @param box the bounding box to check
  11199. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11200. * @returns if the box was hit
  11201. */
  11202. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11203. /**
  11204. * If the ray hits a sphere
  11205. * @param sphere the bounding sphere to check
  11206. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11207. * @returns true if it hits the sphere
  11208. */
  11209. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11210. /**
  11211. * If the ray hits a triange
  11212. * @param vertex0 triangle vertex
  11213. * @param vertex1 triangle vertex
  11214. * @param vertex2 triangle vertex
  11215. * @returns intersection information if hit
  11216. */
  11217. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11218. /**
  11219. * Checks if ray intersects a plane
  11220. * @param plane the plane to check
  11221. * @returns the distance away it was hit
  11222. */
  11223. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11224. /**
  11225. * Calculate the intercept of a ray on a given axis
  11226. * @param axis to check 'x' | 'y' | 'z'
  11227. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11228. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11229. */
  11230. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11231. /**
  11232. * Checks if ray intersects a mesh
  11233. * @param mesh the mesh to check
  11234. * @param fastCheck if only the bounding box should checked
  11235. * @returns picking info of the intersecton
  11236. */
  11237. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11238. /**
  11239. * Checks if ray intersects a mesh
  11240. * @param meshes the meshes to check
  11241. * @param fastCheck if only the bounding box should checked
  11242. * @param results array to store result in
  11243. * @returns Array of picking infos
  11244. */
  11245. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11246. private _comparePickingInfo;
  11247. private static smallnum;
  11248. private static rayl;
  11249. /**
  11250. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11251. * @param sega the first point of the segment to test the intersection against
  11252. * @param segb the second point of the segment to test the intersection against
  11253. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11254. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11255. */
  11256. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11257. /**
  11258. * Update the ray from viewport position
  11259. * @param x position
  11260. * @param y y position
  11261. * @param viewportWidth viewport width
  11262. * @param viewportHeight viewport height
  11263. * @param world world matrix
  11264. * @param view view matrix
  11265. * @param projection projection matrix
  11266. * @returns this ray updated
  11267. */
  11268. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11269. /**
  11270. * Creates a ray with origin and direction of 0,0,0
  11271. * @returns the new ray
  11272. */
  11273. static Zero(): Ray;
  11274. /**
  11275. * Creates a new ray from screen space and viewport
  11276. * @param x position
  11277. * @param y y position
  11278. * @param viewportWidth viewport width
  11279. * @param viewportHeight viewport height
  11280. * @param world world matrix
  11281. * @param view view matrix
  11282. * @param projection projection matrix
  11283. * @returns new ray
  11284. */
  11285. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11286. /**
  11287. * 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
  11288. * transformed to the given world matrix.
  11289. * @param origin The origin point
  11290. * @param end The end point
  11291. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11292. * @returns the new ray
  11293. */
  11294. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11295. /**
  11296. * Transforms a ray by a matrix
  11297. * @param ray ray to transform
  11298. * @param matrix matrix to apply
  11299. * @returns the resulting new ray
  11300. */
  11301. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Transforms a ray by a matrix
  11304. * @param ray ray to transform
  11305. * @param matrix matrix to apply
  11306. * @param result ray to store result in
  11307. */
  11308. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11309. /**
  11310. * Unproject a ray from screen space to object space
  11311. * @param sourceX defines the screen space x coordinate to use
  11312. * @param sourceY defines the screen space y coordinate to use
  11313. * @param viewportWidth defines the current width of the viewport
  11314. * @param viewportHeight defines the current height of the viewport
  11315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11316. * @param view defines the view matrix to use
  11317. * @param projection defines the projection matrix to use
  11318. */
  11319. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11320. }
  11321. /**
  11322. * Type used to define predicate used to select faces when a mesh intersection is detected
  11323. */
  11324. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11325. module "babylonjs/scene" {
  11326. interface Scene {
  11327. /** @hidden */
  11328. _tempPickingRay: Nullable<Ray>;
  11329. /** @hidden */
  11330. _cachedRayForTransform: Ray;
  11331. /** @hidden */
  11332. _pickWithRayInverseMatrix: Matrix;
  11333. /** @hidden */
  11334. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11335. /** @hidden */
  11336. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11337. }
  11338. }
  11339. }
  11340. declare module "babylonjs/sceneComponent" {
  11341. import { Scene } from "babylonjs/scene";
  11342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11344. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11345. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11346. import { Nullable } from "babylonjs/types";
  11347. import { Camera } from "babylonjs/Cameras/camera";
  11348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11349. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11350. import { AbstractScene } from "babylonjs/abstractScene";
  11351. /**
  11352. * Groups all the scene component constants in one place to ease maintenance.
  11353. * @hidden
  11354. */
  11355. export class SceneComponentConstants {
  11356. static readonly NAME_EFFECTLAYER: string;
  11357. static readonly NAME_LAYER: string;
  11358. static readonly NAME_LENSFLARESYSTEM: string;
  11359. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11360. static readonly NAME_PARTICLESYSTEM: string;
  11361. static readonly NAME_GAMEPAD: string;
  11362. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11363. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11364. static readonly NAME_DEPTHRENDERER: string;
  11365. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11366. static readonly NAME_SPRITE: string;
  11367. static readonly NAME_OUTLINERENDERER: string;
  11368. static readonly NAME_PROCEDURALTEXTURE: string;
  11369. static readonly NAME_SHADOWGENERATOR: string;
  11370. static readonly NAME_OCTREE: string;
  11371. static readonly NAME_PHYSICSENGINE: string;
  11372. static readonly NAME_AUDIO: string;
  11373. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11374. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11375. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11376. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11377. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11378. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11379. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11380. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11381. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11382. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11383. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11384. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11385. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11386. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11387. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11388. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11389. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11390. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11391. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11392. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11393. static readonly STEP_AFTERRENDER_AUDIO: number;
  11394. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11395. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11396. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11397. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11398. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11399. static readonly STEP_POINTERMOVE_SPRITE: number;
  11400. static readonly STEP_POINTERDOWN_SPRITE: number;
  11401. static readonly STEP_POINTERUP_SPRITE: number;
  11402. }
  11403. /**
  11404. * This represents a scene component.
  11405. *
  11406. * This is used to decouple the dependency the scene is having on the different workloads like
  11407. * layers, post processes...
  11408. */
  11409. export interface ISceneComponent {
  11410. /**
  11411. * The name of the component. Each component must have a unique name.
  11412. */
  11413. name: string;
  11414. /**
  11415. * The scene the component belongs to.
  11416. */
  11417. scene: Scene;
  11418. /**
  11419. * Register the component to one instance of a scene.
  11420. */
  11421. register(): void;
  11422. /**
  11423. * Rebuilds the elements related to this component in case of
  11424. * context lost for instance.
  11425. */
  11426. rebuild(): void;
  11427. /**
  11428. * Disposes the component and the associated ressources.
  11429. */
  11430. dispose(): void;
  11431. }
  11432. /**
  11433. * This represents a SERIALIZABLE scene component.
  11434. *
  11435. * This extends Scene Component to add Serialization methods on top.
  11436. */
  11437. export interface ISceneSerializableComponent extends ISceneComponent {
  11438. /**
  11439. * Adds all the elements from the container to the scene
  11440. * @param container the container holding the elements
  11441. */
  11442. addFromContainer(container: AbstractScene): void;
  11443. /**
  11444. * Removes all the elements in the container from the scene
  11445. * @param container contains the elements to remove
  11446. * @param dispose if the removed element should be disposed (default: false)
  11447. */
  11448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11449. /**
  11450. * Serializes the component data to the specified json object
  11451. * @param serializationObject The object to serialize to
  11452. */
  11453. serialize(serializationObject: any): void;
  11454. }
  11455. /**
  11456. * Strong typing of a Mesh related stage step action
  11457. */
  11458. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11459. /**
  11460. * Strong typing of a Evaluate Sub Mesh related stage step action
  11461. */
  11462. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11463. /**
  11464. * Strong typing of a Active Mesh related stage step action
  11465. */
  11466. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11467. /**
  11468. * Strong typing of a Camera related stage step action
  11469. */
  11470. export type CameraStageAction = (camera: Camera) => void;
  11471. /**
  11472. * Strong typing of a Camera Frame buffer related stage step action
  11473. */
  11474. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11475. /**
  11476. * Strong typing of a Render Target related stage step action
  11477. */
  11478. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11479. /**
  11480. * Strong typing of a RenderingGroup related stage step action
  11481. */
  11482. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11483. /**
  11484. * Strong typing of a Mesh Render related stage step action
  11485. */
  11486. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11487. /**
  11488. * Strong typing of a simple stage step action
  11489. */
  11490. export type SimpleStageAction = () => void;
  11491. /**
  11492. * Strong typing of a render target action.
  11493. */
  11494. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11495. /**
  11496. * Strong typing of a pointer move action.
  11497. */
  11498. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11499. /**
  11500. * Strong typing of a pointer up/down action.
  11501. */
  11502. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11503. /**
  11504. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11505. * @hidden
  11506. */
  11507. export class Stage<T extends Function> extends Array<{
  11508. index: number;
  11509. component: ISceneComponent;
  11510. action: T;
  11511. }> {
  11512. /**
  11513. * Hide ctor from the rest of the world.
  11514. * @param items The items to add.
  11515. */
  11516. private constructor();
  11517. /**
  11518. * Creates a new Stage.
  11519. * @returns A new instance of a Stage
  11520. */
  11521. static Create<T extends Function>(): Stage<T>;
  11522. /**
  11523. * Registers a step in an ordered way in the targeted stage.
  11524. * @param index Defines the position to register the step in
  11525. * @param component Defines the component attached to the step
  11526. * @param action Defines the action to launch during the step
  11527. */
  11528. registerStep(index: number, component: ISceneComponent, action: T): void;
  11529. /**
  11530. * Clears all the steps from the stage.
  11531. */
  11532. clear(): void;
  11533. }
  11534. }
  11535. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11536. import { Nullable } from "babylonjs/types";
  11537. import { Observable } from "babylonjs/Misc/observable";
  11538. import { Scene } from "babylonjs/scene";
  11539. import { Sprite } from "babylonjs/Sprites/sprite";
  11540. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. import { Camera } from "babylonjs/Cameras/camera";
  11543. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11544. import { ISceneComponent } from "babylonjs/sceneComponent";
  11545. module "babylonjs/scene" {
  11546. interface Scene {
  11547. /** @hidden */
  11548. _pointerOverSprite: Nullable<Sprite>;
  11549. /** @hidden */
  11550. _pickedDownSprite: Nullable<Sprite>;
  11551. /** @hidden */
  11552. _tempSpritePickingRay: Nullable<Ray>;
  11553. /**
  11554. * All of the sprite managers added to this scene
  11555. * @see http://doc.babylonjs.com/babylon101/sprites
  11556. */
  11557. spriteManagers: Array<ISpriteManager>;
  11558. /**
  11559. * An event triggered when sprites rendering is about to start
  11560. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11561. */
  11562. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11563. /**
  11564. * An event triggered when sprites rendering is done
  11565. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11566. */
  11567. onAfterSpritesRenderingObservable: Observable<Scene>;
  11568. /** @hidden */
  11569. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11570. /** Launch a ray to try to pick a sprite in the scene
  11571. * @param x position on screen
  11572. * @param y position on screen
  11573. * @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
  11574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11575. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11576. * @returns a PickingInfo
  11577. */
  11578. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Use the given ray to pick a sprite in the scene
  11580. * @param ray The ray (in world space) to use to pick meshes
  11581. * @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
  11582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11583. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11584. * @returns a PickingInfo
  11585. */
  11586. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11587. /** @hidden */
  11588. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11589. /** Launch a ray to try to pick sprites in the scene
  11590. * @param x position on screen
  11591. * @param y position on screen
  11592. * @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
  11593. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11594. * @returns a PickingInfo array
  11595. */
  11596. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11597. /** Use the given ray to pick sprites in the scene
  11598. * @param ray The ray (in world space) to use to pick meshes
  11599. * @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
  11600. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11601. * @returns a PickingInfo array
  11602. */
  11603. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11604. /**
  11605. * Force the sprite under the pointer
  11606. * @param sprite defines the sprite to use
  11607. */
  11608. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11609. /**
  11610. * Gets the sprite under the pointer
  11611. * @returns a Sprite or null if no sprite is under the pointer
  11612. */
  11613. getPointerOverSprite(): Nullable<Sprite>;
  11614. }
  11615. }
  11616. /**
  11617. * Defines the sprite scene component responsible to manage sprites
  11618. * in a given scene.
  11619. */
  11620. export class SpriteSceneComponent implements ISceneComponent {
  11621. /**
  11622. * The component name helpfull to identify the component in the list of scene components.
  11623. */
  11624. readonly name: string;
  11625. /**
  11626. * The scene the component belongs to.
  11627. */
  11628. scene: Scene;
  11629. /** @hidden */
  11630. private _spritePredicate;
  11631. /**
  11632. * Creates a new instance of the component for the given scene
  11633. * @param scene Defines the scene to register the component in
  11634. */
  11635. constructor(scene: Scene);
  11636. /**
  11637. * Registers the component in a given scene
  11638. */
  11639. register(): void;
  11640. /**
  11641. * Rebuilds the elements related to this component in case of
  11642. * context lost for instance.
  11643. */
  11644. rebuild(): void;
  11645. /**
  11646. * Disposes the component and the associated ressources.
  11647. */
  11648. dispose(): void;
  11649. private _pickSpriteButKeepRay;
  11650. private _pointerMove;
  11651. private _pointerDown;
  11652. private _pointerUp;
  11653. }
  11654. }
  11655. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11656. /** @hidden */
  11657. export var fogFragmentDeclaration: {
  11658. name: string;
  11659. shader: string;
  11660. };
  11661. }
  11662. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11663. /** @hidden */
  11664. export var fogFragment: {
  11665. name: string;
  11666. shader: string;
  11667. };
  11668. }
  11669. declare module "babylonjs/Shaders/sprites.fragment" {
  11670. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11671. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11672. /** @hidden */
  11673. export var spritesPixelShader: {
  11674. name: string;
  11675. shader: string;
  11676. };
  11677. }
  11678. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11679. /** @hidden */
  11680. export var fogVertexDeclaration: {
  11681. name: string;
  11682. shader: string;
  11683. };
  11684. }
  11685. declare module "babylonjs/Shaders/sprites.vertex" {
  11686. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11687. /** @hidden */
  11688. export var spritesVertexShader: {
  11689. name: string;
  11690. shader: string;
  11691. };
  11692. }
  11693. declare module "babylonjs/Sprites/spriteManager" {
  11694. import { IDisposable, Scene } from "babylonjs/scene";
  11695. import { Nullable } from "babylonjs/types";
  11696. import { Observable } from "babylonjs/Misc/observable";
  11697. import { Sprite } from "babylonjs/Sprites/sprite";
  11698. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11699. import { Camera } from "babylonjs/Cameras/camera";
  11700. import { Texture } from "babylonjs/Materials/Textures/texture";
  11701. import "babylonjs/Shaders/sprites.fragment";
  11702. import "babylonjs/Shaders/sprites.vertex";
  11703. import { Ray } from "babylonjs/Culling/ray";
  11704. /**
  11705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11706. */
  11707. export interface ISpriteManager extends IDisposable {
  11708. /**
  11709. * Restricts the camera to viewing objects with the same layerMask.
  11710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11711. */
  11712. layerMask: number;
  11713. /**
  11714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11715. */
  11716. isPickable: boolean;
  11717. /**
  11718. * Specifies the rendering group id for this mesh (0 by default)
  11719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11720. */
  11721. renderingGroupId: number;
  11722. /**
  11723. * Defines the list of sprites managed by the manager.
  11724. */
  11725. sprites: Array<Sprite>;
  11726. /**
  11727. * Tests the intersection of a sprite with a specific ray.
  11728. * @param ray The ray we are sending to test the collision
  11729. * @param camera The camera space we are sending rays in
  11730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11732. * @returns picking info or null.
  11733. */
  11734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11735. /**
  11736. * Intersects the sprites with a ray
  11737. * @param ray defines the ray to intersect with
  11738. * @param camera defines the current active camera
  11739. * @param predicate defines a predicate used to select candidate sprites
  11740. * @returns null if no hit or a PickingInfo array
  11741. */
  11742. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11743. /**
  11744. * Renders the list of sprites on screen.
  11745. */
  11746. render(): void;
  11747. }
  11748. /**
  11749. * Class used to manage multiple sprites on the same spritesheet
  11750. * @see http://doc.babylonjs.com/babylon101/sprites
  11751. */
  11752. export class SpriteManager implements ISpriteManager {
  11753. /** defines the manager's name */
  11754. name: string;
  11755. /** Gets the list of sprites */
  11756. sprites: Sprite[];
  11757. /** Gets or sets the rendering group id (0 by default) */
  11758. renderingGroupId: number;
  11759. /** Gets or sets camera layer mask */
  11760. layerMask: number;
  11761. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11762. fogEnabled: boolean;
  11763. /** Gets or sets a boolean indicating if the sprites are pickable */
  11764. isPickable: boolean;
  11765. /** Defines the default width of a cell in the spritesheet */
  11766. cellWidth: number;
  11767. /** Defines the default height of a cell in the spritesheet */
  11768. cellHeight: number;
  11769. /** Associative array from JSON sprite data file */
  11770. private _cellData;
  11771. /** Array of sprite names from JSON sprite data file */
  11772. private _spriteMap;
  11773. /** True when packed cell data from JSON file is ready*/
  11774. private _packedAndReady;
  11775. /**
  11776. * An event triggered when the manager is disposed.
  11777. */
  11778. onDisposeObservable: Observable<SpriteManager>;
  11779. private _onDisposeObserver;
  11780. /**
  11781. * Callback called when the manager is disposed
  11782. */
  11783. onDispose: () => void;
  11784. private _capacity;
  11785. private _fromPacked;
  11786. private _spriteTexture;
  11787. private _epsilon;
  11788. private _scene;
  11789. private _vertexData;
  11790. private _buffer;
  11791. private _vertexBuffers;
  11792. private _indexBuffer;
  11793. private _effectBase;
  11794. private _effectFog;
  11795. /**
  11796. * Gets or sets the spritesheet texture
  11797. */
  11798. texture: Texture;
  11799. /**
  11800. * Creates a new sprite manager
  11801. * @param name defines the manager's name
  11802. * @param imgUrl defines the sprite sheet url
  11803. * @param capacity defines the maximum allowed number of sprites
  11804. * @param cellSize defines the size of a sprite cell
  11805. * @param scene defines the hosting scene
  11806. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11807. * @param samplingMode defines the smapling mode to use with spritesheet
  11808. * @param fromPacked set to false; do not alter
  11809. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11810. */
  11811. constructor(
  11812. /** defines the manager's name */
  11813. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11814. private _makePacked;
  11815. private _appendSpriteVertex;
  11816. /**
  11817. * Intersects the sprites with a ray
  11818. * @param ray defines the ray to intersect with
  11819. * @param camera defines the current active camera
  11820. * @param predicate defines a predicate used to select candidate sprites
  11821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11822. * @returns null if no hit or a PickingInfo
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Intersects the sprites with a ray
  11827. * @param ray defines the ray to intersect with
  11828. * @param camera defines the current active camera
  11829. * @param predicate defines a predicate used to select candidate sprites
  11830. * @returns null if no hit or a PickingInfo array
  11831. */
  11832. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11833. /**
  11834. * Render all child sprites
  11835. */
  11836. render(): void;
  11837. /**
  11838. * Release associated resources
  11839. */
  11840. dispose(): void;
  11841. }
  11842. }
  11843. declare module "babylonjs/Sprites/sprite" {
  11844. import { Vector3 } from "babylonjs/Maths/math.vector";
  11845. import { Nullable } from "babylonjs/types";
  11846. import { ActionManager } from "babylonjs/Actions/actionManager";
  11847. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11848. import { Color4 } from "babylonjs/Maths/math.color";
  11849. /**
  11850. * Class used to represent a sprite
  11851. * @see http://doc.babylonjs.com/babylon101/sprites
  11852. */
  11853. export class Sprite {
  11854. /** defines the name */
  11855. name: string;
  11856. /** Gets or sets the current world position */
  11857. position: Vector3;
  11858. /** Gets or sets the main color */
  11859. color: Color4;
  11860. /** Gets or sets the width */
  11861. width: number;
  11862. /** Gets or sets the height */
  11863. height: number;
  11864. /** Gets or sets rotation angle */
  11865. angle: number;
  11866. /** Gets or sets the cell index in the sprite sheet */
  11867. cellIndex: number;
  11868. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11869. cellRef: string;
  11870. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11871. invertU: number;
  11872. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11873. invertV: number;
  11874. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11875. disposeWhenFinishedAnimating: boolean;
  11876. /** Gets the list of attached animations */
  11877. animations: Animation[];
  11878. /** Gets or sets a boolean indicating if the sprite can be picked */
  11879. isPickable: boolean;
  11880. /**
  11881. * Gets or sets the associated action manager
  11882. */
  11883. actionManager: Nullable<ActionManager>;
  11884. private _animationStarted;
  11885. private _loopAnimation;
  11886. private _fromIndex;
  11887. private _toIndex;
  11888. private _delay;
  11889. private _direction;
  11890. private _manager;
  11891. private _time;
  11892. private _onAnimationEnd;
  11893. /**
  11894. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11895. */
  11896. isVisible: boolean;
  11897. /**
  11898. * Gets or sets the sprite size
  11899. */
  11900. size: number;
  11901. /**
  11902. * Creates a new Sprite
  11903. * @param name defines the name
  11904. * @param manager defines the manager
  11905. */
  11906. constructor(
  11907. /** defines the name */
  11908. name: string, manager: ISpriteManager);
  11909. /**
  11910. * Starts an animation
  11911. * @param from defines the initial key
  11912. * @param to defines the end key
  11913. * @param loop defines if the animation must loop
  11914. * @param delay defines the start delay (in ms)
  11915. * @param onAnimationEnd defines a callback to call when animation ends
  11916. */
  11917. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11918. /** Stops current animation (if any) */
  11919. stopAnimation(): void;
  11920. /** @hidden */
  11921. _animate(deltaTime: number): void;
  11922. /** Release associated resources */
  11923. dispose(): void;
  11924. }
  11925. }
  11926. declare module "babylonjs/Collisions/pickingInfo" {
  11927. import { Nullable } from "babylonjs/types";
  11928. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11930. import { Sprite } from "babylonjs/Sprites/sprite";
  11931. import { Ray } from "babylonjs/Culling/ray";
  11932. /**
  11933. * Information about the result of picking within a scene
  11934. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11935. */
  11936. export class PickingInfo {
  11937. /** @hidden */
  11938. _pickingUnavailable: boolean;
  11939. /**
  11940. * If the pick collided with an object
  11941. */
  11942. hit: boolean;
  11943. /**
  11944. * Distance away where the pick collided
  11945. */
  11946. distance: number;
  11947. /**
  11948. * The location of pick collision
  11949. */
  11950. pickedPoint: Nullable<Vector3>;
  11951. /**
  11952. * The mesh corresponding the the pick collision
  11953. */
  11954. pickedMesh: Nullable<AbstractMesh>;
  11955. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11956. bu: number;
  11957. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11958. bv: number;
  11959. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11960. faceId: number;
  11961. /** Id of the the submesh that was picked */
  11962. subMeshId: number;
  11963. /** If a sprite was picked, this will be the sprite the pick collided with */
  11964. pickedSprite: Nullable<Sprite>;
  11965. /**
  11966. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11967. */
  11968. originMesh: Nullable<AbstractMesh>;
  11969. /**
  11970. * The ray that was used to perform the picking.
  11971. */
  11972. ray: Nullable<Ray>;
  11973. /**
  11974. * Gets the normal correspodning to the face the pick collided with
  11975. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11976. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11977. * @returns The normal correspodning to the face the pick collided with
  11978. */
  11979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11980. /**
  11981. * Gets the texture coordinates of where the pick occured
  11982. * @returns the vector containing the coordnates of the texture
  11983. */
  11984. getTextureCoordinates(): Nullable<Vector2>;
  11985. }
  11986. }
  11987. declare module "babylonjs/Events/pointerEvents" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector2 } from "babylonjs/Maths/math.vector";
  11990. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11991. import { Ray } from "babylonjs/Culling/ray";
  11992. /**
  11993. * Gather the list of pointer event types as constants.
  11994. */
  11995. export class PointerEventTypes {
  11996. /**
  11997. * 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.
  11998. */
  11999. static readonly POINTERDOWN: number;
  12000. /**
  12001. * The pointerup event is fired when a pointer is no longer active.
  12002. */
  12003. static readonly POINTERUP: number;
  12004. /**
  12005. * The pointermove event is fired when a pointer changes coordinates.
  12006. */
  12007. static readonly POINTERMOVE: number;
  12008. /**
  12009. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12010. */
  12011. static readonly POINTERWHEEL: number;
  12012. /**
  12013. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12014. */
  12015. static readonly POINTERPICK: number;
  12016. /**
  12017. * The pointertap event is fired when a the object has been touched and released without drag.
  12018. */
  12019. static readonly POINTERTAP: number;
  12020. /**
  12021. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12022. */
  12023. static readonly POINTERDOUBLETAP: number;
  12024. }
  12025. /**
  12026. * Base class of pointer info types.
  12027. */
  12028. export class PointerInfoBase {
  12029. /**
  12030. * Defines the type of event (PointerEventTypes)
  12031. */
  12032. type: number;
  12033. /**
  12034. * Defines the related dom event
  12035. */
  12036. event: PointerEvent | MouseWheelEvent;
  12037. /**
  12038. * Instantiates the base class of pointers info.
  12039. * @param type Defines the type of event (PointerEventTypes)
  12040. * @param event Defines the related dom event
  12041. */
  12042. constructor(
  12043. /**
  12044. * Defines the type of event (PointerEventTypes)
  12045. */
  12046. type: number,
  12047. /**
  12048. * Defines the related dom event
  12049. */
  12050. event: PointerEvent | MouseWheelEvent);
  12051. }
  12052. /**
  12053. * This class is used to store pointer related info for the onPrePointerObservable event.
  12054. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12055. */
  12056. export class PointerInfoPre extends PointerInfoBase {
  12057. /**
  12058. * Ray from a pointer if availible (eg. 6dof controller)
  12059. */
  12060. ray: Nullable<Ray>;
  12061. /**
  12062. * Defines the local position of the pointer on the canvas.
  12063. */
  12064. localPosition: Vector2;
  12065. /**
  12066. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12067. */
  12068. skipOnPointerObservable: boolean;
  12069. /**
  12070. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12071. * @param type Defines the type of event (PointerEventTypes)
  12072. * @param event Defines the related dom event
  12073. * @param localX Defines the local x coordinates of the pointer when the event occured
  12074. * @param localY Defines the local y coordinates of the pointer when the event occured
  12075. */
  12076. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12077. }
  12078. /**
  12079. * This type contains all the data related to a pointer event in Babylon.js.
  12080. * 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.
  12081. */
  12082. export class PointerInfo extends PointerInfoBase {
  12083. /**
  12084. * Defines the picking info associated to the info (if any)\
  12085. */
  12086. pickInfo: Nullable<PickingInfo>;
  12087. /**
  12088. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12089. * @param type Defines the type of event (PointerEventTypes)
  12090. * @param event Defines the related dom event
  12091. * @param pickInfo Defines the picking info associated to the info (if any)\
  12092. */
  12093. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12094. /**
  12095. * Defines the picking info associated to the info (if any)\
  12096. */
  12097. pickInfo: Nullable<PickingInfo>);
  12098. }
  12099. /**
  12100. * Data relating to a touch event on the screen.
  12101. */
  12102. export interface PointerTouch {
  12103. /**
  12104. * X coordinate of touch.
  12105. */
  12106. x: number;
  12107. /**
  12108. * Y coordinate of touch.
  12109. */
  12110. y: number;
  12111. /**
  12112. * Id of touch. Unique for each finger.
  12113. */
  12114. pointerId: number;
  12115. /**
  12116. * Event type passed from DOM.
  12117. */
  12118. type: any;
  12119. }
  12120. }
  12121. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12122. import { Observable } from "babylonjs/Misc/observable";
  12123. import { Nullable } from "babylonjs/types";
  12124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12126. /**
  12127. * Manage the mouse inputs to control the movement of a free camera.
  12128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12129. */
  12130. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12131. /**
  12132. * Define if touch is enabled in the mouse input
  12133. */
  12134. touchEnabled: boolean;
  12135. /**
  12136. * Defines the camera the input is attached to.
  12137. */
  12138. camera: FreeCamera;
  12139. /**
  12140. * Defines the buttons associated with the input to handle camera move.
  12141. */
  12142. buttons: number[];
  12143. /**
  12144. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12145. */
  12146. angularSensibility: number;
  12147. private _pointerInput;
  12148. private _onMouseMove;
  12149. private _observer;
  12150. private previousPosition;
  12151. /**
  12152. * Observable for when a pointer move event occurs containing the move offset
  12153. */
  12154. onPointerMovedObservable: Observable<{
  12155. offsetX: number;
  12156. offsetY: number;
  12157. }>;
  12158. /**
  12159. * @hidden
  12160. * If the camera should be rotated automatically based on pointer movement
  12161. */
  12162. _allowCameraRotation: boolean;
  12163. /**
  12164. * Manage the mouse inputs to control the movement of a free camera.
  12165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12166. * @param touchEnabled Defines if touch is enabled or not
  12167. */
  12168. constructor(
  12169. /**
  12170. * Define if touch is enabled in the mouse input
  12171. */
  12172. touchEnabled?: boolean);
  12173. /**
  12174. * Attach the input controls to a specific dom element to get the input from.
  12175. * @param element Defines the element the controls should be listened from
  12176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12177. */
  12178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12179. /**
  12180. * Called on JS contextmenu event.
  12181. * Override this method to provide functionality.
  12182. */
  12183. protected onContextMenu(evt: PointerEvent): void;
  12184. /**
  12185. * Detach the current controls from the specified dom element.
  12186. * @param element Defines the element to stop listening the inputs from
  12187. */
  12188. detachControl(element: Nullable<HTMLElement>): void;
  12189. /**
  12190. * Gets the class name of the current intput.
  12191. * @returns the class name
  12192. */
  12193. getClassName(): string;
  12194. /**
  12195. * Get the friendly name associated with the input class.
  12196. * @returns the input friendly name
  12197. */
  12198. getSimpleName(): string;
  12199. }
  12200. }
  12201. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12202. import { Nullable } from "babylonjs/types";
  12203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. /**
  12206. * Manage the touch inputs to control the movement of a free camera.
  12207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12208. */
  12209. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12210. /**
  12211. * Defines the camera the input is attached to.
  12212. */
  12213. camera: FreeCamera;
  12214. /**
  12215. * Defines the touch sensibility for rotation.
  12216. * The higher the faster.
  12217. */
  12218. touchAngularSensibility: number;
  12219. /**
  12220. * Defines the touch sensibility for move.
  12221. * The higher the faster.
  12222. */
  12223. touchMoveSensibility: number;
  12224. private _offsetX;
  12225. private _offsetY;
  12226. private _pointerPressed;
  12227. private _pointerInput;
  12228. private _observer;
  12229. private _onLostFocus;
  12230. /**
  12231. * Attach the input controls to a specific dom element to get the input from.
  12232. * @param element Defines the element the controls should be listened from
  12233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12234. */
  12235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12236. /**
  12237. * Detach the current controls from the specified dom element.
  12238. * @param element Defines the element to stop listening the inputs from
  12239. */
  12240. detachControl(element: Nullable<HTMLElement>): void;
  12241. /**
  12242. * Update the current camera state depending on the inputs that have been used this frame.
  12243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12244. */
  12245. checkInputs(): void;
  12246. /**
  12247. * Gets the class name of the current intput.
  12248. * @returns the class name
  12249. */
  12250. getClassName(): string;
  12251. /**
  12252. * Get the friendly name associated with the input class.
  12253. * @returns the input friendly name
  12254. */
  12255. getSimpleName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12259. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12260. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12261. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12262. import { Nullable } from "babylonjs/types";
  12263. /**
  12264. * Default Inputs manager for the FreeCamera.
  12265. * It groups all the default supported inputs for ease of use.
  12266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12267. */
  12268. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12269. /**
  12270. * @hidden
  12271. */
  12272. _mouseInput: Nullable<FreeCameraMouseInput>;
  12273. /**
  12274. * Instantiates a new FreeCameraInputsManager.
  12275. * @param camera Defines the camera the inputs belong to
  12276. */
  12277. constructor(camera: FreeCamera);
  12278. /**
  12279. * Add keyboard input support to the input manager.
  12280. * @returns the current input manager
  12281. */
  12282. addKeyboard(): FreeCameraInputsManager;
  12283. /**
  12284. * Add mouse input support to the input manager.
  12285. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12286. * @returns the current input manager
  12287. */
  12288. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12289. /**
  12290. * Removes the mouse input support from the manager
  12291. * @returns the current input manager
  12292. */
  12293. removeMouse(): FreeCameraInputsManager;
  12294. /**
  12295. * Add touch input support to the input manager.
  12296. * @returns the current input manager
  12297. */
  12298. addTouch(): FreeCameraInputsManager;
  12299. /**
  12300. * Remove all attached input methods from a camera
  12301. */
  12302. clear(): void;
  12303. }
  12304. }
  12305. declare module "babylonjs/Cameras/freeCamera" {
  12306. import { Vector3 } from "babylonjs/Maths/math.vector";
  12307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12308. import { Scene } from "babylonjs/scene";
  12309. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12310. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12311. /**
  12312. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12313. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12314. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12315. */
  12316. export class FreeCamera extends TargetCamera {
  12317. /**
  12318. * Define the collision ellipsoid of the camera.
  12319. * This is helpful to simulate a camera body like the player body around the camera
  12320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12321. */
  12322. ellipsoid: Vector3;
  12323. /**
  12324. * Define an offset for the position of the ellipsoid around the camera.
  12325. * This can be helpful to determine the center of the body near the gravity center of the body
  12326. * instead of its head.
  12327. */
  12328. ellipsoidOffset: Vector3;
  12329. /**
  12330. * Enable or disable collisions of the camera with the rest of the scene objects.
  12331. */
  12332. checkCollisions: boolean;
  12333. /**
  12334. * Enable or disable gravity on the camera.
  12335. */
  12336. applyGravity: boolean;
  12337. /**
  12338. * Define the input manager associated to the camera.
  12339. */
  12340. inputs: FreeCameraInputsManager;
  12341. /**
  12342. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12343. * Higher values reduce sensitivity.
  12344. */
  12345. /**
  12346. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12347. * Higher values reduce sensitivity.
  12348. */
  12349. angularSensibility: number;
  12350. /**
  12351. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12352. */
  12353. keysUp: number[];
  12354. /**
  12355. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12356. */
  12357. keysDown: number[];
  12358. /**
  12359. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12360. */
  12361. keysLeft: number[];
  12362. /**
  12363. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12364. */
  12365. keysRight: number[];
  12366. /**
  12367. * Event raised when the camera collide with a mesh in the scene.
  12368. */
  12369. onCollide: (collidedMesh: AbstractMesh) => void;
  12370. private _collider;
  12371. private _needMoveForGravity;
  12372. private _oldPosition;
  12373. private _diffPosition;
  12374. private _newPosition;
  12375. /** @hidden */
  12376. _localDirection: Vector3;
  12377. /** @hidden */
  12378. _transformedDirection: Vector3;
  12379. /**
  12380. * Instantiates a Free Camera.
  12381. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12382. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12384. * @param name Define the name of the camera in the scene
  12385. * @param position Define the start position of the camera in the scene
  12386. * @param scene Define the scene the camera belongs to
  12387. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12388. */
  12389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12390. /**
  12391. * Attached controls to the current camera.
  12392. * @param element Defines the element the controls should be listened from
  12393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12394. */
  12395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12396. /**
  12397. * Detach the current controls from the camera.
  12398. * The camera will stop reacting to inputs.
  12399. * @param element Defines the element to stop listening the inputs from
  12400. */
  12401. detachControl(element: HTMLElement): void;
  12402. private _collisionMask;
  12403. /**
  12404. * Define a collision mask to limit the list of object the camera can collide with
  12405. */
  12406. collisionMask: number;
  12407. /** @hidden */
  12408. _collideWithWorld(displacement: Vector3): void;
  12409. private _onCollisionPositionChange;
  12410. /** @hidden */
  12411. _checkInputs(): void;
  12412. /** @hidden */
  12413. _decideIfNeedsToMove(): boolean;
  12414. /** @hidden */
  12415. _updatePosition(): void;
  12416. /**
  12417. * Destroy the camera and release the current resources hold by it.
  12418. */
  12419. dispose(): void;
  12420. /**
  12421. * Gets the current object class name.
  12422. * @return the class name
  12423. */
  12424. getClassName(): string;
  12425. }
  12426. }
  12427. declare module "babylonjs/Gamepads/gamepad" {
  12428. import { Observable } from "babylonjs/Misc/observable";
  12429. /**
  12430. * Represents a gamepad control stick position
  12431. */
  12432. export class StickValues {
  12433. /**
  12434. * The x component of the control stick
  12435. */
  12436. x: number;
  12437. /**
  12438. * The y component of the control stick
  12439. */
  12440. y: number;
  12441. /**
  12442. * Initializes the gamepad x and y control stick values
  12443. * @param x The x component of the gamepad control stick value
  12444. * @param y The y component of the gamepad control stick value
  12445. */
  12446. constructor(
  12447. /**
  12448. * The x component of the control stick
  12449. */
  12450. x: number,
  12451. /**
  12452. * The y component of the control stick
  12453. */
  12454. y: number);
  12455. }
  12456. /**
  12457. * An interface which manages callbacks for gamepad button changes
  12458. */
  12459. export interface GamepadButtonChanges {
  12460. /**
  12461. * Called when a gamepad has been changed
  12462. */
  12463. changed: boolean;
  12464. /**
  12465. * Called when a gamepad press event has been triggered
  12466. */
  12467. pressChanged: boolean;
  12468. /**
  12469. * Called when a touch event has been triggered
  12470. */
  12471. touchChanged: boolean;
  12472. /**
  12473. * Called when a value has changed
  12474. */
  12475. valueChanged: boolean;
  12476. }
  12477. /**
  12478. * Represents a gamepad
  12479. */
  12480. export class Gamepad {
  12481. /**
  12482. * The id of the gamepad
  12483. */
  12484. id: string;
  12485. /**
  12486. * The index of the gamepad
  12487. */
  12488. index: number;
  12489. /**
  12490. * The browser gamepad
  12491. */
  12492. browserGamepad: any;
  12493. /**
  12494. * Specifies what type of gamepad this represents
  12495. */
  12496. type: number;
  12497. private _leftStick;
  12498. private _rightStick;
  12499. /** @hidden */
  12500. _isConnected: boolean;
  12501. private _leftStickAxisX;
  12502. private _leftStickAxisY;
  12503. private _rightStickAxisX;
  12504. private _rightStickAxisY;
  12505. /**
  12506. * Triggered when the left control stick has been changed
  12507. */
  12508. private _onleftstickchanged;
  12509. /**
  12510. * Triggered when the right control stick has been changed
  12511. */
  12512. private _onrightstickchanged;
  12513. /**
  12514. * Represents a gamepad controller
  12515. */
  12516. static GAMEPAD: number;
  12517. /**
  12518. * Represents a generic controller
  12519. */
  12520. static GENERIC: number;
  12521. /**
  12522. * Represents an XBox controller
  12523. */
  12524. static XBOX: number;
  12525. /**
  12526. * Represents a pose-enabled controller
  12527. */
  12528. static POSE_ENABLED: number;
  12529. /**
  12530. * Represents an Dual Shock controller
  12531. */
  12532. static DUALSHOCK: number;
  12533. /**
  12534. * Specifies whether the left control stick should be Y-inverted
  12535. */
  12536. protected _invertLeftStickY: boolean;
  12537. /**
  12538. * Specifies if the gamepad has been connected
  12539. */
  12540. readonly isConnected: boolean;
  12541. /**
  12542. * Initializes the gamepad
  12543. * @param id The id of the gamepad
  12544. * @param index The index of the gamepad
  12545. * @param browserGamepad The browser gamepad
  12546. * @param leftStickX The x component of the left joystick
  12547. * @param leftStickY The y component of the left joystick
  12548. * @param rightStickX The x component of the right joystick
  12549. * @param rightStickY The y component of the right joystick
  12550. */
  12551. constructor(
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string,
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number,
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12564. /**
  12565. * Callback triggered when the left joystick has changed
  12566. * @param callback
  12567. */
  12568. onleftstickchanged(callback: (values: StickValues) => void): void;
  12569. /**
  12570. * Callback triggered when the right joystick has changed
  12571. * @param callback
  12572. */
  12573. onrightstickchanged(callback: (values: StickValues) => void): void;
  12574. /**
  12575. * Gets the left joystick
  12576. */
  12577. /**
  12578. * Sets the left joystick values
  12579. */
  12580. leftStick: StickValues;
  12581. /**
  12582. * Gets the right joystick
  12583. */
  12584. /**
  12585. * Sets the right joystick value
  12586. */
  12587. rightStick: StickValues;
  12588. /**
  12589. * Updates the gamepad joystick positions
  12590. */
  12591. update(): void;
  12592. /**
  12593. * Disposes the gamepad
  12594. */
  12595. dispose(): void;
  12596. }
  12597. /**
  12598. * Represents a generic gamepad
  12599. */
  12600. export class GenericPad extends Gamepad {
  12601. private _buttons;
  12602. private _onbuttondown;
  12603. private _onbuttonup;
  12604. /**
  12605. * Observable triggered when a button has been pressed
  12606. */
  12607. onButtonDownObservable: Observable<number>;
  12608. /**
  12609. * Observable triggered when a button has been released
  12610. */
  12611. onButtonUpObservable: Observable<number>;
  12612. /**
  12613. * Callback triggered when a button has been pressed
  12614. * @param callback Called when a button has been pressed
  12615. */
  12616. onbuttondown(callback: (buttonPressed: number) => void): void;
  12617. /**
  12618. * Callback triggered when a button has been released
  12619. * @param callback Called when a button has been released
  12620. */
  12621. onbuttonup(callback: (buttonReleased: number) => void): void;
  12622. /**
  12623. * Initializes the generic gamepad
  12624. * @param id The id of the generic gamepad
  12625. * @param index The index of the generic gamepad
  12626. * @param browserGamepad The browser gamepad
  12627. */
  12628. constructor(id: string, index: number, browserGamepad: any);
  12629. private _setButtonValue;
  12630. /**
  12631. * Updates the generic gamepad
  12632. */
  12633. update(): void;
  12634. /**
  12635. * Disposes the generic gamepad
  12636. */
  12637. dispose(): void;
  12638. }
  12639. }
  12640. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12641. import { Nullable } from "babylonjs/types";
  12642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12643. import { Scene } from "babylonjs/scene";
  12644. module "babylonjs/Engines/engine" {
  12645. interface Engine {
  12646. /**
  12647. * Creates a raw texture
  12648. * @param data defines the data to store in the texture
  12649. * @param width defines the width of the texture
  12650. * @param height defines the height of the texture
  12651. * @param format defines the format of the data
  12652. * @param generateMipMaps defines if the engine should generate the mip levels
  12653. * @param invertY defines if data must be stored with Y axis inverted
  12654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12655. * @param compression defines the compression used (null by default)
  12656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12657. * @returns the raw texture inside an InternalTexture
  12658. */
  12659. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12660. /**
  12661. * Update a raw texture
  12662. * @param texture defines the texture to update
  12663. * @param data defines the data to store in the texture
  12664. * @param format defines the format of the data
  12665. * @param invertY defines if data must be stored with Y axis inverted
  12666. */
  12667. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12668. /**
  12669. * Update a raw texture
  12670. * @param texture defines the texture to update
  12671. * @param data defines the data to store in the texture
  12672. * @param format defines the format of the data
  12673. * @param invertY defines if data must be stored with Y axis inverted
  12674. * @param compression defines the compression used (null by default)
  12675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12676. */
  12677. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12678. /**
  12679. * Creates a new raw cube texture
  12680. * @param data defines the array of data to use to create each face
  12681. * @param size defines the size of the textures
  12682. * @param format defines the format of the data
  12683. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12684. * @param generateMipMaps defines if the engine should generate the mip levels
  12685. * @param invertY defines if data must be stored with Y axis inverted
  12686. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12687. * @param compression defines the compression used (null by default)
  12688. * @returns the cube texture as an InternalTexture
  12689. */
  12690. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12691. /**
  12692. * Update a raw cube texture
  12693. * @param texture defines the texture to udpdate
  12694. * @param data defines the data to store
  12695. * @param format defines the data format
  12696. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12697. * @param invertY defines if data must be stored with Y axis inverted
  12698. */
  12699. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12700. /**
  12701. * Update a raw cube texture
  12702. * @param texture defines the texture to udpdate
  12703. * @param data defines the data to store
  12704. * @param format defines the data format
  12705. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param compression defines the compression used (null by default)
  12708. */
  12709. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12710. /**
  12711. * Update a raw cube texture
  12712. * @param texture defines the texture to udpdate
  12713. * @param data defines the data to store
  12714. * @param format defines the data format
  12715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param compression defines the compression used (null by default)
  12718. * @param level defines which level of the texture to update
  12719. */
  12720. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12721. /**
  12722. * Creates a new raw cube texture from a specified url
  12723. * @param url defines the url where the data is located
  12724. * @param scene defines the current scene
  12725. * @param size defines the size of the textures
  12726. * @param format defines the format of the data
  12727. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12728. * @param noMipmap defines if the engine should avoid generating the mip levels
  12729. * @param callback defines a callback used to extract texture data from loaded data
  12730. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12731. * @param onLoad defines a callback called when texture is loaded
  12732. * @param onError defines a callback called if there is an error
  12733. * @returns the cube texture as an InternalTexture
  12734. */
  12735. 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;
  12736. /**
  12737. * Creates a new raw cube texture from a specified url
  12738. * @param url defines the url where the data is located
  12739. * @param scene defines the current scene
  12740. * @param size defines the size of the textures
  12741. * @param format defines the format of the data
  12742. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12743. * @param noMipmap defines if the engine should avoid generating the mip levels
  12744. * @param callback defines a callback used to extract texture data from loaded data
  12745. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12746. * @param onLoad defines a callback called when texture is loaded
  12747. * @param onError defines a callback called if there is an error
  12748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12749. * @param invertY defines if data must be stored with Y axis inverted
  12750. * @returns the cube texture as an InternalTexture
  12751. */
  12752. 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;
  12753. /**
  12754. * Creates a new raw 3D texture
  12755. * @param data defines the data used to create the texture
  12756. * @param width defines the width of the texture
  12757. * @param height defines the height of the texture
  12758. * @param depth defines the depth of the texture
  12759. * @param format defines the format of the texture
  12760. * @param generateMipMaps defines if the engine must generate mip levels
  12761. * @param invertY defines if data must be stored with Y axis inverted
  12762. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12763. * @param compression defines the compressed used (can be null)
  12764. * @param textureType defines the compressed used (can be null)
  12765. * @returns a new raw 3D texture (stored in an InternalTexture)
  12766. */
  12767. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12768. /**
  12769. * Update a raw 3D texture
  12770. * @param texture defines the texture to update
  12771. * @param data defines the data to store
  12772. * @param format defines the data format
  12773. * @param invertY defines if data must be stored with Y axis inverted
  12774. */
  12775. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12776. /**
  12777. * Update a raw 3D texture
  12778. * @param texture defines the texture to update
  12779. * @param data defines the data to store
  12780. * @param format defines the data format
  12781. * @param invertY defines if data must be stored with Y axis inverted
  12782. * @param compression defines the used compression (can be null)
  12783. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12784. */
  12785. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12786. }
  12787. }
  12788. }
  12789. declare module "babylonjs/Materials/Textures/rawTexture" {
  12790. import { Scene } from "babylonjs/scene";
  12791. import { Texture } from "babylonjs/Materials/Textures/texture";
  12792. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12793. /**
  12794. * Raw texture can help creating a texture directly from an array of data.
  12795. * This can be super useful if you either get the data from an uncompressed source or
  12796. * if you wish to create your texture pixel by pixel.
  12797. */
  12798. export class RawTexture extends Texture {
  12799. /**
  12800. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12801. */
  12802. format: number;
  12803. private _engine;
  12804. /**
  12805. * Instantiates a new RawTexture.
  12806. * Raw texture can help creating a texture directly from an array of data.
  12807. * This can be super useful if you either get the data from an uncompressed source or
  12808. * if you wish to create your texture pixel by pixel.
  12809. * @param data define the array of data to use to create the texture
  12810. * @param width define the width of the texture
  12811. * @param height define the height of the texture
  12812. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12813. * @param scene define the scene the texture belongs to
  12814. * @param generateMipMaps define whether mip maps should be generated or not
  12815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12817. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12818. */
  12819. constructor(data: ArrayBufferView, width: number, height: number,
  12820. /**
  12821. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12822. */
  12823. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12824. /**
  12825. * Updates the texture underlying data.
  12826. * @param data Define the new data of the texture
  12827. */
  12828. update(data: ArrayBufferView): void;
  12829. /**
  12830. * Creates a luminance texture from some data.
  12831. * @param data Define the texture data
  12832. * @param width Define the width of the texture
  12833. * @param height Define the height of the texture
  12834. * @param scene Define the scene the texture belongs to
  12835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12838. * @returns the luminance texture
  12839. */
  12840. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12841. /**
  12842. * Creates a luminance alpha texture from some data.
  12843. * @param data Define the texture data
  12844. * @param width Define the width of the texture
  12845. * @param height Define the height of the texture
  12846. * @param scene Define the scene the texture belongs to
  12847. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12848. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12849. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12850. * @returns the luminance alpha texture
  12851. */
  12852. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12853. /**
  12854. * Creates an alpha texture from some data.
  12855. * @param data Define the texture data
  12856. * @param width Define the width of the texture
  12857. * @param height Define the height of the texture
  12858. * @param scene Define the scene the texture belongs to
  12859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12862. * @returns the alpha texture
  12863. */
  12864. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12865. /**
  12866. * Creates a RGB texture from some data.
  12867. * @param data Define the texture data
  12868. * @param width Define the width of the texture
  12869. * @param height Define the height of the texture
  12870. * @param scene Define the scene the texture belongs to
  12871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12874. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12875. * @returns the RGB alpha texture
  12876. */
  12877. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12878. /**
  12879. * Creates a RGBA texture from some data.
  12880. * @param data Define the texture data
  12881. * @param width Define the width of the texture
  12882. * @param height Define the height of the texture
  12883. * @param scene Define the scene the texture belongs to
  12884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12887. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12888. * @returns the RGBA texture
  12889. */
  12890. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12891. /**
  12892. * Creates a R texture from some data.
  12893. * @param data Define the texture data
  12894. * @param width Define the width of the texture
  12895. * @param height Define the height of the texture
  12896. * @param scene Define the scene the texture belongs to
  12897. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12898. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12899. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12900. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12901. * @returns the R texture
  12902. */
  12903. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12904. }
  12905. }
  12906. declare module "babylonjs/Maths/math.size" {
  12907. /**
  12908. * Interface for the size containing width and height
  12909. */
  12910. export interface ISize {
  12911. /**
  12912. * Width
  12913. */
  12914. width: number;
  12915. /**
  12916. * Heighht
  12917. */
  12918. height: number;
  12919. }
  12920. /**
  12921. * Size containing widht and height
  12922. */
  12923. export class Size implements ISize {
  12924. /**
  12925. * Width
  12926. */
  12927. width: number;
  12928. /**
  12929. * Height
  12930. */
  12931. height: number;
  12932. /**
  12933. * Creates a Size object from the given width and height (floats).
  12934. * @param width width of the new size
  12935. * @param height height of the new size
  12936. */
  12937. constructor(width: number, height: number);
  12938. /**
  12939. * Returns a string with the Size width and height
  12940. * @returns a string with the Size width and height
  12941. */
  12942. toString(): string;
  12943. /**
  12944. * "Size"
  12945. * @returns the string "Size"
  12946. */
  12947. getClassName(): string;
  12948. /**
  12949. * Returns the Size hash code.
  12950. * @returns a hash code for a unique width and height
  12951. */
  12952. getHashCode(): number;
  12953. /**
  12954. * Updates the current size from the given one.
  12955. * @param src the given size
  12956. */
  12957. copyFrom(src: Size): void;
  12958. /**
  12959. * Updates in place the current Size from the given floats.
  12960. * @param width width of the new size
  12961. * @param height height of the new size
  12962. * @returns the updated Size.
  12963. */
  12964. copyFromFloats(width: number, height: number): Size;
  12965. /**
  12966. * Updates in place the current Size from the given floats.
  12967. * @param width width to set
  12968. * @param height height to set
  12969. * @returns the updated Size.
  12970. */
  12971. set(width: number, height: number): Size;
  12972. /**
  12973. * Multiplies the width and height by numbers
  12974. * @param w factor to multiple the width by
  12975. * @param h factor to multiple the height by
  12976. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12977. */
  12978. multiplyByFloats(w: number, h: number): Size;
  12979. /**
  12980. * Clones the size
  12981. * @returns a new Size copied from the given one.
  12982. */
  12983. clone(): Size;
  12984. /**
  12985. * True if the current Size and the given one width and height are strictly equal.
  12986. * @param other the other size to compare against
  12987. * @returns True if the current Size and the given one width and height are strictly equal.
  12988. */
  12989. equals(other: Size): boolean;
  12990. /**
  12991. * The surface of the Size : width * height (float).
  12992. */
  12993. readonly surface: number;
  12994. /**
  12995. * Create a new size of zero
  12996. * @returns a new Size set to (0.0, 0.0)
  12997. */
  12998. static Zero(): Size;
  12999. /**
  13000. * Sums the width and height of two sizes
  13001. * @param otherSize size to add to this size
  13002. * @returns a new Size set as the addition result of the current Size and the given one.
  13003. */
  13004. add(otherSize: Size): Size;
  13005. /**
  13006. * Subtracts the width and height of two
  13007. * @param otherSize size to subtract to this size
  13008. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13009. */
  13010. subtract(otherSize: Size): Size;
  13011. /**
  13012. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13013. * @param start starting size to lerp between
  13014. * @param end end size to lerp between
  13015. * @param amount amount to lerp between the start and end values
  13016. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13017. */
  13018. static Lerp(start: Size, end: Size, amount: number): Size;
  13019. }
  13020. }
  13021. declare module "babylonjs/Animations/runtimeAnimation" {
  13022. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13023. import { Animatable } from "babylonjs/Animations/animatable";
  13024. import { Scene } from "babylonjs/scene";
  13025. /**
  13026. * Defines a runtime animation
  13027. */
  13028. export class RuntimeAnimation {
  13029. private _events;
  13030. /**
  13031. * The current frame of the runtime animation
  13032. */
  13033. private _currentFrame;
  13034. /**
  13035. * The animation used by the runtime animation
  13036. */
  13037. private _animation;
  13038. /**
  13039. * The target of the runtime animation
  13040. */
  13041. private _target;
  13042. /**
  13043. * The initiating animatable
  13044. */
  13045. private _host;
  13046. /**
  13047. * The original value of the runtime animation
  13048. */
  13049. private _originalValue;
  13050. /**
  13051. * The original blend value of the runtime animation
  13052. */
  13053. private _originalBlendValue;
  13054. /**
  13055. * The offsets cache of the runtime animation
  13056. */
  13057. private _offsetsCache;
  13058. /**
  13059. * The high limits cache of the runtime animation
  13060. */
  13061. private _highLimitsCache;
  13062. /**
  13063. * Specifies if the runtime animation has been stopped
  13064. */
  13065. private _stopped;
  13066. /**
  13067. * The blending factor of the runtime animation
  13068. */
  13069. private _blendingFactor;
  13070. /**
  13071. * The BabylonJS scene
  13072. */
  13073. private _scene;
  13074. /**
  13075. * The current value of the runtime animation
  13076. */
  13077. private _currentValue;
  13078. /** @hidden */
  13079. _animationState: _IAnimationState;
  13080. /**
  13081. * The active target of the runtime animation
  13082. */
  13083. private _activeTargets;
  13084. private _currentActiveTarget;
  13085. private _directTarget;
  13086. /**
  13087. * The target path of the runtime animation
  13088. */
  13089. private _targetPath;
  13090. /**
  13091. * The weight of the runtime animation
  13092. */
  13093. private _weight;
  13094. /**
  13095. * The ratio offset of the runtime animation
  13096. */
  13097. private _ratioOffset;
  13098. /**
  13099. * The previous delay of the runtime animation
  13100. */
  13101. private _previousDelay;
  13102. /**
  13103. * The previous ratio of the runtime animation
  13104. */
  13105. private _previousRatio;
  13106. private _enableBlending;
  13107. private _keys;
  13108. private _minFrame;
  13109. private _maxFrame;
  13110. private _minValue;
  13111. private _maxValue;
  13112. private _targetIsArray;
  13113. /**
  13114. * Gets the current frame of the runtime animation
  13115. */
  13116. readonly currentFrame: number;
  13117. /**
  13118. * Gets the weight of the runtime animation
  13119. */
  13120. readonly weight: number;
  13121. /**
  13122. * Gets the current value of the runtime animation
  13123. */
  13124. readonly currentValue: any;
  13125. /**
  13126. * Gets the target path of the runtime animation
  13127. */
  13128. readonly targetPath: string;
  13129. /**
  13130. * Gets the actual target of the runtime animation
  13131. */
  13132. readonly target: any;
  13133. /** @hidden */
  13134. _onLoop: () => void;
  13135. /**
  13136. * Create a new RuntimeAnimation object
  13137. * @param target defines the target of the animation
  13138. * @param animation defines the source animation object
  13139. * @param scene defines the hosting scene
  13140. * @param host defines the initiating Animatable
  13141. */
  13142. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13143. private _preparePath;
  13144. /**
  13145. * Gets the animation from the runtime animation
  13146. */
  13147. readonly animation: Animation;
  13148. /**
  13149. * Resets the runtime animation to the beginning
  13150. * @param restoreOriginal defines whether to restore the target property to the original value
  13151. */
  13152. reset(restoreOriginal?: boolean): void;
  13153. /**
  13154. * Specifies if the runtime animation is stopped
  13155. * @returns Boolean specifying if the runtime animation is stopped
  13156. */
  13157. isStopped(): boolean;
  13158. /**
  13159. * Disposes of the runtime animation
  13160. */
  13161. dispose(): void;
  13162. /**
  13163. * Apply the interpolated value to the target
  13164. * @param currentValue defines the value computed by the animation
  13165. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13166. */
  13167. setValue(currentValue: any, weight: number): void;
  13168. private _getOriginalValues;
  13169. private _setValue;
  13170. /**
  13171. * Gets the loop pmode of the runtime animation
  13172. * @returns Loop Mode
  13173. */
  13174. private _getCorrectLoopMode;
  13175. /**
  13176. * Move the current animation to a given frame
  13177. * @param frame defines the frame to move to
  13178. */
  13179. goToFrame(frame: number): void;
  13180. /**
  13181. * @hidden Internal use only
  13182. */
  13183. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13184. /**
  13185. * Execute the current animation
  13186. * @param delay defines the delay to add to the current frame
  13187. * @param from defines the lower bound of the animation range
  13188. * @param to defines the upper bound of the animation range
  13189. * @param loop defines if the current animation must loop
  13190. * @param speedRatio defines the current speed ratio
  13191. * @param weight defines the weight of the animation (default is -1 so no weight)
  13192. * @param onLoop optional callback called when animation loops
  13193. * @returns a boolean indicating if the animation is running
  13194. */
  13195. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13196. }
  13197. }
  13198. declare module "babylonjs/Animations/animatable" {
  13199. import { Animation } from "babylonjs/Animations/animation";
  13200. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13201. import { Nullable } from "babylonjs/types";
  13202. import { Observable } from "babylonjs/Misc/observable";
  13203. import { Scene } from "babylonjs/scene";
  13204. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13205. import { Node } from "babylonjs/node";
  13206. /**
  13207. * Class used to store an actual running animation
  13208. */
  13209. export class Animatable {
  13210. /** defines the target object */
  13211. target: any;
  13212. /** defines the starting frame number (default is 0) */
  13213. fromFrame: number;
  13214. /** defines the ending frame number (default is 100) */
  13215. toFrame: number;
  13216. /** defines if the animation must loop (default is false) */
  13217. loopAnimation: boolean;
  13218. /** defines a callback to call when animation ends if it is not looping */
  13219. onAnimationEnd?: (() => void) | null | undefined;
  13220. /** defines a callback to call when animation loops */
  13221. onAnimationLoop?: (() => void) | null | undefined;
  13222. private _localDelayOffset;
  13223. private _pausedDelay;
  13224. private _runtimeAnimations;
  13225. private _paused;
  13226. private _scene;
  13227. private _speedRatio;
  13228. private _weight;
  13229. private _syncRoot;
  13230. /**
  13231. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13232. * This will only apply for non looping animation (default is true)
  13233. */
  13234. disposeOnEnd: boolean;
  13235. /**
  13236. * Gets a boolean indicating if the animation has started
  13237. */
  13238. animationStarted: boolean;
  13239. /**
  13240. * Observer raised when the animation ends
  13241. */
  13242. onAnimationEndObservable: Observable<Animatable>;
  13243. /**
  13244. * Observer raised when the animation loops
  13245. */
  13246. onAnimationLoopObservable: Observable<Animatable>;
  13247. /**
  13248. * Gets the root Animatable used to synchronize and normalize animations
  13249. */
  13250. readonly syncRoot: Nullable<Animatable>;
  13251. /**
  13252. * Gets the current frame of the first RuntimeAnimation
  13253. * Used to synchronize Animatables
  13254. */
  13255. readonly masterFrame: number;
  13256. /**
  13257. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13258. */
  13259. weight: number;
  13260. /**
  13261. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13262. */
  13263. speedRatio: number;
  13264. /**
  13265. * Creates a new Animatable
  13266. * @param scene defines the hosting scene
  13267. * @param target defines the target object
  13268. * @param fromFrame defines the starting frame number (default is 0)
  13269. * @param toFrame defines the ending frame number (default is 100)
  13270. * @param loopAnimation defines if the animation must loop (default is false)
  13271. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13272. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13273. * @param animations defines a group of animation to add to the new Animatable
  13274. * @param onAnimationLoop defines a callback to call when animation loops
  13275. */
  13276. constructor(scene: Scene,
  13277. /** defines the target object */
  13278. target: any,
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame?: number,
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame?: number,
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation?: boolean, speedRatio?: number,
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined);
  13289. /**
  13290. * Synchronize and normalize current Animatable with a source Animatable
  13291. * This is useful when using animation weights and when animations are not of the same length
  13292. * @param root defines the root Animatable to synchronize with
  13293. * @returns the current Animatable
  13294. */
  13295. syncWith(root: Animatable): Animatable;
  13296. /**
  13297. * Gets the list of runtime animations
  13298. * @returns an array of RuntimeAnimation
  13299. */
  13300. getAnimations(): RuntimeAnimation[];
  13301. /**
  13302. * Adds more animations to the current animatable
  13303. * @param target defines the target of the animations
  13304. * @param animations defines the new animations to add
  13305. */
  13306. appendAnimations(target: any, animations: Animation[]): void;
  13307. /**
  13308. * Gets the source animation for a specific property
  13309. * @param property defines the propertyu to look for
  13310. * @returns null or the source animation for the given property
  13311. */
  13312. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13313. /**
  13314. * Gets the runtime animation for a specific property
  13315. * @param property defines the propertyu to look for
  13316. * @returns null or the runtime animation for the given property
  13317. */
  13318. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13319. /**
  13320. * Resets the animatable to its original state
  13321. */
  13322. reset(): void;
  13323. /**
  13324. * Allows the animatable to blend with current running animations
  13325. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13326. * @param blendingSpeed defines the blending speed to use
  13327. */
  13328. enableBlending(blendingSpeed: number): void;
  13329. /**
  13330. * Disable animation blending
  13331. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13332. */
  13333. disableBlending(): void;
  13334. /**
  13335. * Jump directly to a given frame
  13336. * @param frame defines the frame to jump to
  13337. */
  13338. goToFrame(frame: number): void;
  13339. /**
  13340. * Pause the animation
  13341. */
  13342. pause(): void;
  13343. /**
  13344. * Restart the animation
  13345. */
  13346. restart(): void;
  13347. private _raiseOnAnimationEnd;
  13348. /**
  13349. * Stop and delete the current animation
  13350. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13351. * @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)
  13352. */
  13353. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13354. /**
  13355. * Wait asynchronously for the animation to end
  13356. * @returns a promise which will be fullfilled when the animation ends
  13357. */
  13358. waitAsync(): Promise<Animatable>;
  13359. /** @hidden */
  13360. _animate(delay: number): boolean;
  13361. }
  13362. module "babylonjs/scene" {
  13363. interface Scene {
  13364. /** @hidden */
  13365. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13366. /** @hidden */
  13367. _processLateAnimationBindingsForMatrices(holder: {
  13368. totalWeight: number;
  13369. animations: RuntimeAnimation[];
  13370. originalValue: Matrix;
  13371. }): any;
  13372. /** @hidden */
  13373. _processLateAnimationBindingsForQuaternions(holder: {
  13374. totalWeight: number;
  13375. animations: RuntimeAnimation[];
  13376. originalValue: Quaternion;
  13377. }, refQuaternion: Quaternion): Quaternion;
  13378. /** @hidden */
  13379. _processLateAnimationBindings(): void;
  13380. /**
  13381. * Will start the animation sequence of a given target
  13382. * @param target defines the target
  13383. * @param from defines from which frame should animation start
  13384. * @param to defines until which frame should animation run.
  13385. * @param weight defines the weight to apply to the animation (1.0 by default)
  13386. * @param loop defines if the animation loops
  13387. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13388. * @param onAnimationEnd defines the function to be executed when the animation ends
  13389. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13390. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13391. * @param onAnimationLoop defines the callback to call when an animation loops
  13392. * @returns the animatable object created for this animation
  13393. */
  13394. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13395. /**
  13396. * Will start the animation sequence of a given target
  13397. * @param target defines the target
  13398. * @param from defines from which frame should animation start
  13399. * @param to defines until which frame should animation run.
  13400. * @param loop defines if the animation loops
  13401. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13402. * @param onAnimationEnd defines the function to be executed when the animation ends
  13403. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13404. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13405. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13406. * @param onAnimationLoop defines the callback to call when an animation loops
  13407. * @returns the animatable object created for this animation
  13408. */
  13409. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13410. /**
  13411. * Will start the animation sequence of a given target and its hierarchy
  13412. * @param target defines the target
  13413. * @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.
  13414. * @param from defines from which frame should animation start
  13415. * @param to defines until which frame should animation run.
  13416. * @param loop defines if the animation loops
  13417. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13418. * @param onAnimationEnd defines the function to be executed when the animation ends
  13419. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13420. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13421. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13422. * @param onAnimationLoop defines the callback to call when an animation loops
  13423. * @returns the list of created animatables
  13424. */
  13425. 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[];
  13426. /**
  13427. * Begin a new animation on a given node
  13428. * @param target defines the target where the animation will take place
  13429. * @param animations defines the list of animations to start
  13430. * @param from defines the initial value
  13431. * @param to defines the final value
  13432. * @param loop defines if you want animation to loop (off by default)
  13433. * @param speedRatio defines the speed ratio to apply to all animations
  13434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13435. * @param onAnimationLoop defines the callback to call when an animation loops
  13436. * @returns the list of created animatables
  13437. */
  13438. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13439. /**
  13440. * Begin a new animation on a given node and its hierarchy
  13441. * @param target defines the root node where the animation will take place
  13442. * @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.
  13443. * @param animations defines the list of animations to start
  13444. * @param from defines the initial value
  13445. * @param to defines the final value
  13446. * @param loop defines if you want animation to loop (off by default)
  13447. * @param speedRatio defines the speed ratio to apply to all animations
  13448. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13449. * @param onAnimationLoop defines the callback to call when an animation loops
  13450. * @returns the list of animatables created for all nodes
  13451. */
  13452. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13453. /**
  13454. * Gets the animatable associated with a specific target
  13455. * @param target defines the target of the animatable
  13456. * @returns the required animatable if found
  13457. */
  13458. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13459. /**
  13460. * Gets all animatables associated with a given target
  13461. * @param target defines the target to look animatables for
  13462. * @returns an array of Animatables
  13463. */
  13464. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13465. /**
  13466. * Stops and removes all animations that have been applied to the scene
  13467. */
  13468. stopAllAnimations(): void;
  13469. /**
  13470. * Gets the current delta time used by animation engine
  13471. */
  13472. deltaTime: number;
  13473. }
  13474. }
  13475. module "babylonjs/Bones/bone" {
  13476. interface Bone {
  13477. /**
  13478. * Copy an animation range from another bone
  13479. * @param source defines the source bone
  13480. * @param rangeName defines the range name to copy
  13481. * @param frameOffset defines the frame offset
  13482. * @param rescaleAsRequired defines if rescaling must be applied if required
  13483. * @param skelDimensionsRatio defines the scaling ratio
  13484. * @returns true if operation was successful
  13485. */
  13486. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13487. }
  13488. }
  13489. }
  13490. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13491. /**
  13492. * Class used to override all child animations of a given target
  13493. */
  13494. export class AnimationPropertiesOverride {
  13495. /**
  13496. * Gets or sets a value indicating if animation blending must be used
  13497. */
  13498. enableBlending: boolean;
  13499. /**
  13500. * Gets or sets the blending speed to use when enableBlending is true
  13501. */
  13502. blendingSpeed: number;
  13503. /**
  13504. * Gets or sets the default loop mode to use
  13505. */
  13506. loopMode: number;
  13507. }
  13508. }
  13509. declare module "babylonjs/Bones/skeleton" {
  13510. import { Bone } from "babylonjs/Bones/bone";
  13511. import { Observable } from "babylonjs/Misc/observable";
  13512. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13513. import { Scene } from "babylonjs/scene";
  13514. import { Nullable } from "babylonjs/types";
  13515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13516. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13517. import { Animatable } from "babylonjs/Animations/animatable";
  13518. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13519. import { Animation } from "babylonjs/Animations/animation";
  13520. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13521. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13523. /**
  13524. * Class used to handle skinning animations
  13525. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13526. */
  13527. export class Skeleton implements IAnimatable {
  13528. /** defines the skeleton name */
  13529. name: string;
  13530. /** defines the skeleton Id */
  13531. id: string;
  13532. /**
  13533. * Defines the list of child bones
  13534. */
  13535. bones: Bone[];
  13536. /**
  13537. * Defines an estimate of the dimension of the skeleton at rest
  13538. */
  13539. dimensionsAtRest: Vector3;
  13540. /**
  13541. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13542. */
  13543. needInitialSkinMatrix: boolean;
  13544. /**
  13545. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13546. */
  13547. overrideMesh: Nullable<AbstractMesh>;
  13548. /**
  13549. * Gets the list of animations attached to this skeleton
  13550. */
  13551. animations: Array<Animation>;
  13552. private _scene;
  13553. private _isDirty;
  13554. private _transformMatrices;
  13555. private _transformMatrixTexture;
  13556. private _meshesWithPoseMatrix;
  13557. private _animatables;
  13558. private _identity;
  13559. private _synchronizedWithMesh;
  13560. private _ranges;
  13561. private _lastAbsoluteTransformsUpdateId;
  13562. private _canUseTextureForBones;
  13563. private _uniqueId;
  13564. /** @hidden */
  13565. _numBonesWithLinkedTransformNode: number;
  13566. /** @hidden */
  13567. _hasWaitingData: Nullable<boolean>;
  13568. /**
  13569. * Specifies if the skeleton should be serialized
  13570. */
  13571. doNotSerialize: boolean;
  13572. private _useTextureToStoreBoneMatrices;
  13573. /**
  13574. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13575. * Please note that this option is not available if the hardware does not support it
  13576. */
  13577. useTextureToStoreBoneMatrices: boolean;
  13578. private _animationPropertiesOverride;
  13579. /**
  13580. * Gets or sets the animation properties override
  13581. */
  13582. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13583. /**
  13584. * List of inspectable custom properties (used by the Inspector)
  13585. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13586. */
  13587. inspectableCustomProperties: IInspectable[];
  13588. /**
  13589. * An observable triggered before computing the skeleton's matrices
  13590. */
  13591. onBeforeComputeObservable: Observable<Skeleton>;
  13592. /**
  13593. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13594. */
  13595. readonly isUsingTextureForMatrices: boolean;
  13596. /**
  13597. * Gets the unique ID of this skeleton
  13598. */
  13599. readonly uniqueId: number;
  13600. /**
  13601. * Creates a new skeleton
  13602. * @param name defines the skeleton name
  13603. * @param id defines the skeleton Id
  13604. * @param scene defines the hosting scene
  13605. */
  13606. constructor(
  13607. /** defines the skeleton name */
  13608. name: string,
  13609. /** defines the skeleton Id */
  13610. id: string, scene: Scene);
  13611. /**
  13612. * Gets the current object class name.
  13613. * @return the class name
  13614. */
  13615. getClassName(): string;
  13616. /**
  13617. * Returns an array containing the root bones
  13618. * @returns an array containing the root bones
  13619. */
  13620. getChildren(): Array<Bone>;
  13621. /**
  13622. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13623. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13624. * @returns a Float32Array containing matrices data
  13625. */
  13626. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13627. /**
  13628. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13629. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13630. * @returns a raw texture containing the data
  13631. */
  13632. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13633. /**
  13634. * Gets the current hosting scene
  13635. * @returns a scene object
  13636. */
  13637. getScene(): Scene;
  13638. /**
  13639. * Gets a string representing the current skeleton data
  13640. * @param fullDetails defines a boolean indicating if we want a verbose version
  13641. * @returns a string representing the current skeleton data
  13642. */
  13643. toString(fullDetails?: boolean): string;
  13644. /**
  13645. * Get bone's index searching by name
  13646. * @param name defines bone's name to search for
  13647. * @return the indice of the bone. Returns -1 if not found
  13648. */
  13649. getBoneIndexByName(name: string): number;
  13650. /**
  13651. * Creater a new animation range
  13652. * @param name defines the name of the range
  13653. * @param from defines the start key
  13654. * @param to defines the end key
  13655. */
  13656. createAnimationRange(name: string, from: number, to: number): void;
  13657. /**
  13658. * Delete a specific animation range
  13659. * @param name defines the name of the range
  13660. * @param deleteFrames defines if frames must be removed as well
  13661. */
  13662. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13663. /**
  13664. * Gets a specific animation range
  13665. * @param name defines the name of the range to look for
  13666. * @returns the requested animation range or null if not found
  13667. */
  13668. getAnimationRange(name: string): Nullable<AnimationRange>;
  13669. /**
  13670. * Gets the list of all animation ranges defined on this skeleton
  13671. * @returns an array
  13672. */
  13673. getAnimationRanges(): Nullable<AnimationRange>[];
  13674. /**
  13675. * Copy animation range from a source skeleton.
  13676. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13677. * @param source defines the source skeleton
  13678. * @param name defines the name of the range to copy
  13679. * @param rescaleAsRequired defines if rescaling must be applied if required
  13680. * @returns true if operation was successful
  13681. */
  13682. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13683. /**
  13684. * Forces the skeleton to go to rest pose
  13685. */
  13686. returnToRest(): void;
  13687. private _getHighestAnimationFrame;
  13688. /**
  13689. * Begin a specific animation range
  13690. * @param name defines the name of the range to start
  13691. * @param loop defines if looping must be turned on (false by default)
  13692. * @param speedRatio defines the speed ratio to apply (1 by default)
  13693. * @param onAnimationEnd defines a callback which will be called when animation will end
  13694. * @returns a new animatable
  13695. */
  13696. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13697. /** @hidden */
  13698. _markAsDirty(): void;
  13699. /** @hidden */
  13700. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13701. /** @hidden */
  13702. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13703. private _computeTransformMatrices;
  13704. /**
  13705. * Build all resources required to render a skeleton
  13706. */
  13707. prepare(): void;
  13708. /**
  13709. * Gets the list of animatables currently running for this skeleton
  13710. * @returns an array of animatables
  13711. */
  13712. getAnimatables(): IAnimatable[];
  13713. /**
  13714. * Clone the current skeleton
  13715. * @param name defines the name of the new skeleton
  13716. * @param id defines the id of the new skeleton
  13717. * @returns the new skeleton
  13718. */
  13719. clone(name: string, id: string): Skeleton;
  13720. /**
  13721. * Enable animation blending for this skeleton
  13722. * @param blendingSpeed defines the blending speed to apply
  13723. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13724. */
  13725. enableBlending(blendingSpeed?: number): void;
  13726. /**
  13727. * Releases all resources associated with the current skeleton
  13728. */
  13729. dispose(): void;
  13730. /**
  13731. * Serialize the skeleton in a JSON object
  13732. * @returns a JSON object
  13733. */
  13734. serialize(): any;
  13735. /**
  13736. * Creates a new skeleton from serialized data
  13737. * @param parsedSkeleton defines the serialized data
  13738. * @param scene defines the hosting scene
  13739. * @returns a new skeleton
  13740. */
  13741. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13742. /**
  13743. * Compute all node absolute transforms
  13744. * @param forceUpdate defines if computation must be done even if cache is up to date
  13745. */
  13746. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13747. /**
  13748. * Gets the root pose matrix
  13749. * @returns a matrix
  13750. */
  13751. getPoseMatrix(): Nullable<Matrix>;
  13752. /**
  13753. * Sorts bones per internal index
  13754. */
  13755. sortBones(): void;
  13756. private _sortBones;
  13757. }
  13758. }
  13759. declare module "babylonjs/Bones/bone" {
  13760. import { Skeleton } from "babylonjs/Bones/skeleton";
  13761. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13762. import { Nullable } from "babylonjs/types";
  13763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13764. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13765. import { Node } from "babylonjs/node";
  13766. import { Space } from "babylonjs/Maths/math.axis";
  13767. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13768. /**
  13769. * Class used to store bone information
  13770. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13771. */
  13772. export class Bone extends Node {
  13773. /**
  13774. * defines the bone name
  13775. */
  13776. name: string;
  13777. private static _tmpVecs;
  13778. private static _tmpQuat;
  13779. private static _tmpMats;
  13780. /**
  13781. * Gets the list of child bones
  13782. */
  13783. children: Bone[];
  13784. /** Gets the animations associated with this bone */
  13785. animations: import("babylonjs/Animations/animation").Animation[];
  13786. /**
  13787. * Gets or sets bone length
  13788. */
  13789. length: number;
  13790. /**
  13791. * @hidden Internal only
  13792. * Set this value to map this bone to a different index in the transform matrices
  13793. * Set this value to -1 to exclude the bone from the transform matrices
  13794. */
  13795. _index: Nullable<number>;
  13796. private _skeleton;
  13797. private _localMatrix;
  13798. private _restPose;
  13799. private _baseMatrix;
  13800. private _absoluteTransform;
  13801. private _invertedAbsoluteTransform;
  13802. private _parent;
  13803. private _scalingDeterminant;
  13804. private _worldTransform;
  13805. private _localScaling;
  13806. private _localRotation;
  13807. private _localPosition;
  13808. private _needToDecompose;
  13809. private _needToCompose;
  13810. /** @hidden */
  13811. _linkedTransformNode: Nullable<TransformNode>;
  13812. /** @hidden */
  13813. _waitingTransformNodeId: Nullable<string>;
  13814. /** @hidden */
  13815. /** @hidden */
  13816. _matrix: Matrix;
  13817. /**
  13818. * Create a new bone
  13819. * @param name defines the bone name
  13820. * @param skeleton defines the parent skeleton
  13821. * @param parentBone defines the parent (can be null if the bone is the root)
  13822. * @param localMatrix defines the local matrix
  13823. * @param restPose defines the rest pose matrix
  13824. * @param baseMatrix defines the base matrix
  13825. * @param index defines index of the bone in the hiearchy
  13826. */
  13827. constructor(
  13828. /**
  13829. * defines the bone name
  13830. */
  13831. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13832. /**
  13833. * Gets the current object class name.
  13834. * @return the class name
  13835. */
  13836. getClassName(): string;
  13837. /**
  13838. * Gets the parent skeleton
  13839. * @returns a skeleton
  13840. */
  13841. getSkeleton(): Skeleton;
  13842. /**
  13843. * Gets parent bone
  13844. * @returns a bone or null if the bone is the root of the bone hierarchy
  13845. */
  13846. getParent(): Nullable<Bone>;
  13847. /**
  13848. * Returns an array containing the root bones
  13849. * @returns an array containing the root bones
  13850. */
  13851. getChildren(): Array<Bone>;
  13852. /**
  13853. * Sets the parent bone
  13854. * @param parent defines the parent (can be null if the bone is the root)
  13855. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13856. */
  13857. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13858. /**
  13859. * Gets the local matrix
  13860. * @returns a matrix
  13861. */
  13862. getLocalMatrix(): Matrix;
  13863. /**
  13864. * Gets the base matrix (initial matrix which remains unchanged)
  13865. * @returns a matrix
  13866. */
  13867. getBaseMatrix(): Matrix;
  13868. /**
  13869. * Gets the rest pose matrix
  13870. * @returns a matrix
  13871. */
  13872. getRestPose(): Matrix;
  13873. /**
  13874. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13875. */
  13876. getWorldMatrix(): Matrix;
  13877. /**
  13878. * Sets the local matrix to rest pose matrix
  13879. */
  13880. returnToRest(): void;
  13881. /**
  13882. * Gets the inverse of the absolute transform matrix.
  13883. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13884. * @returns a matrix
  13885. */
  13886. getInvertedAbsoluteTransform(): Matrix;
  13887. /**
  13888. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13889. * @returns a matrix
  13890. */
  13891. getAbsoluteTransform(): Matrix;
  13892. /**
  13893. * Links with the given transform node.
  13894. * The local matrix of this bone is copied from the transform node every frame.
  13895. * @param transformNode defines the transform node to link to
  13896. */
  13897. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13898. /**
  13899. * Gets the node used to drive the bone's transformation
  13900. * @returns a transform node or null
  13901. */
  13902. getTransformNode(): Nullable<TransformNode>;
  13903. /** Gets or sets current position (in local space) */
  13904. position: Vector3;
  13905. /** Gets or sets current rotation (in local space) */
  13906. rotation: Vector3;
  13907. /** Gets or sets current rotation quaternion (in local space) */
  13908. rotationQuaternion: Quaternion;
  13909. /** Gets or sets current scaling (in local space) */
  13910. scaling: Vector3;
  13911. /**
  13912. * Gets the animation properties override
  13913. */
  13914. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13915. private _decompose;
  13916. private _compose;
  13917. /**
  13918. * Update the base and local matrices
  13919. * @param matrix defines the new base or local matrix
  13920. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13921. * @param updateLocalMatrix defines if the local matrix should be updated
  13922. */
  13923. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13924. /** @hidden */
  13925. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13926. /**
  13927. * Flag the bone as dirty (Forcing it to update everything)
  13928. */
  13929. markAsDirty(): void;
  13930. /** @hidden */
  13931. _markAsDirtyAndCompose(): void;
  13932. private _markAsDirtyAndDecompose;
  13933. /**
  13934. * Translate the bone in local or world space
  13935. * @param vec The amount to translate the bone
  13936. * @param space The space that the translation is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. */
  13939. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13940. /**
  13941. * Set the postion of the bone in local or world space
  13942. * @param position The position to set the bone
  13943. * @param space The space that the position is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. */
  13946. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13947. /**
  13948. * Set the absolute position of the bone (world space)
  13949. * @param position The position to set the bone
  13950. * @param mesh The mesh that this bone is attached to
  13951. */
  13952. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13953. /**
  13954. * Scale the bone on the x, y and z axes (in local space)
  13955. * @param x The amount to scale the bone on the x axis
  13956. * @param y The amount to scale the bone on the y axis
  13957. * @param z The amount to scale the bone on the z axis
  13958. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13959. */
  13960. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13961. /**
  13962. * Set the bone scaling in local space
  13963. * @param scale defines the scaling vector
  13964. */
  13965. setScale(scale: Vector3): void;
  13966. /**
  13967. * Gets the current scaling in local space
  13968. * @returns the current scaling vector
  13969. */
  13970. getScale(): Vector3;
  13971. /**
  13972. * Gets the current scaling in local space and stores it in a target vector
  13973. * @param result defines the target vector
  13974. */
  13975. getScaleToRef(result: Vector3): void;
  13976. /**
  13977. * Set the yaw, pitch, and roll of the bone in local or world space
  13978. * @param yaw The rotation of the bone on the y axis
  13979. * @param pitch The rotation of the bone on the x axis
  13980. * @param roll The rotation of the bone on the z axis
  13981. * @param space The space that the axes of rotation are in
  13982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13983. */
  13984. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13985. /**
  13986. * Add a rotation to the bone on an axis in local or world space
  13987. * @param axis The axis to rotate the bone on
  13988. * @param amount The amount to rotate the bone
  13989. * @param space The space that the axis is in
  13990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13991. */
  13992. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13993. /**
  13994. * Set the rotation of the bone to a particular axis angle in local or world space
  13995. * @param axis The axis to rotate the bone on
  13996. * @param angle The angle that the bone should be rotated to
  13997. * @param space The space that the axis is in
  13998. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13999. */
  14000. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14001. /**
  14002. * Set the euler rotation of the bone in local of world space
  14003. * @param rotation The euler rotation that the bone should be set to
  14004. * @param space The space that the rotation is in
  14005. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14006. */
  14007. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14008. /**
  14009. * Set the quaternion rotation of the bone in local of world space
  14010. * @param quat The quaternion rotation that the bone should be set to
  14011. * @param space The space that the rotation is in
  14012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14013. */
  14014. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14015. /**
  14016. * Set the rotation matrix of the bone in local of world space
  14017. * @param rotMat The rotation matrix that the bone should be set to
  14018. * @param space The space that the rotation is in
  14019. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14020. */
  14021. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14022. private _rotateWithMatrix;
  14023. private _getNegativeRotationToRef;
  14024. /**
  14025. * Get the position of the bone in local or world space
  14026. * @param space The space that the returned position is in
  14027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14028. * @returns The position of the bone
  14029. */
  14030. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14031. /**
  14032. * Copy the position of the bone to a vector3 in local or world space
  14033. * @param space The space that the returned position is in
  14034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14035. * @param result The vector3 to copy the position to
  14036. */
  14037. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14038. /**
  14039. * Get the absolute position of the bone (world space)
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @returns The absolute position of the bone
  14042. */
  14043. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14044. /**
  14045. * Copy the absolute position of the bone (world space) to the result param
  14046. * @param mesh The mesh that this bone is attached to
  14047. * @param result The vector3 to copy the absolute position to
  14048. */
  14049. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14050. /**
  14051. * Compute the absolute transforms of this bone and its children
  14052. */
  14053. computeAbsoluteTransforms(): void;
  14054. /**
  14055. * Get the world direction from an axis that is in the local space of the bone
  14056. * @param localAxis The local direction that is used to compute the world direction
  14057. * @param mesh The mesh that this bone is attached to
  14058. * @returns The world direction
  14059. */
  14060. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14061. /**
  14062. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14063. * @param localAxis The local direction that is used to compute the world direction
  14064. * @param mesh The mesh that this bone is attached to
  14065. * @param result The vector3 that the world direction will be copied to
  14066. */
  14067. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14068. /**
  14069. * Get the euler rotation of the bone in local or world space
  14070. * @param space The space that the rotation should be in
  14071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14072. * @returns The euler rotation
  14073. */
  14074. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14075. /**
  14076. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14077. * @param space The space that the rotation should be in
  14078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14079. * @param result The vector3 that the rotation should be copied to
  14080. */
  14081. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14082. /**
  14083. * Get the quaternion rotation of the bone in either local or world space
  14084. * @param space The space that the rotation should be in
  14085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14086. * @returns The quaternion rotation
  14087. */
  14088. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14089. /**
  14090. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14091. * @param space The space that the rotation should be in
  14092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14093. * @param result The quaternion that the rotation should be copied to
  14094. */
  14095. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14096. /**
  14097. * Get the rotation matrix of the bone in local or world space
  14098. * @param space The space that the rotation should be in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. * @returns The rotation matrix
  14101. */
  14102. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14103. /**
  14104. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14105. * @param space The space that the rotation should be in
  14106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14107. * @param result The quaternion that the rotation should be copied to
  14108. */
  14109. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14110. /**
  14111. * Get the world position of a point that is in the local space of the bone
  14112. * @param position The local position
  14113. * @param mesh The mesh that this bone is attached to
  14114. * @returns The world position
  14115. */
  14116. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14117. /**
  14118. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14119. * @param position The local position
  14120. * @param mesh The mesh that this bone is attached to
  14121. * @param result The vector3 that the world position should be copied to
  14122. */
  14123. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14124. /**
  14125. * Get the local position of a point that is in world space
  14126. * @param position The world position
  14127. * @param mesh The mesh that this bone is attached to
  14128. * @returns The local position
  14129. */
  14130. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14131. /**
  14132. * Get the local position of a point that is in world space and copy it to the result param
  14133. * @param position The world position
  14134. * @param mesh The mesh that this bone is attached to
  14135. * @param result The vector3 that the local position should be copied to
  14136. */
  14137. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14138. }
  14139. }
  14140. declare module "babylonjs/Meshes/transformNode" {
  14141. import { DeepImmutable } from "babylonjs/types";
  14142. import { Observable } from "babylonjs/Misc/observable";
  14143. import { Nullable } from "babylonjs/types";
  14144. import { Camera } from "babylonjs/Cameras/camera";
  14145. import { Scene } from "babylonjs/scene";
  14146. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14147. import { Node } from "babylonjs/node";
  14148. import { Bone } from "babylonjs/Bones/bone";
  14149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14150. import { Space } from "babylonjs/Maths/math.axis";
  14151. /**
  14152. * 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.
  14153. * @see https://doc.babylonjs.com/how_to/transformnode
  14154. */
  14155. export class TransformNode extends Node {
  14156. /**
  14157. * Object will not rotate to face the camera
  14158. */
  14159. static BILLBOARDMODE_NONE: number;
  14160. /**
  14161. * Object will rotate to face the camera but only on the x axis
  14162. */
  14163. static BILLBOARDMODE_X: number;
  14164. /**
  14165. * Object will rotate to face the camera but only on the y axis
  14166. */
  14167. static BILLBOARDMODE_Y: number;
  14168. /**
  14169. * Object will rotate to face the camera but only on the z axis
  14170. */
  14171. static BILLBOARDMODE_Z: number;
  14172. /**
  14173. * Object will rotate to face the camera
  14174. */
  14175. static BILLBOARDMODE_ALL: number;
  14176. /**
  14177. * Object will rotate to face the camera's position instead of orientation
  14178. */
  14179. static BILLBOARDMODE_USE_POSITION: number;
  14180. private _forward;
  14181. private _forwardInverted;
  14182. private _up;
  14183. private _right;
  14184. private _rightInverted;
  14185. private _position;
  14186. private _rotation;
  14187. private _rotationQuaternion;
  14188. protected _scaling: Vector3;
  14189. protected _isDirty: boolean;
  14190. private _transformToBoneReferal;
  14191. private _isAbsoluteSynced;
  14192. private _billboardMode;
  14193. /**
  14194. * Gets or sets the billboard mode. Default is 0.
  14195. *
  14196. * | Value | Type | Description |
  14197. * | --- | --- | --- |
  14198. * | 0 | BILLBOARDMODE_NONE | |
  14199. * | 1 | BILLBOARDMODE_X | |
  14200. * | 2 | BILLBOARDMODE_Y | |
  14201. * | 4 | BILLBOARDMODE_Z | |
  14202. * | 7 | BILLBOARDMODE_ALL | |
  14203. *
  14204. */
  14205. billboardMode: number;
  14206. private _preserveParentRotationForBillboard;
  14207. /**
  14208. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14209. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14210. */
  14211. preserveParentRotationForBillboard: boolean;
  14212. /**
  14213. * 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
  14214. */
  14215. scalingDeterminant: number;
  14216. private _infiniteDistance;
  14217. /**
  14218. * Gets or sets the distance of the object to max, often used by skybox
  14219. */
  14220. infiniteDistance: boolean;
  14221. /**
  14222. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14223. * By default the system will update normals to compensate
  14224. */
  14225. ignoreNonUniformScaling: boolean;
  14226. /**
  14227. * 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
  14228. */
  14229. reIntegrateRotationIntoRotationQuaternion: boolean;
  14230. /** @hidden */
  14231. _poseMatrix: Nullable<Matrix>;
  14232. /** @hidden */
  14233. _localMatrix: Matrix;
  14234. private _usePivotMatrix;
  14235. private _absolutePosition;
  14236. private _absoluteScaling;
  14237. private _absoluteRotationQuaternion;
  14238. private _pivotMatrix;
  14239. private _pivotMatrixInverse;
  14240. protected _postMultiplyPivotMatrix: boolean;
  14241. protected _isWorldMatrixFrozen: boolean;
  14242. /** @hidden */
  14243. _indexInSceneTransformNodesArray: number;
  14244. /**
  14245. * An event triggered after the world matrix is updated
  14246. */
  14247. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14248. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14249. /**
  14250. * Gets a string identifying the name of the class
  14251. * @returns "TransformNode" string
  14252. */
  14253. getClassName(): string;
  14254. /**
  14255. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14256. */
  14257. position: Vector3;
  14258. /**
  14259. * 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)).
  14260. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14261. */
  14262. rotation: Vector3;
  14263. /**
  14264. * 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)).
  14265. */
  14266. scaling: Vector3;
  14267. /**
  14268. * 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).
  14269. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14270. */
  14271. rotationQuaternion: Nullable<Quaternion>;
  14272. /**
  14273. * The forward direction of that transform in world space.
  14274. */
  14275. readonly forward: Vector3;
  14276. /**
  14277. * The up direction of that transform in world space.
  14278. */
  14279. readonly up: Vector3;
  14280. /**
  14281. * The right direction of that transform in world space.
  14282. */
  14283. readonly right: Vector3;
  14284. /**
  14285. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14286. * @param matrix the matrix to copy the pose from
  14287. * @returns this TransformNode.
  14288. */
  14289. updatePoseMatrix(matrix: Matrix): TransformNode;
  14290. /**
  14291. * Returns the mesh Pose matrix.
  14292. * @returns the pose matrix
  14293. */
  14294. getPoseMatrix(): Matrix;
  14295. /** @hidden */
  14296. _isSynchronized(): boolean;
  14297. /** @hidden */
  14298. _initCache(): void;
  14299. /**
  14300. * Flag the transform node as dirty (Forcing it to update everything)
  14301. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14302. * @returns this transform node
  14303. */
  14304. markAsDirty(property: string): TransformNode;
  14305. /**
  14306. * Returns the current mesh absolute position.
  14307. * Returns a Vector3.
  14308. */
  14309. readonly absolutePosition: Vector3;
  14310. /**
  14311. * Returns the current mesh absolute scaling.
  14312. * Returns a Vector3.
  14313. */
  14314. readonly absoluteScaling: Vector3;
  14315. /**
  14316. * Returns the current mesh absolute rotation.
  14317. * Returns a Quaternion.
  14318. */
  14319. readonly absoluteRotationQuaternion: Quaternion;
  14320. /**
  14321. * Sets a new matrix to apply before all other transformation
  14322. * @param matrix defines the transform matrix
  14323. * @returns the current TransformNode
  14324. */
  14325. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14326. /**
  14327. * Sets a new pivot matrix to the current node
  14328. * @param matrix defines the new pivot matrix to use
  14329. * @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
  14330. * @returns the current TransformNode
  14331. */
  14332. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14333. /**
  14334. * Returns the mesh pivot matrix.
  14335. * Default : Identity.
  14336. * @returns the matrix
  14337. */
  14338. getPivotMatrix(): Matrix;
  14339. /**
  14340. * Instantiate (when possible) or clone that node with its hierarchy
  14341. * @param newParent defines the new parent to use for the instance (or clone)
  14342. * @returns an instance (or a clone) of the current node with its hiearchy
  14343. */
  14344. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14345. /**
  14346. * Prevents the World matrix to be computed any longer
  14347. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14348. * @returns the TransformNode.
  14349. */
  14350. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14351. /**
  14352. * Allows back the World matrix computation.
  14353. * @returns the TransformNode.
  14354. */
  14355. unfreezeWorldMatrix(): this;
  14356. /**
  14357. * True if the World matrix has been frozen.
  14358. */
  14359. readonly isWorldMatrixFrozen: boolean;
  14360. /**
  14361. * Retuns the mesh absolute position in the World.
  14362. * @returns a Vector3.
  14363. */
  14364. getAbsolutePosition(): Vector3;
  14365. /**
  14366. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14367. * @param absolutePosition the absolute position to set
  14368. * @returns the TransformNode.
  14369. */
  14370. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14371. /**
  14372. * Sets the mesh position in its local space.
  14373. * @param vector3 the position to set in localspace
  14374. * @returns the TransformNode.
  14375. */
  14376. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14377. /**
  14378. * Returns the mesh position in the local space from the current World matrix values.
  14379. * @returns a new Vector3.
  14380. */
  14381. getPositionExpressedInLocalSpace(): Vector3;
  14382. /**
  14383. * Translates the mesh along the passed Vector3 in its local space.
  14384. * @param vector3 the distance to translate in localspace
  14385. * @returns the TransformNode.
  14386. */
  14387. locallyTranslate(vector3: Vector3): TransformNode;
  14388. private static _lookAtVectorCache;
  14389. /**
  14390. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14391. * @param targetPoint the position (must be in same space as current mesh) to look at
  14392. * @param yawCor optional yaw (y-axis) correction in radians
  14393. * @param pitchCor optional pitch (x-axis) correction in radians
  14394. * @param rollCor optional roll (z-axis) correction in radians
  14395. * @param space the choosen space of the target
  14396. * @returns the TransformNode.
  14397. */
  14398. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14399. /**
  14400. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14401. * This Vector3 is expressed in the World space.
  14402. * @param localAxis axis to rotate
  14403. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14404. */
  14405. getDirection(localAxis: Vector3): Vector3;
  14406. /**
  14407. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14408. * localAxis is expressed in the mesh local space.
  14409. * result is computed in the Wordl space from the mesh World matrix.
  14410. * @param localAxis axis to rotate
  14411. * @param result the resulting transformnode
  14412. * @returns this TransformNode.
  14413. */
  14414. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14415. /**
  14416. * Sets this transform node rotation to the given local axis.
  14417. * @param localAxis the axis in local space
  14418. * @param yawCor optional yaw (y-axis) correction in radians
  14419. * @param pitchCor optional pitch (x-axis) correction in radians
  14420. * @param rollCor optional roll (z-axis) correction in radians
  14421. * @returns this TransformNode
  14422. */
  14423. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14424. /**
  14425. * Sets a new pivot point to the current node
  14426. * @param point defines the new pivot point to use
  14427. * @param space defines if the point is in world or local space (local by default)
  14428. * @returns the current TransformNode
  14429. */
  14430. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14431. /**
  14432. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14433. * @returns the pivot point
  14434. */
  14435. getPivotPoint(): Vector3;
  14436. /**
  14437. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14438. * @param result the vector3 to store the result
  14439. * @returns this TransformNode.
  14440. */
  14441. getPivotPointToRef(result: Vector3): TransformNode;
  14442. /**
  14443. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14444. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14445. */
  14446. getAbsolutePivotPoint(): Vector3;
  14447. /**
  14448. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14449. * @param result vector3 to store the result
  14450. * @returns this TransformNode.
  14451. */
  14452. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14453. /**
  14454. * Defines the passed node as the parent of the current node.
  14455. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14456. * @see https://doc.babylonjs.com/how_to/parenting
  14457. * @param node the node ot set as the parent
  14458. * @returns this TransformNode.
  14459. */
  14460. setParent(node: Nullable<Node>): TransformNode;
  14461. private _nonUniformScaling;
  14462. /**
  14463. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14464. */
  14465. readonly nonUniformScaling: boolean;
  14466. /** @hidden */
  14467. _updateNonUniformScalingState(value: boolean): boolean;
  14468. /**
  14469. * Attach the current TransformNode to another TransformNode associated with a bone
  14470. * @param bone Bone affecting the TransformNode
  14471. * @param affectedTransformNode TransformNode associated with the bone
  14472. * @returns this object
  14473. */
  14474. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14475. /**
  14476. * Detach the transform node if its associated with a bone
  14477. * @returns this object
  14478. */
  14479. detachFromBone(): TransformNode;
  14480. private static _rotationAxisCache;
  14481. /**
  14482. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14483. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14484. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14485. * The passed axis is also normalized.
  14486. * @param axis the axis to rotate around
  14487. * @param amount the amount to rotate in radians
  14488. * @param space Space to rotate in (Default: local)
  14489. * @returns the TransformNode.
  14490. */
  14491. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14492. /**
  14493. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14494. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14495. * The passed axis is also normalized. .
  14496. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14497. * @param point the point to rotate around
  14498. * @param axis the axis to rotate around
  14499. * @param amount the amount to rotate in radians
  14500. * @returns the TransformNode
  14501. */
  14502. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14503. /**
  14504. * Translates the mesh along the axis vector for the passed distance in the given space.
  14505. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14506. * @param axis the axis to translate in
  14507. * @param distance the distance to translate
  14508. * @param space Space to rotate in (Default: local)
  14509. * @returns the TransformNode.
  14510. */
  14511. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14512. /**
  14513. * Adds a rotation step to the mesh current rotation.
  14514. * x, y, z are Euler angles expressed in radians.
  14515. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14516. * This means this rotation is made in the mesh local space only.
  14517. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14518. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14519. * ```javascript
  14520. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14521. * ```
  14522. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14523. * 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.
  14524. * @param x Rotation to add
  14525. * @param y Rotation to add
  14526. * @param z Rotation to add
  14527. * @returns the TransformNode.
  14528. */
  14529. addRotation(x: number, y: number, z: number): TransformNode;
  14530. /**
  14531. * @hidden
  14532. */
  14533. protected _getEffectiveParent(): Nullable<Node>;
  14534. /**
  14535. * Computes the world matrix of the node
  14536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14537. * @returns the world matrix
  14538. */
  14539. computeWorldMatrix(force?: boolean): Matrix;
  14540. protected _afterComputeWorldMatrix(): void;
  14541. /**
  14542. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14543. * @param func callback function to add
  14544. *
  14545. * @returns the TransformNode.
  14546. */
  14547. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14548. /**
  14549. * Removes a registered callback function.
  14550. * @param func callback function to remove
  14551. * @returns the TransformNode.
  14552. */
  14553. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14554. /**
  14555. * Gets the position of the current mesh in camera space
  14556. * @param camera defines the camera to use
  14557. * @returns a position
  14558. */
  14559. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14560. /**
  14561. * Returns the distance from the mesh to the active camera
  14562. * @param camera defines the camera to use
  14563. * @returns the distance
  14564. */
  14565. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14566. /**
  14567. * Clone the current transform node
  14568. * @param name Name of the new clone
  14569. * @param newParent New parent for the clone
  14570. * @param doNotCloneChildren Do not clone children hierarchy
  14571. * @returns the new transform node
  14572. */
  14573. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14574. /**
  14575. * Serializes the objects information.
  14576. * @param currentSerializationObject defines the object to serialize in
  14577. * @returns the serialized object
  14578. */
  14579. serialize(currentSerializationObject?: any): any;
  14580. /**
  14581. * Returns a new TransformNode object parsed from the source provided.
  14582. * @param parsedTransformNode is the source.
  14583. * @param scene the scne the object belongs to
  14584. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14585. * @returns a new TransformNode object parsed from the source provided.
  14586. */
  14587. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14588. /**
  14589. * Get all child-transformNodes of this node
  14590. * @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
  14591. * @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
  14592. * @returns an array of TransformNode
  14593. */
  14594. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14595. /**
  14596. * Releases resources associated with this transform node.
  14597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14599. */
  14600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14601. /**
  14602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14606. * @returns the current mesh
  14607. */
  14608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14609. private _syncAbsoluteScalingAndRotation;
  14610. }
  14611. }
  14612. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14613. import { Observable } from "babylonjs/Misc/observable";
  14614. import { Nullable } from "babylonjs/types";
  14615. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14616. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14618. import { Ray } from "babylonjs/Culling/ray";
  14619. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14620. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14621. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14622. /**
  14623. * Defines the types of pose enabled controllers that are supported
  14624. */
  14625. export enum PoseEnabledControllerType {
  14626. /**
  14627. * HTC Vive
  14628. */
  14629. VIVE = 0,
  14630. /**
  14631. * Oculus Rift
  14632. */
  14633. OCULUS = 1,
  14634. /**
  14635. * Windows mixed reality
  14636. */
  14637. WINDOWS = 2,
  14638. /**
  14639. * Samsung gear VR
  14640. */
  14641. GEAR_VR = 3,
  14642. /**
  14643. * Google Daydream
  14644. */
  14645. DAYDREAM = 4,
  14646. /**
  14647. * Generic
  14648. */
  14649. GENERIC = 5
  14650. }
  14651. /**
  14652. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14653. */
  14654. export interface MutableGamepadButton {
  14655. /**
  14656. * Value of the button/trigger
  14657. */
  14658. value: number;
  14659. /**
  14660. * If the button/trigger is currently touched
  14661. */
  14662. touched: boolean;
  14663. /**
  14664. * If the button/trigger is currently pressed
  14665. */
  14666. pressed: boolean;
  14667. }
  14668. /**
  14669. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14670. * @hidden
  14671. */
  14672. export interface ExtendedGamepadButton extends GamepadButton {
  14673. /**
  14674. * If the button/trigger is currently pressed
  14675. */
  14676. readonly pressed: boolean;
  14677. /**
  14678. * If the button/trigger is currently touched
  14679. */
  14680. readonly touched: boolean;
  14681. /**
  14682. * Value of the button/trigger
  14683. */
  14684. readonly value: number;
  14685. }
  14686. /** @hidden */
  14687. export interface _GamePadFactory {
  14688. /**
  14689. * Returns wether or not the current gamepad can be created for this type of controller.
  14690. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14691. * @returns true if it can be created, otherwise false
  14692. */
  14693. canCreate(gamepadInfo: any): boolean;
  14694. /**
  14695. * Creates a new instance of the Gamepad.
  14696. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14697. * @returns the new gamepad instance
  14698. */
  14699. create(gamepadInfo: any): Gamepad;
  14700. }
  14701. /**
  14702. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14703. */
  14704. export class PoseEnabledControllerHelper {
  14705. /** @hidden */
  14706. static _ControllerFactories: _GamePadFactory[];
  14707. /** @hidden */
  14708. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14709. /**
  14710. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14711. * @param vrGamepad the gamepad to initialized
  14712. * @returns a vr controller of the type the gamepad identified as
  14713. */
  14714. static InitiateController(vrGamepad: any): Gamepad;
  14715. }
  14716. /**
  14717. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14718. */
  14719. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14720. /**
  14721. * If the controller is used in a webXR session
  14722. */
  14723. isXR: boolean;
  14724. private _deviceRoomPosition;
  14725. private _deviceRoomRotationQuaternion;
  14726. /**
  14727. * The device position in babylon space
  14728. */
  14729. devicePosition: Vector3;
  14730. /**
  14731. * The device rotation in babylon space
  14732. */
  14733. deviceRotationQuaternion: Quaternion;
  14734. /**
  14735. * The scale factor of the device in babylon space
  14736. */
  14737. deviceScaleFactor: number;
  14738. /**
  14739. * (Likely devicePosition should be used instead) The device position in its room space
  14740. */
  14741. position: Vector3;
  14742. /**
  14743. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14744. */
  14745. rotationQuaternion: Quaternion;
  14746. /**
  14747. * The type of controller (Eg. Windows mixed reality)
  14748. */
  14749. controllerType: PoseEnabledControllerType;
  14750. protected _calculatedPosition: Vector3;
  14751. private _calculatedRotation;
  14752. /**
  14753. * The raw pose from the device
  14754. */
  14755. rawPose: DevicePose;
  14756. private _trackPosition;
  14757. private _maxRotationDistFromHeadset;
  14758. private _draggedRoomRotation;
  14759. /**
  14760. * @hidden
  14761. */
  14762. _disableTrackPosition(fixedPosition: Vector3): void;
  14763. /**
  14764. * Internal, the mesh attached to the controller
  14765. * @hidden
  14766. */
  14767. _mesh: Nullable<AbstractMesh>;
  14768. private _poseControlledCamera;
  14769. private _leftHandSystemQuaternion;
  14770. /**
  14771. * Internal, matrix used to convert room space to babylon space
  14772. * @hidden
  14773. */
  14774. _deviceToWorld: Matrix;
  14775. /**
  14776. * Node to be used when casting a ray from the controller
  14777. * @hidden
  14778. */
  14779. _pointingPoseNode: Nullable<TransformNode>;
  14780. /**
  14781. * Name of the child mesh that can be used to cast a ray from the controller
  14782. */
  14783. static readonly POINTING_POSE: string;
  14784. /**
  14785. * Creates a new PoseEnabledController from a gamepad
  14786. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14787. */
  14788. constructor(browserGamepad: any);
  14789. private _workingMatrix;
  14790. /**
  14791. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14792. */
  14793. update(): void;
  14794. /**
  14795. * Updates only the pose device and mesh without doing any button event checking
  14796. */
  14797. protected _updatePoseAndMesh(): void;
  14798. /**
  14799. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14800. * @param poseData raw pose fromthe device
  14801. */
  14802. updateFromDevice(poseData: DevicePose): void;
  14803. /**
  14804. * @hidden
  14805. */
  14806. _meshAttachedObservable: Observable<AbstractMesh>;
  14807. /**
  14808. * Attaches a mesh to the controller
  14809. * @param mesh the mesh to be attached
  14810. */
  14811. attachToMesh(mesh: AbstractMesh): void;
  14812. /**
  14813. * Attaches the controllers mesh to a camera
  14814. * @param camera the camera the mesh should be attached to
  14815. */
  14816. attachToPoseControlledCamera(camera: TargetCamera): void;
  14817. /**
  14818. * Disposes of the controller
  14819. */
  14820. dispose(): void;
  14821. /**
  14822. * The mesh that is attached to the controller
  14823. */
  14824. readonly mesh: Nullable<AbstractMesh>;
  14825. /**
  14826. * Gets the ray of the controller in the direction the controller is pointing
  14827. * @param length the length the resulting ray should be
  14828. * @returns a ray in the direction the controller is pointing
  14829. */
  14830. getForwardRay(length?: number): Ray;
  14831. }
  14832. }
  14833. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14834. import { Observable } from "babylonjs/Misc/observable";
  14835. import { Scene } from "babylonjs/scene";
  14836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14837. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14838. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14839. import { Nullable } from "babylonjs/types";
  14840. /**
  14841. * Defines the WebVRController object that represents controllers tracked in 3D space
  14842. */
  14843. export abstract class WebVRController extends PoseEnabledController {
  14844. /**
  14845. * Internal, the default controller model for the controller
  14846. */
  14847. protected _defaultModel: Nullable<AbstractMesh>;
  14848. /**
  14849. * Fired when the trigger state has changed
  14850. */
  14851. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14852. /**
  14853. * Fired when the main button state has changed
  14854. */
  14855. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14856. /**
  14857. * Fired when the secondary button state has changed
  14858. */
  14859. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14860. /**
  14861. * Fired when the pad state has changed
  14862. */
  14863. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14864. /**
  14865. * Fired when controllers stick values have changed
  14866. */
  14867. onPadValuesChangedObservable: Observable<StickValues>;
  14868. /**
  14869. * Array of button availible on the controller
  14870. */
  14871. protected _buttons: Array<MutableGamepadButton>;
  14872. private _onButtonStateChange;
  14873. /**
  14874. * Fired when a controller button's state has changed
  14875. * @param callback the callback containing the button that was modified
  14876. */
  14877. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14878. /**
  14879. * X and Y axis corresponding to the controllers joystick
  14880. */
  14881. pad: StickValues;
  14882. /**
  14883. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14884. */
  14885. hand: string;
  14886. /**
  14887. * The default controller model for the controller
  14888. */
  14889. readonly defaultModel: Nullable<AbstractMesh>;
  14890. /**
  14891. * Creates a new WebVRController from a gamepad
  14892. * @param vrGamepad the gamepad that the WebVRController should be created from
  14893. */
  14894. constructor(vrGamepad: any);
  14895. /**
  14896. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14897. */
  14898. update(): void;
  14899. /**
  14900. * Function to be called when a button is modified
  14901. */
  14902. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14903. /**
  14904. * Loads a mesh and attaches it to the controller
  14905. * @param scene the scene the mesh should be added to
  14906. * @param meshLoaded callback for when the mesh has been loaded
  14907. */
  14908. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14909. private _setButtonValue;
  14910. private _changes;
  14911. private _checkChanges;
  14912. /**
  14913. * Disposes of th webVRCOntroller
  14914. */
  14915. dispose(): void;
  14916. }
  14917. }
  14918. declare module "babylonjs/Lights/hemisphericLight" {
  14919. import { Nullable } from "babylonjs/types";
  14920. import { Scene } from "babylonjs/scene";
  14921. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14922. import { Color3 } from "babylonjs/Maths/math.color";
  14923. import { Effect } from "babylonjs/Materials/effect";
  14924. import { Light } from "babylonjs/Lights/light";
  14925. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14926. /**
  14927. * The HemisphericLight simulates the ambient environment light,
  14928. * so the passed direction is the light reflection direction, not the incoming direction.
  14929. */
  14930. export class HemisphericLight extends Light {
  14931. /**
  14932. * The groundColor is the light in the opposite direction to the one specified during creation.
  14933. * 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.
  14934. */
  14935. groundColor: Color3;
  14936. /**
  14937. * The light reflection direction, not the incoming direction.
  14938. */
  14939. direction: Vector3;
  14940. /**
  14941. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14942. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14943. * The HemisphericLight can't cast shadows.
  14944. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14945. * @param name The friendly name of the light
  14946. * @param direction The direction of the light reflection
  14947. * @param scene The scene the light belongs to
  14948. */
  14949. constructor(name: string, direction: Vector3, scene: Scene);
  14950. protected _buildUniformLayout(): void;
  14951. /**
  14952. * Returns the string "HemisphericLight".
  14953. * @return The class name
  14954. */
  14955. getClassName(): string;
  14956. /**
  14957. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14958. * Returns the updated direction.
  14959. * @param target The target the direction should point to
  14960. * @return The computed direction
  14961. */
  14962. setDirectionToTarget(target: Vector3): Vector3;
  14963. /**
  14964. * Returns the shadow generator associated to the light.
  14965. * @returns Always null for hemispheric lights because it does not support shadows.
  14966. */
  14967. getShadowGenerator(): Nullable<IShadowGenerator>;
  14968. /**
  14969. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14970. * @param effect The effect to update
  14971. * @param lightIndex The index of the light in the effect to update
  14972. * @returns The hemispheric light
  14973. */
  14974. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14975. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14976. /**
  14977. * Computes the world matrix of the node
  14978. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14979. * @param useWasUpdatedFlag defines a reserved property
  14980. * @returns the world matrix
  14981. */
  14982. computeWorldMatrix(): Matrix;
  14983. /**
  14984. * Returns the integer 3.
  14985. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14986. */
  14987. getTypeID(): number;
  14988. /**
  14989. * Prepares the list of defines specific to the light type.
  14990. * @param defines the list of defines
  14991. * @param lightIndex defines the index of the light for the effect
  14992. */
  14993. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14994. }
  14995. }
  14996. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14997. /** @hidden */
  14998. export var vrMultiviewToSingleviewPixelShader: {
  14999. name: string;
  15000. shader: string;
  15001. };
  15002. }
  15003. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15005. import { Scene } from "babylonjs/scene";
  15006. /**
  15007. * Renders to multiple views with a single draw call
  15008. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15009. */
  15010. export class MultiviewRenderTarget extends RenderTargetTexture {
  15011. /**
  15012. * Creates a multiview render target
  15013. * @param scene scene used with the render target
  15014. * @param size the size of the render target (used for each view)
  15015. */
  15016. constructor(scene: Scene, size?: number | {
  15017. width: number;
  15018. height: number;
  15019. } | {
  15020. ratio: number;
  15021. });
  15022. /**
  15023. * @hidden
  15024. * @param faceIndex the face index, if its a cube texture
  15025. */
  15026. _bindFrameBuffer(faceIndex?: number): void;
  15027. /**
  15028. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15029. * @returns the view count
  15030. */
  15031. getViewCount(): number;
  15032. }
  15033. }
  15034. declare module "babylonjs/Maths/math.frustum" {
  15035. import { Matrix } from "babylonjs/Maths/math.vector";
  15036. import { DeepImmutable } from "babylonjs/types";
  15037. import { Plane } from "babylonjs/Maths/math.plane";
  15038. /**
  15039. * Represents a camera frustum
  15040. */
  15041. export class Frustum {
  15042. /**
  15043. * Gets the planes representing the frustum
  15044. * @param transform matrix to be applied to the returned planes
  15045. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15046. */
  15047. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15048. /**
  15049. * Gets the near frustum plane transformed by the transform matrix
  15050. * @param transform transformation matrix to be applied to the resulting frustum plane
  15051. * @param frustumPlane the resuling frustum plane
  15052. */
  15053. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15054. /**
  15055. * Gets the far frustum plane transformed by the transform matrix
  15056. * @param transform transformation matrix to be applied to the resulting frustum plane
  15057. * @param frustumPlane the resuling frustum plane
  15058. */
  15059. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15060. /**
  15061. * Gets the left frustum plane transformed by the transform matrix
  15062. * @param transform transformation matrix to be applied to the resulting frustum plane
  15063. * @param frustumPlane the resuling frustum plane
  15064. */
  15065. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15066. /**
  15067. * Gets the right frustum plane transformed by the transform matrix
  15068. * @param transform transformation matrix to be applied to the resulting frustum plane
  15069. * @param frustumPlane the resuling frustum plane
  15070. */
  15071. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15072. /**
  15073. * Gets the top frustum plane transformed by the transform matrix
  15074. * @param transform transformation matrix to be applied to the resulting frustum plane
  15075. * @param frustumPlane the resuling frustum plane
  15076. */
  15077. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15078. /**
  15079. * Gets the bottom frustum plane transformed by the transform matrix
  15080. * @param transform transformation matrix to be applied to the resulting frustum plane
  15081. * @param frustumPlane the resuling frustum plane
  15082. */
  15083. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15084. /**
  15085. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15086. * @param transform transformation matrix to be applied to the resulting frustum planes
  15087. * @param frustumPlanes the resuling frustum planes
  15088. */
  15089. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15090. }
  15091. }
  15092. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15093. import { Camera } from "babylonjs/Cameras/camera";
  15094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15095. import { Nullable } from "babylonjs/types";
  15096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15097. import { Matrix } from "babylonjs/Maths/math.vector";
  15098. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15099. module "babylonjs/Engines/engine" {
  15100. interface Engine {
  15101. /**
  15102. * Creates a new multiview render target
  15103. * @param width defines the width of the texture
  15104. * @param height defines the height of the texture
  15105. * @returns the created multiview texture
  15106. */
  15107. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15108. /**
  15109. * Binds a multiview framebuffer to be drawn to
  15110. * @param multiviewTexture texture to bind
  15111. */
  15112. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15113. }
  15114. }
  15115. module "babylonjs/Cameras/camera" {
  15116. interface Camera {
  15117. /**
  15118. * @hidden
  15119. * 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)
  15120. */
  15121. _useMultiviewToSingleView: boolean;
  15122. /**
  15123. * @hidden
  15124. * 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)
  15125. */
  15126. _multiviewTexture: Nullable<RenderTargetTexture>;
  15127. /**
  15128. * @hidden
  15129. * ensures the multiview texture of the camera exists and has the specified width/height
  15130. * @param width height to set on the multiview texture
  15131. * @param height width to set on the multiview texture
  15132. */
  15133. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15134. }
  15135. }
  15136. module "babylonjs/scene" {
  15137. interface Scene {
  15138. /** @hidden */
  15139. _transformMatrixR: Matrix;
  15140. /** @hidden */
  15141. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15142. /** @hidden */
  15143. _createMultiviewUbo(): void;
  15144. /** @hidden */
  15145. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15146. /** @hidden */
  15147. _renderMultiviewToSingleView(camera: Camera): void;
  15148. }
  15149. }
  15150. }
  15151. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15152. import { Camera } from "babylonjs/Cameras/camera";
  15153. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15154. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15155. import "babylonjs/Engines/Extensions/engine.multiview";
  15156. /**
  15157. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15158. * This will not be used for webXR as it supports displaying texture arrays directly
  15159. */
  15160. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15161. /**
  15162. * Initializes a VRMultiviewToSingleview
  15163. * @param name name of the post process
  15164. * @param camera camera to be applied to
  15165. * @param scaleFactor scaling factor to the size of the output texture
  15166. */
  15167. constructor(name: string, camera: Camera, scaleFactor: number);
  15168. }
  15169. }
  15170. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15171. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15172. import { Nullable } from "babylonjs/types";
  15173. import { Size } from "babylonjs/Maths/math.size";
  15174. import { Observable } from "babylonjs/Misc/observable";
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /** @hidden */
  15178. _vrDisplay: any;
  15179. /** @hidden */
  15180. _vrSupported: boolean;
  15181. /** @hidden */
  15182. _oldSize: Size;
  15183. /** @hidden */
  15184. _oldHardwareScaleFactor: number;
  15185. /** @hidden */
  15186. _vrExclusivePointerMode: boolean;
  15187. /** @hidden */
  15188. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15189. /** @hidden */
  15190. _onVRDisplayPointerRestricted: () => void;
  15191. /** @hidden */
  15192. _onVRDisplayPointerUnrestricted: () => void;
  15193. /** @hidden */
  15194. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15195. /** @hidden */
  15196. _onVrDisplayDisconnect: Nullable<() => void>;
  15197. /** @hidden */
  15198. _onVrDisplayPresentChange: Nullable<() => void>;
  15199. /**
  15200. * Observable signaled when VR display mode changes
  15201. */
  15202. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15203. /**
  15204. * Observable signaled when VR request present is complete
  15205. */
  15206. onVRRequestPresentComplete: Observable<boolean>;
  15207. /**
  15208. * Observable signaled when VR request present starts
  15209. */
  15210. onVRRequestPresentStart: Observable<Engine>;
  15211. /**
  15212. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15213. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15214. */
  15215. isInVRExclusivePointerMode: boolean;
  15216. /**
  15217. * Gets a boolean indicating if a webVR device was detected
  15218. * @returns true if a webVR device was detected
  15219. */
  15220. isVRDevicePresent(): boolean;
  15221. /**
  15222. * Gets the current webVR device
  15223. * @returns the current webVR device (or null)
  15224. */
  15225. getVRDevice(): any;
  15226. /**
  15227. * Initializes a webVR display and starts listening to display change events
  15228. * The onVRDisplayChangedObservable will be notified upon these changes
  15229. * @returns A promise containing a VRDisplay and if vr is supported
  15230. */
  15231. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15232. /** @hidden */
  15233. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15234. /**
  15235. * Call this function to switch to webVR mode
  15236. * Will do nothing if webVR is not supported or if there is no webVR device
  15237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15238. */
  15239. enableVR(): void;
  15240. /** @hidden */
  15241. _onVRFullScreenTriggered(): void;
  15242. }
  15243. }
  15244. }
  15245. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15246. import { Nullable } from "babylonjs/types";
  15247. import { Observable } from "babylonjs/Misc/observable";
  15248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15249. import { Scene } from "babylonjs/scene";
  15250. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15251. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15252. import { Node } from "babylonjs/node";
  15253. import { Ray } from "babylonjs/Culling/ray";
  15254. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15255. import "babylonjs/Engines/Extensions/engine.webVR";
  15256. /**
  15257. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15258. * IMPORTANT!! The data is right-hand data.
  15259. * @export
  15260. * @interface DevicePose
  15261. */
  15262. export interface DevicePose {
  15263. /**
  15264. * The position of the device, values in array are [x,y,z].
  15265. */
  15266. readonly position: Nullable<Float32Array>;
  15267. /**
  15268. * The linearVelocity of the device, values in array are [x,y,z].
  15269. */
  15270. readonly linearVelocity: Nullable<Float32Array>;
  15271. /**
  15272. * The linearAcceleration of the device, values in array are [x,y,z].
  15273. */
  15274. readonly linearAcceleration: Nullable<Float32Array>;
  15275. /**
  15276. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15277. */
  15278. readonly orientation: Nullable<Float32Array>;
  15279. /**
  15280. * The angularVelocity of the device, values in array are [x,y,z].
  15281. */
  15282. readonly angularVelocity: Nullable<Float32Array>;
  15283. /**
  15284. * The angularAcceleration of the device, values in array are [x,y,z].
  15285. */
  15286. readonly angularAcceleration: Nullable<Float32Array>;
  15287. }
  15288. /**
  15289. * Interface representing a pose controlled object in Babylon.
  15290. * A pose controlled object has both regular pose values as well as pose values
  15291. * from an external device such as a VR head mounted display
  15292. */
  15293. export interface PoseControlled {
  15294. /**
  15295. * The position of the object in babylon space.
  15296. */
  15297. position: Vector3;
  15298. /**
  15299. * The rotation quaternion of the object in babylon space.
  15300. */
  15301. rotationQuaternion: Quaternion;
  15302. /**
  15303. * The position of the device in babylon space.
  15304. */
  15305. devicePosition?: Vector3;
  15306. /**
  15307. * The rotation quaternion of the device in babylon space.
  15308. */
  15309. deviceRotationQuaternion: Quaternion;
  15310. /**
  15311. * The raw pose coming from the device.
  15312. */
  15313. rawPose: Nullable<DevicePose>;
  15314. /**
  15315. * The scale of the device to be used when translating from device space to babylon space.
  15316. */
  15317. deviceScaleFactor: number;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData the pose data to update the object with
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. }
  15324. /**
  15325. * Set of options to customize the webVRCamera
  15326. */
  15327. export interface WebVROptions {
  15328. /**
  15329. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15330. */
  15331. trackPosition?: boolean;
  15332. /**
  15333. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15334. */
  15335. positionScale?: number;
  15336. /**
  15337. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15338. */
  15339. displayName?: string;
  15340. /**
  15341. * Should the native controller meshes be initialized. (default: true)
  15342. */
  15343. controllerMeshes?: boolean;
  15344. /**
  15345. * Creating a default HemiLight only on controllers. (default: true)
  15346. */
  15347. defaultLightingOnControllers?: boolean;
  15348. /**
  15349. * If you don't want to use the default VR button of the helper. (default: false)
  15350. */
  15351. useCustomVRButton?: boolean;
  15352. /**
  15353. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15354. */
  15355. customVRButton?: HTMLButtonElement;
  15356. /**
  15357. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15358. */
  15359. rayLength?: number;
  15360. /**
  15361. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15362. */
  15363. defaultHeight?: number;
  15364. /**
  15365. * If multiview should be used if availible (default: false)
  15366. */
  15367. useMultiview?: boolean;
  15368. }
  15369. /**
  15370. * This represents a WebVR camera.
  15371. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15372. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15373. */
  15374. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15375. private webVROptions;
  15376. /**
  15377. * @hidden
  15378. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15379. */
  15380. _vrDevice: any;
  15381. /**
  15382. * The rawPose of the vrDevice.
  15383. */
  15384. rawPose: Nullable<DevicePose>;
  15385. private _onVREnabled;
  15386. private _specsVersion;
  15387. private _attached;
  15388. private _frameData;
  15389. protected _descendants: Array<Node>;
  15390. private _deviceRoomPosition;
  15391. /** @hidden */
  15392. _deviceRoomRotationQuaternion: Quaternion;
  15393. private _standingMatrix;
  15394. /**
  15395. * Represents device position in babylon space.
  15396. */
  15397. devicePosition: Vector3;
  15398. /**
  15399. * Represents device rotation in babylon space.
  15400. */
  15401. deviceRotationQuaternion: Quaternion;
  15402. /**
  15403. * The scale of the device to be used when translating from device space to babylon space.
  15404. */
  15405. deviceScaleFactor: number;
  15406. private _deviceToWorld;
  15407. private _worldToDevice;
  15408. /**
  15409. * References to the webVR controllers for the vrDevice.
  15410. */
  15411. controllers: Array<WebVRController>;
  15412. /**
  15413. * Emits an event when a controller is attached.
  15414. */
  15415. onControllersAttachedObservable: Observable<WebVRController[]>;
  15416. /**
  15417. * Emits an event when a controller's mesh has been loaded;
  15418. */
  15419. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15420. /**
  15421. * Emits an event when the HMD's pose has been updated.
  15422. */
  15423. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15424. private _poseSet;
  15425. /**
  15426. * If the rig cameras be used as parent instead of this camera.
  15427. */
  15428. rigParenting: boolean;
  15429. private _lightOnControllers;
  15430. private _defaultHeight?;
  15431. /**
  15432. * Instantiates a WebVRFreeCamera.
  15433. * @param name The name of the WebVRFreeCamera
  15434. * @param position The starting anchor position for the camera
  15435. * @param scene The scene the camera belongs to
  15436. * @param webVROptions a set of customizable options for the webVRCamera
  15437. */
  15438. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15439. /**
  15440. * Gets the device distance from the ground in meters.
  15441. * @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.
  15442. */
  15443. deviceDistanceToRoomGround(): number;
  15444. /**
  15445. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15446. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15447. */
  15448. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15449. /**
  15450. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15451. * @returns A promise with a boolean set to if the standing matrix is supported.
  15452. */
  15453. useStandingMatrixAsync(): Promise<boolean>;
  15454. /**
  15455. * Disposes the camera
  15456. */
  15457. dispose(): void;
  15458. /**
  15459. * Gets a vrController by name.
  15460. * @param name The name of the controller to retreive
  15461. * @returns the controller matching the name specified or null if not found
  15462. */
  15463. getControllerByName(name: string): Nullable<WebVRController>;
  15464. private _leftController;
  15465. /**
  15466. * The controller corresponding to the users left hand.
  15467. */
  15468. readonly leftController: Nullable<WebVRController>;
  15469. private _rightController;
  15470. /**
  15471. * The controller corresponding to the users right hand.
  15472. */
  15473. readonly rightController: Nullable<WebVRController>;
  15474. /**
  15475. * Casts a ray forward from the vrCamera's gaze.
  15476. * @param length Length of the ray (default: 100)
  15477. * @returns the ray corresponding to the gaze
  15478. */
  15479. getForwardRay(length?: number): Ray;
  15480. /**
  15481. * @hidden
  15482. * Updates the camera based on device's frame data
  15483. */
  15484. _checkInputs(): void;
  15485. /**
  15486. * Updates the poseControlled values based on the input device pose.
  15487. * @param poseData Pose coming from the device
  15488. */
  15489. updateFromDevice(poseData: DevicePose): void;
  15490. private _htmlElementAttached;
  15491. private _detachIfAttached;
  15492. /**
  15493. * WebVR's attach control will start broadcasting frames to the device.
  15494. * Note that in certain browsers (chrome for example) this function must be called
  15495. * within a user-interaction callback. Example:
  15496. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15497. *
  15498. * @param element html element to attach the vrDevice to
  15499. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15500. */
  15501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15502. /**
  15503. * Detaches the camera from the html element and disables VR
  15504. *
  15505. * @param element html element to detach from
  15506. */
  15507. detachControl(element: HTMLElement): void;
  15508. /**
  15509. * @returns the name of this class
  15510. */
  15511. getClassName(): string;
  15512. /**
  15513. * Calls resetPose on the vrDisplay
  15514. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15515. */
  15516. resetToCurrentRotation(): void;
  15517. /**
  15518. * @hidden
  15519. * Updates the rig cameras (left and right eye)
  15520. */
  15521. _updateRigCameras(): void;
  15522. private _workingVector;
  15523. private _oneVector;
  15524. private _workingMatrix;
  15525. private updateCacheCalled;
  15526. private _correctPositionIfNotTrackPosition;
  15527. /**
  15528. * @hidden
  15529. * Updates the cached values of the camera
  15530. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15531. */
  15532. _updateCache(ignoreParentClass?: boolean): void;
  15533. /**
  15534. * @hidden
  15535. * Get current device position in babylon world
  15536. */
  15537. _computeDevicePosition(): void;
  15538. /**
  15539. * Updates the current device position and rotation in the babylon world
  15540. */
  15541. update(): void;
  15542. /**
  15543. * @hidden
  15544. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15545. * @returns an identity matrix
  15546. */
  15547. _getViewMatrix(): Matrix;
  15548. private _tmpMatrix;
  15549. /**
  15550. * This function is called by the two RIG cameras.
  15551. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15552. * @hidden
  15553. */
  15554. _getWebVRViewMatrix(): Matrix;
  15555. /** @hidden */
  15556. _getWebVRProjectionMatrix(): Matrix;
  15557. private _onGamepadConnectedObserver;
  15558. private _onGamepadDisconnectedObserver;
  15559. private _updateCacheWhenTrackingDisabledObserver;
  15560. /**
  15561. * Initializes the controllers and their meshes
  15562. */
  15563. initControllers(): void;
  15564. }
  15565. }
  15566. declare module "babylonjs/PostProcesses/postProcess" {
  15567. import { Nullable } from "babylonjs/types";
  15568. import { SmartArray } from "babylonjs/Misc/smartArray";
  15569. import { Observable } from "babylonjs/Misc/observable";
  15570. import { Vector2 } from "babylonjs/Maths/math.vector";
  15571. import { Camera } from "babylonjs/Cameras/camera";
  15572. import { Effect } from "babylonjs/Materials/effect";
  15573. import "babylonjs/Shaders/postprocess.vertex";
  15574. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15575. import { Engine } from "babylonjs/Engines/engine";
  15576. import { Color4 } from "babylonjs/Maths/math.color";
  15577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15578. /**
  15579. * Size options for a post process
  15580. */
  15581. export type PostProcessOptions = {
  15582. width: number;
  15583. height: number;
  15584. };
  15585. /**
  15586. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15587. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15588. */
  15589. export class PostProcess {
  15590. /** Name of the PostProcess. */
  15591. name: string;
  15592. /**
  15593. * Gets or sets the unique id of the post process
  15594. */
  15595. uniqueId: number;
  15596. /**
  15597. * Width of the texture to apply the post process on
  15598. */
  15599. width: number;
  15600. /**
  15601. * Height of the texture to apply the post process on
  15602. */
  15603. height: number;
  15604. /**
  15605. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15606. * @hidden
  15607. */
  15608. _outputTexture: Nullable<InternalTexture>;
  15609. /**
  15610. * Sampling mode used by the shader
  15611. * See https://doc.babylonjs.com/classes/3.1/texture
  15612. */
  15613. renderTargetSamplingMode: number;
  15614. /**
  15615. * Clear color to use when screen clearing
  15616. */
  15617. clearColor: Color4;
  15618. /**
  15619. * If the buffer needs to be cleared before applying the post process. (default: true)
  15620. * Should be set to false if shader will overwrite all previous pixels.
  15621. */
  15622. autoClear: boolean;
  15623. /**
  15624. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15625. */
  15626. alphaMode: number;
  15627. /**
  15628. * Sets the setAlphaBlendConstants of the babylon engine
  15629. */
  15630. alphaConstants: Color4;
  15631. /**
  15632. * Animations to be used for the post processing
  15633. */
  15634. animations: import("babylonjs/Animations/animation").Animation[];
  15635. /**
  15636. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15637. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15638. */
  15639. enablePixelPerfectMode: boolean;
  15640. /**
  15641. * Force the postprocess to be applied without taking in account viewport
  15642. */
  15643. forceFullscreenViewport: boolean;
  15644. /**
  15645. * List of inspectable custom properties (used by the Inspector)
  15646. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15647. */
  15648. inspectableCustomProperties: IInspectable[];
  15649. /**
  15650. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15651. *
  15652. * | Value | Type | Description |
  15653. * | ----- | ----------------------------------- | ----------- |
  15654. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15655. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15656. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15657. *
  15658. */
  15659. scaleMode: number;
  15660. /**
  15661. * Force textures to be a power of two (default: false)
  15662. */
  15663. alwaysForcePOT: boolean;
  15664. private _samples;
  15665. /**
  15666. * Number of sample textures (default: 1)
  15667. */
  15668. samples: number;
  15669. /**
  15670. * Modify the scale of the post process to be the same as the viewport (default: false)
  15671. */
  15672. adaptScaleToCurrentViewport: boolean;
  15673. private _camera;
  15674. private _scene;
  15675. private _engine;
  15676. private _options;
  15677. private _reusable;
  15678. private _textureType;
  15679. /**
  15680. * Smart array of input and output textures for the post process.
  15681. * @hidden
  15682. */
  15683. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15684. /**
  15685. * The index in _textures that corresponds to the output texture.
  15686. * @hidden
  15687. */
  15688. _currentRenderTextureInd: number;
  15689. private _effect;
  15690. private _samplers;
  15691. private _fragmentUrl;
  15692. private _vertexUrl;
  15693. private _parameters;
  15694. private _scaleRatio;
  15695. protected _indexParameters: any;
  15696. private _shareOutputWithPostProcess;
  15697. private _texelSize;
  15698. private _forcedOutputTexture;
  15699. /**
  15700. * Returns the fragment url or shader name used in the post process.
  15701. * @returns the fragment url or name in the shader store.
  15702. */
  15703. getEffectName(): string;
  15704. /**
  15705. * An event triggered when the postprocess is activated.
  15706. */
  15707. onActivateObservable: Observable<Camera>;
  15708. private _onActivateObserver;
  15709. /**
  15710. * A function that is added to the onActivateObservable
  15711. */
  15712. onActivate: Nullable<(camera: Camera) => void>;
  15713. /**
  15714. * An event triggered when the postprocess changes its size.
  15715. */
  15716. onSizeChangedObservable: Observable<PostProcess>;
  15717. private _onSizeChangedObserver;
  15718. /**
  15719. * A function that is added to the onSizeChangedObservable
  15720. */
  15721. onSizeChanged: (postProcess: PostProcess) => void;
  15722. /**
  15723. * An event triggered when the postprocess applies its effect.
  15724. */
  15725. onApplyObservable: Observable<Effect>;
  15726. private _onApplyObserver;
  15727. /**
  15728. * A function that is added to the onApplyObservable
  15729. */
  15730. onApply: (effect: Effect) => void;
  15731. /**
  15732. * An event triggered before rendering the postprocess
  15733. */
  15734. onBeforeRenderObservable: Observable<Effect>;
  15735. private _onBeforeRenderObserver;
  15736. /**
  15737. * A function that is added to the onBeforeRenderObservable
  15738. */
  15739. onBeforeRender: (effect: Effect) => void;
  15740. /**
  15741. * An event triggered after rendering the postprocess
  15742. */
  15743. onAfterRenderObservable: Observable<Effect>;
  15744. private _onAfterRenderObserver;
  15745. /**
  15746. * A function that is added to the onAfterRenderObservable
  15747. */
  15748. onAfterRender: (efect: Effect) => void;
  15749. /**
  15750. * 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
  15751. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15752. */
  15753. inputTexture: InternalTexture;
  15754. /**
  15755. * Gets the camera which post process is applied to.
  15756. * @returns The camera the post process is applied to.
  15757. */
  15758. getCamera(): Camera;
  15759. /**
  15760. * Gets the texel size of the postprocess.
  15761. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15762. */
  15763. readonly texelSize: Vector2;
  15764. /**
  15765. * Creates a new instance PostProcess
  15766. * @param name The name of the PostProcess.
  15767. * @param fragmentUrl The url of the fragment shader to be used.
  15768. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15769. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15770. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15771. * @param camera The camera to apply the render pass to.
  15772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15773. * @param engine The engine which the post process will be applied. (default: current engine)
  15774. * @param reusable If the post process can be reused on the same frame. (default: false)
  15775. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15776. * @param textureType Type of textures used when performing the post process. (default: 0)
  15777. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15778. * @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
  15779. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15780. */
  15781. constructor(
  15782. /** Name of the PostProcess. */
  15783. 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);
  15784. /**
  15785. * Gets a string idenfifying the name of the class
  15786. * @returns "PostProcess" string
  15787. */
  15788. getClassName(): string;
  15789. /**
  15790. * Gets the engine which this post process belongs to.
  15791. * @returns The engine the post process was enabled with.
  15792. */
  15793. getEngine(): Engine;
  15794. /**
  15795. * The effect that is created when initializing the post process.
  15796. * @returns The created effect corresponding the the postprocess.
  15797. */
  15798. getEffect(): Effect;
  15799. /**
  15800. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15801. * @param postProcess The post process to share the output with.
  15802. * @returns This post process.
  15803. */
  15804. shareOutputWith(postProcess: PostProcess): PostProcess;
  15805. /**
  15806. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15807. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15808. */
  15809. useOwnOutput(): void;
  15810. /**
  15811. * Updates the effect with the current post process compile time values and recompiles the shader.
  15812. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15813. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15814. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15815. * @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
  15816. * @param onCompiled Called when the shader has been compiled.
  15817. * @param onError Called if there is an error when compiling a shader.
  15818. */
  15819. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15820. /**
  15821. * The post process is reusable if it can be used multiple times within one frame.
  15822. * @returns If the post process is reusable
  15823. */
  15824. isReusable(): boolean;
  15825. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15826. markTextureDirty(): void;
  15827. /**
  15828. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15829. * 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.
  15830. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15831. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15832. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15833. * @returns The target texture that was bound to be written to.
  15834. */
  15835. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15836. /**
  15837. * If the post process is supported.
  15838. */
  15839. readonly isSupported: boolean;
  15840. /**
  15841. * The aspect ratio of the output texture.
  15842. */
  15843. readonly aspectRatio: number;
  15844. /**
  15845. * Get a value indicating if the post-process is ready to be used
  15846. * @returns true if the post-process is ready (shader is compiled)
  15847. */
  15848. isReady(): boolean;
  15849. /**
  15850. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15851. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15852. */
  15853. apply(): Nullable<Effect>;
  15854. private _disposeTextures;
  15855. /**
  15856. * Disposes the post process.
  15857. * @param camera The camera to dispose the post process on.
  15858. */
  15859. dispose(camera?: Camera): void;
  15860. }
  15861. }
  15862. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15863. /** @hidden */
  15864. export var kernelBlurVaryingDeclaration: {
  15865. name: string;
  15866. shader: string;
  15867. };
  15868. }
  15869. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15870. /** @hidden */
  15871. export var kernelBlurFragment: {
  15872. name: string;
  15873. shader: string;
  15874. };
  15875. }
  15876. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15877. /** @hidden */
  15878. export var kernelBlurFragment2: {
  15879. name: string;
  15880. shader: string;
  15881. };
  15882. }
  15883. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15884. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15885. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15886. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15887. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15888. /** @hidden */
  15889. export var kernelBlurPixelShader: {
  15890. name: string;
  15891. shader: string;
  15892. };
  15893. }
  15894. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15895. /** @hidden */
  15896. export var kernelBlurVertex: {
  15897. name: string;
  15898. shader: string;
  15899. };
  15900. }
  15901. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15902. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15903. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15904. /** @hidden */
  15905. export var kernelBlurVertexShader: {
  15906. name: string;
  15907. shader: string;
  15908. };
  15909. }
  15910. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15911. import { Vector2 } from "babylonjs/Maths/math.vector";
  15912. import { Nullable } from "babylonjs/types";
  15913. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15914. import { Camera } from "babylonjs/Cameras/camera";
  15915. import { Effect } from "babylonjs/Materials/effect";
  15916. import { Engine } from "babylonjs/Engines/engine";
  15917. import "babylonjs/Shaders/kernelBlur.fragment";
  15918. import "babylonjs/Shaders/kernelBlur.vertex";
  15919. /**
  15920. * The Blur Post Process which blurs an image based on a kernel and direction.
  15921. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15922. */
  15923. export class BlurPostProcess extends PostProcess {
  15924. /** The direction in which to blur the image. */
  15925. direction: Vector2;
  15926. private blockCompilation;
  15927. protected _kernel: number;
  15928. protected _idealKernel: number;
  15929. protected _packedFloat: boolean;
  15930. private _staticDefines;
  15931. /**
  15932. * Sets the length in pixels of the blur sample region
  15933. */
  15934. /**
  15935. * Gets the length in pixels of the blur sample region
  15936. */
  15937. kernel: number;
  15938. /**
  15939. * Sets wether or not the blur needs to unpack/repack floats
  15940. */
  15941. /**
  15942. * Gets wether or not the blur is unpacking/repacking floats
  15943. */
  15944. packedFloat: boolean;
  15945. /**
  15946. * Creates a new instance BlurPostProcess
  15947. * @param name The name of the effect.
  15948. * @param direction The direction in which to blur the image.
  15949. * @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.
  15950. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15951. * @param camera The camera to apply the render pass to.
  15952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15953. * @param engine The engine which the post process will be applied. (default: current engine)
  15954. * @param reusable If the post process can be reused on the same frame. (default: false)
  15955. * @param textureType Type of textures used when performing the post process. (default: 0)
  15956. * @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)
  15957. */
  15958. constructor(name: string,
  15959. /** The direction in which to blur the image. */
  15960. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15961. /**
  15962. * Updates the effect with the current post process compile time values and recompiles the shader.
  15963. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15964. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15965. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15966. * @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
  15967. * @param onCompiled Called when the shader has been compiled.
  15968. * @param onError Called if there is an error when compiling a shader.
  15969. */
  15970. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15971. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15972. /**
  15973. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15974. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15975. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15976. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15977. * The gaps between physical kernels are compensated for in the weighting of the samples
  15978. * @param idealKernel Ideal blur kernel.
  15979. * @return Nearest best kernel.
  15980. */
  15981. protected _nearestBestKernel(idealKernel: number): number;
  15982. /**
  15983. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15984. * @param x The point on the Gaussian distribution to sample.
  15985. * @return the value of the Gaussian function at x.
  15986. */
  15987. protected _gaussianWeight(x: number): number;
  15988. /**
  15989. * Generates a string that can be used as a floating point number in GLSL.
  15990. * @param x Value to print.
  15991. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15992. * @return GLSL float string.
  15993. */
  15994. protected _glslFloat(x: number, decimalFigures?: number): string;
  15995. }
  15996. }
  15997. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15998. import { Scene } from "babylonjs/scene";
  15999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16000. import { Plane } from "babylonjs/Maths/math.plane";
  16001. /**
  16002. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16003. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16004. * You can then easily use it as a reflectionTexture on a flat surface.
  16005. * In case the surface is not a plane, please consider relying on reflection probes.
  16006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16007. */
  16008. export class MirrorTexture extends RenderTargetTexture {
  16009. private scene;
  16010. /**
  16011. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16012. * 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.
  16013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16014. */
  16015. mirrorPlane: Plane;
  16016. /**
  16017. * Define the blur ratio used to blur the reflection if needed.
  16018. */
  16019. blurRatio: number;
  16020. /**
  16021. * Define the adaptive blur kernel used to blur the reflection if needed.
  16022. * This will autocompute the closest best match for the `blurKernel`
  16023. */
  16024. adaptiveBlurKernel: number;
  16025. /**
  16026. * Define the blur kernel used to blur the reflection if needed.
  16027. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16028. */
  16029. blurKernel: number;
  16030. /**
  16031. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16033. */
  16034. blurKernelX: number;
  16035. /**
  16036. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16038. */
  16039. blurKernelY: number;
  16040. private _autoComputeBlurKernel;
  16041. protected _onRatioRescale(): void;
  16042. private _updateGammaSpace;
  16043. private _imageProcessingConfigChangeObserver;
  16044. private _transformMatrix;
  16045. private _mirrorMatrix;
  16046. private _savedViewMatrix;
  16047. private _blurX;
  16048. private _blurY;
  16049. private _adaptiveBlurKernel;
  16050. private _blurKernelX;
  16051. private _blurKernelY;
  16052. private _blurRatio;
  16053. /**
  16054. * Instantiates a Mirror Texture.
  16055. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16056. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16057. * You can then easily use it as a reflectionTexture on a flat surface.
  16058. * In case the surface is not a plane, please consider relying on reflection probes.
  16059. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16060. * @param name
  16061. * @param size
  16062. * @param scene
  16063. * @param generateMipMaps
  16064. * @param type
  16065. * @param samplingMode
  16066. * @param generateDepthBuffer
  16067. */
  16068. constructor(name: string, size: number | {
  16069. width: number;
  16070. height: number;
  16071. } | {
  16072. ratio: number;
  16073. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16074. private _preparePostProcesses;
  16075. /**
  16076. * Clone the mirror texture.
  16077. * @returns the cloned texture
  16078. */
  16079. clone(): MirrorTexture;
  16080. /**
  16081. * Serialize the texture to a JSON representation you could use in Parse later on
  16082. * @returns the serialized JSON representation
  16083. */
  16084. serialize(): any;
  16085. /**
  16086. * Dispose the texture and release its associated resources.
  16087. */
  16088. dispose(): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Materials/Textures/texture" {
  16092. import { Observable } from "babylonjs/Misc/observable";
  16093. import { Nullable } from "babylonjs/types";
  16094. import { Scene } from "babylonjs/scene";
  16095. import { Matrix } from "babylonjs/Maths/math.vector";
  16096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16097. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16098. import { Engine } from "babylonjs/Engines/engine";
  16099. /**
  16100. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16101. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16102. */
  16103. export class Texture extends BaseTexture {
  16104. /**
  16105. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16106. */
  16107. static SerializeBuffers: boolean;
  16108. /** @hidden */
  16109. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16110. /** @hidden */
  16111. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16112. /** @hidden */
  16113. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16114. /** nearest is mag = nearest and min = nearest and mip = linear */
  16115. static readonly NEAREST_SAMPLINGMODE: number;
  16116. /** nearest is mag = nearest and min = nearest and mip = linear */
  16117. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16118. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16119. static readonly BILINEAR_SAMPLINGMODE: number;
  16120. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16121. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16122. /** Trilinear is mag = linear and min = linear and mip = linear */
  16123. static readonly TRILINEAR_SAMPLINGMODE: number;
  16124. /** Trilinear is mag = linear and min = linear and mip = linear */
  16125. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16126. /** mag = nearest and min = nearest and mip = nearest */
  16127. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16128. /** mag = nearest and min = linear and mip = nearest */
  16129. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16130. /** mag = nearest and min = linear and mip = linear */
  16131. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16132. /** mag = nearest and min = linear and mip = none */
  16133. static readonly NEAREST_LINEAR: number;
  16134. /** mag = nearest and min = nearest and mip = none */
  16135. static readonly NEAREST_NEAREST: number;
  16136. /** mag = linear and min = nearest and mip = nearest */
  16137. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16138. /** mag = linear and min = nearest and mip = linear */
  16139. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16140. /** mag = linear and min = linear and mip = none */
  16141. static readonly LINEAR_LINEAR: number;
  16142. /** mag = linear and min = nearest and mip = none */
  16143. static readonly LINEAR_NEAREST: number;
  16144. /** Explicit coordinates mode */
  16145. static readonly EXPLICIT_MODE: number;
  16146. /** Spherical coordinates mode */
  16147. static readonly SPHERICAL_MODE: number;
  16148. /** Planar coordinates mode */
  16149. static readonly PLANAR_MODE: number;
  16150. /** Cubic coordinates mode */
  16151. static readonly CUBIC_MODE: number;
  16152. /** Projection coordinates mode */
  16153. static readonly PROJECTION_MODE: number;
  16154. /** Inverse Cubic coordinates mode */
  16155. static readonly SKYBOX_MODE: number;
  16156. /** Inverse Cubic coordinates mode */
  16157. static readonly INVCUBIC_MODE: number;
  16158. /** Equirectangular coordinates mode */
  16159. static readonly EQUIRECTANGULAR_MODE: number;
  16160. /** Equirectangular Fixed coordinates mode */
  16161. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16162. /** Equirectangular Fixed Mirrored coordinates mode */
  16163. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16164. /** Texture is not repeating outside of 0..1 UVs */
  16165. static readonly CLAMP_ADDRESSMODE: number;
  16166. /** Texture is repeating outside of 0..1 UVs */
  16167. static readonly WRAP_ADDRESSMODE: number;
  16168. /** Texture is repeating and mirrored */
  16169. static readonly MIRROR_ADDRESSMODE: number;
  16170. /**
  16171. * 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
  16172. */
  16173. static UseSerializedUrlIfAny: boolean;
  16174. /**
  16175. * Define the url of the texture.
  16176. */
  16177. url: Nullable<string>;
  16178. /**
  16179. * Define an offset on the texture to offset the u coordinates of the UVs
  16180. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16181. */
  16182. uOffset: number;
  16183. /**
  16184. * Define an offset on the texture to offset the v coordinates of the UVs
  16185. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16186. */
  16187. vOffset: number;
  16188. /**
  16189. * Define an offset on the texture to scale the u coordinates of the UVs
  16190. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16191. */
  16192. uScale: number;
  16193. /**
  16194. * Define an offset on the texture to scale the v coordinates of the UVs
  16195. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16196. */
  16197. vScale: number;
  16198. /**
  16199. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16200. * @see http://doc.babylonjs.com/how_to/more_materials
  16201. */
  16202. uAng: number;
  16203. /**
  16204. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16205. * @see http://doc.babylonjs.com/how_to/more_materials
  16206. */
  16207. vAng: number;
  16208. /**
  16209. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16210. * @see http://doc.babylonjs.com/how_to/more_materials
  16211. */
  16212. wAng: number;
  16213. /**
  16214. * Defines the center of rotation (U)
  16215. */
  16216. uRotationCenter: number;
  16217. /**
  16218. * Defines the center of rotation (V)
  16219. */
  16220. vRotationCenter: number;
  16221. /**
  16222. * Defines the center of rotation (W)
  16223. */
  16224. wRotationCenter: number;
  16225. /**
  16226. * Are mip maps generated for this texture or not.
  16227. */
  16228. readonly noMipmap: boolean;
  16229. /**
  16230. * List of inspectable custom properties (used by the Inspector)
  16231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16232. */
  16233. inspectableCustomProperties: Nullable<IInspectable[]>;
  16234. private _noMipmap;
  16235. /** @hidden */
  16236. _invertY: boolean;
  16237. private _rowGenerationMatrix;
  16238. private _cachedTextureMatrix;
  16239. private _projectionModeMatrix;
  16240. private _t0;
  16241. private _t1;
  16242. private _t2;
  16243. private _cachedUOffset;
  16244. private _cachedVOffset;
  16245. private _cachedUScale;
  16246. private _cachedVScale;
  16247. private _cachedUAng;
  16248. private _cachedVAng;
  16249. private _cachedWAng;
  16250. private _cachedProjectionMatrixId;
  16251. private _cachedCoordinatesMode;
  16252. /** @hidden */
  16253. protected _initialSamplingMode: number;
  16254. /** @hidden */
  16255. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16256. private _deleteBuffer;
  16257. protected _format: Nullable<number>;
  16258. private _delayedOnLoad;
  16259. private _delayedOnError;
  16260. /**
  16261. * Observable triggered once the texture has been loaded.
  16262. */
  16263. onLoadObservable: Observable<Texture>;
  16264. protected _isBlocking: boolean;
  16265. /**
  16266. * Is the texture preventing material to render while loading.
  16267. * If false, a default texture will be used instead of the loading one during the preparation step.
  16268. */
  16269. isBlocking: boolean;
  16270. /**
  16271. * Get the current sampling mode associated with the texture.
  16272. */
  16273. readonly samplingMode: number;
  16274. /**
  16275. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16276. */
  16277. readonly invertY: boolean;
  16278. /**
  16279. * Instantiates a new texture.
  16280. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16281. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16282. * @param url define the url of the picture to load as a texture
  16283. * @param scene define the scene or engine the texture will belong to
  16284. * @param noMipmap define if the texture will require mip maps or not
  16285. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16286. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16287. * @param onLoad define a callback triggered when the texture has been loaded
  16288. * @param onError define a callback triggered when an error occurred during the loading session
  16289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16290. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16292. */
  16293. 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);
  16294. /**
  16295. * Update the url (and optional buffer) of this texture if url was null during construction.
  16296. * @param url the url of the texture
  16297. * @param buffer the buffer of the texture (defaults to null)
  16298. * @param onLoad callback called when the texture is loaded (defaults to null)
  16299. */
  16300. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16301. /**
  16302. * Finish the loading sequence of a texture flagged as delayed load.
  16303. * @hidden
  16304. */
  16305. delayLoad(): void;
  16306. private _prepareRowForTextureGeneration;
  16307. /**
  16308. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16309. * @returns the transform matrix of the texture.
  16310. */
  16311. getTextureMatrix(): Matrix;
  16312. /**
  16313. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16314. * @returns The reflection texture transform
  16315. */
  16316. getReflectionTextureMatrix(): Matrix;
  16317. /**
  16318. * Clones the texture.
  16319. * @returns the cloned texture
  16320. */
  16321. clone(): Texture;
  16322. /**
  16323. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16324. * @returns The JSON representation of the texture
  16325. */
  16326. serialize(): any;
  16327. /**
  16328. * Get the current class name of the texture useful for serialization or dynamic coding.
  16329. * @returns "Texture"
  16330. */
  16331. getClassName(): string;
  16332. /**
  16333. * Dispose the texture and release its associated resources.
  16334. */
  16335. dispose(): void;
  16336. /**
  16337. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16338. * @param parsedTexture Define the JSON representation of the texture
  16339. * @param scene Define the scene the parsed texture should be instantiated in
  16340. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16341. * @returns The parsed texture if successful
  16342. */
  16343. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16344. /**
  16345. * Creates a texture from its base 64 representation.
  16346. * @param data Define the base64 payload without the data: prefix
  16347. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16348. * @param scene Define the scene the texture should belong to
  16349. * @param noMipmap Forces the texture to not create mip map information if true
  16350. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16351. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16352. * @param onLoad define a callback triggered when the texture has been loaded
  16353. * @param onError define a callback triggered when an error occurred during the loading session
  16354. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16355. * @returns the created texture
  16356. */
  16357. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16358. /**
  16359. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16360. * @param data Define the base64 payload without the data: prefix
  16361. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16362. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16363. * @param scene Define the scene the texture should belong to
  16364. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16365. * @param noMipmap Forces the texture to not create mip map information if true
  16366. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16367. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16368. * @param onLoad define a callback triggered when the texture has been loaded
  16369. * @param onError define a callback triggered when an error occurred during the loading session
  16370. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16371. * @returns the created texture
  16372. */
  16373. 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;
  16374. }
  16375. }
  16376. declare module "babylonjs/PostProcesses/postProcessManager" {
  16377. import { Nullable } from "babylonjs/types";
  16378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16379. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16380. import { Scene } from "babylonjs/scene";
  16381. /**
  16382. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16383. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16384. */
  16385. export class PostProcessManager {
  16386. private _scene;
  16387. private _indexBuffer;
  16388. private _vertexBuffers;
  16389. /**
  16390. * Creates a new instance PostProcess
  16391. * @param scene The scene that the post process is associated with.
  16392. */
  16393. constructor(scene: Scene);
  16394. private _prepareBuffers;
  16395. private _buildIndexBuffer;
  16396. /**
  16397. * Rebuilds the vertex buffers of the manager.
  16398. * @hidden
  16399. */
  16400. _rebuild(): void;
  16401. /**
  16402. * Prepares a frame to be run through a post process.
  16403. * @param sourceTexture The input texture to the post procesess. (default: null)
  16404. * @param postProcesses An array of post processes to be run. (default: null)
  16405. * @returns True if the post processes were able to be run.
  16406. * @hidden
  16407. */
  16408. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16409. /**
  16410. * Manually render a set of post processes to a texture.
  16411. * @param postProcesses An array of post processes to be run.
  16412. * @param targetTexture The target texture to render to.
  16413. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16414. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16415. * @param lodLevel defines which lod of the texture to render to
  16416. */
  16417. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16418. /**
  16419. * Finalize the result of the output of the postprocesses.
  16420. * @param doNotPresent If true the result will not be displayed to the screen.
  16421. * @param targetTexture The target texture to render to.
  16422. * @param faceIndex The index of the face to bind the target texture to.
  16423. * @param postProcesses The array of post processes to render.
  16424. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16425. * @hidden
  16426. */
  16427. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16428. /**
  16429. * Disposes of the post process manager.
  16430. */
  16431. dispose(): void;
  16432. }
  16433. }
  16434. declare module "babylonjs/Misc/gradients" {
  16435. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16436. /** Interface used by value gradients (color, factor, ...) */
  16437. export interface IValueGradient {
  16438. /**
  16439. * Gets or sets the gradient value (between 0 and 1)
  16440. */
  16441. gradient: number;
  16442. }
  16443. /** Class used to store color4 gradient */
  16444. export class ColorGradient implements IValueGradient {
  16445. /**
  16446. * Gets or sets the gradient value (between 0 and 1)
  16447. */
  16448. gradient: number;
  16449. /**
  16450. * Gets or sets first associated color
  16451. */
  16452. color1: Color4;
  16453. /**
  16454. * Gets or sets second associated color
  16455. */
  16456. color2?: Color4;
  16457. /**
  16458. * Will get a color picked randomly between color1 and color2.
  16459. * If color2 is undefined then color1 will be used
  16460. * @param result defines the target Color4 to store the result in
  16461. */
  16462. getColorToRef(result: Color4): void;
  16463. }
  16464. /** Class used to store color 3 gradient */
  16465. export class Color3Gradient implements IValueGradient {
  16466. /**
  16467. * Gets or sets the gradient value (between 0 and 1)
  16468. */
  16469. gradient: number;
  16470. /**
  16471. * Gets or sets the associated color
  16472. */
  16473. color: Color3;
  16474. }
  16475. /** Class used to store factor gradient */
  16476. export class FactorGradient implements IValueGradient {
  16477. /**
  16478. * Gets or sets the gradient value (between 0 and 1)
  16479. */
  16480. gradient: number;
  16481. /**
  16482. * Gets or sets first associated factor
  16483. */
  16484. factor1: number;
  16485. /**
  16486. * Gets or sets second associated factor
  16487. */
  16488. factor2?: number;
  16489. /**
  16490. * Will get a number picked randomly between factor1 and factor2.
  16491. * If factor2 is undefined then factor1 will be used
  16492. * @returns the picked number
  16493. */
  16494. getFactor(): number;
  16495. }
  16496. /**
  16497. * Helper used to simplify some generic gradient tasks
  16498. */
  16499. export class GradientHelper {
  16500. /**
  16501. * Gets the current gradient from an array of IValueGradient
  16502. * @param ratio defines the current ratio to get
  16503. * @param gradients defines the array of IValueGradient
  16504. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16505. */
  16506. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16507. }
  16508. }
  16509. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16510. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16511. import { Nullable } from "babylonjs/types";
  16512. module "babylonjs/Engines/thinEngine" {
  16513. interface ThinEngine {
  16514. /**
  16515. * Creates a dynamic texture
  16516. * @param width defines the width of the texture
  16517. * @param height defines the height of the texture
  16518. * @param generateMipMaps defines if the engine should generate the mip levels
  16519. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16520. * @returns the dynamic texture inside an InternalTexture
  16521. */
  16522. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16523. /**
  16524. * Update the content of a dynamic texture
  16525. * @param texture defines the texture to update
  16526. * @param canvas defines the canvas containing the source
  16527. * @param invertY defines if data must be stored with Y axis inverted
  16528. * @param premulAlpha defines if alpha is stored as premultiplied
  16529. * @param format defines the format of the data
  16530. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16531. */
  16532. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16533. }
  16534. }
  16535. }
  16536. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16537. import { Scene } from "babylonjs/scene";
  16538. import { Texture } from "babylonjs/Materials/Textures/texture";
  16539. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16540. /**
  16541. * A class extending Texture allowing drawing on a texture
  16542. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16543. */
  16544. export class DynamicTexture extends Texture {
  16545. private _generateMipMaps;
  16546. private _canvas;
  16547. private _context;
  16548. private _engine;
  16549. /**
  16550. * Creates a DynamicTexture
  16551. * @param name defines the name of the texture
  16552. * @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
  16553. * @param scene defines the scene where you want the texture
  16554. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16555. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16556. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16557. */
  16558. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16559. /**
  16560. * Get the current class name of the texture useful for serialization or dynamic coding.
  16561. * @returns "DynamicTexture"
  16562. */
  16563. getClassName(): string;
  16564. /**
  16565. * Gets the current state of canRescale
  16566. */
  16567. readonly canRescale: boolean;
  16568. private _recreate;
  16569. /**
  16570. * Scales the texture
  16571. * @param ratio the scale factor to apply to both width and height
  16572. */
  16573. scale(ratio: number): void;
  16574. /**
  16575. * Resizes the texture
  16576. * @param width the new width
  16577. * @param height the new height
  16578. */
  16579. scaleTo(width: number, height: number): void;
  16580. /**
  16581. * Gets the context of the canvas used by the texture
  16582. * @returns the canvas context of the dynamic texture
  16583. */
  16584. getContext(): CanvasRenderingContext2D;
  16585. /**
  16586. * Clears the texture
  16587. */
  16588. clear(): void;
  16589. /**
  16590. * Updates the texture
  16591. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16592. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16593. */
  16594. update(invertY?: boolean, premulAlpha?: boolean): void;
  16595. /**
  16596. * Draws text onto the texture
  16597. * @param text defines the text to be drawn
  16598. * @param x defines the placement of the text from the left
  16599. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16600. * @param font defines the font to be used with font-style, font-size, font-name
  16601. * @param color defines the color used for the text
  16602. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16603. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16604. * @param update defines whether texture is immediately update (default is true)
  16605. */
  16606. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16607. /**
  16608. * Clones the texture
  16609. * @returns the clone of the texture.
  16610. */
  16611. clone(): DynamicTexture;
  16612. /**
  16613. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16614. * @returns a serialized dynamic texture object
  16615. */
  16616. serialize(): any;
  16617. /** @hidden */
  16618. _rebuild(): void;
  16619. }
  16620. }
  16621. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16622. import { Scene } from "babylonjs/scene";
  16623. import { ISceneComponent } from "babylonjs/sceneComponent";
  16624. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16625. module "babylonjs/abstractScene" {
  16626. interface AbstractScene {
  16627. /**
  16628. * The list of procedural textures added to the scene
  16629. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16630. */
  16631. proceduralTextures: Array<ProceduralTexture>;
  16632. }
  16633. }
  16634. /**
  16635. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16636. * in a given scene.
  16637. */
  16638. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16639. /**
  16640. * The component name helpfull to identify the component in the list of scene components.
  16641. */
  16642. readonly name: string;
  16643. /**
  16644. * The scene the component belongs to.
  16645. */
  16646. scene: Scene;
  16647. /**
  16648. * Creates a new instance of the component for the given scene
  16649. * @param scene Defines the scene to register the component in
  16650. */
  16651. constructor(scene: Scene);
  16652. /**
  16653. * Registers the component in a given scene
  16654. */
  16655. register(): void;
  16656. /**
  16657. * Rebuilds the elements related to this component in case of
  16658. * context lost for instance.
  16659. */
  16660. rebuild(): void;
  16661. /**
  16662. * Disposes the component and the associated ressources.
  16663. */
  16664. dispose(): void;
  16665. private _beforeClear;
  16666. }
  16667. }
  16668. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16670. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16671. module "babylonjs/Engines/thinEngine" {
  16672. interface ThinEngine {
  16673. /**
  16674. * Creates a new render target cube texture
  16675. * @param size defines the size of the texture
  16676. * @param options defines the options used to create the texture
  16677. * @returns a new render target cube texture stored in an InternalTexture
  16678. */
  16679. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16680. }
  16681. }
  16682. }
  16683. declare module "babylonjs/Shaders/procedural.vertex" {
  16684. /** @hidden */
  16685. export var proceduralVertexShader: {
  16686. name: string;
  16687. shader: string;
  16688. };
  16689. }
  16690. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16691. import { Observable } from "babylonjs/Misc/observable";
  16692. import { Nullable } from "babylonjs/types";
  16693. import { Scene } from "babylonjs/scene";
  16694. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16695. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16696. import { Effect } from "babylonjs/Materials/effect";
  16697. import { Texture } from "babylonjs/Materials/Textures/texture";
  16698. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16699. import "babylonjs/Shaders/procedural.vertex";
  16700. /**
  16701. * 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.
  16702. * This is the base class of any Procedural texture and contains most of the shareable code.
  16703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16704. */
  16705. export class ProceduralTexture extends Texture {
  16706. isCube: boolean;
  16707. /**
  16708. * Define if the texture is enabled or not (disabled texture will not render)
  16709. */
  16710. isEnabled: boolean;
  16711. /**
  16712. * Define if the texture must be cleared before rendering (default is true)
  16713. */
  16714. autoClear: boolean;
  16715. /**
  16716. * Callback called when the texture is generated
  16717. */
  16718. onGenerated: () => void;
  16719. /**
  16720. * Event raised when the texture is generated
  16721. */
  16722. onGeneratedObservable: Observable<ProceduralTexture>;
  16723. /** @hidden */
  16724. _generateMipMaps: boolean;
  16725. /** @hidden **/
  16726. _effect: Effect;
  16727. /** @hidden */
  16728. _textures: {
  16729. [key: string]: Texture;
  16730. };
  16731. private _size;
  16732. private _currentRefreshId;
  16733. private _refreshRate;
  16734. private _vertexBuffers;
  16735. private _indexBuffer;
  16736. private _uniforms;
  16737. private _samplers;
  16738. private _fragment;
  16739. private _floats;
  16740. private _ints;
  16741. private _floatsArrays;
  16742. private _colors3;
  16743. private _colors4;
  16744. private _vectors2;
  16745. private _vectors3;
  16746. private _matrices;
  16747. private _fallbackTexture;
  16748. private _fallbackTextureUsed;
  16749. private _engine;
  16750. private _cachedDefines;
  16751. private _contentUpdateId;
  16752. private _contentData;
  16753. /**
  16754. * Instantiates a new procedural texture.
  16755. * 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.
  16756. * This is the base class of any Procedural texture and contains most of the shareable code.
  16757. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16758. * @param name Define the name of the texture
  16759. * @param size Define the size of the texture to create
  16760. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16761. * @param scene Define the scene the texture belongs to
  16762. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16763. * @param generateMipMaps Define if the texture should creates mip maps or not
  16764. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16765. */
  16766. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16767. /**
  16768. * The effect that is created when initializing the post process.
  16769. * @returns The created effect corresponding the the postprocess.
  16770. */
  16771. getEffect(): Effect;
  16772. /**
  16773. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16774. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16775. */
  16776. getContent(): Nullable<ArrayBufferView>;
  16777. private _createIndexBuffer;
  16778. /** @hidden */
  16779. _rebuild(): void;
  16780. /**
  16781. * Resets the texture in order to recreate its associated resources.
  16782. * This can be called in case of context loss
  16783. */
  16784. reset(): void;
  16785. protected _getDefines(): string;
  16786. /**
  16787. * Is the texture ready to be used ? (rendered at least once)
  16788. * @returns true if ready, otherwise, false.
  16789. */
  16790. isReady(): boolean;
  16791. /**
  16792. * Resets the refresh counter of the texture and start bak from scratch.
  16793. * Could be useful to regenerate the texture if it is setup to render only once.
  16794. */
  16795. resetRefreshCounter(): void;
  16796. /**
  16797. * Set the fragment shader to use in order to render the texture.
  16798. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16799. */
  16800. setFragment(fragment: any): void;
  16801. /**
  16802. * Define the refresh rate of the texture or the rendering frequency.
  16803. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16804. */
  16805. refreshRate: number;
  16806. /** @hidden */
  16807. _shouldRender(): boolean;
  16808. /**
  16809. * Get the size the texture is rendering at.
  16810. * @returns the size (texture is always squared)
  16811. */
  16812. getRenderSize(): number;
  16813. /**
  16814. * Resize the texture to new value.
  16815. * @param size Define the new size the texture should have
  16816. * @param generateMipMaps Define whether the new texture should create mip maps
  16817. */
  16818. resize(size: number, generateMipMaps: boolean): void;
  16819. private _checkUniform;
  16820. /**
  16821. * Set a texture in the shader program used to render.
  16822. * @param name Define the name of the uniform samplers as defined in the shader
  16823. * @param texture Define the texture to bind to this sampler
  16824. * @return the texture itself allowing "fluent" like uniform updates
  16825. */
  16826. setTexture(name: string, texture: Texture): ProceduralTexture;
  16827. /**
  16828. * Set a float in the shader.
  16829. * @param name Define the name of the uniform as defined in the shader
  16830. * @param value Define the value to give to the uniform
  16831. * @return the texture itself allowing "fluent" like uniform updates
  16832. */
  16833. setFloat(name: string, value: number): ProceduralTexture;
  16834. /**
  16835. * Set a int in the shader.
  16836. * @param name Define the name of the uniform as defined in the shader
  16837. * @param value Define the value to give to the uniform
  16838. * @return the texture itself allowing "fluent" like uniform updates
  16839. */
  16840. setInt(name: string, value: number): ProceduralTexture;
  16841. /**
  16842. * Set an array of floats in the shader.
  16843. * @param name Define the name of the uniform as defined in the shader
  16844. * @param value Define the value to give to the uniform
  16845. * @return the texture itself allowing "fluent" like uniform updates
  16846. */
  16847. setFloats(name: string, value: number[]): ProceduralTexture;
  16848. /**
  16849. * Set a vec3 in the shader from a Color3.
  16850. * @param name Define the name of the uniform as defined in the shader
  16851. * @param value Define the value to give to the uniform
  16852. * @return the texture itself allowing "fluent" like uniform updates
  16853. */
  16854. setColor3(name: string, value: Color3): ProceduralTexture;
  16855. /**
  16856. * Set a vec4 in the shader from a Color4.
  16857. * @param name Define the name of the uniform as defined in the shader
  16858. * @param value Define the value to give to the uniform
  16859. * @return the texture itself allowing "fluent" like uniform updates
  16860. */
  16861. setColor4(name: string, value: Color4): ProceduralTexture;
  16862. /**
  16863. * Set a vec2 in the shader from a Vector2.
  16864. * @param name Define the name of the uniform as defined in the shader
  16865. * @param value Define the value to give to the uniform
  16866. * @return the texture itself allowing "fluent" like uniform updates
  16867. */
  16868. setVector2(name: string, value: Vector2): ProceduralTexture;
  16869. /**
  16870. * Set a vec3 in the shader from a Vector3.
  16871. * @param name Define the name of the uniform as defined in the shader
  16872. * @param value Define the value to give to the uniform
  16873. * @return the texture itself allowing "fluent" like uniform updates
  16874. */
  16875. setVector3(name: string, value: Vector3): ProceduralTexture;
  16876. /**
  16877. * Set a mat4 in the shader from a MAtrix.
  16878. * @param name Define the name of the uniform as defined in the shader
  16879. * @param value Define the value to give to the uniform
  16880. * @return the texture itself allowing "fluent" like uniform updates
  16881. */
  16882. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16883. /**
  16884. * Render the texture to its associated render target.
  16885. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16886. */
  16887. render(useCameraPostProcess?: boolean): void;
  16888. /**
  16889. * Clone the texture.
  16890. * @returns the cloned texture
  16891. */
  16892. clone(): ProceduralTexture;
  16893. /**
  16894. * Dispose the texture and release its asoociated resources.
  16895. */
  16896. dispose(): void;
  16897. }
  16898. }
  16899. declare module "babylonjs/Particles/baseParticleSystem" {
  16900. import { Nullable } from "babylonjs/types";
  16901. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16903. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16904. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16905. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16906. import { Scene } from "babylonjs/scene";
  16907. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16908. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16909. import { Texture } from "babylonjs/Materials/Textures/texture";
  16910. import { Color4 } from "babylonjs/Maths/math.color";
  16911. import { Animation } from "babylonjs/Animations/animation";
  16912. /**
  16913. * This represents the base class for particle system in Babylon.
  16914. * 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.
  16915. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16916. * @example https://doc.babylonjs.com/babylon101/particles
  16917. */
  16918. export class BaseParticleSystem {
  16919. /**
  16920. * Source color is added to the destination color without alpha affecting the result
  16921. */
  16922. static BLENDMODE_ONEONE: number;
  16923. /**
  16924. * Blend current color and particle color using particle’s alpha
  16925. */
  16926. static BLENDMODE_STANDARD: number;
  16927. /**
  16928. * Add current color and particle color multiplied by particle’s alpha
  16929. */
  16930. static BLENDMODE_ADD: number;
  16931. /**
  16932. * Multiply current color with particle color
  16933. */
  16934. static BLENDMODE_MULTIPLY: number;
  16935. /**
  16936. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16937. */
  16938. static BLENDMODE_MULTIPLYADD: number;
  16939. /**
  16940. * List of animations used by the particle system.
  16941. */
  16942. animations: Animation[];
  16943. /**
  16944. * The id of the Particle system.
  16945. */
  16946. id: string;
  16947. /**
  16948. * The friendly name of the Particle system.
  16949. */
  16950. name: string;
  16951. /**
  16952. * The rendering group used by the Particle system to chose when to render.
  16953. */
  16954. renderingGroupId: number;
  16955. /**
  16956. * The emitter represents the Mesh or position we are attaching the particle system to.
  16957. */
  16958. emitter: Nullable<AbstractMesh | Vector3>;
  16959. /**
  16960. * The maximum number of particles to emit per frame
  16961. */
  16962. emitRate: number;
  16963. /**
  16964. * If you want to launch only a few particles at once, that can be done, as well.
  16965. */
  16966. manualEmitCount: number;
  16967. /**
  16968. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16969. */
  16970. updateSpeed: number;
  16971. /**
  16972. * The amount of time the particle system is running (depends of the overall update speed).
  16973. */
  16974. targetStopDuration: number;
  16975. /**
  16976. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16977. */
  16978. disposeOnStop: boolean;
  16979. /**
  16980. * Minimum power of emitting particles.
  16981. */
  16982. minEmitPower: number;
  16983. /**
  16984. * Maximum power of emitting particles.
  16985. */
  16986. maxEmitPower: number;
  16987. /**
  16988. * Minimum life time of emitting particles.
  16989. */
  16990. minLifeTime: number;
  16991. /**
  16992. * Maximum life time of emitting particles.
  16993. */
  16994. maxLifeTime: number;
  16995. /**
  16996. * Minimum Size of emitting particles.
  16997. */
  16998. minSize: number;
  16999. /**
  17000. * Maximum Size of emitting particles.
  17001. */
  17002. maxSize: number;
  17003. /**
  17004. * Minimum scale of emitting particles on X axis.
  17005. */
  17006. minScaleX: number;
  17007. /**
  17008. * Maximum scale of emitting particles on X axis.
  17009. */
  17010. maxScaleX: number;
  17011. /**
  17012. * Minimum scale of emitting particles on Y axis.
  17013. */
  17014. minScaleY: number;
  17015. /**
  17016. * Maximum scale of emitting particles on Y axis.
  17017. */
  17018. maxScaleY: number;
  17019. /**
  17020. * Gets or sets the minimal initial rotation in radians.
  17021. */
  17022. minInitialRotation: number;
  17023. /**
  17024. * Gets or sets the maximal initial rotation in radians.
  17025. */
  17026. maxInitialRotation: number;
  17027. /**
  17028. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17029. */
  17030. minAngularSpeed: number;
  17031. /**
  17032. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17033. */
  17034. maxAngularSpeed: number;
  17035. /**
  17036. * The texture used to render each particle. (this can be a spritesheet)
  17037. */
  17038. particleTexture: Nullable<Texture>;
  17039. /**
  17040. * The layer mask we are rendering the particles through.
  17041. */
  17042. layerMask: number;
  17043. /**
  17044. * This can help using your own shader to render the particle system.
  17045. * The according effect will be created
  17046. */
  17047. customShader: any;
  17048. /**
  17049. * By default particle system starts as soon as they are created. This prevents the
  17050. * automatic start to happen and let you decide when to start emitting particles.
  17051. */
  17052. preventAutoStart: boolean;
  17053. private _noiseTexture;
  17054. /**
  17055. * Gets or sets a texture used to add random noise to particle positions
  17056. */
  17057. noiseTexture: Nullable<ProceduralTexture>;
  17058. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17059. noiseStrength: Vector3;
  17060. /**
  17061. * Callback triggered when the particle animation is ending.
  17062. */
  17063. onAnimationEnd: Nullable<() => void>;
  17064. /**
  17065. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17066. */
  17067. blendMode: number;
  17068. /**
  17069. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17070. * to override the particles.
  17071. */
  17072. forceDepthWrite: boolean;
  17073. /** 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 */
  17074. preWarmCycles: number;
  17075. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17076. preWarmStepOffset: number;
  17077. /**
  17078. * 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)
  17079. */
  17080. spriteCellChangeSpeed: number;
  17081. /**
  17082. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17083. */
  17084. startSpriteCellID: number;
  17085. /**
  17086. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17087. */
  17088. endSpriteCellID: number;
  17089. /**
  17090. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17091. */
  17092. spriteCellWidth: number;
  17093. /**
  17094. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17095. */
  17096. spriteCellHeight: number;
  17097. /**
  17098. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17099. */
  17100. spriteRandomStartCell: boolean;
  17101. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17102. translationPivot: Vector2;
  17103. /** @hidden */
  17104. protected _isAnimationSheetEnabled: boolean;
  17105. /**
  17106. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17107. */
  17108. beginAnimationOnStart: boolean;
  17109. /**
  17110. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17111. */
  17112. beginAnimationFrom: number;
  17113. /**
  17114. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17115. */
  17116. beginAnimationTo: number;
  17117. /**
  17118. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17119. */
  17120. beginAnimationLoop: boolean;
  17121. /**
  17122. * Gets or sets a world offset applied to all particles
  17123. */
  17124. worldOffset: Vector3;
  17125. /**
  17126. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17127. */
  17128. isAnimationSheetEnabled: boolean;
  17129. /**
  17130. * Get hosting scene
  17131. * @returns the scene
  17132. */
  17133. getScene(): Scene;
  17134. /**
  17135. * You can use gravity if you want to give an orientation to your particles.
  17136. */
  17137. gravity: Vector3;
  17138. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17139. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17140. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17141. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17142. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17143. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17144. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17145. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17146. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17147. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17148. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17149. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17150. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17151. /**
  17152. * Defines the delay in milliseconds before starting the system (0 by default)
  17153. */
  17154. startDelay: number;
  17155. /**
  17156. * Gets the current list of drag gradients.
  17157. * You must use addDragGradient and removeDragGradient to udpate this list
  17158. * @returns the list of drag gradients
  17159. */
  17160. getDragGradients(): Nullable<Array<FactorGradient>>;
  17161. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17162. limitVelocityDamping: number;
  17163. /**
  17164. * Gets the current list of limit velocity gradients.
  17165. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17166. * @returns the list of limit velocity gradients
  17167. */
  17168. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17169. /**
  17170. * Gets the current list of color gradients.
  17171. * You must use addColorGradient and removeColorGradient to udpate this list
  17172. * @returns the list of color gradients
  17173. */
  17174. getColorGradients(): Nullable<Array<ColorGradient>>;
  17175. /**
  17176. * Gets the current list of size gradients.
  17177. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17178. * @returns the list of size gradients
  17179. */
  17180. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17181. /**
  17182. * Gets the current list of color remap gradients.
  17183. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17184. * @returns the list of color remap gradients
  17185. */
  17186. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17187. /**
  17188. * Gets the current list of alpha remap gradients.
  17189. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17190. * @returns the list of alpha remap gradients
  17191. */
  17192. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17193. /**
  17194. * Gets the current list of life time gradients.
  17195. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17196. * @returns the list of life time gradients
  17197. */
  17198. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17199. /**
  17200. * Gets the current list of angular speed gradients.
  17201. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17202. * @returns the list of angular speed gradients
  17203. */
  17204. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17205. /**
  17206. * Gets the current list of velocity gradients.
  17207. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17208. * @returns the list of velocity gradients
  17209. */
  17210. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17211. /**
  17212. * Gets the current list of start size gradients.
  17213. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17214. * @returns the list of start size gradients
  17215. */
  17216. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17217. /**
  17218. * Gets the current list of emit rate gradients.
  17219. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17220. * @returns the list of emit rate gradients
  17221. */
  17222. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17223. /**
  17224. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17225. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17226. */
  17227. direction1: Vector3;
  17228. /**
  17229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17230. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17231. */
  17232. direction2: Vector3;
  17233. /**
  17234. * 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.
  17235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17236. */
  17237. minEmitBox: Vector3;
  17238. /**
  17239. * 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.
  17240. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17241. */
  17242. maxEmitBox: Vector3;
  17243. /**
  17244. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17245. */
  17246. color1: Color4;
  17247. /**
  17248. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17249. */
  17250. color2: Color4;
  17251. /**
  17252. * Color the particle will have at the end of its lifetime
  17253. */
  17254. colorDead: Color4;
  17255. /**
  17256. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17257. */
  17258. textureMask: Color4;
  17259. /**
  17260. * The particle emitter type defines the emitter used by the particle system.
  17261. * It can be for example box, sphere, or cone...
  17262. */
  17263. particleEmitterType: IParticleEmitterType;
  17264. /** @hidden */
  17265. _isSubEmitter: boolean;
  17266. /**
  17267. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17268. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17269. */
  17270. billboardMode: number;
  17271. protected _isBillboardBased: boolean;
  17272. /**
  17273. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17274. */
  17275. isBillboardBased: boolean;
  17276. /**
  17277. * The scene the particle system belongs to.
  17278. */
  17279. protected _scene: Scene;
  17280. /**
  17281. * Local cache of defines for image processing.
  17282. */
  17283. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17284. /**
  17285. * Default configuration related to image processing available in the standard Material.
  17286. */
  17287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17288. /**
  17289. * Gets the image processing configuration used either in this material.
  17290. */
  17291. /**
  17292. * Sets the Default image processing configuration used either in the this material.
  17293. *
  17294. * If sets to null, the scene one is in use.
  17295. */
  17296. imageProcessingConfiguration: ImageProcessingConfiguration;
  17297. /**
  17298. * Attaches a new image processing configuration to the Standard Material.
  17299. * @param configuration
  17300. */
  17301. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17302. /** @hidden */
  17303. protected _reset(): void;
  17304. /** @hidden */
  17305. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17306. /**
  17307. * Instantiates a particle system.
  17308. * 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.
  17309. * @param name The name of the particle system
  17310. */
  17311. constructor(name: string);
  17312. /**
  17313. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17316. * @returns the emitter
  17317. */
  17318. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17319. /**
  17320. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17321. * @param radius The radius of the hemisphere to emit from
  17322. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17323. * @returns the emitter
  17324. */
  17325. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17326. /**
  17327. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17328. * @param radius The radius of the sphere to emit from
  17329. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17330. * @returns the emitter
  17331. */
  17332. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17333. /**
  17334. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17335. * @param radius The radius of the sphere to emit from
  17336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17338. * @returns the emitter
  17339. */
  17340. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17341. /**
  17342. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17343. * @param radius The radius of the emission cylinder
  17344. * @param height The height of the emission cylinder
  17345. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17346. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17347. * @returns the emitter
  17348. */
  17349. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17350. /**
  17351. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17352. * @param radius The radius of the cylinder to emit from
  17353. * @param height The height of the emission cylinder
  17354. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17355. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17356. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17357. * @returns the emitter
  17358. */
  17359. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17360. /**
  17361. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17362. * @param radius The radius of the cone to emit from
  17363. * @param angle The base angle of the cone
  17364. * @returns the emitter
  17365. */
  17366. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17367. /**
  17368. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17371. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17372. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17373. * @returns the emitter
  17374. */
  17375. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17376. }
  17377. }
  17378. declare module "babylonjs/Particles/subEmitter" {
  17379. import { Scene } from "babylonjs/scene";
  17380. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17381. /**
  17382. * Type of sub emitter
  17383. */
  17384. export enum SubEmitterType {
  17385. /**
  17386. * Attached to the particle over it's lifetime
  17387. */
  17388. ATTACHED = 0,
  17389. /**
  17390. * Created when the particle dies
  17391. */
  17392. END = 1
  17393. }
  17394. /**
  17395. * Sub emitter class used to emit particles from an existing particle
  17396. */
  17397. export class SubEmitter {
  17398. /**
  17399. * the particle system to be used by the sub emitter
  17400. */
  17401. particleSystem: ParticleSystem;
  17402. /**
  17403. * Type of the submitter (Default: END)
  17404. */
  17405. type: SubEmitterType;
  17406. /**
  17407. * 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)
  17408. * Note: This only is supported when using an emitter of type Mesh
  17409. */
  17410. inheritDirection: boolean;
  17411. /**
  17412. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17413. */
  17414. inheritedVelocityAmount: number;
  17415. /**
  17416. * Creates a sub emitter
  17417. * @param particleSystem the particle system to be used by the sub emitter
  17418. */
  17419. constructor(
  17420. /**
  17421. * the particle system to be used by the sub emitter
  17422. */
  17423. particleSystem: ParticleSystem);
  17424. /**
  17425. * Clones the sub emitter
  17426. * @returns the cloned sub emitter
  17427. */
  17428. clone(): SubEmitter;
  17429. /**
  17430. * Serialize current object to a JSON object
  17431. * @returns the serialized object
  17432. */
  17433. serialize(): any;
  17434. /** @hidden */
  17435. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17436. /**
  17437. * Creates a new SubEmitter from a serialized JSON version
  17438. * @param serializationObject defines the JSON object to read from
  17439. * @param scene defines the hosting scene
  17440. * @param rootUrl defines the rootUrl for data loading
  17441. * @returns a new SubEmitter
  17442. */
  17443. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17444. /** Release associated resources */
  17445. dispose(): void;
  17446. }
  17447. }
  17448. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17449. /** @hidden */
  17450. export var clipPlaneFragmentDeclaration: {
  17451. name: string;
  17452. shader: string;
  17453. };
  17454. }
  17455. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17456. /** @hidden */
  17457. export var imageProcessingDeclaration: {
  17458. name: string;
  17459. shader: string;
  17460. };
  17461. }
  17462. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17463. /** @hidden */
  17464. export var imageProcessingFunctions: {
  17465. name: string;
  17466. shader: string;
  17467. };
  17468. }
  17469. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17470. /** @hidden */
  17471. export var clipPlaneFragment: {
  17472. name: string;
  17473. shader: string;
  17474. };
  17475. }
  17476. declare module "babylonjs/Shaders/particles.fragment" {
  17477. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17478. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17479. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17480. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17481. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17482. /** @hidden */
  17483. export var particlesPixelShader: {
  17484. name: string;
  17485. shader: string;
  17486. };
  17487. }
  17488. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17489. /** @hidden */
  17490. export var clipPlaneVertexDeclaration: {
  17491. name: string;
  17492. shader: string;
  17493. };
  17494. }
  17495. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17496. /** @hidden */
  17497. export var clipPlaneVertex: {
  17498. name: string;
  17499. shader: string;
  17500. };
  17501. }
  17502. declare module "babylonjs/Shaders/particles.vertex" {
  17503. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17505. /** @hidden */
  17506. export var particlesVertexShader: {
  17507. name: string;
  17508. shader: string;
  17509. };
  17510. }
  17511. declare module "babylonjs/Particles/particleSystem" {
  17512. import { Nullable } from "babylonjs/types";
  17513. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17514. import { Observable } from "babylonjs/Misc/observable";
  17515. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17516. import { Effect } from "babylonjs/Materials/effect";
  17517. import { Scene, IDisposable } from "babylonjs/scene";
  17518. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17519. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17520. import { Particle } from "babylonjs/Particles/particle";
  17521. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17523. import "babylonjs/Shaders/particles.fragment";
  17524. import "babylonjs/Shaders/particles.vertex";
  17525. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17526. /**
  17527. * This represents a particle system in Babylon.
  17528. * 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.
  17529. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17530. * @example https://doc.babylonjs.com/babylon101/particles
  17531. */
  17532. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17533. /**
  17534. * Billboard mode will only apply to Y axis
  17535. */
  17536. static readonly BILLBOARDMODE_Y: number;
  17537. /**
  17538. * Billboard mode will apply to all axes
  17539. */
  17540. static readonly BILLBOARDMODE_ALL: number;
  17541. /**
  17542. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17543. */
  17544. static readonly BILLBOARDMODE_STRETCHED: number;
  17545. /**
  17546. * This function can be defined to provide custom update for active particles.
  17547. * This function will be called instead of regular update (age, position, color, etc.).
  17548. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17549. */
  17550. updateFunction: (particles: Particle[]) => void;
  17551. private _emitterWorldMatrix;
  17552. /**
  17553. * This function can be defined to specify initial direction for every new particle.
  17554. * It by default use the emitterType defined function
  17555. */
  17556. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17557. /**
  17558. * This function can be defined to specify initial position for every new particle.
  17559. * It by default use the emitterType defined function
  17560. */
  17561. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17562. /**
  17563. * @hidden
  17564. */
  17565. _inheritedVelocityOffset: Vector3;
  17566. /**
  17567. * An event triggered when the system is disposed
  17568. */
  17569. onDisposeObservable: Observable<ParticleSystem>;
  17570. private _onDisposeObserver;
  17571. /**
  17572. * Sets a callback that will be triggered when the system is disposed
  17573. */
  17574. onDispose: () => void;
  17575. private _particles;
  17576. private _epsilon;
  17577. private _capacity;
  17578. private _stockParticles;
  17579. private _newPartsExcess;
  17580. private _vertexData;
  17581. private _vertexBuffer;
  17582. private _vertexBuffers;
  17583. private _spriteBuffer;
  17584. private _indexBuffer;
  17585. private _effect;
  17586. private _customEffect;
  17587. private _cachedDefines;
  17588. private _scaledColorStep;
  17589. private _colorDiff;
  17590. private _scaledDirection;
  17591. private _scaledGravity;
  17592. private _currentRenderId;
  17593. private _alive;
  17594. private _useInstancing;
  17595. private _started;
  17596. private _stopped;
  17597. private _actualFrame;
  17598. private _scaledUpdateSpeed;
  17599. private _vertexBufferSize;
  17600. /** @hidden */
  17601. _currentEmitRateGradient: Nullable<FactorGradient>;
  17602. /** @hidden */
  17603. _currentEmitRate1: number;
  17604. /** @hidden */
  17605. _currentEmitRate2: number;
  17606. /** @hidden */
  17607. _currentStartSizeGradient: Nullable<FactorGradient>;
  17608. /** @hidden */
  17609. _currentStartSize1: number;
  17610. /** @hidden */
  17611. _currentStartSize2: number;
  17612. private readonly _rawTextureWidth;
  17613. private _rampGradientsTexture;
  17614. private _useRampGradients;
  17615. /** Gets or sets a boolean indicating that ramp gradients must be used
  17616. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17617. */
  17618. useRampGradients: boolean;
  17619. /**
  17620. * 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.
  17621. * 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: [])
  17622. */
  17623. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17624. private _subEmitters;
  17625. /**
  17626. * @hidden
  17627. * If the particle systems emitter should be disposed when the particle system is disposed
  17628. */
  17629. _disposeEmitterOnDispose: boolean;
  17630. /**
  17631. * The current active Sub-systems, this property is used by the root particle system only.
  17632. */
  17633. activeSubSystems: Array<ParticleSystem>;
  17634. private _rootParticleSystem;
  17635. /**
  17636. * Gets the current list of active particles
  17637. */
  17638. readonly particles: Particle[];
  17639. /**
  17640. * Returns the string "ParticleSystem"
  17641. * @returns a string containing the class name
  17642. */
  17643. getClassName(): string;
  17644. /**
  17645. * Instantiates a particle system.
  17646. * 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.
  17647. * @param name The name of the particle system
  17648. * @param capacity The max number of particles alive at the same time
  17649. * @param scene The scene the particle system belongs to
  17650. * @param customEffect a custom effect used to change the way particles are rendered by default
  17651. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17652. * @param epsilon Offset used to render the particles
  17653. */
  17654. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17655. private _addFactorGradient;
  17656. private _removeFactorGradient;
  17657. /**
  17658. * Adds a new life time gradient
  17659. * @param gradient defines the gradient to use (between 0 and 1)
  17660. * @param factor defines the life time factor to affect to the specified gradient
  17661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17662. * @returns the current particle system
  17663. */
  17664. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17665. /**
  17666. * Remove a specific life time gradient
  17667. * @param gradient defines the gradient to remove
  17668. * @returns the current particle system
  17669. */
  17670. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17671. /**
  17672. * Adds a new size gradient
  17673. * @param gradient defines the gradient to use (between 0 and 1)
  17674. * @param factor defines the size factor to affect to the specified gradient
  17675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17676. * @returns the current particle system
  17677. */
  17678. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17679. /**
  17680. * Remove a specific size gradient
  17681. * @param gradient defines the gradient to remove
  17682. * @returns the current particle system
  17683. */
  17684. removeSizeGradient(gradient: number): IParticleSystem;
  17685. /**
  17686. * Adds a new color remap gradient
  17687. * @param gradient defines the gradient to use (between 0 and 1)
  17688. * @param min defines the color remap minimal range
  17689. * @param max defines the color remap maximal range
  17690. * @returns the current particle system
  17691. */
  17692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17693. /**
  17694. * Remove a specific color remap gradient
  17695. * @param gradient defines the gradient to remove
  17696. * @returns the current particle system
  17697. */
  17698. removeColorRemapGradient(gradient: number): IParticleSystem;
  17699. /**
  17700. * Adds a new alpha remap gradient
  17701. * @param gradient defines the gradient to use (between 0 and 1)
  17702. * @param min defines the alpha remap minimal range
  17703. * @param max defines the alpha remap maximal range
  17704. * @returns the current particle system
  17705. */
  17706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17707. /**
  17708. * Remove a specific alpha remap gradient
  17709. * @param gradient defines the gradient to remove
  17710. * @returns the current particle system
  17711. */
  17712. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17713. /**
  17714. * Adds a new angular speed gradient
  17715. * @param gradient defines the gradient to use (between 0 and 1)
  17716. * @param factor defines the angular speed to affect to the specified gradient
  17717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17718. * @returns the current particle system
  17719. */
  17720. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17721. /**
  17722. * Remove a specific angular speed gradient
  17723. * @param gradient defines the gradient to remove
  17724. * @returns the current particle system
  17725. */
  17726. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17727. /**
  17728. * Adds a new velocity gradient
  17729. * @param gradient defines the gradient to use (between 0 and 1)
  17730. * @param factor defines the velocity to affect to the specified gradient
  17731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17732. * @returns the current particle system
  17733. */
  17734. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17735. /**
  17736. * Remove a specific velocity gradient
  17737. * @param gradient defines the gradient to remove
  17738. * @returns the current particle system
  17739. */
  17740. removeVelocityGradient(gradient: number): IParticleSystem;
  17741. /**
  17742. * Adds a new limit velocity gradient
  17743. * @param gradient defines the gradient to use (between 0 and 1)
  17744. * @param factor defines the limit velocity value to affect to the specified gradient
  17745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17746. * @returns the current particle system
  17747. */
  17748. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17749. /**
  17750. * Remove a specific limit velocity gradient
  17751. * @param gradient defines the gradient to remove
  17752. * @returns the current particle system
  17753. */
  17754. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17755. /**
  17756. * Adds a new drag gradient
  17757. * @param gradient defines the gradient to use (between 0 and 1)
  17758. * @param factor defines the drag value to affect to the specified gradient
  17759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17760. * @returns the current particle system
  17761. */
  17762. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17763. /**
  17764. * Remove a specific drag gradient
  17765. * @param gradient defines the gradient to remove
  17766. * @returns the current particle system
  17767. */
  17768. removeDragGradient(gradient: number): IParticleSystem;
  17769. /**
  17770. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17771. * @param gradient defines the gradient to use (between 0 and 1)
  17772. * @param factor defines the emit rate value to affect to the specified gradient
  17773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17774. * @returns the current particle system
  17775. */
  17776. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17777. /**
  17778. * Remove a specific emit rate gradient
  17779. * @param gradient defines the gradient to remove
  17780. * @returns the current particle system
  17781. */
  17782. removeEmitRateGradient(gradient: number): IParticleSystem;
  17783. /**
  17784. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17785. * @param gradient defines the gradient to use (between 0 and 1)
  17786. * @param factor defines the start size value to affect to the specified gradient
  17787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17788. * @returns the current particle system
  17789. */
  17790. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17791. /**
  17792. * Remove a specific start size gradient
  17793. * @param gradient defines the gradient to remove
  17794. * @returns the current particle system
  17795. */
  17796. removeStartSizeGradient(gradient: number): IParticleSystem;
  17797. private _createRampGradientTexture;
  17798. /**
  17799. * Gets the current list of ramp gradients.
  17800. * You must use addRampGradient and removeRampGradient to udpate this list
  17801. * @returns the list of ramp gradients
  17802. */
  17803. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17804. /**
  17805. * Adds a new ramp gradient used to remap particle colors
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param color defines the color to affect to the specified gradient
  17808. * @returns the current particle system
  17809. */
  17810. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17811. /**
  17812. * Remove a specific ramp gradient
  17813. * @param gradient defines the gradient to remove
  17814. * @returns the current particle system
  17815. */
  17816. removeRampGradient(gradient: number): ParticleSystem;
  17817. /**
  17818. * Adds a new color gradient
  17819. * @param gradient defines the gradient to use (between 0 and 1)
  17820. * @param color1 defines the color to affect to the specified gradient
  17821. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17822. * @returns this particle system
  17823. */
  17824. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17825. /**
  17826. * Remove a specific color gradient
  17827. * @param gradient defines the gradient to remove
  17828. * @returns this particle system
  17829. */
  17830. removeColorGradient(gradient: number): IParticleSystem;
  17831. private _fetchR;
  17832. protected _reset(): void;
  17833. private _resetEffect;
  17834. private _createVertexBuffers;
  17835. private _createIndexBuffer;
  17836. /**
  17837. * Gets the maximum number of particles active at the same time.
  17838. * @returns The max number of active particles.
  17839. */
  17840. getCapacity(): number;
  17841. /**
  17842. * Gets whether there are still active particles in the system.
  17843. * @returns True if it is alive, otherwise false.
  17844. */
  17845. isAlive(): boolean;
  17846. /**
  17847. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17848. * @returns True if it has been started, otherwise false.
  17849. */
  17850. isStarted(): boolean;
  17851. private _prepareSubEmitterInternalArray;
  17852. /**
  17853. * Starts the particle system and begins to emit
  17854. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17855. */
  17856. start(delay?: number): void;
  17857. /**
  17858. * Stops the particle system.
  17859. * @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.
  17860. */
  17861. stop(stopSubEmitters?: boolean): void;
  17862. /**
  17863. * Remove all active particles
  17864. */
  17865. reset(): void;
  17866. /**
  17867. * @hidden (for internal use only)
  17868. */
  17869. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17870. /**
  17871. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17872. * Its lifetime will start back at 0.
  17873. */
  17874. recycleParticle: (particle: Particle) => void;
  17875. private _stopSubEmitters;
  17876. private _createParticle;
  17877. private _removeFromRoot;
  17878. private _emitFromParticle;
  17879. private _update;
  17880. /** @hidden */
  17881. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17882. /** @hidden */
  17883. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17884. /** @hidden */
  17885. private _getEffect;
  17886. /**
  17887. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17888. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17889. */
  17890. animate(preWarmOnly?: boolean): void;
  17891. private _appendParticleVertices;
  17892. /**
  17893. * Rebuilds the particle system.
  17894. */
  17895. rebuild(): void;
  17896. /**
  17897. * Is this system ready to be used/rendered
  17898. * @return true if the system is ready
  17899. */
  17900. isReady(): boolean;
  17901. private _render;
  17902. /**
  17903. * Renders the particle system in its current state.
  17904. * @returns the current number of particles
  17905. */
  17906. render(): number;
  17907. /**
  17908. * Disposes the particle system and free the associated resources
  17909. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17910. */
  17911. dispose(disposeTexture?: boolean): void;
  17912. /**
  17913. * Clones the particle system.
  17914. * @param name The name of the cloned object
  17915. * @param newEmitter The new emitter to use
  17916. * @returns the cloned particle system
  17917. */
  17918. clone(name: string, newEmitter: any): ParticleSystem;
  17919. /**
  17920. * Serializes the particle system to a JSON object.
  17921. * @returns the JSON object
  17922. */
  17923. serialize(): any;
  17924. /** @hidden */
  17925. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17926. /** @hidden */
  17927. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17928. /**
  17929. * Parses a JSON object to create a particle system.
  17930. * @param parsedParticleSystem The JSON object to parse
  17931. * @param scene The scene to create the particle system in
  17932. * @param rootUrl The root url to use to load external dependencies like texture
  17933. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17934. * @returns the Parsed particle system
  17935. */
  17936. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17937. }
  17938. }
  17939. declare module "babylonjs/Particles/particle" {
  17940. import { Nullable } from "babylonjs/types";
  17941. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17942. import { Color4 } from "babylonjs/Maths/math.color";
  17943. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17944. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17945. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17946. /**
  17947. * A particle represents one of the element emitted by a particle system.
  17948. * This is mainly define by its coordinates, direction, velocity and age.
  17949. */
  17950. export class Particle {
  17951. /**
  17952. * The particle system the particle belongs to.
  17953. */
  17954. particleSystem: ParticleSystem;
  17955. private static _Count;
  17956. /**
  17957. * Unique ID of the particle
  17958. */
  17959. id: number;
  17960. /**
  17961. * The world position of the particle in the scene.
  17962. */
  17963. position: Vector3;
  17964. /**
  17965. * The world direction of the particle in the scene.
  17966. */
  17967. direction: Vector3;
  17968. /**
  17969. * The color of the particle.
  17970. */
  17971. color: Color4;
  17972. /**
  17973. * The color change of the particle per step.
  17974. */
  17975. colorStep: Color4;
  17976. /**
  17977. * Defines how long will the life of the particle be.
  17978. */
  17979. lifeTime: number;
  17980. /**
  17981. * The current age of the particle.
  17982. */
  17983. age: number;
  17984. /**
  17985. * The current size of the particle.
  17986. */
  17987. size: number;
  17988. /**
  17989. * The current scale of the particle.
  17990. */
  17991. scale: Vector2;
  17992. /**
  17993. * The current angle of the particle.
  17994. */
  17995. angle: number;
  17996. /**
  17997. * Defines how fast is the angle changing.
  17998. */
  17999. angularSpeed: number;
  18000. /**
  18001. * Defines the cell index used by the particle to be rendered from a sprite.
  18002. */
  18003. cellIndex: number;
  18004. /**
  18005. * The information required to support color remapping
  18006. */
  18007. remapData: Vector4;
  18008. /** @hidden */
  18009. _randomCellOffset?: number;
  18010. /** @hidden */
  18011. _initialDirection: Nullable<Vector3>;
  18012. /** @hidden */
  18013. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18014. /** @hidden */
  18015. _initialStartSpriteCellID: number;
  18016. /** @hidden */
  18017. _initialEndSpriteCellID: number;
  18018. /** @hidden */
  18019. _currentColorGradient: Nullable<ColorGradient>;
  18020. /** @hidden */
  18021. _currentColor1: Color4;
  18022. /** @hidden */
  18023. _currentColor2: Color4;
  18024. /** @hidden */
  18025. _currentSizeGradient: Nullable<FactorGradient>;
  18026. /** @hidden */
  18027. _currentSize1: number;
  18028. /** @hidden */
  18029. _currentSize2: number;
  18030. /** @hidden */
  18031. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18032. /** @hidden */
  18033. _currentAngularSpeed1: number;
  18034. /** @hidden */
  18035. _currentAngularSpeed2: number;
  18036. /** @hidden */
  18037. _currentVelocityGradient: Nullable<FactorGradient>;
  18038. /** @hidden */
  18039. _currentVelocity1: number;
  18040. /** @hidden */
  18041. _currentVelocity2: number;
  18042. /** @hidden */
  18043. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18044. /** @hidden */
  18045. _currentLimitVelocity1: number;
  18046. /** @hidden */
  18047. _currentLimitVelocity2: number;
  18048. /** @hidden */
  18049. _currentDragGradient: Nullable<FactorGradient>;
  18050. /** @hidden */
  18051. _currentDrag1: number;
  18052. /** @hidden */
  18053. _currentDrag2: number;
  18054. /** @hidden */
  18055. _randomNoiseCoordinates1: Vector3;
  18056. /** @hidden */
  18057. _randomNoiseCoordinates2: Vector3;
  18058. /**
  18059. * Creates a new instance Particle
  18060. * @param particleSystem the particle system the particle belongs to
  18061. */
  18062. constructor(
  18063. /**
  18064. * The particle system the particle belongs to.
  18065. */
  18066. particleSystem: ParticleSystem);
  18067. private updateCellInfoFromSystem;
  18068. /**
  18069. * Defines how the sprite cell index is updated for the particle
  18070. */
  18071. updateCellIndex(): void;
  18072. /** @hidden */
  18073. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18074. /** @hidden */
  18075. _inheritParticleInfoToSubEmitters(): void;
  18076. /** @hidden */
  18077. _reset(): void;
  18078. /**
  18079. * Copy the properties of particle to another one.
  18080. * @param other the particle to copy the information to.
  18081. */
  18082. copyTo(other: Particle): void;
  18083. }
  18084. }
  18085. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18087. import { Effect } from "babylonjs/Materials/effect";
  18088. import { Particle } from "babylonjs/Particles/particle";
  18089. /**
  18090. * Particle emitter represents a volume emitting particles.
  18091. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18092. */
  18093. export interface IParticleEmitterType {
  18094. /**
  18095. * Called by the particle System when the direction is computed for the created particle.
  18096. * @param worldMatrix is the world matrix of the particle system
  18097. * @param directionToUpdate is the direction vector to update with the result
  18098. * @param particle is the particle we are computed the direction for
  18099. */
  18100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18101. /**
  18102. * Called by the particle System when the position is computed for the created particle.
  18103. * @param worldMatrix is the world matrix of the particle system
  18104. * @param positionToUpdate is the position vector to update with the result
  18105. * @param particle is the particle we are computed the position for
  18106. */
  18107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18108. /**
  18109. * Clones the current emitter and returns a copy of it
  18110. * @returns the new emitter
  18111. */
  18112. clone(): IParticleEmitterType;
  18113. /**
  18114. * Called by the GPUParticleSystem to setup the update shader
  18115. * @param effect defines the update shader
  18116. */
  18117. applyToShader(effect: Effect): void;
  18118. /**
  18119. * Returns a string to use to update the GPU particles update shader
  18120. * @returns the effect defines string
  18121. */
  18122. getEffectDefines(): string;
  18123. /**
  18124. * Returns a string representing the class name
  18125. * @returns a string containing the class name
  18126. */
  18127. getClassName(): string;
  18128. /**
  18129. * Serializes the particle system to a JSON object.
  18130. * @returns the JSON object
  18131. */
  18132. serialize(): any;
  18133. /**
  18134. * Parse properties from a JSON object
  18135. * @param serializationObject defines the JSON object
  18136. */
  18137. parse(serializationObject: any): void;
  18138. }
  18139. }
  18140. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18141. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18142. import { Effect } from "babylonjs/Materials/effect";
  18143. import { Particle } from "babylonjs/Particles/particle";
  18144. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18145. /**
  18146. * Particle emitter emitting particles from the inside of a box.
  18147. * It emits the particles randomly between 2 given directions.
  18148. */
  18149. export class BoxParticleEmitter implements IParticleEmitterType {
  18150. /**
  18151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18152. */
  18153. direction1: Vector3;
  18154. /**
  18155. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18156. */
  18157. direction2: Vector3;
  18158. /**
  18159. * 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.
  18160. */
  18161. minEmitBox: Vector3;
  18162. /**
  18163. * 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.
  18164. */
  18165. maxEmitBox: Vector3;
  18166. /**
  18167. * Creates a new instance BoxParticleEmitter
  18168. */
  18169. constructor();
  18170. /**
  18171. * Called by the particle System when the direction is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param directionToUpdate is the direction vector to update with the result
  18174. * @param particle is the particle we are computed the direction for
  18175. */
  18176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Called by the particle System when the position is computed for the created particle.
  18179. * @param worldMatrix is the world matrix of the particle system
  18180. * @param positionToUpdate is the position vector to update with the result
  18181. * @param particle is the particle we are computed the position for
  18182. */
  18183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18184. /**
  18185. * Clones the current emitter and returns a copy of it
  18186. * @returns the new emitter
  18187. */
  18188. clone(): BoxParticleEmitter;
  18189. /**
  18190. * Called by the GPUParticleSystem to setup the update shader
  18191. * @param effect defines the update shader
  18192. */
  18193. applyToShader(effect: Effect): void;
  18194. /**
  18195. * Returns a string to use to update the GPU particles update shader
  18196. * @returns a string containng the defines string
  18197. */
  18198. getEffectDefines(): string;
  18199. /**
  18200. * Returns the string "BoxParticleEmitter"
  18201. * @returns a string containing the class name
  18202. */
  18203. getClassName(): string;
  18204. /**
  18205. * Serializes the particle system to a JSON object.
  18206. * @returns the JSON object
  18207. */
  18208. serialize(): any;
  18209. /**
  18210. * Parse properties from a JSON object
  18211. * @param serializationObject defines the JSON object
  18212. */
  18213. parse(serializationObject: any): void;
  18214. }
  18215. }
  18216. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18217. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18218. import { Effect } from "babylonjs/Materials/effect";
  18219. import { Particle } from "babylonjs/Particles/particle";
  18220. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18221. /**
  18222. * Particle emitter emitting particles from the inside of a cone.
  18223. * It emits the particles alongside the cone volume from the base to the particle.
  18224. * The emission direction might be randomized.
  18225. */
  18226. export class ConeParticleEmitter implements IParticleEmitterType {
  18227. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18228. directionRandomizer: number;
  18229. private _radius;
  18230. private _angle;
  18231. private _height;
  18232. /**
  18233. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18234. */
  18235. radiusRange: number;
  18236. /**
  18237. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18238. */
  18239. heightRange: number;
  18240. /**
  18241. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18242. */
  18243. emitFromSpawnPointOnly: boolean;
  18244. /**
  18245. * Gets or sets the radius of the emission cone
  18246. */
  18247. radius: number;
  18248. /**
  18249. * Gets or sets the angle of the emission cone
  18250. */
  18251. angle: number;
  18252. private _buildHeight;
  18253. /**
  18254. * Creates a new instance ConeParticleEmitter
  18255. * @param radius the radius of the emission cone (1 by default)
  18256. * @param angle the cone base angle (PI by default)
  18257. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18258. */
  18259. constructor(radius?: number, angle?: number,
  18260. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18261. directionRandomizer?: number);
  18262. /**
  18263. * Called by the particle System when the direction is computed for the created particle.
  18264. * @param worldMatrix is the world matrix of the particle system
  18265. * @param directionToUpdate is the direction vector to update with the result
  18266. * @param particle is the particle we are computed the direction for
  18267. */
  18268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18269. /**
  18270. * Called by the particle System when the position is computed for the created particle.
  18271. * @param worldMatrix is the world matrix of the particle system
  18272. * @param positionToUpdate is the position vector to update with the result
  18273. * @param particle is the particle we are computed the position for
  18274. */
  18275. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18276. /**
  18277. * Clones the current emitter and returns a copy of it
  18278. * @returns the new emitter
  18279. */
  18280. clone(): ConeParticleEmitter;
  18281. /**
  18282. * Called by the GPUParticleSystem to setup the update shader
  18283. * @param effect defines the update shader
  18284. */
  18285. applyToShader(effect: Effect): void;
  18286. /**
  18287. * Returns a string to use to update the GPU particles update shader
  18288. * @returns a string containng the defines string
  18289. */
  18290. getEffectDefines(): string;
  18291. /**
  18292. * Returns the string "ConeParticleEmitter"
  18293. * @returns a string containing the class name
  18294. */
  18295. getClassName(): string;
  18296. /**
  18297. * Serializes the particle system to a JSON object.
  18298. * @returns the JSON object
  18299. */
  18300. serialize(): any;
  18301. /**
  18302. * Parse properties from a JSON object
  18303. * @param serializationObject defines the JSON object
  18304. */
  18305. parse(serializationObject: any): void;
  18306. }
  18307. }
  18308. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18309. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18310. import { Effect } from "babylonjs/Materials/effect";
  18311. import { Particle } from "babylonjs/Particles/particle";
  18312. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18313. /**
  18314. * Particle emitter emitting particles from the inside of a cylinder.
  18315. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18316. */
  18317. export class CylinderParticleEmitter implements IParticleEmitterType {
  18318. /**
  18319. * The radius of the emission cylinder.
  18320. */
  18321. radius: number;
  18322. /**
  18323. * The height of the emission cylinder.
  18324. */
  18325. height: number;
  18326. /**
  18327. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18328. */
  18329. radiusRange: number;
  18330. /**
  18331. * How much to randomize the particle direction [0-1].
  18332. */
  18333. directionRandomizer: number;
  18334. /**
  18335. * Creates a new instance CylinderParticleEmitter
  18336. * @param radius the radius of the emission cylinder (1 by default)
  18337. * @param height the height of the emission cylinder (1 by default)
  18338. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18339. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18340. */
  18341. constructor(
  18342. /**
  18343. * The radius of the emission cylinder.
  18344. */
  18345. radius?: number,
  18346. /**
  18347. * The height of the emission cylinder.
  18348. */
  18349. height?: number,
  18350. /**
  18351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18352. */
  18353. radiusRange?: number,
  18354. /**
  18355. * How much to randomize the particle direction [0-1].
  18356. */
  18357. directionRandomizer?: number);
  18358. /**
  18359. * Called by the particle System when the direction is computed for the created particle.
  18360. * @param worldMatrix is the world matrix of the particle system
  18361. * @param directionToUpdate is the direction vector to update with the result
  18362. * @param particle is the particle we are computed the direction for
  18363. */
  18364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18365. /**
  18366. * Called by the particle System when the position is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param positionToUpdate is the position vector to update with the result
  18369. * @param particle is the particle we are computed the position for
  18370. */
  18371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Clones the current emitter and returns a copy of it
  18374. * @returns the new emitter
  18375. */
  18376. clone(): CylinderParticleEmitter;
  18377. /**
  18378. * Called by the GPUParticleSystem to setup the update shader
  18379. * @param effect defines the update shader
  18380. */
  18381. applyToShader(effect: Effect): void;
  18382. /**
  18383. * Returns a string to use to update the GPU particles update shader
  18384. * @returns a string containng the defines string
  18385. */
  18386. getEffectDefines(): string;
  18387. /**
  18388. * Returns the string "CylinderParticleEmitter"
  18389. * @returns a string containing the class name
  18390. */
  18391. getClassName(): string;
  18392. /**
  18393. * Serializes the particle system to a JSON object.
  18394. * @returns the JSON object
  18395. */
  18396. serialize(): any;
  18397. /**
  18398. * Parse properties from a JSON object
  18399. * @param serializationObject defines the JSON object
  18400. */
  18401. parse(serializationObject: any): void;
  18402. }
  18403. /**
  18404. * Particle emitter emitting particles from the inside of a cylinder.
  18405. * It emits the particles randomly between two vectors.
  18406. */
  18407. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18408. /**
  18409. * The min limit of the emission direction.
  18410. */
  18411. direction1: Vector3;
  18412. /**
  18413. * The max limit of the emission direction.
  18414. */
  18415. direction2: Vector3;
  18416. /**
  18417. * Creates a new instance CylinderDirectedParticleEmitter
  18418. * @param radius the radius of the emission cylinder (1 by default)
  18419. * @param height the height of the emission cylinder (1 by default)
  18420. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18421. * @param direction1 the min limit of the emission direction (up vector by default)
  18422. * @param direction2 the max limit of the emission direction (up vector by default)
  18423. */
  18424. constructor(radius?: number, height?: number, radiusRange?: number,
  18425. /**
  18426. * The min limit of the emission direction.
  18427. */
  18428. direction1?: Vector3,
  18429. /**
  18430. * The max limit of the emission direction.
  18431. */
  18432. direction2?: Vector3);
  18433. /**
  18434. * Called by the particle System when the direction is computed for the created particle.
  18435. * @param worldMatrix is the world matrix of the particle system
  18436. * @param directionToUpdate is the direction vector to update with the result
  18437. * @param particle is the particle we are computed the direction for
  18438. */
  18439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18440. /**
  18441. * Clones the current emitter and returns a copy of it
  18442. * @returns the new emitter
  18443. */
  18444. clone(): CylinderDirectedParticleEmitter;
  18445. /**
  18446. * Called by the GPUParticleSystem to setup the update shader
  18447. * @param effect defines the update shader
  18448. */
  18449. applyToShader(effect: Effect): void;
  18450. /**
  18451. * Returns a string to use to update the GPU particles update shader
  18452. * @returns a string containng the defines string
  18453. */
  18454. getEffectDefines(): string;
  18455. /**
  18456. * Returns the string "CylinderDirectedParticleEmitter"
  18457. * @returns a string containing the class name
  18458. */
  18459. getClassName(): string;
  18460. /**
  18461. * Serializes the particle system to a JSON object.
  18462. * @returns the JSON object
  18463. */
  18464. serialize(): any;
  18465. /**
  18466. * Parse properties from a JSON object
  18467. * @param serializationObject defines the JSON object
  18468. */
  18469. parse(serializationObject: any): void;
  18470. }
  18471. }
  18472. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18473. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18474. import { Effect } from "babylonjs/Materials/effect";
  18475. import { Particle } from "babylonjs/Particles/particle";
  18476. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18477. /**
  18478. * Particle emitter emitting particles from the inside of a hemisphere.
  18479. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18480. */
  18481. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18482. /**
  18483. * The radius of the emission hemisphere.
  18484. */
  18485. radius: number;
  18486. /**
  18487. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18488. */
  18489. radiusRange: number;
  18490. /**
  18491. * How much to randomize the particle direction [0-1].
  18492. */
  18493. directionRandomizer: number;
  18494. /**
  18495. * Creates a new instance HemisphericParticleEmitter
  18496. * @param radius the radius of the emission hemisphere (1 by default)
  18497. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18498. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18499. */
  18500. constructor(
  18501. /**
  18502. * The radius of the emission hemisphere.
  18503. */
  18504. radius?: number,
  18505. /**
  18506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18507. */
  18508. radiusRange?: number,
  18509. /**
  18510. * How much to randomize the particle direction [0-1].
  18511. */
  18512. directionRandomizer?: number);
  18513. /**
  18514. * Called by the particle System when the direction is computed for the created particle.
  18515. * @param worldMatrix is the world matrix of the particle system
  18516. * @param directionToUpdate is the direction vector to update with the result
  18517. * @param particle is the particle we are computed the direction for
  18518. */
  18519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18520. /**
  18521. * Called by the particle System when the position is computed for the created particle.
  18522. * @param worldMatrix is the world matrix of the particle system
  18523. * @param positionToUpdate is the position vector to update with the result
  18524. * @param particle is the particle we are computed the position for
  18525. */
  18526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18527. /**
  18528. * Clones the current emitter and returns a copy of it
  18529. * @returns the new emitter
  18530. */
  18531. clone(): HemisphericParticleEmitter;
  18532. /**
  18533. * Called by the GPUParticleSystem to setup the update shader
  18534. * @param effect defines the update shader
  18535. */
  18536. applyToShader(effect: Effect): void;
  18537. /**
  18538. * Returns a string to use to update the GPU particles update shader
  18539. * @returns a string containng the defines string
  18540. */
  18541. getEffectDefines(): string;
  18542. /**
  18543. * Returns the string "HemisphericParticleEmitter"
  18544. * @returns a string containing the class name
  18545. */
  18546. getClassName(): string;
  18547. /**
  18548. * Serializes the particle system to a JSON object.
  18549. * @returns the JSON object
  18550. */
  18551. serialize(): any;
  18552. /**
  18553. * Parse properties from a JSON object
  18554. * @param serializationObject defines the JSON object
  18555. */
  18556. parse(serializationObject: any): void;
  18557. }
  18558. }
  18559. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18560. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18561. import { Effect } from "babylonjs/Materials/effect";
  18562. import { Particle } from "babylonjs/Particles/particle";
  18563. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18564. /**
  18565. * Particle emitter emitting particles from a point.
  18566. * It emits the particles randomly between 2 given directions.
  18567. */
  18568. export class PointParticleEmitter implements IParticleEmitterType {
  18569. /**
  18570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18571. */
  18572. direction1: Vector3;
  18573. /**
  18574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18575. */
  18576. direction2: Vector3;
  18577. /**
  18578. * Creates a new instance PointParticleEmitter
  18579. */
  18580. constructor();
  18581. /**
  18582. * Called by the particle System when the direction is computed for the created particle.
  18583. * @param worldMatrix is the world matrix of the particle system
  18584. * @param directionToUpdate is the direction vector to update with the result
  18585. * @param particle is the particle we are computed the direction for
  18586. */
  18587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18588. /**
  18589. * Called by the particle System when the position is computed for the created particle.
  18590. * @param worldMatrix is the world matrix of the particle system
  18591. * @param positionToUpdate is the position vector to update with the result
  18592. * @param particle is the particle we are computed the position for
  18593. */
  18594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18595. /**
  18596. * Clones the current emitter and returns a copy of it
  18597. * @returns the new emitter
  18598. */
  18599. clone(): PointParticleEmitter;
  18600. /**
  18601. * Called by the GPUParticleSystem to setup the update shader
  18602. * @param effect defines the update shader
  18603. */
  18604. applyToShader(effect: Effect): void;
  18605. /**
  18606. * Returns a string to use to update the GPU particles update shader
  18607. * @returns a string containng the defines string
  18608. */
  18609. getEffectDefines(): string;
  18610. /**
  18611. * Returns the string "PointParticleEmitter"
  18612. * @returns a string containing the class name
  18613. */
  18614. getClassName(): string;
  18615. /**
  18616. * Serializes the particle system to a JSON object.
  18617. * @returns the JSON object
  18618. */
  18619. serialize(): any;
  18620. /**
  18621. * Parse properties from a JSON object
  18622. * @param serializationObject defines the JSON object
  18623. */
  18624. parse(serializationObject: any): void;
  18625. }
  18626. }
  18627. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18629. import { Effect } from "babylonjs/Materials/effect";
  18630. import { Particle } from "babylonjs/Particles/particle";
  18631. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18632. /**
  18633. * Particle emitter emitting particles from the inside of a sphere.
  18634. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18635. */
  18636. export class SphereParticleEmitter implements IParticleEmitterType {
  18637. /**
  18638. * The radius of the emission sphere.
  18639. */
  18640. radius: number;
  18641. /**
  18642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18643. */
  18644. radiusRange: number;
  18645. /**
  18646. * How much to randomize the particle direction [0-1].
  18647. */
  18648. directionRandomizer: number;
  18649. /**
  18650. * Creates a new instance SphereParticleEmitter
  18651. * @param radius the radius of the emission sphere (1 by default)
  18652. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18654. */
  18655. constructor(
  18656. /**
  18657. * The radius of the emission sphere.
  18658. */
  18659. radius?: number,
  18660. /**
  18661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18662. */
  18663. radiusRange?: number,
  18664. /**
  18665. * How much to randomize the particle direction [0-1].
  18666. */
  18667. directionRandomizer?: number);
  18668. /**
  18669. * Called by the particle System when the direction is computed for the created particle.
  18670. * @param worldMatrix is the world matrix of the particle system
  18671. * @param directionToUpdate is the direction vector to update with the result
  18672. * @param particle is the particle we are computed the direction for
  18673. */
  18674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18675. /**
  18676. * Called by the particle System when the position is computed for the created particle.
  18677. * @param worldMatrix is the world matrix of the particle system
  18678. * @param positionToUpdate is the position vector to update with the result
  18679. * @param particle is the particle we are computed the position for
  18680. */
  18681. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18682. /**
  18683. * Clones the current emitter and returns a copy of it
  18684. * @returns the new emitter
  18685. */
  18686. clone(): SphereParticleEmitter;
  18687. /**
  18688. * Called by the GPUParticleSystem to setup the update shader
  18689. * @param effect defines the update shader
  18690. */
  18691. applyToShader(effect: Effect): void;
  18692. /**
  18693. * Returns a string to use to update the GPU particles update shader
  18694. * @returns a string containng the defines string
  18695. */
  18696. getEffectDefines(): string;
  18697. /**
  18698. * Returns the string "SphereParticleEmitter"
  18699. * @returns a string containing the class name
  18700. */
  18701. getClassName(): string;
  18702. /**
  18703. * Serializes the particle system to a JSON object.
  18704. * @returns the JSON object
  18705. */
  18706. serialize(): any;
  18707. /**
  18708. * Parse properties from a JSON object
  18709. * @param serializationObject defines the JSON object
  18710. */
  18711. parse(serializationObject: any): void;
  18712. }
  18713. /**
  18714. * Particle emitter emitting particles from the inside of a sphere.
  18715. * It emits the particles randomly between two vectors.
  18716. */
  18717. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18718. /**
  18719. * The min limit of the emission direction.
  18720. */
  18721. direction1: Vector3;
  18722. /**
  18723. * The max limit of the emission direction.
  18724. */
  18725. direction2: Vector3;
  18726. /**
  18727. * Creates a new instance SphereDirectedParticleEmitter
  18728. * @param radius the radius of the emission sphere (1 by default)
  18729. * @param direction1 the min limit of the emission direction (up vector by default)
  18730. * @param direction2 the max limit of the emission direction (up vector by default)
  18731. */
  18732. constructor(radius?: number,
  18733. /**
  18734. * The min limit of the emission direction.
  18735. */
  18736. direction1?: Vector3,
  18737. /**
  18738. * The max limit of the emission direction.
  18739. */
  18740. direction2?: Vector3);
  18741. /**
  18742. * Called by the particle System when the direction is computed for the created particle.
  18743. * @param worldMatrix is the world matrix of the particle system
  18744. * @param directionToUpdate is the direction vector to update with the result
  18745. * @param particle is the particle we are computed the direction for
  18746. */
  18747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18748. /**
  18749. * Clones the current emitter and returns a copy of it
  18750. * @returns the new emitter
  18751. */
  18752. clone(): SphereDirectedParticleEmitter;
  18753. /**
  18754. * Called by the GPUParticleSystem to setup the update shader
  18755. * @param effect defines the update shader
  18756. */
  18757. applyToShader(effect: Effect): void;
  18758. /**
  18759. * Returns a string to use to update the GPU particles update shader
  18760. * @returns a string containng the defines string
  18761. */
  18762. getEffectDefines(): string;
  18763. /**
  18764. * Returns the string "SphereDirectedParticleEmitter"
  18765. * @returns a string containing the class name
  18766. */
  18767. getClassName(): string;
  18768. /**
  18769. * Serializes the particle system to a JSON object.
  18770. * @returns the JSON object
  18771. */
  18772. serialize(): any;
  18773. /**
  18774. * Parse properties from a JSON object
  18775. * @param serializationObject defines the JSON object
  18776. */
  18777. parse(serializationObject: any): void;
  18778. }
  18779. }
  18780. declare module "babylonjs/Particles/EmitterTypes/index" {
  18781. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18782. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18783. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18784. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18785. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18786. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18787. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18788. }
  18789. declare module "babylonjs/Particles/IParticleSystem" {
  18790. import { Nullable } from "babylonjs/types";
  18791. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18792. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18795. import { Texture } from "babylonjs/Materials/Textures/texture";
  18796. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18797. import { Scene } from "babylonjs/scene";
  18798. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18799. import { Animation } from "babylonjs/Animations/animation";
  18800. /**
  18801. * Interface representing a particle system in Babylon.js.
  18802. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18803. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18804. */
  18805. export interface IParticleSystem {
  18806. /**
  18807. * List of animations used by the particle system.
  18808. */
  18809. animations: Animation[];
  18810. /**
  18811. * The id of the Particle system.
  18812. */
  18813. id: string;
  18814. /**
  18815. * The name of the Particle system.
  18816. */
  18817. name: string;
  18818. /**
  18819. * The emitter represents the Mesh or position we are attaching the particle system to.
  18820. */
  18821. emitter: Nullable<AbstractMesh | Vector3>;
  18822. /**
  18823. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18824. */
  18825. isBillboardBased: boolean;
  18826. /**
  18827. * The rendering group used by the Particle system to chose when to render.
  18828. */
  18829. renderingGroupId: number;
  18830. /**
  18831. * The layer mask we are rendering the particles through.
  18832. */
  18833. layerMask: number;
  18834. /**
  18835. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18836. */
  18837. updateSpeed: number;
  18838. /**
  18839. * The amount of time the particle system is running (depends of the overall update speed).
  18840. */
  18841. targetStopDuration: number;
  18842. /**
  18843. * The texture used to render each particle. (this can be a spritesheet)
  18844. */
  18845. particleTexture: Nullable<Texture>;
  18846. /**
  18847. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18848. */
  18849. blendMode: number;
  18850. /**
  18851. * Minimum life time of emitting particles.
  18852. */
  18853. minLifeTime: number;
  18854. /**
  18855. * Maximum life time of emitting particles.
  18856. */
  18857. maxLifeTime: number;
  18858. /**
  18859. * Minimum Size of emitting particles.
  18860. */
  18861. minSize: number;
  18862. /**
  18863. * Maximum Size of emitting particles.
  18864. */
  18865. maxSize: number;
  18866. /**
  18867. * Minimum scale of emitting particles on X axis.
  18868. */
  18869. minScaleX: number;
  18870. /**
  18871. * Maximum scale of emitting particles on X axis.
  18872. */
  18873. maxScaleX: number;
  18874. /**
  18875. * Minimum scale of emitting particles on Y axis.
  18876. */
  18877. minScaleY: number;
  18878. /**
  18879. * Maximum scale of emitting particles on Y axis.
  18880. */
  18881. maxScaleY: number;
  18882. /**
  18883. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18884. */
  18885. color1: Color4;
  18886. /**
  18887. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18888. */
  18889. color2: Color4;
  18890. /**
  18891. * Color the particle will have at the end of its lifetime.
  18892. */
  18893. colorDead: Color4;
  18894. /**
  18895. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18896. */
  18897. emitRate: number;
  18898. /**
  18899. * You can use gravity if you want to give an orientation to your particles.
  18900. */
  18901. gravity: Vector3;
  18902. /**
  18903. * Minimum power of emitting particles.
  18904. */
  18905. minEmitPower: number;
  18906. /**
  18907. * Maximum power of emitting particles.
  18908. */
  18909. maxEmitPower: number;
  18910. /**
  18911. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18912. */
  18913. minAngularSpeed: number;
  18914. /**
  18915. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18916. */
  18917. maxAngularSpeed: number;
  18918. /**
  18919. * Gets or sets the minimal initial rotation in radians.
  18920. */
  18921. minInitialRotation: number;
  18922. /**
  18923. * Gets or sets the maximal initial rotation in radians.
  18924. */
  18925. maxInitialRotation: number;
  18926. /**
  18927. * The particle emitter type defines the emitter used by the particle system.
  18928. * It can be for example box, sphere, or cone...
  18929. */
  18930. particleEmitterType: Nullable<IParticleEmitterType>;
  18931. /**
  18932. * Defines the delay in milliseconds before starting the system (0 by default)
  18933. */
  18934. startDelay: number;
  18935. /**
  18936. * 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
  18937. */
  18938. preWarmCycles: number;
  18939. /**
  18940. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18941. */
  18942. preWarmStepOffset: number;
  18943. /**
  18944. * 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)
  18945. */
  18946. spriteCellChangeSpeed: number;
  18947. /**
  18948. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18949. */
  18950. startSpriteCellID: number;
  18951. /**
  18952. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18953. */
  18954. endSpriteCellID: number;
  18955. /**
  18956. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18957. */
  18958. spriteCellWidth: number;
  18959. /**
  18960. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18961. */
  18962. spriteCellHeight: number;
  18963. /**
  18964. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18965. */
  18966. spriteRandomStartCell: boolean;
  18967. /**
  18968. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18969. */
  18970. isAnimationSheetEnabled: boolean;
  18971. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18972. translationPivot: Vector2;
  18973. /**
  18974. * Gets or sets a texture used to add random noise to particle positions
  18975. */
  18976. noiseTexture: Nullable<BaseTexture>;
  18977. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18978. noiseStrength: Vector3;
  18979. /**
  18980. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18981. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18982. */
  18983. billboardMode: number;
  18984. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18985. limitVelocityDamping: number;
  18986. /**
  18987. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18988. */
  18989. beginAnimationOnStart: boolean;
  18990. /**
  18991. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18992. */
  18993. beginAnimationFrom: number;
  18994. /**
  18995. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18996. */
  18997. beginAnimationTo: number;
  18998. /**
  18999. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19000. */
  19001. beginAnimationLoop: boolean;
  19002. /**
  19003. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19004. */
  19005. disposeOnStop: boolean;
  19006. /**
  19007. * Gets the maximum number of particles active at the same time.
  19008. * @returns The max number of active particles.
  19009. */
  19010. getCapacity(): number;
  19011. /**
  19012. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19013. * @returns True if it has been started, otherwise false.
  19014. */
  19015. isStarted(): boolean;
  19016. /**
  19017. * Animates the particle system for this frame.
  19018. */
  19019. animate(): void;
  19020. /**
  19021. * Renders the particle system in its current state.
  19022. * @returns the current number of particles
  19023. */
  19024. render(): number;
  19025. /**
  19026. * Dispose the particle system and frees its associated resources.
  19027. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19028. */
  19029. dispose(disposeTexture?: boolean): void;
  19030. /**
  19031. * Clones the particle system.
  19032. * @param name The name of the cloned object
  19033. * @param newEmitter The new emitter to use
  19034. * @returns the cloned particle system
  19035. */
  19036. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19037. /**
  19038. * Serializes the particle system to a JSON object.
  19039. * @returns the JSON object
  19040. */
  19041. serialize(): any;
  19042. /**
  19043. * Rebuild the particle system
  19044. */
  19045. rebuild(): void;
  19046. /**
  19047. * Starts the particle system and begins to emit
  19048. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19049. */
  19050. start(delay?: number): void;
  19051. /**
  19052. * Stops the particle system.
  19053. */
  19054. stop(): void;
  19055. /**
  19056. * Remove all active particles
  19057. */
  19058. reset(): void;
  19059. /**
  19060. * Is this system ready to be used/rendered
  19061. * @return true if the system is ready
  19062. */
  19063. isReady(): boolean;
  19064. /**
  19065. * Adds a new color gradient
  19066. * @param gradient defines the gradient to use (between 0 and 1)
  19067. * @param color1 defines the color to affect to the specified gradient
  19068. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19069. * @returns the current particle system
  19070. */
  19071. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19072. /**
  19073. * Remove a specific color gradient
  19074. * @param gradient defines the gradient to remove
  19075. * @returns the current particle system
  19076. */
  19077. removeColorGradient(gradient: number): IParticleSystem;
  19078. /**
  19079. * Adds a new size gradient
  19080. * @param gradient defines the gradient to use (between 0 and 1)
  19081. * @param factor defines the size factor to affect to the specified gradient
  19082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19083. * @returns the current particle system
  19084. */
  19085. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19086. /**
  19087. * Remove a specific size gradient
  19088. * @param gradient defines the gradient to remove
  19089. * @returns the current particle system
  19090. */
  19091. removeSizeGradient(gradient: number): IParticleSystem;
  19092. /**
  19093. * Gets the current list of color gradients.
  19094. * You must use addColorGradient and removeColorGradient to udpate this list
  19095. * @returns the list of color gradients
  19096. */
  19097. getColorGradients(): Nullable<Array<ColorGradient>>;
  19098. /**
  19099. * Gets the current list of size gradients.
  19100. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19101. * @returns the list of size gradients
  19102. */
  19103. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19104. /**
  19105. * Gets the current list of angular speed gradients.
  19106. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19107. * @returns the list of angular speed gradients
  19108. */
  19109. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19110. /**
  19111. * Adds a new angular speed gradient
  19112. * @param gradient defines the gradient to use (between 0 and 1)
  19113. * @param factor defines the angular speed to affect to the specified gradient
  19114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19115. * @returns the current particle system
  19116. */
  19117. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19118. /**
  19119. * Remove a specific angular speed gradient
  19120. * @param gradient defines the gradient to remove
  19121. * @returns the current particle system
  19122. */
  19123. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19124. /**
  19125. * Gets the current list of velocity gradients.
  19126. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19127. * @returns the list of velocity gradients
  19128. */
  19129. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19130. /**
  19131. * Adds a new velocity gradient
  19132. * @param gradient defines the gradient to use (between 0 and 1)
  19133. * @param factor defines the velocity to affect to the specified gradient
  19134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19135. * @returns the current particle system
  19136. */
  19137. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19138. /**
  19139. * Remove a specific velocity gradient
  19140. * @param gradient defines the gradient to remove
  19141. * @returns the current particle system
  19142. */
  19143. removeVelocityGradient(gradient: number): IParticleSystem;
  19144. /**
  19145. * Gets the current list of limit velocity gradients.
  19146. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19147. * @returns the list of limit velocity gradients
  19148. */
  19149. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19150. /**
  19151. * Adds a new limit velocity gradient
  19152. * @param gradient defines the gradient to use (between 0 and 1)
  19153. * @param factor defines the limit velocity to affect to the specified gradient
  19154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19155. * @returns the current particle system
  19156. */
  19157. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19158. /**
  19159. * Remove a specific limit velocity gradient
  19160. * @param gradient defines the gradient to remove
  19161. * @returns the current particle system
  19162. */
  19163. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19164. /**
  19165. * Adds a new drag gradient
  19166. * @param gradient defines the gradient to use (between 0 and 1)
  19167. * @param factor defines the drag to affect to the specified gradient
  19168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19169. * @returns the current particle system
  19170. */
  19171. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19172. /**
  19173. * Remove a specific drag gradient
  19174. * @param gradient defines the gradient to remove
  19175. * @returns the current particle system
  19176. */
  19177. removeDragGradient(gradient: number): IParticleSystem;
  19178. /**
  19179. * Gets the current list of drag gradients.
  19180. * You must use addDragGradient and removeDragGradient to udpate this list
  19181. * @returns the list of drag gradients
  19182. */
  19183. getDragGradients(): Nullable<Array<FactorGradient>>;
  19184. /**
  19185. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19186. * @param gradient defines the gradient to use (between 0 and 1)
  19187. * @param factor defines the emit rate to affect to the specified gradient
  19188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19189. * @returns the current particle system
  19190. */
  19191. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19192. /**
  19193. * Remove a specific emit rate gradient
  19194. * @param gradient defines the gradient to remove
  19195. * @returns the current particle system
  19196. */
  19197. removeEmitRateGradient(gradient: number): IParticleSystem;
  19198. /**
  19199. * Gets the current list of emit rate gradients.
  19200. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19201. * @returns the list of emit rate gradients
  19202. */
  19203. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19204. /**
  19205. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19206. * @param gradient defines the gradient to use (between 0 and 1)
  19207. * @param factor defines the start size to affect to the specified gradient
  19208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19209. * @returns the current particle system
  19210. */
  19211. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19212. /**
  19213. * Remove a specific start size gradient
  19214. * @param gradient defines the gradient to remove
  19215. * @returns the current particle system
  19216. */
  19217. removeStartSizeGradient(gradient: number): IParticleSystem;
  19218. /**
  19219. * Gets the current list of start size gradients.
  19220. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19221. * @returns the list of start size gradients
  19222. */
  19223. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19224. /**
  19225. * Adds a new life time gradient
  19226. * @param gradient defines the gradient to use (between 0 and 1)
  19227. * @param factor defines the life time factor to affect to the specified gradient
  19228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19229. * @returns the current particle system
  19230. */
  19231. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19232. /**
  19233. * Remove a specific life time gradient
  19234. * @param gradient defines the gradient to remove
  19235. * @returns the current particle system
  19236. */
  19237. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19238. /**
  19239. * Gets the current list of life time gradients.
  19240. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19241. * @returns the list of life time gradients
  19242. */
  19243. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19244. /**
  19245. * Gets the current list of color gradients.
  19246. * You must use addColorGradient and removeColorGradient to udpate this list
  19247. * @returns the list of color gradients
  19248. */
  19249. getColorGradients(): Nullable<Array<ColorGradient>>;
  19250. /**
  19251. * Adds a new ramp gradient used to remap particle colors
  19252. * @param gradient defines the gradient to use (between 0 and 1)
  19253. * @param color defines the color to affect to the specified gradient
  19254. * @returns the current particle system
  19255. */
  19256. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19257. /**
  19258. * Gets the current list of ramp gradients.
  19259. * You must use addRampGradient and removeRampGradient to udpate this list
  19260. * @returns the list of ramp gradients
  19261. */
  19262. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19263. /** Gets or sets a boolean indicating that ramp gradients must be used
  19264. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19265. */
  19266. useRampGradients: boolean;
  19267. /**
  19268. * Adds a new color remap gradient
  19269. * @param gradient defines the gradient to use (between 0 and 1)
  19270. * @param min defines the color remap minimal range
  19271. * @param max defines the color remap maximal range
  19272. * @returns the current particle system
  19273. */
  19274. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19275. /**
  19276. * Gets the current list of color remap gradients.
  19277. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19278. * @returns the list of color remap gradients
  19279. */
  19280. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19281. /**
  19282. * Adds a new alpha remap gradient
  19283. * @param gradient defines the gradient to use (between 0 and 1)
  19284. * @param min defines the alpha remap minimal range
  19285. * @param max defines the alpha remap maximal range
  19286. * @returns the current particle system
  19287. */
  19288. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19289. /**
  19290. * Gets the current list of alpha remap gradients.
  19291. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19292. * @returns the list of alpha remap gradients
  19293. */
  19294. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19297. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19298. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19299. * @returns the emitter
  19300. */
  19301. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19302. /**
  19303. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19304. * @param radius The radius of the hemisphere to emit from
  19305. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19306. * @returns the emitter
  19307. */
  19308. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19309. /**
  19310. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19311. * @param radius The radius of the sphere to emit from
  19312. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19313. * @returns the emitter
  19314. */
  19315. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19316. /**
  19317. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19318. * @param radius The radius of the sphere to emit from
  19319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19321. * @returns the emitter
  19322. */
  19323. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19324. /**
  19325. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19326. * @param radius The radius of the emission cylinder
  19327. * @param height The height of the emission cylinder
  19328. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19329. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19330. * @returns the emitter
  19331. */
  19332. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19333. /**
  19334. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19335. * @param radius The radius of the cylinder to emit from
  19336. * @param height The height of the emission cylinder
  19337. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19340. * @returns the emitter
  19341. */
  19342. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19343. /**
  19344. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19345. * @param radius The radius of the cone to emit from
  19346. * @param angle The base angle of the cone
  19347. * @returns the emitter
  19348. */
  19349. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19350. /**
  19351. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19352. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19353. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19354. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19355. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19356. * @returns the emitter
  19357. */
  19358. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19359. /**
  19360. * Get hosting scene
  19361. * @returns the scene
  19362. */
  19363. getScene(): Scene;
  19364. }
  19365. }
  19366. declare module "babylonjs/Meshes/instancedMesh" {
  19367. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19368. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19369. import { Camera } from "babylonjs/Cameras/camera";
  19370. import { Node } from "babylonjs/node";
  19371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19372. import { Mesh } from "babylonjs/Meshes/mesh";
  19373. import { Material } from "babylonjs/Materials/material";
  19374. import { Skeleton } from "babylonjs/Bones/skeleton";
  19375. import { Light } from "babylonjs/Lights/light";
  19376. /**
  19377. * Creates an instance based on a source mesh.
  19378. */
  19379. export class InstancedMesh extends AbstractMesh {
  19380. private _sourceMesh;
  19381. private _currentLOD;
  19382. /** @hidden */
  19383. _indexInSourceMeshInstanceArray: number;
  19384. constructor(name: string, source: Mesh);
  19385. /**
  19386. * Returns the string "InstancedMesh".
  19387. */
  19388. getClassName(): string;
  19389. /** Gets the list of lights affecting that mesh */
  19390. readonly lightSources: Light[];
  19391. _resyncLightSources(): void;
  19392. _resyncLighSource(light: Light): void;
  19393. _removeLightSource(light: Light, dispose: boolean): void;
  19394. /**
  19395. * If the source mesh receives shadows
  19396. */
  19397. readonly receiveShadows: boolean;
  19398. /**
  19399. * The material of the source mesh
  19400. */
  19401. readonly material: Nullable<Material>;
  19402. /**
  19403. * Visibility of the source mesh
  19404. */
  19405. readonly visibility: number;
  19406. /**
  19407. * Skeleton of the source mesh
  19408. */
  19409. readonly skeleton: Nullable<Skeleton>;
  19410. /**
  19411. * Rendering ground id of the source mesh
  19412. */
  19413. renderingGroupId: number;
  19414. /**
  19415. * Returns the total number of vertices (integer).
  19416. */
  19417. getTotalVertices(): number;
  19418. /**
  19419. * Returns a positive integer : the total number of indices in this mesh geometry.
  19420. * @returns the numner of indices or zero if the mesh has no geometry.
  19421. */
  19422. getTotalIndices(): number;
  19423. /**
  19424. * The source mesh of the instance
  19425. */
  19426. readonly sourceMesh: Mesh;
  19427. /**
  19428. * Is this node ready to be used/rendered
  19429. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19430. * @return {boolean} is it ready
  19431. */
  19432. isReady(completeCheck?: boolean): boolean;
  19433. /**
  19434. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19435. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19436. * @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.
  19437. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19438. */
  19439. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19440. /**
  19441. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19442. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19443. * The `data` are either a numeric array either a Float32Array.
  19444. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19445. * 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).
  19446. * Note that a new underlying VertexBuffer object is created each call.
  19447. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19448. *
  19449. * Possible `kind` values :
  19450. * - VertexBuffer.PositionKind
  19451. * - VertexBuffer.UVKind
  19452. * - VertexBuffer.UV2Kind
  19453. * - VertexBuffer.UV3Kind
  19454. * - VertexBuffer.UV4Kind
  19455. * - VertexBuffer.UV5Kind
  19456. * - VertexBuffer.UV6Kind
  19457. * - VertexBuffer.ColorKind
  19458. * - VertexBuffer.MatricesIndicesKind
  19459. * - VertexBuffer.MatricesIndicesExtraKind
  19460. * - VertexBuffer.MatricesWeightsKind
  19461. * - VertexBuffer.MatricesWeightsExtraKind
  19462. *
  19463. * Returns the Mesh.
  19464. */
  19465. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19466. /**
  19467. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19468. * If the mesh has no geometry, it is simply returned as it is.
  19469. * The `data` are either a numeric array either a Float32Array.
  19470. * No new underlying VertexBuffer object is created.
  19471. * 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.
  19472. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19473. *
  19474. * Possible `kind` values :
  19475. * - VertexBuffer.PositionKind
  19476. * - VertexBuffer.UVKind
  19477. * - VertexBuffer.UV2Kind
  19478. * - VertexBuffer.UV3Kind
  19479. * - VertexBuffer.UV4Kind
  19480. * - VertexBuffer.UV5Kind
  19481. * - VertexBuffer.UV6Kind
  19482. * - VertexBuffer.ColorKind
  19483. * - VertexBuffer.MatricesIndicesKind
  19484. * - VertexBuffer.MatricesIndicesExtraKind
  19485. * - VertexBuffer.MatricesWeightsKind
  19486. * - VertexBuffer.MatricesWeightsExtraKind
  19487. *
  19488. * Returns the Mesh.
  19489. */
  19490. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19491. /**
  19492. * Sets the mesh indices.
  19493. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19494. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19495. * This method creates a new index buffer each call.
  19496. * Returns the Mesh.
  19497. */
  19498. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19499. /**
  19500. * Boolean : True if the mesh owns the requested kind of data.
  19501. */
  19502. isVerticesDataPresent(kind: string): boolean;
  19503. /**
  19504. * Returns an array of indices (IndicesArray).
  19505. */
  19506. getIndices(): Nullable<IndicesArray>;
  19507. readonly _positions: Nullable<Vector3[]>;
  19508. /**
  19509. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19510. * This means the mesh underlying bounding box and sphere are recomputed.
  19511. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19512. * @returns the current mesh
  19513. */
  19514. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19515. /** @hidden */
  19516. _preActivate(): InstancedMesh;
  19517. /** @hidden */
  19518. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19519. /** @hidden */
  19520. _postActivate(): void;
  19521. getWorldMatrix(): Matrix;
  19522. readonly isAnInstance: boolean;
  19523. /**
  19524. * Returns the current associated LOD AbstractMesh.
  19525. */
  19526. getLOD(camera: Camera): AbstractMesh;
  19527. /** @hidden */
  19528. _syncSubMeshes(): InstancedMesh;
  19529. /** @hidden */
  19530. _generatePointsArray(): boolean;
  19531. /**
  19532. * Creates a new InstancedMesh from the current mesh.
  19533. * - name (string) : the cloned mesh name
  19534. * - newParent (optional Node) : the optional Node to parent the clone to.
  19535. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19536. *
  19537. * Returns the clone.
  19538. */
  19539. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19540. /**
  19541. * Disposes the InstancedMesh.
  19542. * Returns nothing.
  19543. */
  19544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19545. }
  19546. }
  19547. declare module "babylonjs/Materials/shaderMaterial" {
  19548. import { Scene } from "babylonjs/scene";
  19549. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19551. import { Mesh } from "babylonjs/Meshes/mesh";
  19552. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19554. import { Texture } from "babylonjs/Materials/Textures/texture";
  19555. import { Material } from "babylonjs/Materials/material";
  19556. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19557. /**
  19558. * Defines the options associated with the creation of a shader material.
  19559. */
  19560. export interface IShaderMaterialOptions {
  19561. /**
  19562. * Does the material work in alpha blend mode
  19563. */
  19564. needAlphaBlending: boolean;
  19565. /**
  19566. * Does the material work in alpha test mode
  19567. */
  19568. needAlphaTesting: boolean;
  19569. /**
  19570. * The list of attribute names used in the shader
  19571. */
  19572. attributes: string[];
  19573. /**
  19574. * The list of unifrom names used in the shader
  19575. */
  19576. uniforms: string[];
  19577. /**
  19578. * The list of UBO names used in the shader
  19579. */
  19580. uniformBuffers: string[];
  19581. /**
  19582. * The list of sampler names used in the shader
  19583. */
  19584. samplers: string[];
  19585. /**
  19586. * The list of defines used in the shader
  19587. */
  19588. defines: string[];
  19589. }
  19590. /**
  19591. * 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.
  19592. *
  19593. * This returned material effects how the mesh will look based on the code in the shaders.
  19594. *
  19595. * @see http://doc.babylonjs.com/how_to/shader_material
  19596. */
  19597. export class ShaderMaterial extends Material {
  19598. private _shaderPath;
  19599. private _options;
  19600. private _textures;
  19601. private _textureArrays;
  19602. private _floats;
  19603. private _ints;
  19604. private _floatsArrays;
  19605. private _colors3;
  19606. private _colors3Arrays;
  19607. private _colors4;
  19608. private _colors4Arrays;
  19609. private _vectors2;
  19610. private _vectors3;
  19611. private _vectors4;
  19612. private _matrices;
  19613. private _matrices3x3;
  19614. private _matrices2x2;
  19615. private _vectors2Arrays;
  19616. private _vectors3Arrays;
  19617. private _vectors4Arrays;
  19618. private _cachedWorldViewMatrix;
  19619. private _cachedWorldViewProjectionMatrix;
  19620. private _renderId;
  19621. /**
  19622. * Instantiate a new shader material.
  19623. * 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.
  19624. * This returned material effects how the mesh will look based on the code in the shaders.
  19625. * @see http://doc.babylonjs.com/how_to/shader_material
  19626. * @param name Define the name of the material in the scene
  19627. * @param scene Define the scene the material belongs to
  19628. * @param shaderPath Defines the route to the shader code in one of three ways:
  19629. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19630. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19631. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19632. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19633. * @param options Define the options used to create the shader
  19634. */
  19635. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19636. /**
  19637. * Gets the options used to compile the shader.
  19638. * They can be modified to trigger a new compilation
  19639. */
  19640. readonly options: IShaderMaterialOptions;
  19641. /**
  19642. * Gets the current class name of the material e.g. "ShaderMaterial"
  19643. * Mainly use in serialization.
  19644. * @returns the class name
  19645. */
  19646. getClassName(): string;
  19647. /**
  19648. * Specifies if the material will require alpha blending
  19649. * @returns a boolean specifying if alpha blending is needed
  19650. */
  19651. needAlphaBlending(): boolean;
  19652. /**
  19653. * Specifies if this material should be rendered in alpha test mode
  19654. * @returns a boolean specifying if an alpha test is needed.
  19655. */
  19656. needAlphaTesting(): boolean;
  19657. private _checkUniform;
  19658. /**
  19659. * Set a texture in the shader.
  19660. * @param name Define the name of the uniform samplers as defined in the shader
  19661. * @param texture Define the texture to bind to this sampler
  19662. * @return the material itself allowing "fluent" like uniform updates
  19663. */
  19664. setTexture(name: string, texture: Texture): ShaderMaterial;
  19665. /**
  19666. * Set a texture array in the shader.
  19667. * @param name Define the name of the uniform sampler array as defined in the shader
  19668. * @param textures Define the list of textures to bind to this sampler
  19669. * @return the material itself allowing "fluent" like uniform updates
  19670. */
  19671. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19672. /**
  19673. * Set a float in the shader.
  19674. * @param name Define the name of the uniform as defined in the shader
  19675. * @param value Define the value to give to the uniform
  19676. * @return the material itself allowing "fluent" like uniform updates
  19677. */
  19678. setFloat(name: string, value: number): ShaderMaterial;
  19679. /**
  19680. * Set a int in the shader.
  19681. * @param name Define the name of the uniform as defined in the shader
  19682. * @param value Define the value to give to the uniform
  19683. * @return the material itself allowing "fluent" like uniform updates
  19684. */
  19685. setInt(name: string, value: number): ShaderMaterial;
  19686. /**
  19687. * Set an array of floats in the shader.
  19688. * @param name Define the name of the uniform as defined in the shader
  19689. * @param value Define the value to give to the uniform
  19690. * @return the material itself allowing "fluent" like uniform updates
  19691. */
  19692. setFloats(name: string, value: number[]): ShaderMaterial;
  19693. /**
  19694. * Set a vec3 in the shader from a Color3.
  19695. * @param name Define the name of the uniform as defined in the shader
  19696. * @param value Define the value to give to the uniform
  19697. * @return the material itself allowing "fluent" like uniform updates
  19698. */
  19699. setColor3(name: string, value: Color3): ShaderMaterial;
  19700. /**
  19701. * Set a vec3 array in the shader from a Color3 array.
  19702. * @param name Define the name of the uniform as defined in the shader
  19703. * @param value Define the value to give to the uniform
  19704. * @return the material itself allowing "fluent" like uniform updates
  19705. */
  19706. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19707. /**
  19708. * Set a vec4 in the shader from a Color4.
  19709. * @param name Define the name of the uniform as defined in the shader
  19710. * @param value Define the value to give to the uniform
  19711. * @return the material itself allowing "fluent" like uniform updates
  19712. */
  19713. setColor4(name: string, value: Color4): ShaderMaterial;
  19714. /**
  19715. * Set a vec4 array in the shader from a Color4 array.
  19716. * @param name Define the name of the uniform as defined in the shader
  19717. * @param value Define the value to give to the uniform
  19718. * @return the material itself allowing "fluent" like uniform updates
  19719. */
  19720. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19721. /**
  19722. * Set a vec2 in the shader from a Vector2.
  19723. * @param name Define the name of the uniform as defined in the shader
  19724. * @param value Define the value to give to the uniform
  19725. * @return the material itself allowing "fluent" like uniform updates
  19726. */
  19727. setVector2(name: string, value: Vector2): ShaderMaterial;
  19728. /**
  19729. * Set a vec3 in the shader from a Vector3.
  19730. * @param name Define the name of the uniform as defined in the shader
  19731. * @param value Define the value to give to the uniform
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setVector3(name: string, value: Vector3): ShaderMaterial;
  19735. /**
  19736. * Set a vec4 in the shader from a Vector4.
  19737. * @param name Define the name of the uniform as defined in the shader
  19738. * @param value Define the value to give to the uniform
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setVector4(name: string, value: Vector4): ShaderMaterial;
  19742. /**
  19743. * Set a mat4 in the shader from a Matrix.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19749. /**
  19750. * Set a mat3 in the shader from a Float32Array.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19756. /**
  19757. * Set a mat2 in the shader from a Float32Array.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19763. /**
  19764. * Set a vec2 array in the shader from a number array.
  19765. * @param name Define the name of the uniform as defined in the shader
  19766. * @param value Define the value to give to the uniform
  19767. * @return the material itself allowing "fluent" like uniform updates
  19768. */
  19769. setArray2(name: string, value: number[]): ShaderMaterial;
  19770. /**
  19771. * Set a vec3 array in the shader from a number array.
  19772. * @param name Define the name of the uniform as defined in the shader
  19773. * @param value Define the value to give to the uniform
  19774. * @return the material itself allowing "fluent" like uniform updates
  19775. */
  19776. setArray3(name: string, value: number[]): ShaderMaterial;
  19777. /**
  19778. * Set a vec4 array in the shader from a number array.
  19779. * @param name Define the name of the uniform as defined in the shader
  19780. * @param value Define the value to give to the uniform
  19781. * @return the material itself allowing "fluent" like uniform updates
  19782. */
  19783. setArray4(name: string, value: number[]): ShaderMaterial;
  19784. private _checkCache;
  19785. /**
  19786. * Specifies that the submesh is ready to be used
  19787. * @param mesh defines the mesh to check
  19788. * @param subMesh defines which submesh to check
  19789. * @param useInstances specifies that instances should be used
  19790. * @returns a boolean indicating that the submesh is ready or not
  19791. */
  19792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19793. /**
  19794. * Checks if the material is ready to render the requested mesh
  19795. * @param mesh Define the mesh to render
  19796. * @param useInstances Define whether or not the material is used with instances
  19797. * @returns true if ready, otherwise false
  19798. */
  19799. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19800. /**
  19801. * Binds the world matrix to the material
  19802. * @param world defines the world transformation matrix
  19803. */
  19804. bindOnlyWorldMatrix(world: Matrix): void;
  19805. /**
  19806. * Binds the material to the mesh
  19807. * @param world defines the world transformation matrix
  19808. * @param mesh defines the mesh to bind the material to
  19809. */
  19810. bind(world: Matrix, mesh?: Mesh): void;
  19811. /**
  19812. * Gets the active textures from the material
  19813. * @returns an array of textures
  19814. */
  19815. getActiveTextures(): BaseTexture[];
  19816. /**
  19817. * Specifies if the material uses a texture
  19818. * @param texture defines the texture to check against the material
  19819. * @returns a boolean specifying if the material uses the texture
  19820. */
  19821. hasTexture(texture: BaseTexture): boolean;
  19822. /**
  19823. * Makes a duplicate of the material, and gives it a new name
  19824. * @param name defines the new name for the duplicated material
  19825. * @returns the cloned material
  19826. */
  19827. clone(name: string): ShaderMaterial;
  19828. /**
  19829. * Disposes the material
  19830. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19831. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19832. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19833. */
  19834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19835. /**
  19836. * Serializes this material in a JSON representation
  19837. * @returns the serialized material object
  19838. */
  19839. serialize(): any;
  19840. /**
  19841. * Creates a shader material from parsed shader material data
  19842. * @param source defines the JSON represnetation of the material
  19843. * @param scene defines the hosting scene
  19844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19845. * @returns a new material
  19846. */
  19847. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19848. }
  19849. }
  19850. declare module "babylonjs/Shaders/color.fragment" {
  19851. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19852. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19853. /** @hidden */
  19854. export var colorPixelShader: {
  19855. name: string;
  19856. shader: string;
  19857. };
  19858. }
  19859. declare module "babylonjs/Shaders/color.vertex" {
  19860. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19861. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19862. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19863. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19864. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19865. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19866. /** @hidden */
  19867. export var colorVertexShader: {
  19868. name: string;
  19869. shader: string;
  19870. };
  19871. }
  19872. declare module "babylonjs/Meshes/linesMesh" {
  19873. import { Nullable } from "babylonjs/types";
  19874. import { Scene } from "babylonjs/scene";
  19875. import { Color3 } from "babylonjs/Maths/math.color";
  19876. import { Node } from "babylonjs/node";
  19877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19878. import { Mesh } from "babylonjs/Meshes/mesh";
  19879. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19880. import { Effect } from "babylonjs/Materials/effect";
  19881. import { Material } from "babylonjs/Materials/material";
  19882. import "babylonjs/Shaders/color.fragment";
  19883. import "babylonjs/Shaders/color.vertex";
  19884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19885. /**
  19886. * Line mesh
  19887. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19888. */
  19889. export class LinesMesh extends Mesh {
  19890. /**
  19891. * If vertex color should be applied to the mesh
  19892. */
  19893. readonly useVertexColor?: boolean | undefined;
  19894. /**
  19895. * If vertex alpha should be applied to the mesh
  19896. */
  19897. readonly useVertexAlpha?: boolean | undefined;
  19898. /**
  19899. * Color of the line (Default: White)
  19900. */
  19901. color: Color3;
  19902. /**
  19903. * Alpha of the line (Default: 1)
  19904. */
  19905. alpha: number;
  19906. /**
  19907. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19908. * This margin is expressed in world space coordinates, so its value may vary.
  19909. * Default value is 0.1
  19910. */
  19911. intersectionThreshold: number;
  19912. private _colorShader;
  19913. private color4;
  19914. /**
  19915. * Creates a new LinesMesh
  19916. * @param name defines the name
  19917. * @param scene defines the hosting scene
  19918. * @param parent defines the parent mesh if any
  19919. * @param source defines the optional source LinesMesh used to clone data from
  19920. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19921. * When false, achieved by calling a clone(), also passing False.
  19922. * This will make creation of children, recursive.
  19923. * @param useVertexColor defines if this LinesMesh supports vertex color
  19924. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19925. */
  19926. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19927. /**
  19928. * If vertex color should be applied to the mesh
  19929. */
  19930. useVertexColor?: boolean | undefined,
  19931. /**
  19932. * If vertex alpha should be applied to the mesh
  19933. */
  19934. useVertexAlpha?: boolean | undefined);
  19935. private _addClipPlaneDefine;
  19936. private _removeClipPlaneDefine;
  19937. isReady(): boolean;
  19938. /**
  19939. * Returns the string "LineMesh"
  19940. */
  19941. getClassName(): string;
  19942. /**
  19943. * @hidden
  19944. */
  19945. /**
  19946. * @hidden
  19947. */
  19948. material: Material;
  19949. /**
  19950. * @hidden
  19951. */
  19952. readonly checkCollisions: boolean;
  19953. /** @hidden */
  19954. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19955. /** @hidden */
  19956. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19957. /**
  19958. * Disposes of the line mesh
  19959. * @param doNotRecurse If children should be disposed
  19960. */
  19961. dispose(doNotRecurse?: boolean): void;
  19962. /**
  19963. * Returns a new LineMesh object cloned from the current one.
  19964. */
  19965. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19966. /**
  19967. * Creates a new InstancedLinesMesh object from the mesh model.
  19968. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19969. * @param name defines the name of the new instance
  19970. * @returns a new InstancedLinesMesh
  19971. */
  19972. createInstance(name: string): InstancedLinesMesh;
  19973. }
  19974. /**
  19975. * Creates an instance based on a source LinesMesh
  19976. */
  19977. export class InstancedLinesMesh extends InstancedMesh {
  19978. /**
  19979. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19980. * This margin is expressed in world space coordinates, so its value may vary.
  19981. * Initilized with the intersectionThreshold value of the source LinesMesh
  19982. */
  19983. intersectionThreshold: number;
  19984. constructor(name: string, source: LinesMesh);
  19985. /**
  19986. * Returns the string "InstancedLinesMesh".
  19987. */
  19988. getClassName(): string;
  19989. }
  19990. }
  19991. declare module "babylonjs/Shaders/line.fragment" {
  19992. /** @hidden */
  19993. export var linePixelShader: {
  19994. name: string;
  19995. shader: string;
  19996. };
  19997. }
  19998. declare module "babylonjs/Shaders/line.vertex" {
  19999. /** @hidden */
  20000. export var lineVertexShader: {
  20001. name: string;
  20002. shader: string;
  20003. };
  20004. }
  20005. declare module "babylonjs/Rendering/edgesRenderer" {
  20006. import { Nullable } from "babylonjs/types";
  20007. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20009. import { Vector3 } from "babylonjs/Maths/math.vector";
  20010. import { IDisposable } from "babylonjs/scene";
  20011. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20012. import "babylonjs/Shaders/line.fragment";
  20013. import "babylonjs/Shaders/line.vertex";
  20014. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20015. module "babylonjs/Meshes/abstractMesh" {
  20016. interface AbstractMesh {
  20017. /**
  20018. * Gets the edgesRenderer associated with the mesh
  20019. */
  20020. edgesRenderer: Nullable<EdgesRenderer>;
  20021. }
  20022. }
  20023. module "babylonjs/Meshes/linesMesh" {
  20024. interface LinesMesh {
  20025. /**
  20026. * Enables the edge rendering mode on the mesh.
  20027. * This mode makes the mesh edges visible
  20028. * @param epsilon defines the maximal distance between two angles to detect a face
  20029. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20030. * @returns the currentAbstractMesh
  20031. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20032. */
  20033. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20034. }
  20035. }
  20036. module "babylonjs/Meshes/linesMesh" {
  20037. interface InstancedLinesMesh {
  20038. /**
  20039. * Enables the edge rendering mode on the mesh.
  20040. * This mode makes the mesh edges visible
  20041. * @param epsilon defines the maximal distance between two angles to detect a face
  20042. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20043. * @returns the current InstancedLinesMesh
  20044. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20045. */
  20046. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20047. }
  20048. }
  20049. /**
  20050. * Defines the minimum contract an Edges renderer should follow.
  20051. */
  20052. export interface IEdgesRenderer extends IDisposable {
  20053. /**
  20054. * Gets or sets a boolean indicating if the edgesRenderer is active
  20055. */
  20056. isEnabled: boolean;
  20057. /**
  20058. * Renders the edges of the attached mesh,
  20059. */
  20060. render(): void;
  20061. /**
  20062. * Checks wether or not the edges renderer is ready to render.
  20063. * @return true if ready, otherwise false.
  20064. */
  20065. isReady(): boolean;
  20066. }
  20067. /**
  20068. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20069. */
  20070. export class EdgesRenderer implements IEdgesRenderer {
  20071. /**
  20072. * Define the size of the edges with an orthographic camera
  20073. */
  20074. edgesWidthScalerForOrthographic: number;
  20075. /**
  20076. * Define the size of the edges with a perspective camera
  20077. */
  20078. edgesWidthScalerForPerspective: number;
  20079. protected _source: AbstractMesh;
  20080. protected _linesPositions: number[];
  20081. protected _linesNormals: number[];
  20082. protected _linesIndices: number[];
  20083. protected _epsilon: number;
  20084. protected _indicesCount: number;
  20085. protected _lineShader: ShaderMaterial;
  20086. protected _ib: DataBuffer;
  20087. protected _buffers: {
  20088. [key: string]: Nullable<VertexBuffer>;
  20089. };
  20090. protected _checkVerticesInsteadOfIndices: boolean;
  20091. private _meshRebuildObserver;
  20092. private _meshDisposeObserver;
  20093. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20094. isEnabled: boolean;
  20095. /**
  20096. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20097. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20098. * @param source Mesh used to create edges
  20099. * @param epsilon sum of angles in adjacency to check for edge
  20100. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20101. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20102. */
  20103. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20104. protected _prepareRessources(): void;
  20105. /** @hidden */
  20106. _rebuild(): void;
  20107. /**
  20108. * Releases the required resources for the edges renderer
  20109. */
  20110. dispose(): void;
  20111. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20112. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20113. /**
  20114. * Checks if the pair of p0 and p1 is en edge
  20115. * @param faceIndex
  20116. * @param edge
  20117. * @param faceNormals
  20118. * @param p0
  20119. * @param p1
  20120. * @private
  20121. */
  20122. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20123. /**
  20124. * push line into the position, normal and index buffer
  20125. * @protected
  20126. */
  20127. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20128. /**
  20129. * Generates lines edges from adjacencjes
  20130. * @private
  20131. */
  20132. _generateEdgesLines(): void;
  20133. /**
  20134. * Checks wether or not the edges renderer is ready to render.
  20135. * @return true if ready, otherwise false.
  20136. */
  20137. isReady(): boolean;
  20138. /**
  20139. * Renders the edges of the attached mesh,
  20140. */
  20141. render(): void;
  20142. }
  20143. /**
  20144. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20145. */
  20146. export class LineEdgesRenderer extends EdgesRenderer {
  20147. /**
  20148. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20149. * @param source LineMesh used to generate edges
  20150. * @param epsilon not important (specified angle for edge detection)
  20151. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20152. */
  20153. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20154. /**
  20155. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20156. */
  20157. _generateEdgesLines(): void;
  20158. }
  20159. }
  20160. declare module "babylonjs/Rendering/renderingGroup" {
  20161. import { SmartArray } from "babylonjs/Misc/smartArray";
  20162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20164. import { Nullable } from "babylonjs/types";
  20165. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20166. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20167. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20168. import { Material } from "babylonjs/Materials/material";
  20169. import { Scene } from "babylonjs/scene";
  20170. /**
  20171. * This represents the object necessary to create a rendering group.
  20172. * This is exclusively used and created by the rendering manager.
  20173. * To modify the behavior, you use the available helpers in your scene or meshes.
  20174. * @hidden
  20175. */
  20176. export class RenderingGroup {
  20177. index: number;
  20178. private static _zeroVector;
  20179. private _scene;
  20180. private _opaqueSubMeshes;
  20181. private _transparentSubMeshes;
  20182. private _alphaTestSubMeshes;
  20183. private _depthOnlySubMeshes;
  20184. private _particleSystems;
  20185. private _spriteManagers;
  20186. private _opaqueSortCompareFn;
  20187. private _alphaTestSortCompareFn;
  20188. private _transparentSortCompareFn;
  20189. private _renderOpaque;
  20190. private _renderAlphaTest;
  20191. private _renderTransparent;
  20192. /** @hidden */
  20193. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20194. onBeforeTransparentRendering: () => void;
  20195. /**
  20196. * Set the opaque sort comparison function.
  20197. * If null the sub meshes will be render in the order they were created
  20198. */
  20199. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20200. /**
  20201. * Set the alpha test sort comparison function.
  20202. * If null the sub meshes will be render in the order they were created
  20203. */
  20204. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20205. /**
  20206. * Set the transparent sort comparison function.
  20207. * If null the sub meshes will be render in the order they were created
  20208. */
  20209. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20210. /**
  20211. * Creates a new rendering group.
  20212. * @param index The rendering group index
  20213. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20214. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20215. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20216. */
  20217. 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>);
  20218. /**
  20219. * Render all the sub meshes contained in the group.
  20220. * @param customRenderFunction Used to override the default render behaviour of the group.
  20221. * @returns true if rendered some submeshes.
  20222. */
  20223. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20224. /**
  20225. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20226. * @param subMeshes The submeshes to render
  20227. */
  20228. private renderOpaqueSorted;
  20229. /**
  20230. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20231. * @param subMeshes The submeshes to render
  20232. */
  20233. private renderAlphaTestSorted;
  20234. /**
  20235. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20236. * @param subMeshes The submeshes to render
  20237. */
  20238. private renderTransparentSorted;
  20239. /**
  20240. * Renders the submeshes in a specified order.
  20241. * @param subMeshes The submeshes to sort before render
  20242. * @param sortCompareFn The comparison function use to sort
  20243. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20244. * @param transparent Specifies to activate blending if true
  20245. */
  20246. private static renderSorted;
  20247. /**
  20248. * Renders the submeshes in the order they were dispatched (no sort applied).
  20249. * @param subMeshes The submeshes to render
  20250. */
  20251. private static renderUnsorted;
  20252. /**
  20253. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20254. * are rendered back to front if in the same alpha index.
  20255. *
  20256. * @param a The first submesh
  20257. * @param b The second submesh
  20258. * @returns The result of the comparison
  20259. */
  20260. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20261. /**
  20262. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20263. * are rendered back to front.
  20264. *
  20265. * @param a The first submesh
  20266. * @param b The second submesh
  20267. * @returns The result of the comparison
  20268. */
  20269. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20270. /**
  20271. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20272. * are rendered front to back (prevent overdraw).
  20273. *
  20274. * @param a The first submesh
  20275. * @param b The second submesh
  20276. * @returns The result of the comparison
  20277. */
  20278. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20279. /**
  20280. * Resets the different lists of submeshes to prepare a new frame.
  20281. */
  20282. prepare(): void;
  20283. dispose(): void;
  20284. /**
  20285. * Inserts the submesh in its correct queue depending on its material.
  20286. * @param subMesh The submesh to dispatch
  20287. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20288. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20289. */
  20290. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20291. dispatchSprites(spriteManager: ISpriteManager): void;
  20292. dispatchParticles(particleSystem: IParticleSystem): void;
  20293. private _renderParticles;
  20294. private _renderSprites;
  20295. }
  20296. }
  20297. declare module "babylonjs/Rendering/renderingManager" {
  20298. import { Nullable } from "babylonjs/types";
  20299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20300. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20301. import { SmartArray } from "babylonjs/Misc/smartArray";
  20302. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20303. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20304. import { Material } from "babylonjs/Materials/material";
  20305. import { Scene } from "babylonjs/scene";
  20306. import { Camera } from "babylonjs/Cameras/camera";
  20307. /**
  20308. * Interface describing the different options available in the rendering manager
  20309. * regarding Auto Clear between groups.
  20310. */
  20311. export interface IRenderingManagerAutoClearSetup {
  20312. /**
  20313. * Defines whether or not autoclear is enable.
  20314. */
  20315. autoClear: boolean;
  20316. /**
  20317. * Defines whether or not to autoclear the depth buffer.
  20318. */
  20319. depth: boolean;
  20320. /**
  20321. * Defines whether or not to autoclear the stencil buffer.
  20322. */
  20323. stencil: boolean;
  20324. }
  20325. /**
  20326. * This class is used by the onRenderingGroupObservable
  20327. */
  20328. export class RenderingGroupInfo {
  20329. /**
  20330. * The Scene that being rendered
  20331. */
  20332. scene: Scene;
  20333. /**
  20334. * The camera currently used for the rendering pass
  20335. */
  20336. camera: Nullable<Camera>;
  20337. /**
  20338. * The ID of the renderingGroup being processed
  20339. */
  20340. renderingGroupId: number;
  20341. }
  20342. /**
  20343. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20344. * It is enable to manage the different groups as well as the different necessary sort functions.
  20345. * This should not be used directly aside of the few static configurations
  20346. */
  20347. export class RenderingManager {
  20348. /**
  20349. * The max id used for rendering groups (not included)
  20350. */
  20351. static MAX_RENDERINGGROUPS: number;
  20352. /**
  20353. * The min id used for rendering groups (included)
  20354. */
  20355. static MIN_RENDERINGGROUPS: number;
  20356. /**
  20357. * Used to globally prevent autoclearing scenes.
  20358. */
  20359. static AUTOCLEAR: boolean;
  20360. /**
  20361. * @hidden
  20362. */
  20363. _useSceneAutoClearSetup: boolean;
  20364. private _scene;
  20365. private _renderingGroups;
  20366. private _depthStencilBufferAlreadyCleaned;
  20367. private _autoClearDepthStencil;
  20368. private _customOpaqueSortCompareFn;
  20369. private _customAlphaTestSortCompareFn;
  20370. private _customTransparentSortCompareFn;
  20371. private _renderingGroupInfo;
  20372. /**
  20373. * Instantiates a new rendering group for a particular scene
  20374. * @param scene Defines the scene the groups belongs to
  20375. */
  20376. constructor(scene: Scene);
  20377. private _clearDepthStencilBuffer;
  20378. /**
  20379. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20380. * @hidden
  20381. */
  20382. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20383. /**
  20384. * Resets the different information of the group to prepare a new frame
  20385. * @hidden
  20386. */
  20387. reset(): void;
  20388. /**
  20389. * Dispose and release the group and its associated resources.
  20390. * @hidden
  20391. */
  20392. dispose(): void;
  20393. /**
  20394. * Clear the info related to rendering groups preventing retention points during dispose.
  20395. */
  20396. freeRenderingGroups(): void;
  20397. private _prepareRenderingGroup;
  20398. /**
  20399. * Add a sprite manager to the rendering manager in order to render it this frame.
  20400. * @param spriteManager Define the sprite manager to render
  20401. */
  20402. dispatchSprites(spriteManager: ISpriteManager): void;
  20403. /**
  20404. * Add a particle system to the rendering manager in order to render it this frame.
  20405. * @param particleSystem Define the particle system to render
  20406. */
  20407. dispatchParticles(particleSystem: IParticleSystem): void;
  20408. /**
  20409. * Add a submesh to the manager in order to render it this frame
  20410. * @param subMesh The submesh to dispatch
  20411. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20412. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20413. */
  20414. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20415. /**
  20416. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20417. * This allowed control for front to back rendering or reversly depending of the special needs.
  20418. *
  20419. * @param renderingGroupId The rendering group id corresponding to its index
  20420. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20421. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20422. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20423. */
  20424. 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;
  20425. /**
  20426. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20427. *
  20428. * @param renderingGroupId The rendering group id corresponding to its index
  20429. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20430. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20431. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20432. */
  20433. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20434. /**
  20435. * Gets the current auto clear configuration for one rendering group of the rendering
  20436. * manager.
  20437. * @param index the rendering group index to get the information for
  20438. * @returns The auto clear setup for the requested rendering group
  20439. */
  20440. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20441. }
  20442. }
  20443. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20444. import { Observable } from "babylonjs/Misc/observable";
  20445. import { SmartArray } from "babylonjs/Misc/smartArray";
  20446. import { Nullable } from "babylonjs/types";
  20447. import { Camera } from "babylonjs/Cameras/camera";
  20448. import { Scene } from "babylonjs/scene";
  20449. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20450. import { Color4 } from "babylonjs/Maths/math.color";
  20451. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20454. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20455. import { Texture } from "babylonjs/Materials/Textures/texture";
  20456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20457. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20458. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20459. import { Engine } from "babylonjs/Engines/engine";
  20460. /**
  20461. * This Helps creating a texture that will be created from a camera in your scene.
  20462. * It is basically a dynamic texture that could be used to create special effects for instance.
  20463. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20464. */
  20465. export class RenderTargetTexture extends Texture {
  20466. isCube: boolean;
  20467. /**
  20468. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20469. */
  20470. static readonly REFRESHRATE_RENDER_ONCE: number;
  20471. /**
  20472. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20473. */
  20474. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20475. /**
  20476. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20477. * the central point of your effect and can save a lot of performances.
  20478. */
  20479. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20480. /**
  20481. * Use this predicate to dynamically define the list of mesh you want to render.
  20482. * If set, the renderList property will be overwritten.
  20483. */
  20484. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20485. private _renderList;
  20486. /**
  20487. * Use this list to define the list of mesh you want to render.
  20488. */
  20489. renderList: Nullable<Array<AbstractMesh>>;
  20490. private _hookArray;
  20491. /**
  20492. * Define if particles should be rendered in your texture.
  20493. */
  20494. renderParticles: boolean;
  20495. /**
  20496. * Define if sprites should be rendered in your texture.
  20497. */
  20498. renderSprites: boolean;
  20499. /**
  20500. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20501. */
  20502. coordinatesMode: number;
  20503. /**
  20504. * Define the camera used to render the texture.
  20505. */
  20506. activeCamera: Nullable<Camera>;
  20507. /**
  20508. * Override the render function of the texture with your own one.
  20509. */
  20510. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20511. /**
  20512. * Define if camera post processes should be use while rendering the texture.
  20513. */
  20514. useCameraPostProcesses: boolean;
  20515. /**
  20516. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20517. */
  20518. ignoreCameraViewport: boolean;
  20519. private _postProcessManager;
  20520. private _postProcesses;
  20521. private _resizeObserver;
  20522. /**
  20523. * An event triggered when the texture is unbind.
  20524. */
  20525. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20526. /**
  20527. * An event triggered when the texture is unbind.
  20528. */
  20529. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20530. private _onAfterUnbindObserver;
  20531. /**
  20532. * Set a after unbind callback in the texture.
  20533. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20534. */
  20535. onAfterUnbind: () => void;
  20536. /**
  20537. * An event triggered before rendering the texture
  20538. */
  20539. onBeforeRenderObservable: Observable<number>;
  20540. private _onBeforeRenderObserver;
  20541. /**
  20542. * Set a before render callback in the texture.
  20543. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20544. */
  20545. onBeforeRender: (faceIndex: number) => void;
  20546. /**
  20547. * An event triggered after rendering the texture
  20548. */
  20549. onAfterRenderObservable: Observable<number>;
  20550. private _onAfterRenderObserver;
  20551. /**
  20552. * Set a after render callback in the texture.
  20553. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20554. */
  20555. onAfterRender: (faceIndex: number) => void;
  20556. /**
  20557. * An event triggered after the texture clear
  20558. */
  20559. onClearObservable: Observable<Engine>;
  20560. private _onClearObserver;
  20561. /**
  20562. * Set a clear callback in the texture.
  20563. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20564. */
  20565. onClear: (Engine: Engine) => void;
  20566. /**
  20567. * An event triggered when the texture is resized.
  20568. */
  20569. onResizeObservable: Observable<RenderTargetTexture>;
  20570. /**
  20571. * Define the clear color of the Render Target if it should be different from the scene.
  20572. */
  20573. clearColor: Color4;
  20574. protected _size: number | {
  20575. width: number;
  20576. height: number;
  20577. };
  20578. protected _initialSizeParameter: number | {
  20579. width: number;
  20580. height: number;
  20581. } | {
  20582. ratio: number;
  20583. };
  20584. protected _sizeRatio: Nullable<number>;
  20585. /** @hidden */
  20586. _generateMipMaps: boolean;
  20587. protected _renderingManager: RenderingManager;
  20588. /** @hidden */
  20589. _waitingRenderList: string[];
  20590. protected _doNotChangeAspectRatio: boolean;
  20591. protected _currentRefreshId: number;
  20592. protected _refreshRate: number;
  20593. protected _textureMatrix: Matrix;
  20594. protected _samples: number;
  20595. protected _renderTargetOptions: RenderTargetCreationOptions;
  20596. /**
  20597. * Gets render target creation options that were used.
  20598. */
  20599. readonly renderTargetOptions: RenderTargetCreationOptions;
  20600. protected _engine: Engine;
  20601. protected _onRatioRescale(): void;
  20602. /**
  20603. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20604. * It must define where the camera used to render the texture is set
  20605. */
  20606. boundingBoxPosition: Vector3;
  20607. private _boundingBoxSize;
  20608. /**
  20609. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20610. * When defined, the cubemap will switch to local mode
  20611. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20612. * @example https://www.babylonjs-playground.com/#RNASML
  20613. */
  20614. boundingBoxSize: Vector3;
  20615. /**
  20616. * In case the RTT has been created with a depth texture, get the associated
  20617. * depth texture.
  20618. * Otherwise, return null.
  20619. */
  20620. depthStencilTexture: Nullable<InternalTexture>;
  20621. /**
  20622. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20623. * or used a shadow, depth texture...
  20624. * @param name The friendly name of the texture
  20625. * @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)
  20626. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20627. * @param generateMipMaps True if mip maps need to be generated after render.
  20628. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20629. * @param type The type of the buffer in the RTT (int, half float, float...)
  20630. * @param isCube True if a cube texture needs to be created
  20631. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20632. * @param generateDepthBuffer True to generate a depth buffer
  20633. * @param generateStencilBuffer True to generate a stencil buffer
  20634. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20635. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20637. */
  20638. constructor(name: string, size: number | {
  20639. width: number;
  20640. height: number;
  20641. } | {
  20642. ratio: number;
  20643. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20644. /**
  20645. * Creates a depth stencil texture.
  20646. * This is only available in WebGL 2 or with the depth texture extension available.
  20647. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20648. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20649. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20650. */
  20651. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20652. private _processSizeParameter;
  20653. /**
  20654. * Define the number of samples to use in case of MSAA.
  20655. * It defaults to one meaning no MSAA has been enabled.
  20656. */
  20657. samples: number;
  20658. /**
  20659. * Resets the refresh counter of the texture and start bak from scratch.
  20660. * Could be useful to regenerate the texture if it is setup to render only once.
  20661. */
  20662. resetRefreshCounter(): void;
  20663. /**
  20664. * Define the refresh rate of the texture or the rendering frequency.
  20665. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20666. */
  20667. refreshRate: number;
  20668. /**
  20669. * Adds a post process to the render target rendering passes.
  20670. * @param postProcess define the post process to add
  20671. */
  20672. addPostProcess(postProcess: PostProcess): void;
  20673. /**
  20674. * Clear all the post processes attached to the render target
  20675. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20676. */
  20677. clearPostProcesses(dispose?: boolean): void;
  20678. /**
  20679. * Remove one of the post process from the list of attached post processes to the texture
  20680. * @param postProcess define the post process to remove from the list
  20681. */
  20682. removePostProcess(postProcess: PostProcess): void;
  20683. /** @hidden */
  20684. _shouldRender(): boolean;
  20685. /**
  20686. * Gets the actual render size of the texture.
  20687. * @returns the width of the render size
  20688. */
  20689. getRenderSize(): number;
  20690. /**
  20691. * Gets the actual render width of the texture.
  20692. * @returns the width of the render size
  20693. */
  20694. getRenderWidth(): number;
  20695. /**
  20696. * Gets the actual render height of the texture.
  20697. * @returns the height of the render size
  20698. */
  20699. getRenderHeight(): number;
  20700. /**
  20701. * Get if the texture can be rescaled or not.
  20702. */
  20703. readonly canRescale: boolean;
  20704. /**
  20705. * Resize the texture using a ratio.
  20706. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20707. */
  20708. scale(ratio: number): void;
  20709. /**
  20710. * Get the texture reflection matrix used to rotate/transform the reflection.
  20711. * @returns the reflection matrix
  20712. */
  20713. getReflectionTextureMatrix(): Matrix;
  20714. /**
  20715. * Resize the texture to a new desired size.
  20716. * Be carrefull as it will recreate all the data in the new texture.
  20717. * @param size Define the new size. It can be:
  20718. * - a number for squared texture,
  20719. * - an object containing { width: number, height: number }
  20720. * - or an object containing a ratio { ratio: number }
  20721. */
  20722. resize(size: number | {
  20723. width: number;
  20724. height: number;
  20725. } | {
  20726. ratio: number;
  20727. }): void;
  20728. /**
  20729. * Renders all the objects from the render list into the texture.
  20730. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20731. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20732. */
  20733. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20734. private _bestReflectionRenderTargetDimension;
  20735. /**
  20736. * @hidden
  20737. * @param faceIndex face index to bind to if this is a cubetexture
  20738. */
  20739. _bindFrameBuffer(faceIndex?: number): void;
  20740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20741. private renderToTarget;
  20742. /**
  20743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20744. * This allowed control for front to back rendering or reversly depending of the special needs.
  20745. *
  20746. * @param renderingGroupId The rendering group id corresponding to its index
  20747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20750. */
  20751. 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;
  20752. /**
  20753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20754. *
  20755. * @param renderingGroupId The rendering group id corresponding to its index
  20756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20757. */
  20758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20759. /**
  20760. * Clones the texture.
  20761. * @returns the cloned texture
  20762. */
  20763. clone(): RenderTargetTexture;
  20764. /**
  20765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20766. * @returns The JSON representation of the texture
  20767. */
  20768. serialize(): any;
  20769. /**
  20770. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20771. */
  20772. disposeFramebufferObjects(): void;
  20773. /**
  20774. * Dispose the texture and release its associated resources.
  20775. */
  20776. dispose(): void;
  20777. /** @hidden */
  20778. _rebuild(): void;
  20779. /**
  20780. * Clear the info related to rendering groups preventing retention point in material dispose.
  20781. */
  20782. freeRenderingGroups(): void;
  20783. /**
  20784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20785. * @returns the view count
  20786. */
  20787. getViewCount(): number;
  20788. }
  20789. }
  20790. declare module "babylonjs/Materials/material" {
  20791. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20792. import { SmartArray } from "babylonjs/Misc/smartArray";
  20793. import { Observable } from "babylonjs/Misc/observable";
  20794. import { Nullable } from "babylonjs/types";
  20795. import { Scene } from "babylonjs/scene";
  20796. import { Matrix } from "babylonjs/Maths/math.vector";
  20797. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20799. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20800. import { Effect } from "babylonjs/Materials/effect";
  20801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20803. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20804. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20805. import { Mesh } from "babylonjs/Meshes/mesh";
  20806. import { Animation } from "babylonjs/Animations/animation";
  20807. /**
  20808. * Base class for the main features of a material in Babylon.js
  20809. */
  20810. export class Material implements IAnimatable {
  20811. /**
  20812. * Returns the triangle fill mode
  20813. */
  20814. static readonly TriangleFillMode: number;
  20815. /**
  20816. * Returns the wireframe mode
  20817. */
  20818. static readonly WireFrameFillMode: number;
  20819. /**
  20820. * Returns the point fill mode
  20821. */
  20822. static readonly PointFillMode: number;
  20823. /**
  20824. * Returns the point list draw mode
  20825. */
  20826. static readonly PointListDrawMode: number;
  20827. /**
  20828. * Returns the line list draw mode
  20829. */
  20830. static readonly LineListDrawMode: number;
  20831. /**
  20832. * Returns the line loop draw mode
  20833. */
  20834. static readonly LineLoopDrawMode: number;
  20835. /**
  20836. * Returns the line strip draw mode
  20837. */
  20838. static readonly LineStripDrawMode: number;
  20839. /**
  20840. * Returns the triangle strip draw mode
  20841. */
  20842. static readonly TriangleStripDrawMode: number;
  20843. /**
  20844. * Returns the triangle fan draw mode
  20845. */
  20846. static readonly TriangleFanDrawMode: number;
  20847. /**
  20848. * Stores the clock-wise side orientation
  20849. */
  20850. static readonly ClockWiseSideOrientation: number;
  20851. /**
  20852. * Stores the counter clock-wise side orientation
  20853. */
  20854. static readonly CounterClockWiseSideOrientation: number;
  20855. /**
  20856. * The dirty texture flag value
  20857. */
  20858. static readonly TextureDirtyFlag: number;
  20859. /**
  20860. * The dirty light flag value
  20861. */
  20862. static readonly LightDirtyFlag: number;
  20863. /**
  20864. * The dirty fresnel flag value
  20865. */
  20866. static readonly FresnelDirtyFlag: number;
  20867. /**
  20868. * The dirty attribute flag value
  20869. */
  20870. static readonly AttributesDirtyFlag: number;
  20871. /**
  20872. * The dirty misc flag value
  20873. */
  20874. static readonly MiscDirtyFlag: number;
  20875. /**
  20876. * The all dirty flag value
  20877. */
  20878. static readonly AllDirtyFlag: number;
  20879. /**
  20880. * The ID of the material
  20881. */
  20882. id: string;
  20883. /**
  20884. * Gets or sets the unique id of the material
  20885. */
  20886. uniqueId: number;
  20887. /**
  20888. * The name of the material
  20889. */
  20890. name: string;
  20891. /**
  20892. * Gets or sets user defined metadata
  20893. */
  20894. metadata: any;
  20895. /**
  20896. * For internal use only. Please do not use.
  20897. */
  20898. reservedDataStore: any;
  20899. /**
  20900. * Specifies if the ready state should be checked on each call
  20901. */
  20902. checkReadyOnEveryCall: boolean;
  20903. /**
  20904. * Specifies if the ready state should be checked once
  20905. */
  20906. checkReadyOnlyOnce: boolean;
  20907. /**
  20908. * The state of the material
  20909. */
  20910. state: string;
  20911. /**
  20912. * The alpha value of the material
  20913. */
  20914. protected _alpha: number;
  20915. /**
  20916. * List of inspectable custom properties (used by the Inspector)
  20917. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20918. */
  20919. inspectableCustomProperties: IInspectable[];
  20920. /**
  20921. * Sets the alpha value of the material
  20922. */
  20923. /**
  20924. * Gets the alpha value of the material
  20925. */
  20926. alpha: number;
  20927. /**
  20928. * Specifies if back face culling is enabled
  20929. */
  20930. protected _backFaceCulling: boolean;
  20931. /**
  20932. * Sets the back-face culling state
  20933. */
  20934. /**
  20935. * Gets the back-face culling state
  20936. */
  20937. backFaceCulling: boolean;
  20938. /**
  20939. * Stores the value for side orientation
  20940. */
  20941. sideOrientation: number;
  20942. /**
  20943. * Callback triggered when the material is compiled
  20944. */
  20945. onCompiled: Nullable<(effect: Effect) => void>;
  20946. /**
  20947. * Callback triggered when an error occurs
  20948. */
  20949. onError: Nullable<(effect: Effect, errors: string) => void>;
  20950. /**
  20951. * Callback triggered to get the render target textures
  20952. */
  20953. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20954. /**
  20955. * Gets a boolean indicating that current material needs to register RTT
  20956. */
  20957. readonly hasRenderTargetTextures: boolean;
  20958. /**
  20959. * Specifies if the material should be serialized
  20960. */
  20961. doNotSerialize: boolean;
  20962. /**
  20963. * @hidden
  20964. */
  20965. _storeEffectOnSubMeshes: boolean;
  20966. /**
  20967. * Stores the animations for the material
  20968. */
  20969. animations: Nullable<Array<Animation>>;
  20970. /**
  20971. * An event triggered when the material is disposed
  20972. */
  20973. onDisposeObservable: Observable<Material>;
  20974. /**
  20975. * An observer which watches for dispose events
  20976. */
  20977. private _onDisposeObserver;
  20978. private _onUnBindObservable;
  20979. /**
  20980. * Called during a dispose event
  20981. */
  20982. onDispose: () => void;
  20983. private _onBindObservable;
  20984. /**
  20985. * An event triggered when the material is bound
  20986. */
  20987. readonly onBindObservable: Observable<AbstractMesh>;
  20988. /**
  20989. * An observer which watches for bind events
  20990. */
  20991. private _onBindObserver;
  20992. /**
  20993. * Called during a bind event
  20994. */
  20995. onBind: (Mesh: AbstractMesh) => void;
  20996. /**
  20997. * An event triggered when the material is unbound
  20998. */
  20999. readonly onUnBindObservable: Observable<Material>;
  21000. /**
  21001. * Stores the value of the alpha mode
  21002. */
  21003. private _alphaMode;
  21004. /**
  21005. * Sets the value of the alpha mode.
  21006. *
  21007. * | Value | Type | Description |
  21008. * | --- | --- | --- |
  21009. * | 0 | ALPHA_DISABLE | |
  21010. * | 1 | ALPHA_ADD | |
  21011. * | 2 | ALPHA_COMBINE | |
  21012. * | 3 | ALPHA_SUBTRACT | |
  21013. * | 4 | ALPHA_MULTIPLY | |
  21014. * | 5 | ALPHA_MAXIMIZED | |
  21015. * | 6 | ALPHA_ONEONE | |
  21016. * | 7 | ALPHA_PREMULTIPLIED | |
  21017. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21018. * | 9 | ALPHA_INTERPOLATE | |
  21019. * | 10 | ALPHA_SCREENMODE | |
  21020. *
  21021. */
  21022. /**
  21023. * Gets the value of the alpha mode
  21024. */
  21025. alphaMode: number;
  21026. /**
  21027. * Stores the state of the need depth pre-pass value
  21028. */
  21029. private _needDepthPrePass;
  21030. /**
  21031. * Sets the need depth pre-pass value
  21032. */
  21033. /**
  21034. * Gets the depth pre-pass value
  21035. */
  21036. needDepthPrePass: boolean;
  21037. /**
  21038. * Specifies if depth writing should be disabled
  21039. */
  21040. disableDepthWrite: boolean;
  21041. /**
  21042. * Specifies if depth writing should be forced
  21043. */
  21044. forceDepthWrite: boolean;
  21045. /**
  21046. * Specifies if there should be a separate pass for culling
  21047. */
  21048. separateCullingPass: boolean;
  21049. /**
  21050. * Stores the state specifing if fog should be enabled
  21051. */
  21052. private _fogEnabled;
  21053. /**
  21054. * Sets the state for enabling fog
  21055. */
  21056. /**
  21057. * Gets the value of the fog enabled state
  21058. */
  21059. fogEnabled: boolean;
  21060. /**
  21061. * Stores the size of points
  21062. */
  21063. pointSize: number;
  21064. /**
  21065. * Stores the z offset value
  21066. */
  21067. zOffset: number;
  21068. /**
  21069. * Gets a value specifying if wireframe mode is enabled
  21070. */
  21071. /**
  21072. * Sets the state of wireframe mode
  21073. */
  21074. wireframe: boolean;
  21075. /**
  21076. * Gets the value specifying if point clouds are enabled
  21077. */
  21078. /**
  21079. * Sets the state of point cloud mode
  21080. */
  21081. pointsCloud: boolean;
  21082. /**
  21083. * Gets the material fill mode
  21084. */
  21085. /**
  21086. * Sets the material fill mode
  21087. */
  21088. fillMode: number;
  21089. /**
  21090. * @hidden
  21091. * Stores the effects for the material
  21092. */
  21093. _effect: Nullable<Effect>;
  21094. /**
  21095. * @hidden
  21096. * Specifies if the material was previously ready
  21097. */
  21098. _wasPreviouslyReady: boolean;
  21099. /**
  21100. * Specifies if uniform buffers should be used
  21101. */
  21102. private _useUBO;
  21103. /**
  21104. * Stores a reference to the scene
  21105. */
  21106. private _scene;
  21107. /**
  21108. * Stores the fill mode state
  21109. */
  21110. private _fillMode;
  21111. /**
  21112. * Specifies if the depth write state should be cached
  21113. */
  21114. private _cachedDepthWriteState;
  21115. /**
  21116. * Stores the uniform buffer
  21117. */
  21118. protected _uniformBuffer: UniformBuffer;
  21119. /** @hidden */
  21120. _indexInSceneMaterialArray: number;
  21121. /** @hidden */
  21122. meshMap: Nullable<{
  21123. [id: string]: AbstractMesh | undefined;
  21124. }>;
  21125. /**
  21126. * Creates a material instance
  21127. * @param name defines the name of the material
  21128. * @param scene defines the scene to reference
  21129. * @param doNotAdd specifies if the material should be added to the scene
  21130. */
  21131. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21132. /**
  21133. * Returns a string representation of the current material
  21134. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21135. * @returns a string with material information
  21136. */
  21137. toString(fullDetails?: boolean): string;
  21138. /**
  21139. * Gets the class name of the material
  21140. * @returns a string with the class name of the material
  21141. */
  21142. getClassName(): string;
  21143. /**
  21144. * Specifies if updates for the material been locked
  21145. */
  21146. readonly isFrozen: boolean;
  21147. /**
  21148. * Locks updates for the material
  21149. */
  21150. freeze(): void;
  21151. /**
  21152. * Unlocks updates for the material
  21153. */
  21154. unfreeze(): void;
  21155. /**
  21156. * Specifies if the material is ready to be used
  21157. * @param mesh defines the mesh to check
  21158. * @param useInstances specifies if instances should be used
  21159. * @returns a boolean indicating if the material is ready to be used
  21160. */
  21161. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21162. /**
  21163. * Specifies that the submesh is ready to be used
  21164. * @param mesh defines the mesh to check
  21165. * @param subMesh defines which submesh to check
  21166. * @param useInstances specifies that instances should be used
  21167. * @returns a boolean indicating that the submesh is ready or not
  21168. */
  21169. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21170. /**
  21171. * Returns the material effect
  21172. * @returns the effect associated with the material
  21173. */
  21174. getEffect(): Nullable<Effect>;
  21175. /**
  21176. * Returns the current scene
  21177. * @returns a Scene
  21178. */
  21179. getScene(): Scene;
  21180. /**
  21181. * Specifies if the material will require alpha blending
  21182. * @returns a boolean specifying if alpha blending is needed
  21183. */
  21184. needAlphaBlending(): boolean;
  21185. /**
  21186. * Specifies if the mesh will require alpha blending
  21187. * @param mesh defines the mesh to check
  21188. * @returns a boolean specifying if alpha blending is needed for the mesh
  21189. */
  21190. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21191. /**
  21192. * Specifies if this material should be rendered in alpha test mode
  21193. * @returns a boolean specifying if an alpha test is needed.
  21194. */
  21195. needAlphaTesting(): boolean;
  21196. /**
  21197. * Gets the texture used for the alpha test
  21198. * @returns the texture to use for alpha testing
  21199. */
  21200. getAlphaTestTexture(): Nullable<BaseTexture>;
  21201. /**
  21202. * Marks the material to indicate that it needs to be re-calculated
  21203. */
  21204. markDirty(): void;
  21205. /** @hidden */
  21206. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21207. /**
  21208. * Binds the material to the mesh
  21209. * @param world defines the world transformation matrix
  21210. * @param mesh defines the mesh to bind the material to
  21211. */
  21212. bind(world: Matrix, mesh?: Mesh): void;
  21213. /**
  21214. * Binds the submesh to the material
  21215. * @param world defines the world transformation matrix
  21216. * @param mesh defines the mesh containing the submesh
  21217. * @param subMesh defines the submesh to bind the material to
  21218. */
  21219. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21220. /**
  21221. * Binds the world matrix to the material
  21222. * @param world defines the world transformation matrix
  21223. */
  21224. bindOnlyWorldMatrix(world: Matrix): void;
  21225. /**
  21226. * Binds the scene's uniform buffer to the effect.
  21227. * @param effect defines the effect to bind to the scene uniform buffer
  21228. * @param sceneUbo defines the uniform buffer storing scene data
  21229. */
  21230. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21231. /**
  21232. * Binds the view matrix to the effect
  21233. * @param effect defines the effect to bind the view matrix to
  21234. */
  21235. bindView(effect: Effect): void;
  21236. /**
  21237. * Binds the view projection matrix to the effect
  21238. * @param effect defines the effect to bind the view projection matrix to
  21239. */
  21240. bindViewProjection(effect: Effect): void;
  21241. /**
  21242. * Specifies if material alpha testing should be turned on for the mesh
  21243. * @param mesh defines the mesh to check
  21244. */
  21245. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21246. /**
  21247. * Processes to execute after binding the material to a mesh
  21248. * @param mesh defines the rendered mesh
  21249. */
  21250. protected _afterBind(mesh?: Mesh): void;
  21251. /**
  21252. * Unbinds the material from the mesh
  21253. */
  21254. unbind(): void;
  21255. /**
  21256. * Gets the active textures from the material
  21257. * @returns an array of textures
  21258. */
  21259. getActiveTextures(): BaseTexture[];
  21260. /**
  21261. * Specifies if the material uses a texture
  21262. * @param texture defines the texture to check against the material
  21263. * @returns a boolean specifying if the material uses the texture
  21264. */
  21265. hasTexture(texture: BaseTexture): boolean;
  21266. /**
  21267. * Makes a duplicate of the material, and gives it a new name
  21268. * @param name defines the new name for the duplicated material
  21269. * @returns the cloned material
  21270. */
  21271. clone(name: string): Nullable<Material>;
  21272. /**
  21273. * Gets the meshes bound to the material
  21274. * @returns an array of meshes bound to the material
  21275. */
  21276. getBindedMeshes(): AbstractMesh[];
  21277. /**
  21278. * Force shader compilation
  21279. * @param mesh defines the mesh associated with this material
  21280. * @param onCompiled defines a function to execute once the material is compiled
  21281. * @param options defines the options to configure the compilation
  21282. */
  21283. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21284. clipPlane: boolean;
  21285. }>): void;
  21286. /**
  21287. * Force shader compilation
  21288. * @param mesh defines the mesh that will use this material
  21289. * @param options defines additional options for compiling the shaders
  21290. * @returns a promise that resolves when the compilation completes
  21291. */
  21292. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21293. clipPlane: boolean;
  21294. }>): Promise<void>;
  21295. private static readonly _AllDirtyCallBack;
  21296. private static readonly _ImageProcessingDirtyCallBack;
  21297. private static readonly _TextureDirtyCallBack;
  21298. private static readonly _FresnelDirtyCallBack;
  21299. private static readonly _MiscDirtyCallBack;
  21300. private static readonly _LightsDirtyCallBack;
  21301. private static readonly _AttributeDirtyCallBack;
  21302. private static _FresnelAndMiscDirtyCallBack;
  21303. private static _TextureAndMiscDirtyCallBack;
  21304. private static readonly _DirtyCallbackArray;
  21305. private static readonly _RunDirtyCallBacks;
  21306. /**
  21307. * Marks a define in the material to indicate that it needs to be re-computed
  21308. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21309. */
  21310. markAsDirty(flag: number): void;
  21311. /**
  21312. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21313. * @param func defines a function which checks material defines against the submeshes
  21314. */
  21315. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21316. /**
  21317. * Indicates that we need to re-calculated for all submeshes
  21318. */
  21319. protected _markAllSubMeshesAsAllDirty(): void;
  21320. /**
  21321. * Indicates that image processing needs to be re-calculated for all submeshes
  21322. */
  21323. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21324. /**
  21325. * Indicates that textures need to be re-calculated for all submeshes
  21326. */
  21327. protected _markAllSubMeshesAsTexturesDirty(): void;
  21328. /**
  21329. * Indicates that fresnel needs to be re-calculated for all submeshes
  21330. */
  21331. protected _markAllSubMeshesAsFresnelDirty(): void;
  21332. /**
  21333. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21334. */
  21335. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21336. /**
  21337. * Indicates that lights need to be re-calculated for all submeshes
  21338. */
  21339. protected _markAllSubMeshesAsLightsDirty(): void;
  21340. /**
  21341. * Indicates that attributes need to be re-calculated for all submeshes
  21342. */
  21343. protected _markAllSubMeshesAsAttributesDirty(): void;
  21344. /**
  21345. * Indicates that misc needs to be re-calculated for all submeshes
  21346. */
  21347. protected _markAllSubMeshesAsMiscDirty(): void;
  21348. /**
  21349. * Indicates that textures and misc need to be re-calculated for all submeshes
  21350. */
  21351. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21352. /**
  21353. * Disposes the material
  21354. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21355. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21356. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21357. */
  21358. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21359. /** @hidden */
  21360. private releaseVertexArrayObject;
  21361. /**
  21362. * Serializes this material
  21363. * @returns the serialized material object
  21364. */
  21365. serialize(): any;
  21366. /**
  21367. * Creates a material from parsed material data
  21368. * @param parsedMaterial defines parsed material data
  21369. * @param scene defines the hosting scene
  21370. * @param rootUrl defines the root URL to use to load textures
  21371. * @returns a new material
  21372. */
  21373. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21374. }
  21375. }
  21376. declare module "babylonjs/Materials/multiMaterial" {
  21377. import { Nullable } from "babylonjs/types";
  21378. import { Scene } from "babylonjs/scene";
  21379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21380. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21382. import { Material } from "babylonjs/Materials/material";
  21383. /**
  21384. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21385. * separate meshes. This can be use to improve performances.
  21386. * @see http://doc.babylonjs.com/how_to/multi_materials
  21387. */
  21388. export class MultiMaterial extends Material {
  21389. private _subMaterials;
  21390. /**
  21391. * Gets or Sets the list of Materials used within the multi material.
  21392. * They need to be ordered according to the submeshes order in the associated mesh
  21393. */
  21394. subMaterials: Nullable<Material>[];
  21395. /**
  21396. * Function used to align with Node.getChildren()
  21397. * @returns the list of Materials used within the multi material
  21398. */
  21399. getChildren(): Nullable<Material>[];
  21400. /**
  21401. * Instantiates a new Multi Material
  21402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21403. * separate meshes. This can be use to improve performances.
  21404. * @see http://doc.babylonjs.com/how_to/multi_materials
  21405. * @param name Define the name in the scene
  21406. * @param scene Define the scene the material belongs to
  21407. */
  21408. constructor(name: string, scene: Scene);
  21409. private _hookArray;
  21410. /**
  21411. * Get one of the submaterial by its index in the submaterials array
  21412. * @param index The index to look the sub material at
  21413. * @returns The Material if the index has been defined
  21414. */
  21415. getSubMaterial(index: number): Nullable<Material>;
  21416. /**
  21417. * Get the list of active textures for the whole sub materials list.
  21418. * @returns All the textures that will be used during the rendering
  21419. */
  21420. getActiveTextures(): BaseTexture[];
  21421. /**
  21422. * Gets the current class name of the material e.g. "MultiMaterial"
  21423. * Mainly use in serialization.
  21424. * @returns the class name
  21425. */
  21426. getClassName(): string;
  21427. /**
  21428. * Checks if the material is ready to render the requested sub mesh
  21429. * @param mesh Define the mesh the submesh belongs to
  21430. * @param subMesh Define the sub mesh to look readyness for
  21431. * @param useInstances Define whether or not the material is used with instances
  21432. * @returns true if ready, otherwise false
  21433. */
  21434. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21435. /**
  21436. * Clones the current material and its related sub materials
  21437. * @param name Define the name of the newly cloned material
  21438. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21439. * @returns the cloned material
  21440. */
  21441. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21442. /**
  21443. * Serializes the materials into a JSON representation.
  21444. * @returns the JSON representation
  21445. */
  21446. serialize(): any;
  21447. /**
  21448. * Dispose the material and release its associated resources
  21449. * @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)
  21450. * @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)
  21451. * @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)
  21452. */
  21453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21454. /**
  21455. * Creates a MultiMaterial from parsed MultiMaterial data.
  21456. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21457. * @param scene defines the hosting scene
  21458. * @returns a new MultiMaterial
  21459. */
  21460. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21461. }
  21462. }
  21463. declare module "babylonjs/Meshes/subMesh" {
  21464. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21465. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21466. import { Engine } from "babylonjs/Engines/engine";
  21467. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21468. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21469. import { Effect } from "babylonjs/Materials/effect";
  21470. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21471. import { Plane } from "babylonjs/Maths/math.plane";
  21472. import { Collider } from "babylonjs/Collisions/collider";
  21473. import { Material } from "babylonjs/Materials/material";
  21474. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21476. import { Mesh } from "babylonjs/Meshes/mesh";
  21477. import { Ray } from "babylonjs/Culling/ray";
  21478. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21479. /**
  21480. * Base class for submeshes
  21481. */
  21482. export class BaseSubMesh {
  21483. /** @hidden */
  21484. _materialDefines: Nullable<MaterialDefines>;
  21485. /** @hidden */
  21486. _materialEffect: Nullable<Effect>;
  21487. /**
  21488. * Gets associated effect
  21489. */
  21490. readonly effect: Nullable<Effect>;
  21491. /**
  21492. * Sets associated effect (effect used to render this submesh)
  21493. * @param effect defines the effect to associate with
  21494. * @param defines defines the set of defines used to compile this effect
  21495. */
  21496. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21497. }
  21498. /**
  21499. * Defines a subdivision inside a mesh
  21500. */
  21501. export class SubMesh extends BaseSubMesh implements ICullable {
  21502. /** the material index to use */
  21503. materialIndex: number;
  21504. /** vertex index start */
  21505. verticesStart: number;
  21506. /** vertices count */
  21507. verticesCount: number;
  21508. /** index start */
  21509. indexStart: number;
  21510. /** indices count */
  21511. indexCount: number;
  21512. /** @hidden */
  21513. _linesIndexCount: number;
  21514. private _mesh;
  21515. private _renderingMesh;
  21516. private _boundingInfo;
  21517. private _linesIndexBuffer;
  21518. /** @hidden */
  21519. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21520. /** @hidden */
  21521. _trianglePlanes: Plane[];
  21522. /** @hidden */
  21523. _lastColliderTransformMatrix: Nullable<Matrix>;
  21524. /** @hidden */
  21525. _renderId: number;
  21526. /** @hidden */
  21527. _alphaIndex: number;
  21528. /** @hidden */
  21529. _distanceToCamera: number;
  21530. /** @hidden */
  21531. _id: number;
  21532. private _currentMaterial;
  21533. /**
  21534. * Add a new submesh to a mesh
  21535. * @param materialIndex defines the material index to use
  21536. * @param verticesStart defines vertex index start
  21537. * @param verticesCount defines vertices count
  21538. * @param indexStart defines index start
  21539. * @param indexCount defines indices count
  21540. * @param mesh defines the parent mesh
  21541. * @param renderingMesh defines an optional rendering mesh
  21542. * @param createBoundingBox defines if bounding box should be created for this submesh
  21543. * @returns the new submesh
  21544. */
  21545. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21546. /**
  21547. * Creates a new submesh
  21548. * @param materialIndex defines the material index to use
  21549. * @param verticesStart defines vertex index start
  21550. * @param verticesCount defines vertices count
  21551. * @param indexStart defines index start
  21552. * @param indexCount defines indices count
  21553. * @param mesh defines the parent mesh
  21554. * @param renderingMesh defines an optional rendering mesh
  21555. * @param createBoundingBox defines if bounding box should be created for this submesh
  21556. */
  21557. constructor(
  21558. /** the material index to use */
  21559. materialIndex: number,
  21560. /** vertex index start */
  21561. verticesStart: number,
  21562. /** vertices count */
  21563. verticesCount: number,
  21564. /** index start */
  21565. indexStart: number,
  21566. /** indices count */
  21567. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21568. /**
  21569. * Returns true if this submesh covers the entire parent mesh
  21570. * @ignorenaming
  21571. */
  21572. readonly IsGlobal: boolean;
  21573. /**
  21574. * Returns the submesh BoudingInfo object
  21575. * @returns current bounding info (or mesh's one if the submesh is global)
  21576. */
  21577. getBoundingInfo(): BoundingInfo;
  21578. /**
  21579. * Sets the submesh BoundingInfo
  21580. * @param boundingInfo defines the new bounding info to use
  21581. * @returns the SubMesh
  21582. */
  21583. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21584. /**
  21585. * Returns the mesh of the current submesh
  21586. * @return the parent mesh
  21587. */
  21588. getMesh(): AbstractMesh;
  21589. /**
  21590. * Returns the rendering mesh of the submesh
  21591. * @returns the rendering mesh (could be different from parent mesh)
  21592. */
  21593. getRenderingMesh(): Mesh;
  21594. /**
  21595. * Returns the submesh material
  21596. * @returns null or the current material
  21597. */
  21598. getMaterial(): Nullable<Material>;
  21599. /**
  21600. * Sets a new updated BoundingInfo object to the submesh
  21601. * @param data defines an optional position array to use to determine the bounding info
  21602. * @returns the SubMesh
  21603. */
  21604. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21605. /** @hidden */
  21606. _checkCollision(collider: Collider): boolean;
  21607. /**
  21608. * Updates the submesh BoundingInfo
  21609. * @param world defines the world matrix to use to update the bounding info
  21610. * @returns the submesh
  21611. */
  21612. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21613. /**
  21614. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21615. * @param frustumPlanes defines the frustum planes
  21616. * @returns true if the submesh is intersecting with the frustum
  21617. */
  21618. isInFrustum(frustumPlanes: Plane[]): boolean;
  21619. /**
  21620. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21621. * @param frustumPlanes defines the frustum planes
  21622. * @returns true if the submesh is inside the frustum
  21623. */
  21624. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21625. /**
  21626. * Renders the submesh
  21627. * @param enableAlphaMode defines if alpha needs to be used
  21628. * @returns the submesh
  21629. */
  21630. render(enableAlphaMode: boolean): SubMesh;
  21631. /**
  21632. * @hidden
  21633. */
  21634. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21635. /**
  21636. * Checks if the submesh intersects with a ray
  21637. * @param ray defines the ray to test
  21638. * @returns true is the passed ray intersects the submesh bounding box
  21639. */
  21640. canIntersects(ray: Ray): boolean;
  21641. /**
  21642. * Intersects current submesh with a ray
  21643. * @param ray defines the ray to test
  21644. * @param positions defines mesh's positions array
  21645. * @param indices defines mesh's indices array
  21646. * @param fastCheck defines if only bounding info should be used
  21647. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21648. * @returns intersection info or null if no intersection
  21649. */
  21650. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21651. /** @hidden */
  21652. private _intersectLines;
  21653. /** @hidden */
  21654. private _intersectUnIndexedLines;
  21655. /** @hidden */
  21656. private _intersectTriangles;
  21657. /** @hidden */
  21658. private _intersectUnIndexedTriangles;
  21659. /** @hidden */
  21660. _rebuild(): void;
  21661. /**
  21662. * Creates a new submesh from the passed mesh
  21663. * @param newMesh defines the new hosting mesh
  21664. * @param newRenderingMesh defines an optional rendering mesh
  21665. * @returns the new submesh
  21666. */
  21667. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21668. /**
  21669. * Release associated resources
  21670. */
  21671. dispose(): void;
  21672. /**
  21673. * Gets the class name
  21674. * @returns the string "SubMesh".
  21675. */
  21676. getClassName(): string;
  21677. /**
  21678. * Creates a new submesh from indices data
  21679. * @param materialIndex the index of the main mesh material
  21680. * @param startIndex the index where to start the copy in the mesh indices array
  21681. * @param indexCount the number of indices to copy then from the startIndex
  21682. * @param mesh the main mesh to create the submesh from
  21683. * @param renderingMesh the optional rendering mesh
  21684. * @returns a new submesh
  21685. */
  21686. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21687. }
  21688. }
  21689. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21690. /**
  21691. * Class used to represent data loading progression
  21692. */
  21693. export class SceneLoaderFlags {
  21694. private static _ForceFullSceneLoadingForIncremental;
  21695. private static _ShowLoadingScreen;
  21696. private static _CleanBoneMatrixWeights;
  21697. private static _loggingLevel;
  21698. /**
  21699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21700. */
  21701. static ForceFullSceneLoadingForIncremental: boolean;
  21702. /**
  21703. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21704. */
  21705. static ShowLoadingScreen: boolean;
  21706. /**
  21707. * Defines the current logging level (while loading the scene)
  21708. * @ignorenaming
  21709. */
  21710. static loggingLevel: number;
  21711. /**
  21712. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21713. */
  21714. static CleanBoneMatrixWeights: boolean;
  21715. }
  21716. }
  21717. declare module "babylonjs/Meshes/geometry" {
  21718. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21719. import { Scene } from "babylonjs/scene";
  21720. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21721. import { Engine } from "babylonjs/Engines/engine";
  21722. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21723. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21724. import { Effect } from "babylonjs/Materials/effect";
  21725. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21726. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21727. import { Mesh } from "babylonjs/Meshes/mesh";
  21728. /**
  21729. * Class used to store geometry data (vertex buffers + index buffer)
  21730. */
  21731. export class Geometry implements IGetSetVerticesData {
  21732. /**
  21733. * Gets or sets the ID of the geometry
  21734. */
  21735. id: string;
  21736. /**
  21737. * Gets or sets the unique ID of the geometry
  21738. */
  21739. uniqueId: number;
  21740. /**
  21741. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21742. */
  21743. delayLoadState: number;
  21744. /**
  21745. * Gets the file containing the data to load when running in delay load state
  21746. */
  21747. delayLoadingFile: Nullable<string>;
  21748. /**
  21749. * Callback called when the geometry is updated
  21750. */
  21751. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21752. private _scene;
  21753. private _engine;
  21754. private _meshes;
  21755. private _totalVertices;
  21756. /** @hidden */
  21757. _indices: IndicesArray;
  21758. /** @hidden */
  21759. _vertexBuffers: {
  21760. [key: string]: VertexBuffer;
  21761. };
  21762. private _isDisposed;
  21763. private _extend;
  21764. private _boundingBias;
  21765. /** @hidden */
  21766. _delayInfo: Array<string>;
  21767. private _indexBuffer;
  21768. private _indexBufferIsUpdatable;
  21769. /** @hidden */
  21770. _boundingInfo: Nullable<BoundingInfo>;
  21771. /** @hidden */
  21772. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21773. /** @hidden */
  21774. _softwareSkinningFrameId: number;
  21775. private _vertexArrayObjects;
  21776. private _updatable;
  21777. /** @hidden */
  21778. _positions: Nullable<Vector3[]>;
  21779. /**
  21780. * 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
  21781. */
  21782. /**
  21783. * 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
  21784. */
  21785. boundingBias: Vector2;
  21786. /**
  21787. * Static function used to attach a new empty geometry to a mesh
  21788. * @param mesh defines the mesh to attach the geometry to
  21789. * @returns the new Geometry
  21790. */
  21791. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21792. /**
  21793. * Creates a new geometry
  21794. * @param id defines the unique ID
  21795. * @param scene defines the hosting scene
  21796. * @param vertexData defines the VertexData used to get geometry data
  21797. * @param updatable defines if geometry must be updatable (false by default)
  21798. * @param mesh defines the mesh that will be associated with the geometry
  21799. */
  21800. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21801. /**
  21802. * Gets the current extend of the geometry
  21803. */
  21804. readonly extend: {
  21805. minimum: Vector3;
  21806. maximum: Vector3;
  21807. };
  21808. /**
  21809. * Gets the hosting scene
  21810. * @returns the hosting Scene
  21811. */
  21812. getScene(): Scene;
  21813. /**
  21814. * Gets the hosting engine
  21815. * @returns the hosting Engine
  21816. */
  21817. getEngine(): Engine;
  21818. /**
  21819. * Defines if the geometry is ready to use
  21820. * @returns true if the geometry is ready to be used
  21821. */
  21822. isReady(): boolean;
  21823. /**
  21824. * Gets a value indicating that the geometry should not be serialized
  21825. */
  21826. readonly doNotSerialize: boolean;
  21827. /** @hidden */
  21828. _rebuild(): void;
  21829. /**
  21830. * Affects all geometry data in one call
  21831. * @param vertexData defines the geometry data
  21832. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21833. */
  21834. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21835. /**
  21836. * Set specific vertex data
  21837. * @param kind defines the data kind (Position, normal, etc...)
  21838. * @param data defines the vertex data to use
  21839. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21840. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21841. */
  21842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21843. /**
  21844. * Removes a specific vertex data
  21845. * @param kind defines the data kind (Position, normal, etc...)
  21846. */
  21847. removeVerticesData(kind: string): void;
  21848. /**
  21849. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21850. * @param buffer defines the vertex buffer to use
  21851. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21852. */
  21853. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21854. /**
  21855. * Update a specific vertex buffer
  21856. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21857. * It will do nothing if the buffer is not updatable
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param data defines the data to use
  21860. * @param offset defines the offset in the target buffer where to store the data
  21861. * @param useBytes set to true if the offset is in bytes
  21862. */
  21863. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21864. /**
  21865. * Update a specific vertex buffer
  21866. * This function will create a new buffer if the current one is not updatable
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. * @param data defines the data to use
  21869. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21870. */
  21871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21872. private _updateBoundingInfo;
  21873. /** @hidden */
  21874. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21875. /**
  21876. * Gets total number of vertices
  21877. * @returns the total number of vertices
  21878. */
  21879. getTotalVertices(): number;
  21880. /**
  21881. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21882. * @param kind defines the data kind (Position, normal, etc...)
  21883. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21885. * @returns a float array containing vertex data
  21886. */
  21887. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21888. /**
  21889. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21890. * @param kind defines the data kind (Position, normal, etc...)
  21891. * @returns true if the vertex buffer with the specified kind is updatable
  21892. */
  21893. isVertexBufferUpdatable(kind: string): boolean;
  21894. /**
  21895. * Gets a specific vertex buffer
  21896. * @param kind defines the data kind (Position, normal, etc...)
  21897. * @returns a VertexBuffer
  21898. */
  21899. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21900. /**
  21901. * Returns all vertex buffers
  21902. * @return an object holding all vertex buffers indexed by kind
  21903. */
  21904. getVertexBuffers(): Nullable<{
  21905. [key: string]: VertexBuffer;
  21906. }>;
  21907. /**
  21908. * Gets a boolean indicating if specific vertex buffer is present
  21909. * @param kind defines the data kind (Position, normal, etc...)
  21910. * @returns true if data is present
  21911. */
  21912. isVerticesDataPresent(kind: string): boolean;
  21913. /**
  21914. * Gets a list of all attached data kinds (Position, normal, etc...)
  21915. * @returns a list of string containing all kinds
  21916. */
  21917. getVerticesDataKinds(): string[];
  21918. /**
  21919. * Update index buffer
  21920. * @param indices defines the indices to store in the index buffer
  21921. * @param offset defines the offset in the target buffer where to store the data
  21922. * @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)
  21923. */
  21924. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21925. /**
  21926. * Creates a new index buffer
  21927. * @param indices defines the indices to store in the index buffer
  21928. * @param totalVertices defines the total number of vertices (could be null)
  21929. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21930. */
  21931. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21932. /**
  21933. * Return the total number of indices
  21934. * @returns the total number of indices
  21935. */
  21936. getTotalIndices(): number;
  21937. /**
  21938. * Gets the index buffer array
  21939. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21940. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21941. * @returns the index buffer array
  21942. */
  21943. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21944. /**
  21945. * Gets the index buffer
  21946. * @return the index buffer
  21947. */
  21948. getIndexBuffer(): Nullable<DataBuffer>;
  21949. /** @hidden */
  21950. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21951. /**
  21952. * Release the associated resources for a specific mesh
  21953. * @param mesh defines the source mesh
  21954. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21955. */
  21956. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21957. /**
  21958. * Apply current geometry to a given mesh
  21959. * @param mesh defines the mesh to apply geometry to
  21960. */
  21961. applyToMesh(mesh: Mesh): void;
  21962. private _updateExtend;
  21963. private _applyToMesh;
  21964. private notifyUpdate;
  21965. /**
  21966. * Load the geometry if it was flagged as delay loaded
  21967. * @param scene defines the hosting scene
  21968. * @param onLoaded defines a callback called when the geometry is loaded
  21969. */
  21970. load(scene: Scene, onLoaded?: () => void): void;
  21971. private _queueLoad;
  21972. /**
  21973. * Invert the geometry to move from a right handed system to a left handed one.
  21974. */
  21975. toLeftHanded(): void;
  21976. /** @hidden */
  21977. _resetPointsArrayCache(): void;
  21978. /** @hidden */
  21979. _generatePointsArray(): boolean;
  21980. /**
  21981. * Gets a value indicating if the geometry is disposed
  21982. * @returns true if the geometry was disposed
  21983. */
  21984. isDisposed(): boolean;
  21985. private _disposeVertexArrayObjects;
  21986. /**
  21987. * Free all associated resources
  21988. */
  21989. dispose(): void;
  21990. /**
  21991. * Clone the current geometry into a new geometry
  21992. * @param id defines the unique ID of the new geometry
  21993. * @returns a new geometry object
  21994. */
  21995. copy(id: string): Geometry;
  21996. /**
  21997. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21998. * @return a JSON representation of the current geometry data (without the vertices data)
  21999. */
  22000. serialize(): any;
  22001. private toNumberArray;
  22002. /**
  22003. * Serialize all vertices data into a JSON oject
  22004. * @returns a JSON representation of the current geometry data
  22005. */
  22006. serializeVerticeData(): any;
  22007. /**
  22008. * Extracts a clone of a mesh geometry
  22009. * @param mesh defines the source mesh
  22010. * @param id defines the unique ID of the new geometry object
  22011. * @returns the new geometry object
  22012. */
  22013. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22014. /**
  22015. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22016. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22017. * Be aware Math.random() could cause collisions, but:
  22018. * "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"
  22019. * @returns a string containing a new GUID
  22020. */
  22021. static RandomId(): string;
  22022. /** @hidden */
  22023. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22024. private static _CleanMatricesWeights;
  22025. /**
  22026. * Create a new geometry from persisted data (Using .babylon file format)
  22027. * @param parsedVertexData defines the persisted data
  22028. * @param scene defines the hosting scene
  22029. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22030. * @returns the new geometry object
  22031. */
  22032. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22033. }
  22034. }
  22035. declare module "babylonjs/Meshes/mesh.vertexData" {
  22036. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22037. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22038. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22039. import { Geometry } from "babylonjs/Meshes/geometry";
  22040. import { Mesh } from "babylonjs/Meshes/mesh";
  22041. /**
  22042. * Define an interface for all classes that will get and set the data on vertices
  22043. */
  22044. export interface IGetSetVerticesData {
  22045. /**
  22046. * Gets a boolean indicating if specific vertex data is present
  22047. * @param kind defines the vertex data kind to use
  22048. * @returns true is data kind is present
  22049. */
  22050. isVerticesDataPresent(kind: string): boolean;
  22051. /**
  22052. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22055. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22056. * @returns a float array containing vertex data
  22057. */
  22058. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22059. /**
  22060. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22061. * @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.
  22062. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22063. * @returns the indices array or an empty array if the mesh has no geometry
  22064. */
  22065. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22066. /**
  22067. * Set specific vertex data
  22068. * @param kind defines the data kind (Position, normal, etc...)
  22069. * @param data defines the vertex data to use
  22070. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22071. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22072. */
  22073. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22074. /**
  22075. * Update a specific associated vertex buffer
  22076. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22077. * - VertexBuffer.PositionKind
  22078. * - VertexBuffer.UVKind
  22079. * - VertexBuffer.UV2Kind
  22080. * - VertexBuffer.UV3Kind
  22081. * - VertexBuffer.UV4Kind
  22082. * - VertexBuffer.UV5Kind
  22083. * - VertexBuffer.UV6Kind
  22084. * - VertexBuffer.ColorKind
  22085. * - VertexBuffer.MatricesIndicesKind
  22086. * - VertexBuffer.MatricesIndicesExtraKind
  22087. * - VertexBuffer.MatricesWeightsKind
  22088. * - VertexBuffer.MatricesWeightsExtraKind
  22089. * @param data defines the data source
  22090. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22091. * @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)
  22092. */
  22093. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22094. /**
  22095. * Creates a new index buffer
  22096. * @param indices defines the indices to store in the index buffer
  22097. * @param totalVertices defines the total number of vertices (could be null)
  22098. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22099. */
  22100. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22101. }
  22102. /**
  22103. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22104. */
  22105. export class VertexData {
  22106. /**
  22107. * Mesh side orientation : usually the external or front surface
  22108. */
  22109. static readonly FRONTSIDE: number;
  22110. /**
  22111. * Mesh side orientation : usually the internal or back surface
  22112. */
  22113. static readonly BACKSIDE: number;
  22114. /**
  22115. * Mesh side orientation : both internal and external or front and back surfaces
  22116. */
  22117. static readonly DOUBLESIDE: number;
  22118. /**
  22119. * Mesh side orientation : by default, `FRONTSIDE`
  22120. */
  22121. static readonly DEFAULTSIDE: number;
  22122. /**
  22123. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22124. */
  22125. positions: Nullable<FloatArray>;
  22126. /**
  22127. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22128. */
  22129. normals: Nullable<FloatArray>;
  22130. /**
  22131. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22132. */
  22133. tangents: Nullable<FloatArray>;
  22134. /**
  22135. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22136. */
  22137. uvs: Nullable<FloatArray>;
  22138. /**
  22139. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22140. */
  22141. uvs2: Nullable<FloatArray>;
  22142. /**
  22143. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22144. */
  22145. uvs3: Nullable<FloatArray>;
  22146. /**
  22147. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22148. */
  22149. uvs4: Nullable<FloatArray>;
  22150. /**
  22151. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22152. */
  22153. uvs5: Nullable<FloatArray>;
  22154. /**
  22155. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22156. */
  22157. uvs6: Nullable<FloatArray>;
  22158. /**
  22159. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22160. */
  22161. colors: Nullable<FloatArray>;
  22162. /**
  22163. * 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).
  22164. */
  22165. matricesIndices: Nullable<FloatArray>;
  22166. /**
  22167. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22168. */
  22169. matricesWeights: Nullable<FloatArray>;
  22170. /**
  22171. * An array extending the number of possible indices
  22172. */
  22173. matricesIndicesExtra: Nullable<FloatArray>;
  22174. /**
  22175. * An array extending the number of possible weights when the number of indices is extended
  22176. */
  22177. matricesWeightsExtra: Nullable<FloatArray>;
  22178. /**
  22179. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22180. */
  22181. indices: Nullable<IndicesArray>;
  22182. /**
  22183. * Uses the passed data array to set the set the values for the specified kind of data
  22184. * @param data a linear array of floating numbers
  22185. * @param kind the type of data that is being set, eg positions, colors etc
  22186. */
  22187. set(data: FloatArray, kind: string): void;
  22188. /**
  22189. * Associates the vertexData to the passed Mesh.
  22190. * Sets it as updatable or not (default `false`)
  22191. * @param mesh the mesh the vertexData is applied to
  22192. * @param updatable when used and having the value true allows new data to update the vertexData
  22193. * @returns the VertexData
  22194. */
  22195. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22196. /**
  22197. * Associates the vertexData to the passed Geometry.
  22198. * Sets it as updatable or not (default `false`)
  22199. * @param geometry the geometry the vertexData is applied to
  22200. * @param updatable when used and having the value true allows new data to update the vertexData
  22201. * @returns VertexData
  22202. */
  22203. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22204. /**
  22205. * Updates the associated mesh
  22206. * @param mesh the mesh to be updated
  22207. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22208. * @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
  22209. * @returns VertexData
  22210. */
  22211. updateMesh(mesh: Mesh): VertexData;
  22212. /**
  22213. * Updates the associated geometry
  22214. * @param geometry the geometry to be updated
  22215. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22216. * @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
  22217. * @returns VertexData.
  22218. */
  22219. updateGeometry(geometry: Geometry): VertexData;
  22220. private _applyTo;
  22221. private _update;
  22222. /**
  22223. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22224. * @param matrix the transforming matrix
  22225. * @returns the VertexData
  22226. */
  22227. transform(matrix: Matrix): VertexData;
  22228. /**
  22229. * Merges the passed VertexData into the current one
  22230. * @param other the VertexData to be merged into the current one
  22231. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22232. * @returns the modified VertexData
  22233. */
  22234. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22235. private _mergeElement;
  22236. private _validate;
  22237. /**
  22238. * Serializes the VertexData
  22239. * @returns a serialized object
  22240. */
  22241. serialize(): any;
  22242. /**
  22243. * Extracts the vertexData from a mesh
  22244. * @param mesh the mesh from which to extract the VertexData
  22245. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22246. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22247. * @returns the object VertexData associated to the passed mesh
  22248. */
  22249. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22250. /**
  22251. * Extracts the vertexData from the geometry
  22252. * @param geometry the geometry from which to extract the VertexData
  22253. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22254. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22255. * @returns the object VertexData associated to the passed mesh
  22256. */
  22257. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22258. private static _ExtractFrom;
  22259. /**
  22260. * Creates the VertexData for a Ribbon
  22261. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22262. * * pathArray array of paths, each of which an array of successive Vector3
  22263. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22264. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22265. * * 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
  22266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22270. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22271. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22272. * @returns the VertexData of the ribbon
  22273. */
  22274. static CreateRibbon(options: {
  22275. pathArray: Vector3[][];
  22276. closeArray?: boolean;
  22277. closePath?: boolean;
  22278. offset?: number;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. invertUV?: boolean;
  22283. uvs?: Vector2[];
  22284. colors?: Color4[];
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for a box
  22288. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22289. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22290. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22291. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22292. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22293. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22294. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22296. * * 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)
  22297. * * 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)
  22298. * @returns the VertexData of the box
  22299. */
  22300. static CreateBox(options: {
  22301. size?: number;
  22302. width?: number;
  22303. height?: number;
  22304. depth?: number;
  22305. faceUV?: Vector4[];
  22306. faceColors?: Color4[];
  22307. sideOrientation?: number;
  22308. frontUVs?: Vector4;
  22309. backUVs?: Vector4;
  22310. }): VertexData;
  22311. /**
  22312. * Creates the VertexData for a tiled box
  22313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22314. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22315. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22316. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22318. * @returns the VertexData of the box
  22319. */
  22320. static CreateTiledBox(options: {
  22321. pattern?: number;
  22322. width?: number;
  22323. height?: number;
  22324. depth?: number;
  22325. tileSize?: number;
  22326. tileWidth?: number;
  22327. tileHeight?: number;
  22328. alignHorizontal?: number;
  22329. alignVertical?: number;
  22330. faceUV?: Vector4[];
  22331. faceColors?: Color4[];
  22332. sideOrientation?: number;
  22333. }): VertexData;
  22334. /**
  22335. * Creates the VertexData for a tiled plane
  22336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22337. * * pattern a limited pattern arrangement depending on the number
  22338. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22339. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22340. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22342. * * 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)
  22343. * * 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)
  22344. * @returns the VertexData of the tiled plane
  22345. */
  22346. static CreateTiledPlane(options: {
  22347. pattern?: number;
  22348. tileSize?: number;
  22349. tileWidth?: number;
  22350. tileHeight?: number;
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. alignHorizontal?: number;
  22355. alignVertical?: number;
  22356. sideOrientation?: number;
  22357. frontUVs?: Vector4;
  22358. backUVs?: Vector4;
  22359. }): VertexData;
  22360. /**
  22361. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22363. * * segments sets the number of horizontal strips optional, default 32
  22364. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22365. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22366. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22367. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22368. * * 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
  22369. * * 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
  22370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22371. * * 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)
  22372. * * 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)
  22373. * @returns the VertexData of the ellipsoid
  22374. */
  22375. static CreateSphere(options: {
  22376. segments?: number;
  22377. diameter?: number;
  22378. diameterX?: number;
  22379. diameterY?: number;
  22380. diameterZ?: number;
  22381. arc?: number;
  22382. slice?: number;
  22383. sideOrientation?: number;
  22384. frontUVs?: Vector4;
  22385. backUVs?: Vector4;
  22386. }): VertexData;
  22387. /**
  22388. * Creates the VertexData for a cylinder, cone or prism
  22389. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22390. * * height sets the height (y direction) of the cylinder, optional, default 2
  22391. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22392. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22393. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22394. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22395. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22396. * * 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
  22397. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22398. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22399. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22400. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22402. * * 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)
  22403. * * 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)
  22404. * @returns the VertexData of the cylinder, cone or prism
  22405. */
  22406. static CreateCylinder(options: {
  22407. height?: number;
  22408. diameterTop?: number;
  22409. diameterBottom?: number;
  22410. diameter?: number;
  22411. tessellation?: number;
  22412. subdivisions?: number;
  22413. arc?: number;
  22414. faceColors?: Color4[];
  22415. faceUV?: Vector4[];
  22416. hasRings?: boolean;
  22417. enclose?: boolean;
  22418. sideOrientation?: number;
  22419. frontUVs?: Vector4;
  22420. backUVs?: Vector4;
  22421. }): VertexData;
  22422. /**
  22423. * Creates the VertexData for a torus
  22424. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22425. * * diameter the diameter of the torus, optional default 1
  22426. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22427. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22429. * * 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)
  22430. * * 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)
  22431. * @returns the VertexData of the torus
  22432. */
  22433. static CreateTorus(options: {
  22434. diameter?: number;
  22435. thickness?: number;
  22436. tessellation?: number;
  22437. sideOrientation?: number;
  22438. frontUVs?: Vector4;
  22439. backUVs?: Vector4;
  22440. }): VertexData;
  22441. /**
  22442. * Creates the VertexData of the LineSystem
  22443. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22444. * - lines an array of lines, each line being an array of successive Vector3
  22445. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22446. * @returns the VertexData of the LineSystem
  22447. */
  22448. static CreateLineSystem(options: {
  22449. lines: Vector3[][];
  22450. colors?: Nullable<Color4[][]>;
  22451. }): VertexData;
  22452. /**
  22453. * Create the VertexData for a DashedLines
  22454. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22455. * - points an array successive Vector3
  22456. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22457. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22458. * - dashNb the intended total number of dashes, optional, default 200
  22459. * @returns the VertexData for the DashedLines
  22460. */
  22461. static CreateDashedLines(options: {
  22462. points: Vector3[];
  22463. dashSize?: number;
  22464. gapSize?: number;
  22465. dashNb?: number;
  22466. }): VertexData;
  22467. /**
  22468. * Creates the VertexData for a Ground
  22469. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22470. * - width the width (x direction) of the ground, optional, default 1
  22471. * - height the height (z direction) of the ground, optional, default 1
  22472. * - subdivisions the number of subdivisions per side, optional, default 1
  22473. * @returns the VertexData of the Ground
  22474. */
  22475. static CreateGround(options: {
  22476. width?: number;
  22477. height?: number;
  22478. subdivisions?: number;
  22479. subdivisionsX?: number;
  22480. subdivisionsY?: number;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22484. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22485. * * xmin the ground minimum X coordinate, optional, default -1
  22486. * * zmin the ground minimum Z coordinate, optional, default -1
  22487. * * xmax the ground maximum X coordinate, optional, default 1
  22488. * * zmax the ground maximum Z coordinate, optional, default 1
  22489. * * 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}
  22490. * * 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}
  22491. * @returns the VertexData of the TiledGround
  22492. */
  22493. static CreateTiledGround(options: {
  22494. xmin: number;
  22495. zmin: number;
  22496. xmax: number;
  22497. zmax: number;
  22498. subdivisions?: {
  22499. w: number;
  22500. h: number;
  22501. };
  22502. precision?: {
  22503. w: number;
  22504. h: number;
  22505. };
  22506. }): VertexData;
  22507. /**
  22508. * Creates the VertexData of the Ground designed from a heightmap
  22509. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22510. * * width the width (x direction) of the ground
  22511. * * height the height (z direction) of the ground
  22512. * * subdivisions the number of subdivisions per side
  22513. * * minHeight the minimum altitude on the ground, optional, default 0
  22514. * * maxHeight the maximum altitude on the ground, optional default 1
  22515. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22516. * * buffer the array holding the image color data
  22517. * * bufferWidth the width of image
  22518. * * bufferHeight the height of image
  22519. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22520. * @returns the VertexData of the Ground designed from a heightmap
  22521. */
  22522. static CreateGroundFromHeightMap(options: {
  22523. width: number;
  22524. height: number;
  22525. subdivisions: number;
  22526. minHeight: number;
  22527. maxHeight: number;
  22528. colorFilter: Color3;
  22529. buffer: Uint8Array;
  22530. bufferWidth: number;
  22531. bufferHeight: number;
  22532. alphaFilter: number;
  22533. }): VertexData;
  22534. /**
  22535. * Creates the VertexData for a Plane
  22536. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22537. * * size sets the width and height of the plane to the value of size, optional default 1
  22538. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22539. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22541. * * 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)
  22542. * * 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)
  22543. * @returns the VertexData of the box
  22544. */
  22545. static CreatePlane(options: {
  22546. size?: number;
  22547. width?: number;
  22548. height?: number;
  22549. sideOrientation?: number;
  22550. frontUVs?: Vector4;
  22551. backUVs?: Vector4;
  22552. }): VertexData;
  22553. /**
  22554. * Creates the VertexData of the Disc or regular Polygon
  22555. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22556. * * radius the radius of the disc, optional default 0.5
  22557. * * tessellation the number of polygon sides, optional, default 64
  22558. * * 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
  22559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22560. * * 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)
  22561. * * 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)
  22562. * @returns the VertexData of the box
  22563. */
  22564. static CreateDisc(options: {
  22565. radius?: number;
  22566. tessellation?: number;
  22567. arc?: number;
  22568. sideOrientation?: number;
  22569. frontUVs?: Vector4;
  22570. backUVs?: Vector4;
  22571. }): VertexData;
  22572. /**
  22573. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22574. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22575. * @param polygon a mesh built from polygonTriangulation.build()
  22576. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22577. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22578. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22579. * @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)
  22580. * @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)
  22581. * @returns the VertexData of the Polygon
  22582. */
  22583. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22584. /**
  22585. * Creates the VertexData of the IcoSphere
  22586. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22587. * * radius the radius of the IcoSphere, optional default 1
  22588. * * radiusX allows stretching in the x direction, optional, default radius
  22589. * * radiusY allows stretching in the y direction, optional, default radius
  22590. * * radiusZ allows stretching in the z direction, optional, default radius
  22591. * * flat when true creates a flat shaded mesh, optional, default true
  22592. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22594. * * 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)
  22595. * * 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)
  22596. * @returns the VertexData of the IcoSphere
  22597. */
  22598. static CreateIcoSphere(options: {
  22599. radius?: number;
  22600. radiusX?: number;
  22601. radiusY?: number;
  22602. radiusZ?: number;
  22603. flat?: boolean;
  22604. subdivisions?: number;
  22605. sideOrientation?: number;
  22606. frontUVs?: Vector4;
  22607. backUVs?: Vector4;
  22608. }): VertexData;
  22609. /**
  22610. * Creates the VertexData for a Polyhedron
  22611. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22612. * * type provided types are:
  22613. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22614. * * 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)
  22615. * * size the size of the IcoSphere, optional default 1
  22616. * * sizeX allows stretching in the x direction, optional, default size
  22617. * * sizeY allows stretching in the y direction, optional, default size
  22618. * * sizeZ allows stretching in the z direction, optional, default size
  22619. * * 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
  22620. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22621. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22622. * * flat when true creates a flat shaded mesh, optional, default true
  22623. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22625. * * 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)
  22626. * * 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)
  22627. * @returns the VertexData of the Polyhedron
  22628. */
  22629. static CreatePolyhedron(options: {
  22630. type?: number;
  22631. size?: number;
  22632. sizeX?: number;
  22633. sizeY?: number;
  22634. sizeZ?: number;
  22635. custom?: any;
  22636. faceUV?: Vector4[];
  22637. faceColors?: Color4[];
  22638. flat?: boolean;
  22639. sideOrientation?: number;
  22640. frontUVs?: Vector4;
  22641. backUVs?: Vector4;
  22642. }): VertexData;
  22643. /**
  22644. * Creates the VertexData for a TorusKnot
  22645. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22646. * * radius the radius of the torus knot, optional, default 2
  22647. * * tube the thickness of the tube, optional, default 0.5
  22648. * * radialSegments the number of sides on each tube segments, optional, default 32
  22649. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22650. * * p the number of windings around the z axis, optional, default 2
  22651. * * q the number of windings around the x axis, optional, default 3
  22652. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22653. * * 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)
  22654. * * 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)
  22655. * @returns the VertexData of the Torus Knot
  22656. */
  22657. static CreateTorusKnot(options: {
  22658. radius?: number;
  22659. tube?: number;
  22660. radialSegments?: number;
  22661. tubularSegments?: number;
  22662. p?: number;
  22663. q?: number;
  22664. sideOrientation?: number;
  22665. frontUVs?: Vector4;
  22666. backUVs?: Vector4;
  22667. }): VertexData;
  22668. /**
  22669. * Compute normals for given positions and indices
  22670. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22671. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22672. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22673. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22674. * * facetNormals : optional array of facet normals (vector3)
  22675. * * facetPositions : optional array of facet positions (vector3)
  22676. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22677. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22678. * * bInfo : optional bounding info, required for facetPartitioning computation
  22679. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22680. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22681. * * useRightHandedSystem: optional boolean to for right handed system computation
  22682. * * depthSort : optional boolean to enable the facet depth sort computation
  22683. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22684. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22685. */
  22686. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22687. facetNormals?: any;
  22688. facetPositions?: any;
  22689. facetPartitioning?: any;
  22690. ratio?: number;
  22691. bInfo?: any;
  22692. bbSize?: Vector3;
  22693. subDiv?: any;
  22694. useRightHandedSystem?: boolean;
  22695. depthSort?: boolean;
  22696. distanceTo?: Vector3;
  22697. depthSortedFacets?: any;
  22698. }): void;
  22699. /** @hidden */
  22700. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22701. /**
  22702. * Applies VertexData created from the imported parameters to the geometry
  22703. * @param parsedVertexData the parsed data from an imported file
  22704. * @param geometry the geometry to apply the VertexData to
  22705. */
  22706. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22707. }
  22708. }
  22709. declare module "babylonjs/Morph/morphTarget" {
  22710. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22711. import { Observable } from "babylonjs/Misc/observable";
  22712. import { Nullable, FloatArray } from "babylonjs/types";
  22713. import { Scene } from "babylonjs/scene";
  22714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22715. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22716. /**
  22717. * Defines a target to use with MorphTargetManager
  22718. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22719. */
  22720. export class MorphTarget implements IAnimatable {
  22721. /** defines the name of the target */
  22722. name: string;
  22723. /**
  22724. * Gets or sets the list of animations
  22725. */
  22726. animations: import("babylonjs/Animations/animation").Animation[];
  22727. private _scene;
  22728. private _positions;
  22729. private _normals;
  22730. private _tangents;
  22731. private _uvs;
  22732. private _influence;
  22733. /**
  22734. * Observable raised when the influence changes
  22735. */
  22736. onInfluenceChanged: Observable<boolean>;
  22737. /** @hidden */
  22738. _onDataLayoutChanged: Observable<void>;
  22739. /**
  22740. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22741. */
  22742. influence: number;
  22743. /**
  22744. * Gets or sets the id of the morph Target
  22745. */
  22746. id: string;
  22747. private _animationPropertiesOverride;
  22748. /**
  22749. * Gets or sets the animation properties override
  22750. */
  22751. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22752. /**
  22753. * Creates a new MorphTarget
  22754. * @param name defines the name of the target
  22755. * @param influence defines the influence to use
  22756. * @param scene defines the scene the morphtarget belongs to
  22757. */
  22758. constructor(
  22759. /** defines the name of the target */
  22760. name: string, influence?: number, scene?: Nullable<Scene>);
  22761. /**
  22762. * Gets a boolean defining if the target contains position data
  22763. */
  22764. readonly hasPositions: boolean;
  22765. /**
  22766. * Gets a boolean defining if the target contains normal data
  22767. */
  22768. readonly hasNormals: boolean;
  22769. /**
  22770. * Gets a boolean defining if the target contains tangent data
  22771. */
  22772. readonly hasTangents: boolean;
  22773. /**
  22774. * Gets a boolean defining if the target contains texture coordinates data
  22775. */
  22776. readonly hasUVs: boolean;
  22777. /**
  22778. * Affects position data to this target
  22779. * @param data defines the position data to use
  22780. */
  22781. setPositions(data: Nullable<FloatArray>): void;
  22782. /**
  22783. * Gets the position data stored in this target
  22784. * @returns a FloatArray containing the position data (or null if not present)
  22785. */
  22786. getPositions(): Nullable<FloatArray>;
  22787. /**
  22788. * Affects normal data to this target
  22789. * @param data defines the normal data to use
  22790. */
  22791. setNormals(data: Nullable<FloatArray>): void;
  22792. /**
  22793. * Gets the normal data stored in this target
  22794. * @returns a FloatArray containing the normal data (or null if not present)
  22795. */
  22796. getNormals(): Nullable<FloatArray>;
  22797. /**
  22798. * Affects tangent data to this target
  22799. * @param data defines the tangent data to use
  22800. */
  22801. setTangents(data: Nullable<FloatArray>): void;
  22802. /**
  22803. * Gets the tangent data stored in this target
  22804. * @returns a FloatArray containing the tangent data (or null if not present)
  22805. */
  22806. getTangents(): Nullable<FloatArray>;
  22807. /**
  22808. * Affects texture coordinates data to this target
  22809. * @param data defines the texture coordinates data to use
  22810. */
  22811. setUVs(data: Nullable<FloatArray>): void;
  22812. /**
  22813. * Gets the texture coordinates data stored in this target
  22814. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22815. */
  22816. getUVs(): Nullable<FloatArray>;
  22817. /**
  22818. * Serializes the current target into a Serialization object
  22819. * @returns the serialized object
  22820. */
  22821. serialize(): any;
  22822. /**
  22823. * Returns the string "MorphTarget"
  22824. * @returns "MorphTarget"
  22825. */
  22826. getClassName(): string;
  22827. /**
  22828. * Creates a new target from serialized data
  22829. * @param serializationObject defines the serialized data to use
  22830. * @returns a new MorphTarget
  22831. */
  22832. static Parse(serializationObject: any): MorphTarget;
  22833. /**
  22834. * Creates a MorphTarget from mesh data
  22835. * @param mesh defines the source mesh
  22836. * @param name defines the name to use for the new target
  22837. * @param influence defines the influence to attach to the target
  22838. * @returns a new MorphTarget
  22839. */
  22840. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22841. }
  22842. }
  22843. declare module "babylonjs/Morph/morphTargetManager" {
  22844. import { Nullable } from "babylonjs/types";
  22845. import { Scene } from "babylonjs/scene";
  22846. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22847. /**
  22848. * This class is used to deform meshes using morphing between different targets
  22849. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22850. */
  22851. export class MorphTargetManager {
  22852. private _targets;
  22853. private _targetInfluenceChangedObservers;
  22854. private _targetDataLayoutChangedObservers;
  22855. private _activeTargets;
  22856. private _scene;
  22857. private _influences;
  22858. private _supportsNormals;
  22859. private _supportsTangents;
  22860. private _supportsUVs;
  22861. private _vertexCount;
  22862. private _uniqueId;
  22863. private _tempInfluences;
  22864. /**
  22865. * Gets or sets a boolean indicating if normals must be morphed
  22866. */
  22867. enableNormalMorphing: boolean;
  22868. /**
  22869. * Gets or sets a boolean indicating if tangents must be morphed
  22870. */
  22871. enableTangentMorphing: boolean;
  22872. /**
  22873. * Gets or sets a boolean indicating if UV must be morphed
  22874. */
  22875. enableUVMorphing: boolean;
  22876. /**
  22877. * Creates a new MorphTargetManager
  22878. * @param scene defines the current scene
  22879. */
  22880. constructor(scene?: Nullable<Scene>);
  22881. /**
  22882. * Gets the unique ID of this manager
  22883. */
  22884. readonly uniqueId: number;
  22885. /**
  22886. * Gets the number of vertices handled by this manager
  22887. */
  22888. readonly vertexCount: number;
  22889. /**
  22890. * Gets a boolean indicating if this manager supports morphing of normals
  22891. */
  22892. readonly supportsNormals: boolean;
  22893. /**
  22894. * Gets a boolean indicating if this manager supports morphing of tangents
  22895. */
  22896. readonly supportsTangents: boolean;
  22897. /**
  22898. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22899. */
  22900. readonly supportsUVs: boolean;
  22901. /**
  22902. * Gets the number of targets stored in this manager
  22903. */
  22904. readonly numTargets: number;
  22905. /**
  22906. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22907. */
  22908. readonly numInfluencers: number;
  22909. /**
  22910. * Gets the list of influences (one per target)
  22911. */
  22912. readonly influences: Float32Array;
  22913. /**
  22914. * Gets the active target at specified index. An active target is a target with an influence > 0
  22915. * @param index defines the index to check
  22916. * @returns the requested target
  22917. */
  22918. getActiveTarget(index: number): MorphTarget;
  22919. /**
  22920. * Gets the target at specified index
  22921. * @param index defines the index to check
  22922. * @returns the requested target
  22923. */
  22924. getTarget(index: number): MorphTarget;
  22925. /**
  22926. * Add a new target to this manager
  22927. * @param target defines the target to add
  22928. */
  22929. addTarget(target: MorphTarget): void;
  22930. /**
  22931. * Removes a target from the manager
  22932. * @param target defines the target to remove
  22933. */
  22934. removeTarget(target: MorphTarget): void;
  22935. /**
  22936. * Serializes the current manager into a Serialization object
  22937. * @returns the serialized object
  22938. */
  22939. serialize(): any;
  22940. private _syncActiveTargets;
  22941. /**
  22942. * Syncrhonize the targets with all the meshes using this morph target manager
  22943. */
  22944. synchronize(): void;
  22945. /**
  22946. * Creates a new MorphTargetManager from serialized data
  22947. * @param serializationObject defines the serialized data
  22948. * @param scene defines the hosting scene
  22949. * @returns the new MorphTargetManager
  22950. */
  22951. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22952. }
  22953. }
  22954. declare module "babylonjs/Meshes/meshLODLevel" {
  22955. import { Mesh } from "babylonjs/Meshes/mesh";
  22956. import { Nullable } from "babylonjs/types";
  22957. /**
  22958. * Class used to represent a specific level of detail of a mesh
  22959. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22960. */
  22961. export class MeshLODLevel {
  22962. /** Defines the distance where this level should start being displayed */
  22963. distance: number;
  22964. /** Defines the mesh to use to render this level */
  22965. mesh: Nullable<Mesh>;
  22966. /**
  22967. * Creates a new LOD level
  22968. * @param distance defines the distance where this level should star being displayed
  22969. * @param mesh defines the mesh to use to render this level
  22970. */
  22971. constructor(
  22972. /** Defines the distance where this level should start being displayed */
  22973. distance: number,
  22974. /** Defines the mesh to use to render this level */
  22975. mesh: Nullable<Mesh>);
  22976. }
  22977. }
  22978. declare module "babylonjs/Meshes/groundMesh" {
  22979. import { Scene } from "babylonjs/scene";
  22980. import { Vector3 } from "babylonjs/Maths/math.vector";
  22981. import { Mesh } from "babylonjs/Meshes/mesh";
  22982. /**
  22983. * Mesh representing the gorund
  22984. */
  22985. export class GroundMesh extends Mesh {
  22986. /** If octree should be generated */
  22987. generateOctree: boolean;
  22988. private _heightQuads;
  22989. /** @hidden */
  22990. _subdivisionsX: number;
  22991. /** @hidden */
  22992. _subdivisionsY: number;
  22993. /** @hidden */
  22994. _width: number;
  22995. /** @hidden */
  22996. _height: number;
  22997. /** @hidden */
  22998. _minX: number;
  22999. /** @hidden */
  23000. _maxX: number;
  23001. /** @hidden */
  23002. _minZ: number;
  23003. /** @hidden */
  23004. _maxZ: number;
  23005. constructor(name: string, scene: Scene);
  23006. /**
  23007. * "GroundMesh"
  23008. * @returns "GroundMesh"
  23009. */
  23010. getClassName(): string;
  23011. /**
  23012. * The minimum of x and y subdivisions
  23013. */
  23014. readonly subdivisions: number;
  23015. /**
  23016. * X subdivisions
  23017. */
  23018. readonly subdivisionsX: number;
  23019. /**
  23020. * Y subdivisions
  23021. */
  23022. readonly subdivisionsY: number;
  23023. /**
  23024. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23025. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23026. * @param chunksCount the number of subdivisions for x and y
  23027. * @param octreeBlocksSize (Default: 32)
  23028. */
  23029. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23030. /**
  23031. * Returns a height (y) value in the Worl system :
  23032. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23033. * @param x x coordinate
  23034. * @param z z coordinate
  23035. * @returns the ground y position if (x, z) are outside the ground surface.
  23036. */
  23037. getHeightAtCoordinates(x: number, z: number): number;
  23038. /**
  23039. * Returns a normalized vector (Vector3) orthogonal to the ground
  23040. * at the ground coordinates (x, z) expressed in the World system.
  23041. * @param x x coordinate
  23042. * @param z z coordinate
  23043. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23044. */
  23045. getNormalAtCoordinates(x: number, z: number): Vector3;
  23046. /**
  23047. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23048. * at the ground coordinates (x, z) expressed in the World system.
  23049. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23050. * @param x x coordinate
  23051. * @param z z coordinate
  23052. * @param ref vector to store the result
  23053. * @returns the GroundMesh.
  23054. */
  23055. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23056. /**
  23057. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23058. * if the ground has been updated.
  23059. * This can be used in the render loop.
  23060. * @returns the GroundMesh.
  23061. */
  23062. updateCoordinateHeights(): GroundMesh;
  23063. private _getFacetAt;
  23064. private _initHeightQuads;
  23065. private _computeHeightQuads;
  23066. /**
  23067. * Serializes this ground mesh
  23068. * @param serializationObject object to write serialization to
  23069. */
  23070. serialize(serializationObject: any): void;
  23071. /**
  23072. * Parses a serialized ground mesh
  23073. * @param parsedMesh the serialized mesh
  23074. * @param scene the scene to create the ground mesh in
  23075. * @returns the created ground mesh
  23076. */
  23077. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23078. }
  23079. }
  23080. declare module "babylonjs/Physics/physicsJoint" {
  23081. import { Vector3 } from "babylonjs/Maths/math.vector";
  23082. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23083. /**
  23084. * Interface for Physics-Joint data
  23085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23086. */
  23087. export interface PhysicsJointData {
  23088. /**
  23089. * The main pivot of the joint
  23090. */
  23091. mainPivot?: Vector3;
  23092. /**
  23093. * The connected pivot of the joint
  23094. */
  23095. connectedPivot?: Vector3;
  23096. /**
  23097. * The main axis of the joint
  23098. */
  23099. mainAxis?: Vector3;
  23100. /**
  23101. * The connected axis of the joint
  23102. */
  23103. connectedAxis?: Vector3;
  23104. /**
  23105. * The collision of the joint
  23106. */
  23107. collision?: boolean;
  23108. /**
  23109. * Native Oimo/Cannon/Energy data
  23110. */
  23111. nativeParams?: any;
  23112. }
  23113. /**
  23114. * This is a holder class for the physics joint created by the physics plugin
  23115. * It holds a set of functions to control the underlying joint
  23116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23117. */
  23118. export class PhysicsJoint {
  23119. /**
  23120. * The type of the physics joint
  23121. */
  23122. type: number;
  23123. /**
  23124. * The data for the physics joint
  23125. */
  23126. jointData: PhysicsJointData;
  23127. private _physicsJoint;
  23128. protected _physicsPlugin: IPhysicsEnginePlugin;
  23129. /**
  23130. * Initializes the physics joint
  23131. * @param type The type of the physics joint
  23132. * @param jointData The data for the physics joint
  23133. */
  23134. constructor(
  23135. /**
  23136. * The type of the physics joint
  23137. */
  23138. type: number,
  23139. /**
  23140. * The data for the physics joint
  23141. */
  23142. jointData: PhysicsJointData);
  23143. /**
  23144. * Gets the physics joint
  23145. */
  23146. /**
  23147. * Sets the physics joint
  23148. */
  23149. physicsJoint: any;
  23150. /**
  23151. * Sets the physics plugin
  23152. */
  23153. physicsPlugin: IPhysicsEnginePlugin;
  23154. /**
  23155. * Execute a function that is physics-plugin specific.
  23156. * @param {Function} func the function that will be executed.
  23157. * It accepts two parameters: the physics world and the physics joint
  23158. */
  23159. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23160. /**
  23161. * Distance-Joint type
  23162. */
  23163. static DistanceJoint: number;
  23164. /**
  23165. * Hinge-Joint type
  23166. */
  23167. static HingeJoint: number;
  23168. /**
  23169. * Ball-and-Socket joint type
  23170. */
  23171. static BallAndSocketJoint: number;
  23172. /**
  23173. * Wheel-Joint type
  23174. */
  23175. static WheelJoint: number;
  23176. /**
  23177. * Slider-Joint type
  23178. */
  23179. static SliderJoint: number;
  23180. /**
  23181. * Prismatic-Joint type
  23182. */
  23183. static PrismaticJoint: number;
  23184. /**
  23185. * Universal-Joint type
  23186. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23187. */
  23188. static UniversalJoint: number;
  23189. /**
  23190. * Hinge-Joint 2 type
  23191. */
  23192. static Hinge2Joint: number;
  23193. /**
  23194. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23195. */
  23196. static PointToPointJoint: number;
  23197. /**
  23198. * Spring-Joint type
  23199. */
  23200. static SpringJoint: number;
  23201. /**
  23202. * Lock-Joint type
  23203. */
  23204. static LockJoint: number;
  23205. }
  23206. /**
  23207. * A class representing a physics distance joint
  23208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23209. */
  23210. export class DistanceJoint extends PhysicsJoint {
  23211. /**
  23212. *
  23213. * @param jointData The data for the Distance-Joint
  23214. */
  23215. constructor(jointData: DistanceJointData);
  23216. /**
  23217. * Update the predefined distance.
  23218. * @param maxDistance The maximum preferred distance
  23219. * @param minDistance The minimum preferred distance
  23220. */
  23221. updateDistance(maxDistance: number, minDistance?: number): void;
  23222. }
  23223. /**
  23224. * Represents a Motor-Enabled Joint
  23225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23226. */
  23227. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23228. /**
  23229. * Initializes the Motor-Enabled Joint
  23230. * @param type The type of the joint
  23231. * @param jointData The physica joint data for the joint
  23232. */
  23233. constructor(type: number, jointData: PhysicsJointData);
  23234. /**
  23235. * Set the motor values.
  23236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23237. * @param force the force to apply
  23238. * @param maxForce max force for this motor.
  23239. */
  23240. setMotor(force?: number, maxForce?: number): void;
  23241. /**
  23242. * Set the motor's limits.
  23243. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23244. * @param upperLimit The upper limit of the motor
  23245. * @param lowerLimit The lower limit of the motor
  23246. */
  23247. setLimit(upperLimit: number, lowerLimit?: number): void;
  23248. }
  23249. /**
  23250. * This class represents a single physics Hinge-Joint
  23251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23252. */
  23253. export class HingeJoint extends MotorEnabledJoint {
  23254. /**
  23255. * Initializes the Hinge-Joint
  23256. * @param jointData The joint data for the Hinge-Joint
  23257. */
  23258. constructor(jointData: PhysicsJointData);
  23259. /**
  23260. * Set the motor values.
  23261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23262. * @param {number} force the force to apply
  23263. * @param {number} maxForce max force for this motor.
  23264. */
  23265. setMotor(force?: number, maxForce?: number): void;
  23266. /**
  23267. * Set the motor's limits.
  23268. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23269. * @param upperLimit The upper limit of the motor
  23270. * @param lowerLimit The lower limit of the motor
  23271. */
  23272. setLimit(upperLimit: number, lowerLimit?: number): void;
  23273. }
  23274. /**
  23275. * This class represents a dual hinge physics joint (same as wheel joint)
  23276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23277. */
  23278. export class Hinge2Joint extends MotorEnabledJoint {
  23279. /**
  23280. * Initializes the Hinge2-Joint
  23281. * @param jointData The joint data for the Hinge2-Joint
  23282. */
  23283. constructor(jointData: PhysicsJointData);
  23284. /**
  23285. * Set the motor values.
  23286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23287. * @param {number} targetSpeed the speed the motor is to reach
  23288. * @param {number} maxForce max force for this motor.
  23289. * @param {motorIndex} the motor's index, 0 or 1.
  23290. */
  23291. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23292. /**
  23293. * Set the motor limits.
  23294. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23295. * @param {number} upperLimit the upper limit
  23296. * @param {number} lowerLimit lower limit
  23297. * @param {motorIndex} the motor's index, 0 or 1.
  23298. */
  23299. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23300. }
  23301. /**
  23302. * Interface for a motor enabled joint
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export interface IMotorEnabledJoint {
  23306. /**
  23307. * Physics joint
  23308. */
  23309. physicsJoint: any;
  23310. /**
  23311. * Sets the motor of the motor-enabled joint
  23312. * @param force The force of the motor
  23313. * @param maxForce The maximum force of the motor
  23314. * @param motorIndex The index of the motor
  23315. */
  23316. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23317. /**
  23318. * Sets the limit of the motor
  23319. * @param upperLimit The upper limit of the motor
  23320. * @param lowerLimit The lower limit of the motor
  23321. * @param motorIndex The index of the motor
  23322. */
  23323. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23324. }
  23325. /**
  23326. * Joint data for a Distance-Joint
  23327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23328. */
  23329. export interface DistanceJointData extends PhysicsJointData {
  23330. /**
  23331. * Max distance the 2 joint objects can be apart
  23332. */
  23333. maxDistance: number;
  23334. }
  23335. /**
  23336. * Joint data from a spring joint
  23337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23338. */
  23339. export interface SpringJointData extends PhysicsJointData {
  23340. /**
  23341. * Length of the spring
  23342. */
  23343. length: number;
  23344. /**
  23345. * Stiffness of the spring
  23346. */
  23347. stiffness: number;
  23348. /**
  23349. * Damping of the spring
  23350. */
  23351. damping: number;
  23352. /** this callback will be called when applying the force to the impostors. */
  23353. forceApplicationCallback: () => void;
  23354. }
  23355. }
  23356. declare module "babylonjs/Physics/physicsRaycastResult" {
  23357. import { Vector3 } from "babylonjs/Maths/math.vector";
  23358. /**
  23359. * Holds the data for the raycast result
  23360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23361. */
  23362. export class PhysicsRaycastResult {
  23363. private _hasHit;
  23364. private _hitDistance;
  23365. private _hitNormalWorld;
  23366. private _hitPointWorld;
  23367. private _rayFromWorld;
  23368. private _rayToWorld;
  23369. /**
  23370. * Gets if there was a hit
  23371. */
  23372. readonly hasHit: boolean;
  23373. /**
  23374. * Gets the distance from the hit
  23375. */
  23376. readonly hitDistance: number;
  23377. /**
  23378. * Gets the hit normal/direction in the world
  23379. */
  23380. readonly hitNormalWorld: Vector3;
  23381. /**
  23382. * Gets the hit point in the world
  23383. */
  23384. readonly hitPointWorld: Vector3;
  23385. /**
  23386. * Gets the ray "start point" of the ray in the world
  23387. */
  23388. readonly rayFromWorld: Vector3;
  23389. /**
  23390. * Gets the ray "end point" of the ray in the world
  23391. */
  23392. readonly rayToWorld: Vector3;
  23393. /**
  23394. * Sets the hit data (normal & point in world space)
  23395. * @param hitNormalWorld defines the normal in world space
  23396. * @param hitPointWorld defines the point in world space
  23397. */
  23398. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23399. /**
  23400. * Sets the distance from the start point to the hit point
  23401. * @param distance
  23402. */
  23403. setHitDistance(distance: number): void;
  23404. /**
  23405. * Calculates the distance manually
  23406. */
  23407. calculateHitDistance(): void;
  23408. /**
  23409. * Resets all the values to default
  23410. * @param from The from point on world space
  23411. * @param to The to point on world space
  23412. */
  23413. reset(from?: Vector3, to?: Vector3): void;
  23414. }
  23415. /**
  23416. * Interface for the size containing width and height
  23417. */
  23418. interface IXYZ {
  23419. /**
  23420. * X
  23421. */
  23422. x: number;
  23423. /**
  23424. * Y
  23425. */
  23426. y: number;
  23427. /**
  23428. * Z
  23429. */
  23430. z: number;
  23431. }
  23432. }
  23433. declare module "babylonjs/Physics/IPhysicsEngine" {
  23434. import { Nullable } from "babylonjs/types";
  23435. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23437. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23438. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23439. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23440. /**
  23441. * Interface used to describe a physics joint
  23442. */
  23443. export interface PhysicsImpostorJoint {
  23444. /** Defines the main impostor to which the joint is linked */
  23445. mainImpostor: PhysicsImpostor;
  23446. /** Defines the impostor that is connected to the main impostor using this joint */
  23447. connectedImpostor: PhysicsImpostor;
  23448. /** Defines the joint itself */
  23449. joint: PhysicsJoint;
  23450. }
  23451. /** @hidden */
  23452. export interface IPhysicsEnginePlugin {
  23453. world: any;
  23454. name: string;
  23455. setGravity(gravity: Vector3): void;
  23456. setTimeStep(timeStep: number): void;
  23457. getTimeStep(): number;
  23458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23462. removePhysicsBody(impostor: PhysicsImpostor): void;
  23463. generateJoint(joint: PhysicsImpostorJoint): void;
  23464. removeJoint(joint: PhysicsImpostorJoint): void;
  23465. isSupported(): boolean;
  23466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23468. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23469. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23470. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23471. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23473. getBodyMass(impostor: PhysicsImpostor): number;
  23474. getBodyFriction(impostor: PhysicsImpostor): number;
  23475. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23476. getBodyRestitution(impostor: PhysicsImpostor): number;
  23477. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23478. getBodyPressure?(impostor: PhysicsImpostor): number;
  23479. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23480. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23481. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23482. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23483. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23484. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23485. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23486. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23487. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23488. sleepBody(impostor: PhysicsImpostor): void;
  23489. wakeUpBody(impostor: PhysicsImpostor): void;
  23490. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23491. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23492. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23493. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23494. getRadius(impostor: PhysicsImpostor): number;
  23495. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23496. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23497. dispose(): void;
  23498. }
  23499. /**
  23500. * Interface used to define a physics engine
  23501. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23502. */
  23503. export interface IPhysicsEngine {
  23504. /**
  23505. * Gets the gravity vector used by the simulation
  23506. */
  23507. gravity: Vector3;
  23508. /**
  23509. * Sets the gravity vector used by the simulation
  23510. * @param gravity defines the gravity vector to use
  23511. */
  23512. setGravity(gravity: Vector3): void;
  23513. /**
  23514. * Set the time step of the physics engine.
  23515. * Default is 1/60.
  23516. * To slow it down, enter 1/600 for example.
  23517. * To speed it up, 1/30
  23518. * @param newTimeStep the new timestep to apply to this world.
  23519. */
  23520. setTimeStep(newTimeStep: number): void;
  23521. /**
  23522. * Get the time step of the physics engine.
  23523. * @returns the current time step
  23524. */
  23525. getTimeStep(): number;
  23526. /**
  23527. * Release all resources
  23528. */
  23529. dispose(): void;
  23530. /**
  23531. * Gets the name of the current physics plugin
  23532. * @returns the name of the plugin
  23533. */
  23534. getPhysicsPluginName(): string;
  23535. /**
  23536. * Adding a new impostor for the impostor tracking.
  23537. * This will be done by the impostor itself.
  23538. * @param impostor the impostor to add
  23539. */
  23540. addImpostor(impostor: PhysicsImpostor): void;
  23541. /**
  23542. * Remove an impostor from the engine.
  23543. * This impostor and its mesh will not longer be updated by the physics engine.
  23544. * @param impostor the impostor to remove
  23545. */
  23546. removeImpostor(impostor: PhysicsImpostor): void;
  23547. /**
  23548. * Add a joint to the physics engine
  23549. * @param mainImpostor defines the main impostor to which the joint is added.
  23550. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23551. * @param joint defines the joint that will connect both impostors.
  23552. */
  23553. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23554. /**
  23555. * Removes a joint from the simulation
  23556. * @param mainImpostor defines the impostor used with the joint
  23557. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23558. * @param joint defines the joint to remove
  23559. */
  23560. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23561. /**
  23562. * Gets the current plugin used to run the simulation
  23563. * @returns current plugin
  23564. */
  23565. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23566. /**
  23567. * Gets the list of physic impostors
  23568. * @returns an array of PhysicsImpostor
  23569. */
  23570. getImpostors(): Array<PhysicsImpostor>;
  23571. /**
  23572. * Gets the impostor for a physics enabled object
  23573. * @param object defines the object impersonated by the impostor
  23574. * @returns the PhysicsImpostor or null if not found
  23575. */
  23576. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23577. /**
  23578. * Gets the impostor for a physics body object
  23579. * @param body defines physics body used by the impostor
  23580. * @returns the PhysicsImpostor or null if not found
  23581. */
  23582. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23583. /**
  23584. * Does a raycast in the physics world
  23585. * @param from when should the ray start?
  23586. * @param to when should the ray end?
  23587. * @returns PhysicsRaycastResult
  23588. */
  23589. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23590. /**
  23591. * Called by the scene. No need to call it.
  23592. * @param delta defines the timespam between frames
  23593. */
  23594. _step(delta: number): void;
  23595. }
  23596. }
  23597. declare module "babylonjs/Physics/physicsImpostor" {
  23598. import { Nullable, IndicesArray } from "babylonjs/types";
  23599. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23602. import { Scene } from "babylonjs/scene";
  23603. import { Bone } from "babylonjs/Bones/bone";
  23604. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23605. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23606. import { Space } from "babylonjs/Maths/math.axis";
  23607. /**
  23608. * The interface for the physics imposter parameters
  23609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23610. */
  23611. export interface PhysicsImpostorParameters {
  23612. /**
  23613. * The mass of the physics imposter
  23614. */
  23615. mass: number;
  23616. /**
  23617. * The friction of the physics imposter
  23618. */
  23619. friction?: number;
  23620. /**
  23621. * The coefficient of restitution of the physics imposter
  23622. */
  23623. restitution?: number;
  23624. /**
  23625. * The native options of the physics imposter
  23626. */
  23627. nativeOptions?: any;
  23628. /**
  23629. * Specifies if the parent should be ignored
  23630. */
  23631. ignoreParent?: boolean;
  23632. /**
  23633. * Specifies if bi-directional transformations should be disabled
  23634. */
  23635. disableBidirectionalTransformation?: boolean;
  23636. /**
  23637. * The pressure inside the physics imposter, soft object only
  23638. */
  23639. pressure?: number;
  23640. /**
  23641. * The stiffness the physics imposter, soft object only
  23642. */
  23643. stiffness?: number;
  23644. /**
  23645. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23646. */
  23647. velocityIterations?: number;
  23648. /**
  23649. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23650. */
  23651. positionIterations?: number;
  23652. /**
  23653. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23654. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23655. * Add to fix multiple points
  23656. */
  23657. fixedPoints?: number;
  23658. /**
  23659. * The collision margin around a soft object
  23660. */
  23661. margin?: number;
  23662. /**
  23663. * The collision margin around a soft object
  23664. */
  23665. damping?: number;
  23666. /**
  23667. * The path for a rope based on an extrusion
  23668. */
  23669. path?: any;
  23670. /**
  23671. * The shape of an extrusion used for a rope based on an extrusion
  23672. */
  23673. shape?: any;
  23674. }
  23675. /**
  23676. * Interface for a physics-enabled object
  23677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23678. */
  23679. export interface IPhysicsEnabledObject {
  23680. /**
  23681. * The position of the physics-enabled object
  23682. */
  23683. position: Vector3;
  23684. /**
  23685. * The rotation of the physics-enabled object
  23686. */
  23687. rotationQuaternion: Nullable<Quaternion>;
  23688. /**
  23689. * The scale of the physics-enabled object
  23690. */
  23691. scaling: Vector3;
  23692. /**
  23693. * The rotation of the physics-enabled object
  23694. */
  23695. rotation?: Vector3;
  23696. /**
  23697. * The parent of the physics-enabled object
  23698. */
  23699. parent?: any;
  23700. /**
  23701. * The bounding info of the physics-enabled object
  23702. * @returns The bounding info of the physics-enabled object
  23703. */
  23704. getBoundingInfo(): BoundingInfo;
  23705. /**
  23706. * Computes the world matrix
  23707. * @param force Specifies if the world matrix should be computed by force
  23708. * @returns A world matrix
  23709. */
  23710. computeWorldMatrix(force: boolean): Matrix;
  23711. /**
  23712. * Gets the world matrix
  23713. * @returns A world matrix
  23714. */
  23715. getWorldMatrix?(): Matrix;
  23716. /**
  23717. * Gets the child meshes
  23718. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23719. * @returns An array of abstract meshes
  23720. */
  23721. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23722. /**
  23723. * Gets the vertex data
  23724. * @param kind The type of vertex data
  23725. * @returns A nullable array of numbers, or a float32 array
  23726. */
  23727. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23728. /**
  23729. * Gets the indices from the mesh
  23730. * @returns A nullable array of index arrays
  23731. */
  23732. getIndices?(): Nullable<IndicesArray>;
  23733. /**
  23734. * Gets the scene from the mesh
  23735. * @returns the indices array or null
  23736. */
  23737. getScene?(): Scene;
  23738. /**
  23739. * Gets the absolute position from the mesh
  23740. * @returns the absolute position
  23741. */
  23742. getAbsolutePosition(): Vector3;
  23743. /**
  23744. * Gets the absolute pivot point from the mesh
  23745. * @returns the absolute pivot point
  23746. */
  23747. getAbsolutePivotPoint(): Vector3;
  23748. /**
  23749. * Rotates the mesh
  23750. * @param axis The axis of rotation
  23751. * @param amount The amount of rotation
  23752. * @param space The space of the rotation
  23753. * @returns The rotation transform node
  23754. */
  23755. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23756. /**
  23757. * Translates the mesh
  23758. * @param axis The axis of translation
  23759. * @param distance The distance of translation
  23760. * @param space The space of the translation
  23761. * @returns The transform node
  23762. */
  23763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23764. /**
  23765. * Sets the absolute position of the mesh
  23766. * @param absolutePosition The absolute position of the mesh
  23767. * @returns The transform node
  23768. */
  23769. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23770. /**
  23771. * Gets the class name of the mesh
  23772. * @returns The class name
  23773. */
  23774. getClassName(): string;
  23775. }
  23776. /**
  23777. * Represents a physics imposter
  23778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23779. */
  23780. export class PhysicsImpostor {
  23781. /**
  23782. * The physics-enabled object used as the physics imposter
  23783. */
  23784. object: IPhysicsEnabledObject;
  23785. /**
  23786. * The type of the physics imposter
  23787. */
  23788. type: number;
  23789. private _options;
  23790. private _scene?;
  23791. /**
  23792. * The default object size of the imposter
  23793. */
  23794. static DEFAULT_OBJECT_SIZE: Vector3;
  23795. /**
  23796. * The identity quaternion of the imposter
  23797. */
  23798. static IDENTITY_QUATERNION: Quaternion;
  23799. /** @hidden */
  23800. _pluginData: any;
  23801. private _physicsEngine;
  23802. private _physicsBody;
  23803. private _bodyUpdateRequired;
  23804. private _onBeforePhysicsStepCallbacks;
  23805. private _onAfterPhysicsStepCallbacks;
  23806. /** @hidden */
  23807. _onPhysicsCollideCallbacks: Array<{
  23808. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23809. otherImpostors: Array<PhysicsImpostor>;
  23810. }>;
  23811. private _deltaPosition;
  23812. private _deltaRotation;
  23813. private _deltaRotationConjugated;
  23814. /** @hidden */
  23815. _isFromLine: boolean;
  23816. private _parent;
  23817. private _isDisposed;
  23818. private static _tmpVecs;
  23819. private static _tmpQuat;
  23820. /**
  23821. * Specifies if the physics imposter is disposed
  23822. */
  23823. readonly isDisposed: boolean;
  23824. /**
  23825. * Gets the mass of the physics imposter
  23826. */
  23827. mass: number;
  23828. /**
  23829. * Gets the coefficient of friction
  23830. */
  23831. /**
  23832. * Sets the coefficient of friction
  23833. */
  23834. friction: number;
  23835. /**
  23836. * Gets the coefficient of restitution
  23837. */
  23838. /**
  23839. * Sets the coefficient of restitution
  23840. */
  23841. restitution: number;
  23842. /**
  23843. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23844. */
  23845. /**
  23846. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23847. */
  23848. pressure: number;
  23849. /**
  23850. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23851. */
  23852. /**
  23853. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23854. */
  23855. stiffness: number;
  23856. /**
  23857. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23858. */
  23859. /**
  23860. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23861. */
  23862. velocityIterations: number;
  23863. /**
  23864. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23865. */
  23866. /**
  23867. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23868. */
  23869. positionIterations: number;
  23870. /**
  23871. * The unique id of the physics imposter
  23872. * set by the physics engine when adding this impostor to the array
  23873. */
  23874. uniqueId: number;
  23875. /**
  23876. * @hidden
  23877. */
  23878. soft: boolean;
  23879. /**
  23880. * @hidden
  23881. */
  23882. segments: number;
  23883. private _joints;
  23884. /**
  23885. * Initializes the physics imposter
  23886. * @param object The physics-enabled object used as the physics imposter
  23887. * @param type The type of the physics imposter
  23888. * @param _options The options for the physics imposter
  23889. * @param _scene The Babylon scene
  23890. */
  23891. constructor(
  23892. /**
  23893. * The physics-enabled object used as the physics imposter
  23894. */
  23895. object: IPhysicsEnabledObject,
  23896. /**
  23897. * The type of the physics imposter
  23898. */
  23899. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23900. /**
  23901. * This function will completly initialize this impostor.
  23902. * It will create a new body - but only if this mesh has no parent.
  23903. * If it has, this impostor will not be used other than to define the impostor
  23904. * of the child mesh.
  23905. * @hidden
  23906. */
  23907. _init(): void;
  23908. private _getPhysicsParent;
  23909. /**
  23910. * Should a new body be generated.
  23911. * @returns boolean specifying if body initialization is required
  23912. */
  23913. isBodyInitRequired(): boolean;
  23914. /**
  23915. * Sets the updated scaling
  23916. * @param updated Specifies if the scaling is updated
  23917. */
  23918. setScalingUpdated(): void;
  23919. /**
  23920. * Force a regeneration of this or the parent's impostor's body.
  23921. * Use under cautious - This will remove all joints already implemented.
  23922. */
  23923. forceUpdate(): void;
  23924. /**
  23925. * Gets the body that holds this impostor. Either its own, or its parent.
  23926. */
  23927. /**
  23928. * Set the physics body. Used mainly by the physics engine/plugin
  23929. */
  23930. physicsBody: any;
  23931. /**
  23932. * Get the parent of the physics imposter
  23933. * @returns Physics imposter or null
  23934. */
  23935. /**
  23936. * Sets the parent of the physics imposter
  23937. */
  23938. parent: Nullable<PhysicsImpostor>;
  23939. /**
  23940. * Resets the update flags
  23941. */
  23942. resetUpdateFlags(): void;
  23943. /**
  23944. * Gets the object extend size
  23945. * @returns the object extend size
  23946. */
  23947. getObjectExtendSize(): Vector3;
  23948. /**
  23949. * Gets the object center
  23950. * @returns The object center
  23951. */
  23952. getObjectCenter(): Vector3;
  23953. /**
  23954. * Get a specific parametes from the options parameter
  23955. * @param paramName The object parameter name
  23956. * @returns The object parameter
  23957. */
  23958. getParam(paramName: string): any;
  23959. /**
  23960. * Sets a specific parameter in the options given to the physics plugin
  23961. * @param paramName The parameter name
  23962. * @param value The value of the parameter
  23963. */
  23964. setParam(paramName: string, value: number): void;
  23965. /**
  23966. * Specifically change the body's mass option. Won't recreate the physics body object
  23967. * @param mass The mass of the physics imposter
  23968. */
  23969. setMass(mass: number): void;
  23970. /**
  23971. * Gets the linear velocity
  23972. * @returns linear velocity or null
  23973. */
  23974. getLinearVelocity(): Nullable<Vector3>;
  23975. /**
  23976. * Sets the linear velocity
  23977. * @param velocity linear velocity or null
  23978. */
  23979. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23980. /**
  23981. * Gets the angular velocity
  23982. * @returns angular velocity or null
  23983. */
  23984. getAngularVelocity(): Nullable<Vector3>;
  23985. /**
  23986. * Sets the angular velocity
  23987. * @param velocity The velocity or null
  23988. */
  23989. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23990. /**
  23991. * Execute a function with the physics plugin native code
  23992. * Provide a function the will have two variables - the world object and the physics body object
  23993. * @param func The function to execute with the physics plugin native code
  23994. */
  23995. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23996. /**
  23997. * Register a function that will be executed before the physics world is stepping forward
  23998. * @param func The function to execute before the physics world is stepped forward
  23999. */
  24000. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24001. /**
  24002. * Unregister a function that will be executed before the physics world is stepping forward
  24003. * @param func The function to execute before the physics world is stepped forward
  24004. */
  24005. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24006. /**
  24007. * Register a function that will be executed after the physics step
  24008. * @param func The function to execute after physics step
  24009. */
  24010. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24011. /**
  24012. * Unregisters a function that will be executed after the physics step
  24013. * @param func The function to execute after physics step
  24014. */
  24015. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24016. /**
  24017. * register a function that will be executed when this impostor collides against a different body
  24018. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24019. * @param func Callback that is executed on collision
  24020. */
  24021. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24022. /**
  24023. * Unregisters the physics imposter on contact
  24024. * @param collideAgainst The physics object to collide against
  24025. * @param func Callback to execute on collision
  24026. */
  24027. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24028. private _tmpQuat;
  24029. private _tmpQuat2;
  24030. /**
  24031. * Get the parent rotation
  24032. * @returns The parent rotation
  24033. */
  24034. getParentsRotation(): Quaternion;
  24035. /**
  24036. * this function is executed by the physics engine.
  24037. */
  24038. beforeStep: () => void;
  24039. /**
  24040. * this function is executed by the physics engine
  24041. */
  24042. afterStep: () => void;
  24043. /**
  24044. * Legacy collision detection event support
  24045. */
  24046. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24047. /**
  24048. * event and body object due to cannon's event-based architecture.
  24049. */
  24050. onCollide: (e: {
  24051. body: any;
  24052. }) => void;
  24053. /**
  24054. * Apply a force
  24055. * @param force The force to apply
  24056. * @param contactPoint The contact point for the force
  24057. * @returns The physics imposter
  24058. */
  24059. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24060. /**
  24061. * Apply an impulse
  24062. * @param force The impulse force
  24063. * @param contactPoint The contact point for the impulse force
  24064. * @returns The physics imposter
  24065. */
  24066. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24067. /**
  24068. * A help function to create a joint
  24069. * @param otherImpostor A physics imposter used to create a joint
  24070. * @param jointType The type of joint
  24071. * @param jointData The data for the joint
  24072. * @returns The physics imposter
  24073. */
  24074. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24075. /**
  24076. * Add a joint to this impostor with a different impostor
  24077. * @param otherImpostor A physics imposter used to add a joint
  24078. * @param joint The joint to add
  24079. * @returns The physics imposter
  24080. */
  24081. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24082. /**
  24083. * Add an anchor to a cloth impostor
  24084. * @param otherImpostor rigid impostor to anchor to
  24085. * @param width ratio across width from 0 to 1
  24086. * @param height ratio up height from 0 to 1
  24087. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24088. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24089. * @returns impostor the soft imposter
  24090. */
  24091. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24092. /**
  24093. * Add a hook to a rope impostor
  24094. * @param otherImpostor rigid impostor to anchor to
  24095. * @param length ratio across rope from 0 to 1
  24096. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24097. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24098. * @returns impostor the rope imposter
  24099. */
  24100. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24101. /**
  24102. * Will keep this body still, in a sleep mode.
  24103. * @returns the physics imposter
  24104. */
  24105. sleep(): PhysicsImpostor;
  24106. /**
  24107. * Wake the body up.
  24108. * @returns The physics imposter
  24109. */
  24110. wakeUp(): PhysicsImpostor;
  24111. /**
  24112. * Clones the physics imposter
  24113. * @param newObject The physics imposter clones to this physics-enabled object
  24114. * @returns A nullable physics imposter
  24115. */
  24116. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24117. /**
  24118. * Disposes the physics imposter
  24119. */
  24120. dispose(): void;
  24121. /**
  24122. * Sets the delta position
  24123. * @param position The delta position amount
  24124. */
  24125. setDeltaPosition(position: Vector3): void;
  24126. /**
  24127. * Sets the delta rotation
  24128. * @param rotation The delta rotation amount
  24129. */
  24130. setDeltaRotation(rotation: Quaternion): void;
  24131. /**
  24132. * Gets the box size of the physics imposter and stores the result in the input parameter
  24133. * @param result Stores the box size
  24134. * @returns The physics imposter
  24135. */
  24136. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24137. /**
  24138. * Gets the radius of the physics imposter
  24139. * @returns Radius of the physics imposter
  24140. */
  24141. getRadius(): number;
  24142. /**
  24143. * Sync a bone with this impostor
  24144. * @param bone The bone to sync to the impostor.
  24145. * @param boneMesh The mesh that the bone is influencing.
  24146. * @param jointPivot The pivot of the joint / bone in local space.
  24147. * @param distToJoint Optional distance from the impostor to the joint.
  24148. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24149. */
  24150. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24151. /**
  24152. * Sync impostor to a bone
  24153. * @param bone The bone that the impostor will be synced to.
  24154. * @param boneMesh The mesh that the bone is influencing.
  24155. * @param jointPivot The pivot of the joint / bone in local space.
  24156. * @param distToJoint Optional distance from the impostor to the joint.
  24157. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24158. * @param boneAxis Optional vector3 axis the bone is aligned with
  24159. */
  24160. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24161. /**
  24162. * No-Imposter type
  24163. */
  24164. static NoImpostor: number;
  24165. /**
  24166. * Sphere-Imposter type
  24167. */
  24168. static SphereImpostor: number;
  24169. /**
  24170. * Box-Imposter type
  24171. */
  24172. static BoxImpostor: number;
  24173. /**
  24174. * Plane-Imposter type
  24175. */
  24176. static PlaneImpostor: number;
  24177. /**
  24178. * Mesh-imposter type
  24179. */
  24180. static MeshImpostor: number;
  24181. /**
  24182. * Capsule-Impostor type (Ammo.js plugin only)
  24183. */
  24184. static CapsuleImpostor: number;
  24185. /**
  24186. * Cylinder-Imposter type
  24187. */
  24188. static CylinderImpostor: number;
  24189. /**
  24190. * Particle-Imposter type
  24191. */
  24192. static ParticleImpostor: number;
  24193. /**
  24194. * Heightmap-Imposter type
  24195. */
  24196. static HeightmapImpostor: number;
  24197. /**
  24198. * ConvexHull-Impostor type (Ammo.js plugin only)
  24199. */
  24200. static ConvexHullImpostor: number;
  24201. /**
  24202. * Rope-Imposter type
  24203. */
  24204. static RopeImpostor: number;
  24205. /**
  24206. * Cloth-Imposter type
  24207. */
  24208. static ClothImpostor: number;
  24209. /**
  24210. * Softbody-Imposter type
  24211. */
  24212. static SoftbodyImpostor: number;
  24213. }
  24214. }
  24215. declare module "babylonjs/Meshes/mesh" {
  24216. import { Observable } from "babylonjs/Misc/observable";
  24217. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24218. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24219. import { Camera } from "babylonjs/Cameras/camera";
  24220. import { Scene } from "babylonjs/scene";
  24221. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24222. import { Color4 } from "babylonjs/Maths/math.color";
  24223. import { Engine } from "babylonjs/Engines/engine";
  24224. import { Node } from "babylonjs/node";
  24225. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24226. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24227. import { Buffer } from "babylonjs/Meshes/buffer";
  24228. import { Geometry } from "babylonjs/Meshes/geometry";
  24229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24231. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24232. import { Effect } from "babylonjs/Materials/effect";
  24233. import { Material } from "babylonjs/Materials/material";
  24234. import { Skeleton } from "babylonjs/Bones/skeleton";
  24235. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24236. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24237. import { Path3D } from "babylonjs/Maths/math.path";
  24238. import { Plane } from "babylonjs/Maths/math.plane";
  24239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24240. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24241. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24242. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24243. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24244. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24245. /**
  24246. * @hidden
  24247. **/
  24248. export class _CreationDataStorage {
  24249. closePath?: boolean;
  24250. closeArray?: boolean;
  24251. idx: number[];
  24252. dashSize: number;
  24253. gapSize: number;
  24254. path3D: Path3D;
  24255. pathArray: Vector3[][];
  24256. arc: number;
  24257. radius: number;
  24258. cap: number;
  24259. tessellation: number;
  24260. }
  24261. /**
  24262. * @hidden
  24263. **/
  24264. class _InstanceDataStorage {
  24265. visibleInstances: any;
  24266. batchCache: _InstancesBatch;
  24267. instancesBufferSize: number;
  24268. instancesBuffer: Nullable<Buffer>;
  24269. instancesData: Float32Array;
  24270. overridenInstanceCount: number;
  24271. isFrozen: boolean;
  24272. previousBatch: Nullable<_InstancesBatch>;
  24273. hardwareInstancedRendering: boolean;
  24274. sideOrientation: number;
  24275. }
  24276. /**
  24277. * @hidden
  24278. **/
  24279. export class _InstancesBatch {
  24280. mustReturn: boolean;
  24281. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24282. renderSelf: boolean[];
  24283. hardwareInstancedRendering: boolean[];
  24284. }
  24285. /**
  24286. * Class used to represent renderable models
  24287. */
  24288. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24289. /**
  24290. * Mesh side orientation : usually the external or front surface
  24291. */
  24292. static readonly FRONTSIDE: number;
  24293. /**
  24294. * Mesh side orientation : usually the internal or back surface
  24295. */
  24296. static readonly BACKSIDE: number;
  24297. /**
  24298. * Mesh side orientation : both internal and external or front and back surfaces
  24299. */
  24300. static readonly DOUBLESIDE: number;
  24301. /**
  24302. * Mesh side orientation : by default, `FRONTSIDE`
  24303. */
  24304. static readonly DEFAULTSIDE: number;
  24305. /**
  24306. * Mesh cap setting : no cap
  24307. */
  24308. static readonly NO_CAP: number;
  24309. /**
  24310. * Mesh cap setting : one cap at the beginning of the mesh
  24311. */
  24312. static readonly CAP_START: number;
  24313. /**
  24314. * Mesh cap setting : one cap at the end of the mesh
  24315. */
  24316. static readonly CAP_END: number;
  24317. /**
  24318. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24319. */
  24320. static readonly CAP_ALL: number;
  24321. /**
  24322. * Mesh pattern setting : no flip or rotate
  24323. */
  24324. static readonly NO_FLIP: number;
  24325. /**
  24326. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24327. */
  24328. static readonly FLIP_TILE: number;
  24329. /**
  24330. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24331. */
  24332. static readonly ROTATE_TILE: number;
  24333. /**
  24334. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24335. */
  24336. static readonly FLIP_ROW: number;
  24337. /**
  24338. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24339. */
  24340. static readonly ROTATE_ROW: number;
  24341. /**
  24342. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24343. */
  24344. static readonly FLIP_N_ROTATE_TILE: number;
  24345. /**
  24346. * Mesh pattern setting : rotate pattern and rotate
  24347. */
  24348. static readonly FLIP_N_ROTATE_ROW: number;
  24349. /**
  24350. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24351. */
  24352. static readonly CENTER: number;
  24353. /**
  24354. * Mesh tile positioning : part tiles on left
  24355. */
  24356. static readonly LEFT: number;
  24357. /**
  24358. * Mesh tile positioning : part tiles on right
  24359. */
  24360. static readonly RIGHT: number;
  24361. /**
  24362. * Mesh tile positioning : part tiles on top
  24363. */
  24364. static readonly TOP: number;
  24365. /**
  24366. * Mesh tile positioning : part tiles on bottom
  24367. */
  24368. static readonly BOTTOM: number;
  24369. /**
  24370. * Gets the default side orientation.
  24371. * @param orientation the orientation to value to attempt to get
  24372. * @returns the default orientation
  24373. * @hidden
  24374. */
  24375. static _GetDefaultSideOrientation(orientation?: number): number;
  24376. private _internalMeshDataInfo;
  24377. /**
  24378. * An event triggered before rendering the mesh
  24379. */
  24380. readonly onBeforeRenderObservable: Observable<Mesh>;
  24381. /**
  24382. * An event triggered before binding the mesh
  24383. */
  24384. readonly onBeforeBindObservable: Observable<Mesh>;
  24385. /**
  24386. * An event triggered after rendering the mesh
  24387. */
  24388. readonly onAfterRenderObservable: Observable<Mesh>;
  24389. /**
  24390. * An event triggered before drawing the mesh
  24391. */
  24392. readonly onBeforeDrawObservable: Observable<Mesh>;
  24393. private _onBeforeDrawObserver;
  24394. /**
  24395. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24396. */
  24397. onBeforeDraw: () => void;
  24398. readonly hasInstances: boolean;
  24399. /**
  24400. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24401. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24402. */
  24403. delayLoadState: number;
  24404. /**
  24405. * Gets the list of instances created from this mesh
  24406. * it is not supposed to be modified manually.
  24407. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24408. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24409. */
  24410. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24411. /**
  24412. * Gets the file containing delay loading data for this mesh
  24413. */
  24414. delayLoadingFile: string;
  24415. /** @hidden */
  24416. _binaryInfo: any;
  24417. /**
  24418. * User defined function used to change how LOD level selection is done
  24419. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24420. */
  24421. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24422. /**
  24423. * Gets or sets the morph target manager
  24424. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24425. */
  24426. morphTargetManager: Nullable<MorphTargetManager>;
  24427. /** @hidden */
  24428. _creationDataStorage: Nullable<_CreationDataStorage>;
  24429. /** @hidden */
  24430. _geometry: Nullable<Geometry>;
  24431. /** @hidden */
  24432. _delayInfo: Array<string>;
  24433. /** @hidden */
  24434. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24435. /** @hidden */
  24436. _instanceDataStorage: _InstanceDataStorage;
  24437. private _effectiveMaterial;
  24438. /** @hidden */
  24439. _shouldGenerateFlatShading: boolean;
  24440. /** @hidden */
  24441. _originalBuilderSideOrientation: number;
  24442. /**
  24443. * Use this property to change the original side orientation defined at construction time
  24444. */
  24445. overrideMaterialSideOrientation: Nullable<number>;
  24446. /**
  24447. * Gets the source mesh (the one used to clone this one from)
  24448. */
  24449. readonly source: Nullable<Mesh>;
  24450. /**
  24451. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24452. */
  24453. isUnIndexed: boolean;
  24454. /**
  24455. * @constructor
  24456. * @param name The value used by scene.getMeshByName() to do a lookup.
  24457. * @param scene The scene to add this mesh to.
  24458. * @param parent The parent of this mesh, if it has one
  24459. * @param source An optional Mesh from which geometry is shared, cloned.
  24460. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24461. * When false, achieved by calling a clone(), also passing False.
  24462. * This will make creation of children, recursive.
  24463. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24464. */
  24465. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24466. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24467. /**
  24468. * Gets the class name
  24469. * @returns the string "Mesh".
  24470. */
  24471. getClassName(): string;
  24472. /** @hidden */
  24473. readonly _isMesh: boolean;
  24474. /**
  24475. * Returns a description of this mesh
  24476. * @param fullDetails define if full details about this mesh must be used
  24477. * @returns a descriptive string representing this mesh
  24478. */
  24479. toString(fullDetails?: boolean): string;
  24480. /** @hidden */
  24481. _unBindEffect(): void;
  24482. /**
  24483. * Gets a boolean indicating if this mesh has LOD
  24484. */
  24485. readonly hasLODLevels: boolean;
  24486. /**
  24487. * Gets the list of MeshLODLevel associated with the current mesh
  24488. * @returns an array of MeshLODLevel
  24489. */
  24490. getLODLevels(): MeshLODLevel[];
  24491. private _sortLODLevels;
  24492. /**
  24493. * Add a mesh as LOD level triggered at the given distance.
  24494. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24495. * @param distance The distance from the center of the object to show this level
  24496. * @param mesh The mesh to be added as LOD level (can be null)
  24497. * @return This mesh (for chaining)
  24498. */
  24499. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24500. /**
  24501. * Returns the LOD level mesh at the passed distance or null if not found.
  24502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24503. * @param distance The distance from the center of the object to show this level
  24504. * @returns a Mesh or `null`
  24505. */
  24506. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24507. /**
  24508. * Remove a mesh from the LOD array
  24509. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24510. * @param mesh defines the mesh to be removed
  24511. * @return This mesh (for chaining)
  24512. */
  24513. removeLODLevel(mesh: Mesh): Mesh;
  24514. /**
  24515. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24517. * @param camera defines the camera to use to compute distance
  24518. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24519. * @return This mesh (for chaining)
  24520. */
  24521. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24522. /**
  24523. * Gets the mesh internal Geometry object
  24524. */
  24525. readonly geometry: Nullable<Geometry>;
  24526. /**
  24527. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24528. * @returns the total number of vertices
  24529. */
  24530. getTotalVertices(): number;
  24531. /**
  24532. * Returns the content of an associated vertex buffer
  24533. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24534. * - VertexBuffer.PositionKind
  24535. * - VertexBuffer.UVKind
  24536. * - VertexBuffer.UV2Kind
  24537. * - VertexBuffer.UV3Kind
  24538. * - VertexBuffer.UV4Kind
  24539. * - VertexBuffer.UV5Kind
  24540. * - VertexBuffer.UV6Kind
  24541. * - VertexBuffer.ColorKind
  24542. * - VertexBuffer.MatricesIndicesKind
  24543. * - VertexBuffer.MatricesIndicesExtraKind
  24544. * - VertexBuffer.MatricesWeightsKind
  24545. * - VertexBuffer.MatricesWeightsExtraKind
  24546. * @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
  24547. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24548. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24549. */
  24550. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24551. /**
  24552. * Returns the mesh VertexBuffer object from the requested `kind`
  24553. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24554. * - VertexBuffer.PositionKind
  24555. * - VertexBuffer.NormalKind
  24556. * - VertexBuffer.UVKind
  24557. * - VertexBuffer.UV2Kind
  24558. * - VertexBuffer.UV3Kind
  24559. * - VertexBuffer.UV4Kind
  24560. * - VertexBuffer.UV5Kind
  24561. * - VertexBuffer.UV6Kind
  24562. * - VertexBuffer.ColorKind
  24563. * - VertexBuffer.MatricesIndicesKind
  24564. * - VertexBuffer.MatricesIndicesExtraKind
  24565. * - VertexBuffer.MatricesWeightsKind
  24566. * - VertexBuffer.MatricesWeightsExtraKind
  24567. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24568. */
  24569. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24570. /**
  24571. * Tests if a specific vertex buffer is associated with this mesh
  24572. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24573. * - VertexBuffer.PositionKind
  24574. * - VertexBuffer.NormalKind
  24575. * - VertexBuffer.UVKind
  24576. * - VertexBuffer.UV2Kind
  24577. * - VertexBuffer.UV3Kind
  24578. * - VertexBuffer.UV4Kind
  24579. * - VertexBuffer.UV5Kind
  24580. * - VertexBuffer.UV6Kind
  24581. * - VertexBuffer.ColorKind
  24582. * - VertexBuffer.MatricesIndicesKind
  24583. * - VertexBuffer.MatricesIndicesExtraKind
  24584. * - VertexBuffer.MatricesWeightsKind
  24585. * - VertexBuffer.MatricesWeightsExtraKind
  24586. * @returns a boolean
  24587. */
  24588. isVerticesDataPresent(kind: string): boolean;
  24589. /**
  24590. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24591. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24592. * - VertexBuffer.PositionKind
  24593. * - VertexBuffer.UVKind
  24594. * - VertexBuffer.UV2Kind
  24595. * - VertexBuffer.UV3Kind
  24596. * - VertexBuffer.UV4Kind
  24597. * - VertexBuffer.UV5Kind
  24598. * - VertexBuffer.UV6Kind
  24599. * - VertexBuffer.ColorKind
  24600. * - VertexBuffer.MatricesIndicesKind
  24601. * - VertexBuffer.MatricesIndicesExtraKind
  24602. * - VertexBuffer.MatricesWeightsKind
  24603. * - VertexBuffer.MatricesWeightsExtraKind
  24604. * @returns a boolean
  24605. */
  24606. isVertexBufferUpdatable(kind: string): boolean;
  24607. /**
  24608. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24609. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24610. * - VertexBuffer.PositionKind
  24611. * - VertexBuffer.NormalKind
  24612. * - VertexBuffer.UVKind
  24613. * - VertexBuffer.UV2Kind
  24614. * - VertexBuffer.UV3Kind
  24615. * - VertexBuffer.UV4Kind
  24616. * - VertexBuffer.UV5Kind
  24617. * - VertexBuffer.UV6Kind
  24618. * - VertexBuffer.ColorKind
  24619. * - VertexBuffer.MatricesIndicesKind
  24620. * - VertexBuffer.MatricesIndicesExtraKind
  24621. * - VertexBuffer.MatricesWeightsKind
  24622. * - VertexBuffer.MatricesWeightsExtraKind
  24623. * @returns an array of strings
  24624. */
  24625. getVerticesDataKinds(): string[];
  24626. /**
  24627. * Returns a positive integer : the total number of indices in this mesh geometry.
  24628. * @returns the numner of indices or zero if the mesh has no geometry.
  24629. */
  24630. getTotalIndices(): number;
  24631. /**
  24632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24633. * @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.
  24634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24635. * @returns the indices array or an empty array if the mesh has no geometry
  24636. */
  24637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24638. readonly isBlocked: boolean;
  24639. /**
  24640. * Determine if the current mesh is ready to be rendered
  24641. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24642. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24643. * @returns true if all associated assets are ready (material, textures, shaders)
  24644. */
  24645. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24646. /**
  24647. * 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.
  24648. */
  24649. readonly areNormalsFrozen: boolean;
  24650. /**
  24651. * 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.
  24652. * @returns the current mesh
  24653. */
  24654. freezeNormals(): Mesh;
  24655. /**
  24656. * 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
  24657. * @returns the current mesh
  24658. */
  24659. unfreezeNormals(): Mesh;
  24660. /**
  24661. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24662. */
  24663. overridenInstanceCount: number;
  24664. /** @hidden */
  24665. _preActivate(): Mesh;
  24666. /** @hidden */
  24667. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24668. /** @hidden */
  24669. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24670. /**
  24671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24672. * This means the mesh underlying bounding box and sphere are recomputed.
  24673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24674. * @returns the current mesh
  24675. */
  24676. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24677. /** @hidden */
  24678. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24679. /**
  24680. * This function will subdivide the mesh into multiple submeshes
  24681. * @param count defines the expected number of submeshes
  24682. */
  24683. subdivide(count: number): void;
  24684. /**
  24685. * Copy a FloatArray into a specific associated vertex buffer
  24686. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24687. * - VertexBuffer.PositionKind
  24688. * - VertexBuffer.UVKind
  24689. * - VertexBuffer.UV2Kind
  24690. * - VertexBuffer.UV3Kind
  24691. * - VertexBuffer.UV4Kind
  24692. * - VertexBuffer.UV5Kind
  24693. * - VertexBuffer.UV6Kind
  24694. * - VertexBuffer.ColorKind
  24695. * - VertexBuffer.MatricesIndicesKind
  24696. * - VertexBuffer.MatricesIndicesExtraKind
  24697. * - VertexBuffer.MatricesWeightsKind
  24698. * - VertexBuffer.MatricesWeightsExtraKind
  24699. * @param data defines the data source
  24700. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24701. * @param stride defines the data stride size (can be null)
  24702. * @returns the current mesh
  24703. */
  24704. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24705. /**
  24706. * Flags an associated vertex buffer as updatable
  24707. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24708. * - VertexBuffer.PositionKind
  24709. * - VertexBuffer.UVKind
  24710. * - VertexBuffer.UV2Kind
  24711. * - VertexBuffer.UV3Kind
  24712. * - VertexBuffer.UV4Kind
  24713. * - VertexBuffer.UV5Kind
  24714. * - VertexBuffer.UV6Kind
  24715. * - VertexBuffer.ColorKind
  24716. * - VertexBuffer.MatricesIndicesKind
  24717. * - VertexBuffer.MatricesIndicesExtraKind
  24718. * - VertexBuffer.MatricesWeightsKind
  24719. * - VertexBuffer.MatricesWeightsExtraKind
  24720. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24721. */
  24722. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24723. /**
  24724. * Sets the mesh global Vertex Buffer
  24725. * @param buffer defines the buffer to use
  24726. * @returns the current mesh
  24727. */
  24728. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24729. /**
  24730. * Update a specific associated vertex buffer
  24731. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24732. * - VertexBuffer.PositionKind
  24733. * - VertexBuffer.UVKind
  24734. * - VertexBuffer.UV2Kind
  24735. * - VertexBuffer.UV3Kind
  24736. * - VertexBuffer.UV4Kind
  24737. * - VertexBuffer.UV5Kind
  24738. * - VertexBuffer.UV6Kind
  24739. * - VertexBuffer.ColorKind
  24740. * - VertexBuffer.MatricesIndicesKind
  24741. * - VertexBuffer.MatricesIndicesExtraKind
  24742. * - VertexBuffer.MatricesWeightsKind
  24743. * - VertexBuffer.MatricesWeightsExtraKind
  24744. * @param data defines the data source
  24745. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24746. * @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)
  24747. * @returns the current mesh
  24748. */
  24749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24750. /**
  24751. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24752. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24753. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24754. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24755. * @returns the current mesh
  24756. */
  24757. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24758. /**
  24759. * Creates a un-shared specific occurence of the geometry for the mesh.
  24760. * @returns the current mesh
  24761. */
  24762. makeGeometryUnique(): Mesh;
  24763. /**
  24764. * Set the index buffer of this mesh
  24765. * @param indices defines the source data
  24766. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24767. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24768. * @returns the current mesh
  24769. */
  24770. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24771. /**
  24772. * Update the current index buffer
  24773. * @param indices defines the source data
  24774. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24775. * @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)
  24776. * @returns the current mesh
  24777. */
  24778. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24779. /**
  24780. * Invert the geometry to move from a right handed system to a left handed one.
  24781. * @returns the current mesh
  24782. */
  24783. toLeftHanded(): Mesh;
  24784. /** @hidden */
  24785. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24786. /** @hidden */
  24787. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24788. /**
  24789. * Registers for this mesh a javascript function called just before the rendering process
  24790. * @param func defines the function to call before rendering this mesh
  24791. * @returns the current mesh
  24792. */
  24793. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24794. /**
  24795. * Disposes a previously registered javascript function called before the rendering
  24796. * @param func defines the function to remove
  24797. * @returns the current mesh
  24798. */
  24799. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24800. /**
  24801. * Registers for this mesh a javascript function called just after the rendering is complete
  24802. * @param func defines the function to call after rendering this mesh
  24803. * @returns the current mesh
  24804. */
  24805. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24806. /**
  24807. * Disposes a previously registered javascript function called after the rendering.
  24808. * @param func defines the function to remove
  24809. * @returns the current mesh
  24810. */
  24811. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24812. /** @hidden */
  24813. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24814. /** @hidden */
  24815. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24816. /** @hidden */
  24817. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24818. /** @hidden */
  24819. _rebuild(): void;
  24820. /** @hidden */
  24821. _freeze(): void;
  24822. /** @hidden */
  24823. _unFreeze(): void;
  24824. /**
  24825. * 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
  24826. * @param subMesh defines the subMesh to render
  24827. * @param enableAlphaMode defines if alpha mode can be changed
  24828. * @returns the current mesh
  24829. */
  24830. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24831. private _onBeforeDraw;
  24832. /**
  24833. * Renormalize the mesh and patch it up if there are no weights
  24834. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24835. * However in the case of zero weights then we set just a single influence to 1.
  24836. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24837. */
  24838. cleanMatrixWeights(): void;
  24839. private normalizeSkinFourWeights;
  24840. private normalizeSkinWeightsAndExtra;
  24841. /**
  24842. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24843. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24844. * the user know there was an issue with importing the mesh
  24845. * @returns a validation object with skinned, valid and report string
  24846. */
  24847. validateSkinning(): {
  24848. skinned: boolean;
  24849. valid: boolean;
  24850. report: string;
  24851. };
  24852. /** @hidden */
  24853. _checkDelayState(): Mesh;
  24854. private _queueLoad;
  24855. /**
  24856. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24857. * A mesh is in the frustum if its bounding box intersects the frustum
  24858. * @param frustumPlanes defines the frustum to test
  24859. * @returns true if the mesh is in the frustum planes
  24860. */
  24861. isInFrustum(frustumPlanes: Plane[]): boolean;
  24862. /**
  24863. * Sets the mesh material by the material or multiMaterial `id` property
  24864. * @param id is a string identifying the material or the multiMaterial
  24865. * @returns the current mesh
  24866. */
  24867. setMaterialByID(id: string): Mesh;
  24868. /**
  24869. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24870. * @returns an array of IAnimatable
  24871. */
  24872. getAnimatables(): IAnimatable[];
  24873. /**
  24874. * Modifies the mesh geometry according to the passed transformation matrix.
  24875. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24876. * The mesh normals are modified using the same transformation.
  24877. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24878. * @param transform defines the transform matrix to use
  24879. * @see http://doc.babylonjs.com/resources/baking_transformations
  24880. * @returns the current mesh
  24881. */
  24882. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24883. /**
  24884. * Modifies the mesh geometry according to its own current World Matrix.
  24885. * The mesh World Matrix is then reset.
  24886. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24887. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24888. * @see http://doc.babylonjs.com/resources/baking_transformations
  24889. * @returns the current mesh
  24890. */
  24891. bakeCurrentTransformIntoVertices(): Mesh;
  24892. /** @hidden */
  24893. readonly _positions: Nullable<Vector3[]>;
  24894. /** @hidden */
  24895. _resetPointsArrayCache(): Mesh;
  24896. /** @hidden */
  24897. _generatePointsArray(): boolean;
  24898. /**
  24899. * Returns a new Mesh object generated from the current mesh properties.
  24900. * This method must not get confused with createInstance()
  24901. * @param name is a string, the name given to the new mesh
  24902. * @param newParent can be any Node object (default `null`)
  24903. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24904. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24905. * @returns a new mesh
  24906. */
  24907. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24908. /**
  24909. * Releases resources associated with this mesh.
  24910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24912. */
  24913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24914. /**
  24915. * Modifies the mesh geometry according to a displacement map.
  24916. * 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.
  24917. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24918. * @param url is a string, the URL from the image file is to be downloaded.
  24919. * @param minHeight is the lower limit of the displacement.
  24920. * @param maxHeight is the upper limit of the displacement.
  24921. * @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.
  24922. * @param uvOffset is an optional vector2 used to offset UV.
  24923. * @param uvScale is an optional vector2 used to scale UV.
  24924. * @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.
  24925. * @returns the Mesh.
  24926. */
  24927. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24928. /**
  24929. * Modifies the mesh geometry according to a displacementMap buffer.
  24930. * 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.
  24931. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24932. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24933. * @param heightMapWidth is the width of the buffer image.
  24934. * @param heightMapHeight is the height of the buffer image.
  24935. * @param minHeight is the lower limit of the displacement.
  24936. * @param maxHeight is the upper limit of the displacement.
  24937. * @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.
  24938. * @param uvOffset is an optional vector2 used to offset UV.
  24939. * @param uvScale is an optional vector2 used to scale UV.
  24940. * @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.
  24941. * @returns the Mesh.
  24942. */
  24943. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24944. /**
  24945. * Modify the mesh to get a flat shading rendering.
  24946. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24947. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24948. * @returns current mesh
  24949. */
  24950. convertToFlatShadedMesh(): Mesh;
  24951. /**
  24952. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24953. * In other words, more vertices, no more indices and a single bigger VBO.
  24954. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24955. * @returns current mesh
  24956. */
  24957. convertToUnIndexedMesh(): Mesh;
  24958. /**
  24959. * Inverses facet orientations.
  24960. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24961. * @param flipNormals will also inverts the normals
  24962. * @returns current mesh
  24963. */
  24964. flipFaces(flipNormals?: boolean): Mesh;
  24965. /**
  24966. * Increase the number of facets and hence vertices in a mesh
  24967. * Vertex normals are interpolated from existing vertex normals
  24968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24969. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24970. */
  24971. increaseVertices(numberPerEdge: number): void;
  24972. /**
  24973. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24974. * This will undo any application of covertToFlatShadedMesh
  24975. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24976. */
  24977. forceSharedVertices(): void;
  24978. /** @hidden */
  24979. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24980. /** @hidden */
  24981. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24982. /**
  24983. * Creates a new InstancedMesh object from the mesh model.
  24984. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24985. * @param name defines the name of the new instance
  24986. * @returns a new InstancedMesh
  24987. */
  24988. createInstance(name: string): InstancedMesh;
  24989. /**
  24990. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24991. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24992. * @returns the current mesh
  24993. */
  24994. synchronizeInstances(): Mesh;
  24995. /**
  24996. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24997. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24998. * This should be used together with the simplification to avoid disappearing triangles.
  24999. * @param successCallback an optional success callback to be called after the optimization finished.
  25000. * @returns the current mesh
  25001. */
  25002. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25003. /**
  25004. * Serialize current mesh
  25005. * @param serializationObject defines the object which will receive the serialization data
  25006. */
  25007. serialize(serializationObject: any): void;
  25008. /** @hidden */
  25009. _syncGeometryWithMorphTargetManager(): void;
  25010. /** @hidden */
  25011. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25012. /**
  25013. * Returns a new Mesh object parsed from the source provided.
  25014. * @param parsedMesh is the source
  25015. * @param scene defines the hosting scene
  25016. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25017. * @returns a new Mesh
  25018. */
  25019. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25020. /**
  25021. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25022. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25023. * @param name defines the name of the mesh to create
  25024. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25025. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25026. * @param closePath creates a seam between the first and the last points of each path of the path array
  25027. * @param offset is taken in account only if the `pathArray` is containing a single path
  25028. * @param scene defines the hosting scene
  25029. * @param updatable defines if the mesh must be flagged as updatable
  25030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25031. * @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)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25035. /**
  25036. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25039. * @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
  25040. * @param scene defines the hosting scene
  25041. * @param updatable defines if the mesh must be flagged as updatable
  25042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25043. * @returns a new Mesh
  25044. */
  25045. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25046. /**
  25047. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25048. * @param name defines the name of the mesh to create
  25049. * @param size sets the size (float) of each box side (default 1)
  25050. * @param scene defines the hosting scene
  25051. * @param updatable defines if the mesh must be flagged as updatable
  25052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25053. * @returns a new Mesh
  25054. */
  25055. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25056. /**
  25057. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25058. * @param name defines the name of the mesh to create
  25059. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25060. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25061. * @param scene defines the hosting scene
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25067. /**
  25068. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25069. * @param name defines the name of the mesh to create
  25070. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25071. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25072. * @param scene defines the hosting scene
  25073. * @returns a new Mesh
  25074. */
  25075. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25076. /**
  25077. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25078. * @param name defines the name of the mesh to create
  25079. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25080. * @param diameterTop set the top cap diameter (floats, default 1)
  25081. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25082. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25083. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25087. * @returns a new Mesh
  25088. */
  25089. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25090. /**
  25091. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25092. * @param name defines the name of the mesh to create
  25093. * @param diameter sets the diameter size (float) of the torus (default 1)
  25094. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25095. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25096. * @param scene defines the hosting scene
  25097. * @param updatable defines if the mesh must be flagged as updatable
  25098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25099. * @returns a new Mesh
  25100. */
  25101. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25102. /**
  25103. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25104. * @param name defines the name of the mesh to create
  25105. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25106. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25107. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25108. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25109. * @param p the number of windings on X axis (positive integers, default 2)
  25110. * @param q the number of windings on Y axis (positive integers, default 3)
  25111. * @param scene defines the hosting scene
  25112. * @param updatable defines if the mesh must be flagged as updatable
  25113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25114. * @returns a new Mesh
  25115. */
  25116. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25117. /**
  25118. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25119. * @param name defines the name of the mesh to create
  25120. * @param points is an array successive Vector3
  25121. * @param scene defines the hosting scene
  25122. * @param updatable defines if the mesh must be flagged as updatable
  25123. * @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).
  25124. * @returns a new Mesh
  25125. */
  25126. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25127. /**
  25128. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25129. * @param name defines the name of the mesh to create
  25130. * @param points is an array successive Vector3
  25131. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25132. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25133. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25134. * @param scene defines the hosting scene
  25135. * @param updatable defines if the mesh must be flagged as updatable
  25136. * @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)
  25137. * @returns a new Mesh
  25138. */
  25139. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25140. /**
  25141. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25142. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25143. * 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.
  25144. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25145. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25146. * Remember you can only change the shape positions, not their number when updating a polygon.
  25147. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25148. * @param name defines the name of the mesh to create
  25149. * @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
  25150. * @param scene defines the hosting scene
  25151. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25152. * @param updatable defines if the mesh must be flagged as updatable
  25153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25154. * @param earcutInjection can be used to inject your own earcut reference
  25155. * @returns a new Mesh
  25156. */
  25157. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25158. /**
  25159. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25160. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25161. * @param name defines the name of the mesh to create
  25162. * @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
  25163. * @param depth defines the height of extrusion
  25164. * @param scene defines the hosting scene
  25165. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25166. * @param updatable defines if the mesh must be flagged as updatable
  25167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25168. * @param earcutInjection can be used to inject your own earcut reference
  25169. * @returns a new Mesh
  25170. */
  25171. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25172. /**
  25173. * Creates an extruded shape mesh.
  25174. * 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
  25175. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25176. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25177. * @param name defines the name of the mesh to create
  25178. * @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
  25179. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25180. * @param scale is the value to scale the shape
  25181. * @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
  25182. * @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
  25183. * @param scene defines the hosting scene
  25184. * @param updatable defines if the mesh must be flagged as updatable
  25185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25186. * @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)
  25187. * @returns a new Mesh
  25188. */
  25189. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25190. /**
  25191. * Creates an custom extruded shape mesh.
  25192. * The custom extrusion is a parametric shape.
  25193. * It has no predefined shape. Its final shape will depend on the input parameters.
  25194. * Please consider using the same method from the MeshBuilder class instead
  25195. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25196. * @param name defines the name of the mesh to create
  25197. * @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
  25198. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25199. * @param scaleFunction is a custom Javascript function called on each path point
  25200. * @param rotationFunction is a custom Javascript function called on each path point
  25201. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25202. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25203. * @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
  25204. * @param scene defines the hosting scene
  25205. * @param updatable defines if the mesh must be flagged as updatable
  25206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25207. * @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)
  25208. * @returns a new Mesh
  25209. */
  25210. 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;
  25211. /**
  25212. * Creates lathe mesh.
  25213. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25214. * Please consider using the same method from the MeshBuilder class instead
  25215. * @param name defines the name of the mesh to create
  25216. * @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
  25217. * @param radius is the radius value of the lathe
  25218. * @param tessellation is the side number of the lathe.
  25219. * @param scene defines the hosting scene
  25220. * @param updatable defines if the mesh must be flagged as updatable
  25221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25222. * @returns a new Mesh
  25223. */
  25224. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25225. /**
  25226. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25227. * @param name defines the name of the mesh to create
  25228. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25232. * @returns a new Mesh
  25233. */
  25234. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25235. /**
  25236. * Creates a ground mesh.
  25237. * Please consider using the same method from the MeshBuilder class instead
  25238. * @param name defines the name of the mesh to create
  25239. * @param width set the width of the ground
  25240. * @param height set the height of the ground
  25241. * @param subdivisions sets the number of subdivisions per side
  25242. * @param scene defines the hosting scene
  25243. * @param updatable defines if the mesh must be flagged as updatable
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25247. /**
  25248. * Creates a tiled ground mesh.
  25249. * Please consider using the same method from the MeshBuilder class instead
  25250. * @param name defines the name of the mesh to create
  25251. * @param xmin set the ground minimum X coordinate
  25252. * @param zmin set the ground minimum Y coordinate
  25253. * @param xmax set the ground maximum X coordinate
  25254. * @param zmax set the ground maximum Z coordinate
  25255. * @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
  25256. * @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
  25257. * @param scene defines the hosting scene
  25258. * @param updatable defines if the mesh must be flagged as updatable
  25259. * @returns a new Mesh
  25260. */
  25261. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25262. w: number;
  25263. h: number;
  25264. }, precision: {
  25265. w: number;
  25266. h: number;
  25267. }, scene: Scene, updatable?: boolean): Mesh;
  25268. /**
  25269. * Creates a ground mesh from a height map.
  25270. * Please consider using the same method from the MeshBuilder class instead
  25271. * @see http://doc.babylonjs.com/babylon101/height_map
  25272. * @param name defines the name of the mesh to create
  25273. * @param url sets the URL of the height map image resource
  25274. * @param width set the ground width size
  25275. * @param height set the ground height size
  25276. * @param subdivisions sets the number of subdivision per side
  25277. * @param minHeight is the minimum altitude on the ground
  25278. * @param maxHeight is the maximum altitude on the ground
  25279. * @param scene defines the hosting scene
  25280. * @param updatable defines if the mesh must be flagged as updatable
  25281. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25282. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25283. * @returns a new Mesh
  25284. */
  25285. 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;
  25286. /**
  25287. * Creates a tube mesh.
  25288. * The tube is a parametric shape.
  25289. * It has no predefined shape. Its final shape will depend on the input parameters.
  25290. * Please consider using the same method from the MeshBuilder class instead
  25291. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25292. * @param name defines the name of the mesh to create
  25293. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25294. * @param radius sets the tube radius size
  25295. * @param tessellation is the number of sides on the tubular surface
  25296. * @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
  25297. * @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
  25298. * @param scene defines the hosting scene
  25299. * @param updatable defines if the mesh must be flagged as updatable
  25300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25301. * @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)
  25302. * @returns a new Mesh
  25303. */
  25304. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25305. (i: number, distance: number): number;
  25306. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25307. /**
  25308. * Creates a polyhedron mesh.
  25309. * Please consider using the same method from the MeshBuilder class instead.
  25310. * * 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
  25311. * * The parameter `size` (positive float, default 1) sets the polygon size
  25312. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25313. * * 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`
  25314. * * 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
  25315. * * 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)`)
  25316. * * 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
  25317. * * 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
  25318. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25319. * * If you create a double-sided mesh, you can choose what parts of 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
  25320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25321. * @param name defines the name of the mesh to create
  25322. * @param options defines the options used to create the mesh
  25323. * @param scene defines the hosting scene
  25324. * @returns a new Mesh
  25325. */
  25326. static CreatePolyhedron(name: string, options: {
  25327. type?: number;
  25328. size?: number;
  25329. sizeX?: number;
  25330. sizeY?: number;
  25331. sizeZ?: number;
  25332. custom?: any;
  25333. faceUV?: Vector4[];
  25334. faceColors?: Color4[];
  25335. updatable?: boolean;
  25336. sideOrientation?: number;
  25337. }, scene: Scene): Mesh;
  25338. /**
  25339. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25340. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25341. * * 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`)
  25342. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25343. * * 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
  25344. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25345. * * If you create a double-sided mesh, you can choose what parts of 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
  25346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25347. * @param name defines the name of the mesh
  25348. * @param options defines the options used to create the mesh
  25349. * @param scene defines the hosting scene
  25350. * @returns a new Mesh
  25351. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25352. */
  25353. static CreateIcoSphere(name: string, options: {
  25354. radius?: number;
  25355. flat?: boolean;
  25356. subdivisions?: number;
  25357. sideOrientation?: number;
  25358. updatable?: boolean;
  25359. }, scene: Scene): Mesh;
  25360. /**
  25361. * Creates a decal mesh.
  25362. * Please consider using the same method from the MeshBuilder class instead.
  25363. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25364. * @param name defines the name of the mesh
  25365. * @param sourceMesh defines the mesh receiving the decal
  25366. * @param position sets the position of the decal in world coordinates
  25367. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25368. * @param size sets the decal scaling
  25369. * @param angle sets the angle to rotate the decal
  25370. * @returns a new Mesh
  25371. */
  25372. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25373. /**
  25374. * Prepare internal position array for software CPU skinning
  25375. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25376. */
  25377. setPositionsForCPUSkinning(): Float32Array;
  25378. /**
  25379. * Prepare internal normal array for software CPU skinning
  25380. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25381. */
  25382. setNormalsForCPUSkinning(): Float32Array;
  25383. /**
  25384. * Updates the vertex buffer by applying transformation from the bones
  25385. * @param skeleton defines the skeleton to apply to current mesh
  25386. * @returns the current mesh
  25387. */
  25388. applySkeleton(skeleton: Skeleton): Mesh;
  25389. /**
  25390. * 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
  25391. * @param meshes defines the list of meshes to scan
  25392. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25393. */
  25394. static MinMax(meshes: AbstractMesh[]): {
  25395. min: Vector3;
  25396. max: Vector3;
  25397. };
  25398. /**
  25399. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25400. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25401. * @returns a vector3
  25402. */
  25403. static Center(meshesOrMinMaxVector: {
  25404. min: Vector3;
  25405. max: Vector3;
  25406. } | AbstractMesh[]): Vector3;
  25407. /**
  25408. * Merge the array of meshes into a single mesh for performance reasons.
  25409. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25410. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25411. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25412. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25413. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25414. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25415. * @returns a new mesh
  25416. */
  25417. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25418. /** @hidden */
  25419. addInstance(instance: InstancedMesh): void;
  25420. /** @hidden */
  25421. removeInstance(instance: InstancedMesh): void;
  25422. }
  25423. }
  25424. declare module "babylonjs/Cameras/camera" {
  25425. import { SmartArray } from "babylonjs/Misc/smartArray";
  25426. import { Observable } from "babylonjs/Misc/observable";
  25427. import { Nullable } from "babylonjs/types";
  25428. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25429. import { Scene } from "babylonjs/scene";
  25430. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25431. import { Node } from "babylonjs/node";
  25432. import { Mesh } from "babylonjs/Meshes/mesh";
  25433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25434. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25435. import { Viewport } from "babylonjs/Maths/math.viewport";
  25436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25438. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25439. import { Ray } from "babylonjs/Culling/ray";
  25440. /**
  25441. * This is the base class of all the camera used in the application.
  25442. * @see http://doc.babylonjs.com/features/cameras
  25443. */
  25444. export class Camera extends Node {
  25445. /** @hidden */
  25446. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25447. /**
  25448. * This is the default projection mode used by the cameras.
  25449. * It helps recreating a feeling of perspective and better appreciate depth.
  25450. * This is the best way to simulate real life cameras.
  25451. */
  25452. static readonly PERSPECTIVE_CAMERA: number;
  25453. /**
  25454. * This helps creating camera with an orthographic mode.
  25455. * 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.
  25456. */
  25457. static readonly ORTHOGRAPHIC_CAMERA: number;
  25458. /**
  25459. * This is the default FOV mode for perspective cameras.
  25460. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25461. */
  25462. static readonly FOVMODE_VERTICAL_FIXED: number;
  25463. /**
  25464. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25465. */
  25466. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25467. /**
  25468. * This specifies ther is no need for a camera rig.
  25469. * Basically only one eye is rendered corresponding to the camera.
  25470. */
  25471. static readonly RIG_MODE_NONE: number;
  25472. /**
  25473. * Simulates a camera Rig with one blue eye and one red eye.
  25474. * This can be use with 3d blue and red glasses.
  25475. */
  25476. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25477. /**
  25478. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25479. */
  25480. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25481. /**
  25482. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25483. */
  25484. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25485. /**
  25486. * Defines that both eyes of the camera will be rendered over under each other.
  25487. */
  25488. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25489. /**
  25490. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25491. */
  25492. static readonly RIG_MODE_VR: number;
  25493. /**
  25494. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25495. */
  25496. static readonly RIG_MODE_WEBVR: number;
  25497. /**
  25498. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25499. */
  25500. static readonly RIG_MODE_CUSTOM: number;
  25501. /**
  25502. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25503. */
  25504. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25505. /**
  25506. * Define the input manager associated with the camera.
  25507. */
  25508. inputs: CameraInputsManager<Camera>;
  25509. /** @hidden */
  25510. _position: Vector3;
  25511. /**
  25512. * Define the current local position of the camera in the scene
  25513. */
  25514. position: Vector3;
  25515. /**
  25516. * The vector the camera should consider as up.
  25517. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25518. */
  25519. upVector: Vector3;
  25520. /**
  25521. * Define the current limit on the left side for an orthographic camera
  25522. * In scene unit
  25523. */
  25524. orthoLeft: Nullable<number>;
  25525. /**
  25526. * Define the current limit on the right side for an orthographic camera
  25527. * In scene unit
  25528. */
  25529. orthoRight: Nullable<number>;
  25530. /**
  25531. * Define the current limit on the bottom side for an orthographic camera
  25532. * In scene unit
  25533. */
  25534. orthoBottom: Nullable<number>;
  25535. /**
  25536. * Define the current limit on the top side for an orthographic camera
  25537. * In scene unit
  25538. */
  25539. orthoTop: Nullable<number>;
  25540. /**
  25541. * Field Of View is set in Radians. (default is 0.8)
  25542. */
  25543. fov: number;
  25544. /**
  25545. * Define the minimum distance the camera can see from.
  25546. * This is important to note that the depth buffer are not infinite and the closer it starts
  25547. * the more your scene might encounter depth fighting issue.
  25548. */
  25549. minZ: number;
  25550. /**
  25551. * Define the maximum distance the camera can see to.
  25552. * This is important to note that the depth buffer are not infinite and the further it end
  25553. * the more your scene might encounter depth fighting issue.
  25554. */
  25555. maxZ: number;
  25556. /**
  25557. * Define the default inertia of the camera.
  25558. * This helps giving a smooth feeling to the camera movement.
  25559. */
  25560. inertia: number;
  25561. /**
  25562. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25563. */
  25564. mode: number;
  25565. /**
  25566. * Define wether the camera is intermediate.
  25567. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25568. */
  25569. isIntermediate: boolean;
  25570. /**
  25571. * Define the viewport of the camera.
  25572. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25573. */
  25574. viewport: Viewport;
  25575. /**
  25576. * Restricts the camera to viewing objects with the same layerMask.
  25577. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25578. */
  25579. layerMask: number;
  25580. /**
  25581. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25582. */
  25583. fovMode: number;
  25584. /**
  25585. * Rig mode of the camera.
  25586. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25587. * This is normally controlled byt the camera themselves as internal use.
  25588. */
  25589. cameraRigMode: number;
  25590. /**
  25591. * Defines the distance between both "eyes" in case of a RIG
  25592. */
  25593. interaxialDistance: number;
  25594. /**
  25595. * Defines if stereoscopic rendering is done side by side or over under.
  25596. */
  25597. isStereoscopicSideBySide: boolean;
  25598. /**
  25599. * 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
  25600. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25601. * else in the scene. (Eg. security camera)
  25602. *
  25603. * 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)
  25604. */
  25605. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25606. /**
  25607. * When set, the camera will render to this render target instead of the default canvas
  25608. *
  25609. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25610. */
  25611. outputRenderTarget: Nullable<RenderTargetTexture>;
  25612. /**
  25613. * Observable triggered when the camera view matrix has changed.
  25614. */
  25615. onViewMatrixChangedObservable: Observable<Camera>;
  25616. /**
  25617. * Observable triggered when the camera Projection matrix has changed.
  25618. */
  25619. onProjectionMatrixChangedObservable: Observable<Camera>;
  25620. /**
  25621. * Observable triggered when the inputs have been processed.
  25622. */
  25623. onAfterCheckInputsObservable: Observable<Camera>;
  25624. /**
  25625. * Observable triggered when reset has been called and applied to the camera.
  25626. */
  25627. onRestoreStateObservable: Observable<Camera>;
  25628. /** @hidden */
  25629. _cameraRigParams: any;
  25630. /** @hidden */
  25631. _rigCameras: Camera[];
  25632. /** @hidden */
  25633. _rigPostProcess: Nullable<PostProcess>;
  25634. protected _webvrViewMatrix: Matrix;
  25635. /** @hidden */
  25636. _skipRendering: boolean;
  25637. /** @hidden */
  25638. _projectionMatrix: Matrix;
  25639. /** @hidden */
  25640. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25641. /** @hidden */
  25642. _activeMeshes: SmartArray<AbstractMesh>;
  25643. protected _globalPosition: Vector3;
  25644. /** @hidden */
  25645. _computedViewMatrix: Matrix;
  25646. private _doNotComputeProjectionMatrix;
  25647. private _transformMatrix;
  25648. private _frustumPlanes;
  25649. private _refreshFrustumPlanes;
  25650. private _storedFov;
  25651. private _stateStored;
  25652. /**
  25653. * Instantiates a new camera object.
  25654. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25655. * @see http://doc.babylonjs.com/features/cameras
  25656. * @param name Defines the name of the camera in the scene
  25657. * @param position Defines the position of the camera
  25658. * @param scene Defines the scene the camera belongs too
  25659. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25660. */
  25661. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25662. /**
  25663. * Store current camera state (fov, position, etc..)
  25664. * @returns the camera
  25665. */
  25666. storeState(): Camera;
  25667. /**
  25668. * Restores the camera state values if it has been stored. You must call storeState() first
  25669. */
  25670. protected _restoreStateValues(): boolean;
  25671. /**
  25672. * Restored camera state. You must call storeState() first.
  25673. * @returns true if restored and false otherwise
  25674. */
  25675. restoreState(): boolean;
  25676. /**
  25677. * Gets the class name of the camera.
  25678. * @returns the class name
  25679. */
  25680. getClassName(): string;
  25681. /** @hidden */
  25682. readonly _isCamera: boolean;
  25683. /**
  25684. * Gets a string representation of the camera useful for debug purpose.
  25685. * @param fullDetails Defines that a more verboe level of logging is required
  25686. * @returns the string representation
  25687. */
  25688. toString(fullDetails?: boolean): string;
  25689. /**
  25690. * Gets the current world space position of the camera.
  25691. */
  25692. readonly globalPosition: Vector3;
  25693. /**
  25694. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25695. * @returns the active meshe list
  25696. */
  25697. getActiveMeshes(): SmartArray<AbstractMesh>;
  25698. /**
  25699. * Check wether a mesh is part of the current active mesh list of the camera
  25700. * @param mesh Defines the mesh to check
  25701. * @returns true if active, false otherwise
  25702. */
  25703. isActiveMesh(mesh: Mesh): boolean;
  25704. /**
  25705. * Is this camera ready to be used/rendered
  25706. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25707. * @return true if the camera is ready
  25708. */
  25709. isReady(completeCheck?: boolean): boolean;
  25710. /** @hidden */
  25711. _initCache(): void;
  25712. /** @hidden */
  25713. _updateCache(ignoreParentClass?: boolean): void;
  25714. /** @hidden */
  25715. _isSynchronized(): boolean;
  25716. /** @hidden */
  25717. _isSynchronizedViewMatrix(): boolean;
  25718. /** @hidden */
  25719. _isSynchronizedProjectionMatrix(): boolean;
  25720. /**
  25721. * Attach the input controls to a specific dom element to get the input from.
  25722. * @param element Defines the element the controls should be listened from
  25723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25724. */
  25725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25726. /**
  25727. * Detach the current controls from the specified dom element.
  25728. * @param element Defines the element to stop listening the inputs from
  25729. */
  25730. detachControl(element: HTMLElement): void;
  25731. /**
  25732. * Update the camera state according to the different inputs gathered during the frame.
  25733. */
  25734. update(): void;
  25735. /** @hidden */
  25736. _checkInputs(): void;
  25737. /** @hidden */
  25738. readonly rigCameras: Camera[];
  25739. /**
  25740. * Gets the post process used by the rig cameras
  25741. */
  25742. readonly rigPostProcess: Nullable<PostProcess>;
  25743. /**
  25744. * Internal, gets the first post proces.
  25745. * @returns the first post process to be run on this camera.
  25746. */
  25747. _getFirstPostProcess(): Nullable<PostProcess>;
  25748. private _cascadePostProcessesToRigCams;
  25749. /**
  25750. * Attach a post process to the camera.
  25751. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25752. * @param postProcess The post process to attach to the camera
  25753. * @param insertAt The position of the post process in case several of them are in use in the scene
  25754. * @returns the position the post process has been inserted at
  25755. */
  25756. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25757. /**
  25758. * Detach a post process to the camera.
  25759. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25760. * @param postProcess The post process to detach from the camera
  25761. */
  25762. detachPostProcess(postProcess: PostProcess): void;
  25763. /**
  25764. * Gets the current world matrix of the camera
  25765. */
  25766. getWorldMatrix(): Matrix;
  25767. /** @hidden */
  25768. _getViewMatrix(): Matrix;
  25769. /**
  25770. * Gets the current view matrix of the camera.
  25771. * @param force forces the camera to recompute the matrix without looking at the cached state
  25772. * @returns the view matrix
  25773. */
  25774. getViewMatrix(force?: boolean): Matrix;
  25775. /**
  25776. * Freeze the projection matrix.
  25777. * It will prevent the cache check of the camera projection compute and can speed up perf
  25778. * if no parameter of the camera are meant to change
  25779. * @param projection Defines manually a projection if necessary
  25780. */
  25781. freezeProjectionMatrix(projection?: Matrix): void;
  25782. /**
  25783. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25784. */
  25785. unfreezeProjectionMatrix(): void;
  25786. /**
  25787. * Gets the current projection matrix of the camera.
  25788. * @param force forces the camera to recompute the matrix without looking at the cached state
  25789. * @returns the projection matrix
  25790. */
  25791. getProjectionMatrix(force?: boolean): Matrix;
  25792. /**
  25793. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25794. * @returns a Matrix
  25795. */
  25796. getTransformationMatrix(): Matrix;
  25797. private _updateFrustumPlanes;
  25798. /**
  25799. * Checks if a cullable object (mesh...) is in the camera frustum
  25800. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25801. * @param target The object to check
  25802. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25803. * @returns true if the object is in frustum otherwise false
  25804. */
  25805. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25806. /**
  25807. * Checks if a cullable object (mesh...) is in the camera frustum
  25808. * Unlike isInFrustum this cheks the full bounding box
  25809. * @param target The object to check
  25810. * @returns true if the object is in frustum otherwise false
  25811. */
  25812. isCompletelyInFrustum(target: ICullable): boolean;
  25813. /**
  25814. * Gets a ray in the forward direction from the camera.
  25815. * @param length Defines the length of the ray to create
  25816. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25817. * @param origin Defines the start point of the ray which defaults to the camera position
  25818. * @returns the forward ray
  25819. */
  25820. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25821. /**
  25822. * Releases resources associated with this node.
  25823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25825. */
  25826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25827. /** @hidden */
  25828. _isLeftCamera: boolean;
  25829. /**
  25830. * Gets the left camera of a rig setup in case of Rigged Camera
  25831. */
  25832. readonly isLeftCamera: boolean;
  25833. /** @hidden */
  25834. _isRightCamera: boolean;
  25835. /**
  25836. * Gets the right camera of a rig setup in case of Rigged Camera
  25837. */
  25838. readonly isRightCamera: boolean;
  25839. /**
  25840. * Gets the left camera of a rig setup in case of Rigged Camera
  25841. */
  25842. readonly leftCamera: Nullable<FreeCamera>;
  25843. /**
  25844. * Gets the right camera of a rig setup in case of Rigged Camera
  25845. */
  25846. readonly rightCamera: Nullable<FreeCamera>;
  25847. /**
  25848. * Gets the left camera target of a rig setup in case of Rigged Camera
  25849. * @returns the target position
  25850. */
  25851. getLeftTarget(): Nullable<Vector3>;
  25852. /**
  25853. * Gets the right camera target of a rig setup in case of Rigged Camera
  25854. * @returns the target position
  25855. */
  25856. getRightTarget(): Nullable<Vector3>;
  25857. /**
  25858. * @hidden
  25859. */
  25860. setCameraRigMode(mode: number, rigParams: any): void;
  25861. /** @hidden */
  25862. static _setStereoscopicRigMode(camera: Camera): void;
  25863. /** @hidden */
  25864. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25865. /** @hidden */
  25866. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25867. /** @hidden */
  25868. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25869. /** @hidden */
  25870. _getVRProjectionMatrix(): Matrix;
  25871. protected _updateCameraRotationMatrix(): void;
  25872. protected _updateWebVRCameraRotationMatrix(): void;
  25873. /**
  25874. * This function MUST be overwritten by the different WebVR cameras available.
  25875. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25876. * @hidden
  25877. */
  25878. _getWebVRProjectionMatrix(): Matrix;
  25879. /**
  25880. * This function MUST be overwritten by the different WebVR cameras available.
  25881. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25882. * @hidden
  25883. */
  25884. _getWebVRViewMatrix(): Matrix;
  25885. /** @hidden */
  25886. setCameraRigParameter(name: string, value: any): void;
  25887. /**
  25888. * needs to be overridden by children so sub has required properties to be copied
  25889. * @hidden
  25890. */
  25891. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25892. /**
  25893. * May need to be overridden by children
  25894. * @hidden
  25895. */
  25896. _updateRigCameras(): void;
  25897. /** @hidden */
  25898. _setupInputs(): void;
  25899. /**
  25900. * Serialiaze the camera setup to a json represention
  25901. * @returns the JSON representation
  25902. */
  25903. serialize(): any;
  25904. /**
  25905. * Clones the current camera.
  25906. * @param name The cloned camera name
  25907. * @returns the cloned camera
  25908. */
  25909. clone(name: string): Camera;
  25910. /**
  25911. * Gets the direction of the camera relative to a given local axis.
  25912. * @param localAxis Defines the reference axis to provide a relative direction.
  25913. * @return the direction
  25914. */
  25915. getDirection(localAxis: Vector3): Vector3;
  25916. /**
  25917. * Returns the current camera absolute rotation
  25918. */
  25919. readonly absoluteRotation: Quaternion;
  25920. /**
  25921. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25922. * @param localAxis Defines the reference axis to provide a relative direction.
  25923. * @param result Defines the vector to store the result in
  25924. */
  25925. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25926. /**
  25927. * Gets a camera constructor for a given camera type
  25928. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25929. * @param name The name of the camera the result will be able to instantiate
  25930. * @param scene The scene the result will construct the camera in
  25931. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25932. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25933. * @returns a factory method to construc the camera
  25934. */
  25935. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25936. /**
  25937. * Compute the world matrix of the camera.
  25938. * @returns the camera workd matrix
  25939. */
  25940. computeWorldMatrix(): Matrix;
  25941. /**
  25942. * Parse a JSON and creates the camera from the parsed information
  25943. * @param parsedCamera The JSON to parse
  25944. * @param scene The scene to instantiate the camera in
  25945. * @returns the newly constructed camera
  25946. */
  25947. static Parse(parsedCamera: any, scene: Scene): Camera;
  25948. }
  25949. }
  25950. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25951. import { Nullable } from "babylonjs/types";
  25952. import { Scene } from "babylonjs/scene";
  25953. import { Vector4 } from "babylonjs/Maths/math.vector";
  25954. import { Mesh } from "babylonjs/Meshes/mesh";
  25955. /**
  25956. * Class containing static functions to help procedurally build meshes
  25957. */
  25958. export class DiscBuilder {
  25959. /**
  25960. * Creates a plane polygonal mesh. By default, this is a disc
  25961. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25962. * * 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
  25963. * * 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
  25964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25967. * @param name defines the name of the mesh
  25968. * @param options defines the options used to create the mesh
  25969. * @param scene defines the hosting scene
  25970. * @returns the plane polygonal mesh
  25971. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25972. */
  25973. static CreateDisc(name: string, options: {
  25974. radius?: number;
  25975. tessellation?: number;
  25976. arc?: number;
  25977. updatable?: boolean;
  25978. sideOrientation?: number;
  25979. frontUVs?: Vector4;
  25980. backUVs?: Vector4;
  25981. }, scene?: Nullable<Scene>): Mesh;
  25982. }
  25983. }
  25984. declare module "babylonjs/Particles/solidParticleSystem" {
  25985. import { Vector3 } from "babylonjs/Maths/math.vector";
  25986. import { Mesh } from "babylonjs/Meshes/mesh";
  25987. import { Scene, IDisposable } from "babylonjs/scene";
  25988. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25989. /**
  25990. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25991. *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.
  25992. * The SPS is also a particle system. It provides some methods to manage the particles.
  25993. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25994. *
  25995. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25996. */
  25997. export class SolidParticleSystem implements IDisposable {
  25998. /**
  25999. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26000. * Example : var p = SPS.particles[i];
  26001. */
  26002. particles: SolidParticle[];
  26003. /**
  26004. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26005. */
  26006. nbParticles: number;
  26007. /**
  26008. * If the particles must ever face the camera (default false). Useful for planar particles.
  26009. */
  26010. billboard: boolean;
  26011. /**
  26012. * Recompute normals when adding a shape
  26013. */
  26014. recomputeNormals: boolean;
  26015. /**
  26016. * This a counter ofr your own usage. It's not set by any SPS functions.
  26017. */
  26018. counter: number;
  26019. /**
  26020. * The SPS name. This name is also given to the underlying mesh.
  26021. */
  26022. name: string;
  26023. /**
  26024. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26025. */
  26026. mesh: Mesh;
  26027. /**
  26028. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26029. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26030. */
  26031. vars: any;
  26032. /**
  26033. * This array is populated when the SPS is set as 'pickable'.
  26034. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26035. * Each element of this array is an object `{idx: int, faceId: int}`.
  26036. * `idx` is the picked particle index in the `SPS.particles` array
  26037. * `faceId` is the picked face index counted within this particle.
  26038. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26039. */
  26040. pickedParticles: {
  26041. idx: number;
  26042. faceId: number;
  26043. }[];
  26044. /**
  26045. * This array is populated when `enableDepthSort` is set to true.
  26046. * Each element of this array is an instance of the class DepthSortedParticle.
  26047. */
  26048. depthSortedParticles: DepthSortedParticle[];
  26049. /**
  26050. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26051. * @hidden
  26052. */
  26053. _bSphereOnly: boolean;
  26054. /**
  26055. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26056. * @hidden
  26057. */
  26058. _bSphereRadiusFactor: number;
  26059. private _scene;
  26060. private _positions;
  26061. private _indices;
  26062. private _normals;
  26063. private _colors;
  26064. private _uvs;
  26065. private _indices32;
  26066. private _positions32;
  26067. private _normals32;
  26068. private _fixedNormal32;
  26069. private _colors32;
  26070. private _uvs32;
  26071. private _index;
  26072. private _updatable;
  26073. private _pickable;
  26074. private _isVisibilityBoxLocked;
  26075. private _alwaysVisible;
  26076. private _depthSort;
  26077. private _shapeCounter;
  26078. private _copy;
  26079. private _color;
  26080. private _computeParticleColor;
  26081. private _computeParticleTexture;
  26082. private _computeParticleRotation;
  26083. private _computeParticleVertex;
  26084. private _computeBoundingBox;
  26085. private _depthSortParticles;
  26086. private _camera;
  26087. private _mustUnrotateFixedNormals;
  26088. private _particlesIntersect;
  26089. private _needs32Bits;
  26090. /**
  26091. * Creates a SPS (Solid Particle System) object.
  26092. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26093. * @param scene (Scene) is the scene in which the SPS is added.
  26094. * @param options defines the options of the sps e.g.
  26095. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26096. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26097. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26098. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26099. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26100. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26101. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26102. */
  26103. constructor(name: string, scene: Scene, options?: {
  26104. updatable?: boolean;
  26105. isPickable?: boolean;
  26106. enableDepthSort?: boolean;
  26107. particleIntersection?: boolean;
  26108. boundingSphereOnly?: boolean;
  26109. bSphereRadiusFactor?: number;
  26110. });
  26111. /**
  26112. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26113. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26114. * @returns the created mesh
  26115. */
  26116. buildMesh(): Mesh;
  26117. /**
  26118. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26119. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26120. * Thus the particles generated from `digest()` have their property `position` set yet.
  26121. * @param mesh ( Mesh ) is the mesh to be digested
  26122. * @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
  26123. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26124. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26125. * @returns the current SPS
  26126. */
  26127. digest(mesh: Mesh, options?: {
  26128. facetNb?: number;
  26129. number?: number;
  26130. delta?: number;
  26131. }): SolidParticleSystem;
  26132. private _unrotateFixedNormals;
  26133. private _resetCopy;
  26134. private _meshBuilder;
  26135. private _posToShape;
  26136. private _uvsToShapeUV;
  26137. private _addParticle;
  26138. /**
  26139. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26140. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26141. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26142. * @param nb (positive integer) the number of particles to be created from this model
  26143. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26144. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26145. * @returns the number of shapes in the system
  26146. */
  26147. addShape(mesh: Mesh, nb: number, options?: {
  26148. positionFunction?: any;
  26149. vertexFunction?: any;
  26150. }): number;
  26151. private _rebuildParticle;
  26152. /**
  26153. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26154. * @returns the SPS.
  26155. */
  26156. rebuildMesh(): SolidParticleSystem;
  26157. /**
  26158. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26159. * This method calls `updateParticle()` for each particle of the SPS.
  26160. * For an animated SPS, it is usually called within the render loop.
  26161. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26162. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26163. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26164. * @returns the SPS.
  26165. */
  26166. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26167. /**
  26168. * Disposes the SPS.
  26169. */
  26170. dispose(): void;
  26171. /**
  26172. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26173. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26174. * @returns the SPS.
  26175. */
  26176. refreshVisibleSize(): SolidParticleSystem;
  26177. /**
  26178. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26179. * @param size the size (float) of the visibility box
  26180. * note : this doesn't lock the SPS mesh bounding box.
  26181. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26182. */
  26183. setVisibilityBox(size: number): void;
  26184. /**
  26185. * Gets whether the SPS as always visible or not
  26186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26187. */
  26188. /**
  26189. * Sets the SPS as always visible or not
  26190. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26191. */
  26192. isAlwaysVisible: boolean;
  26193. /**
  26194. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26196. */
  26197. /**
  26198. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26200. */
  26201. isVisibilityBoxLocked: boolean;
  26202. /**
  26203. * Tells to `setParticles()` to compute the particle rotations or not.
  26204. * Default value : true. The SPS is faster when it's set to false.
  26205. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26206. */
  26207. /**
  26208. * Gets if `setParticles()` computes the particle rotations or not.
  26209. * Default value : true. The SPS is faster when it's set to false.
  26210. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26211. */
  26212. computeParticleRotation: boolean;
  26213. /**
  26214. * Tells to `setParticles()` to compute the particle colors or not.
  26215. * Default value : true. The SPS is faster when it's set to false.
  26216. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26217. */
  26218. /**
  26219. * Gets if `setParticles()` computes the particle colors or not.
  26220. * Default value : true. The SPS is faster when it's set to false.
  26221. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26222. */
  26223. computeParticleColor: boolean;
  26224. /**
  26225. * Gets if `setParticles()` computes the particle textures or not.
  26226. * Default value : true. The SPS is faster when it's set to false.
  26227. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26228. */
  26229. computeParticleTexture: boolean;
  26230. /**
  26231. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26232. * Default value : false. The SPS is faster when it's set to false.
  26233. * Note : the particle custom vertex positions aren't stored values.
  26234. */
  26235. /**
  26236. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26237. * Default value : false. The SPS is faster when it's set to false.
  26238. * Note : the particle custom vertex positions aren't stored values.
  26239. */
  26240. computeParticleVertex: boolean;
  26241. /**
  26242. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26243. */
  26244. /**
  26245. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26246. */
  26247. computeBoundingBox: boolean;
  26248. /**
  26249. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26250. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26251. * Default : `true`
  26252. */
  26253. /**
  26254. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26255. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26256. * Default : `true`
  26257. */
  26258. depthSortParticles: boolean;
  26259. /**
  26260. * This function does nothing. It may be overwritten to set all the particle first values.
  26261. * The SPS doesn't call this function, you may have to call it by your own.
  26262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26263. */
  26264. initParticles(): void;
  26265. /**
  26266. * This function does nothing. It may be overwritten to recycle a particle.
  26267. * The SPS doesn't call this function, you may have to call it by your own.
  26268. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26269. * @param particle The particle to recycle
  26270. * @returns the recycled particle
  26271. */
  26272. recycleParticle(particle: SolidParticle): SolidParticle;
  26273. /**
  26274. * Updates a particle : this function should be overwritten by the user.
  26275. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26276. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26277. * @example : just set a particle position or velocity and recycle conditions
  26278. * @param particle The particle to update
  26279. * @returns the updated particle
  26280. */
  26281. updateParticle(particle: SolidParticle): SolidParticle;
  26282. /**
  26283. * Updates a vertex of a particle : it can be overwritten by the user.
  26284. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26285. * @param particle the current particle
  26286. * @param vertex the current index of the current particle
  26287. * @param pt the index of the current vertex in the particle shape
  26288. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26289. * @example : just set a vertex particle position
  26290. * @returns the updated vertex
  26291. */
  26292. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26293. /**
  26294. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26295. * This does nothing and may be overwritten by the user.
  26296. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26298. * @param update the boolean update value actually passed to setParticles()
  26299. */
  26300. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26301. /**
  26302. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26303. * This will be passed three parameters.
  26304. * This does nothing and may be overwritten by the user.
  26305. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26306. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26307. * @param update the boolean update value actually passed to setParticles()
  26308. */
  26309. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26310. }
  26311. }
  26312. declare module "babylonjs/Particles/solidParticle" {
  26313. import { Nullable } from "babylonjs/types";
  26314. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26315. import { Color4 } from "babylonjs/Maths/math.color";
  26316. import { Mesh } from "babylonjs/Meshes/mesh";
  26317. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26318. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26319. import { Plane } from "babylonjs/Maths/math.plane";
  26320. /**
  26321. * Represents one particle of a solid particle system.
  26322. */
  26323. export class SolidParticle {
  26324. /**
  26325. * particle global index
  26326. */
  26327. idx: number;
  26328. /**
  26329. * The color of the particle
  26330. */
  26331. color: Nullable<Color4>;
  26332. /**
  26333. * The world space position of the particle.
  26334. */
  26335. position: Vector3;
  26336. /**
  26337. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26338. */
  26339. rotation: Vector3;
  26340. /**
  26341. * The world space rotation quaternion of the particle.
  26342. */
  26343. rotationQuaternion: Nullable<Quaternion>;
  26344. /**
  26345. * The scaling of the particle.
  26346. */
  26347. scaling: Vector3;
  26348. /**
  26349. * The uvs of the particle.
  26350. */
  26351. uvs: Vector4;
  26352. /**
  26353. * The current speed of the particle.
  26354. */
  26355. velocity: Vector3;
  26356. /**
  26357. * The pivot point in the particle local space.
  26358. */
  26359. pivot: Vector3;
  26360. /**
  26361. * Must the particle be translated from its pivot point in its local space ?
  26362. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26363. * Default : false
  26364. */
  26365. translateFromPivot: boolean;
  26366. /**
  26367. * Is the particle active or not ?
  26368. */
  26369. alive: boolean;
  26370. /**
  26371. * Is the particle visible or not ?
  26372. */
  26373. isVisible: boolean;
  26374. /**
  26375. * Index of this particle in the global "positions" array (Internal use)
  26376. * @hidden
  26377. */
  26378. _pos: number;
  26379. /**
  26380. * @hidden Index of this particle in the global "indices" array (Internal use)
  26381. */
  26382. _ind: number;
  26383. /**
  26384. * @hidden ModelShape of this particle (Internal use)
  26385. */
  26386. _model: ModelShape;
  26387. /**
  26388. * ModelShape id of this particle
  26389. */
  26390. shapeId: number;
  26391. /**
  26392. * Index of the particle in its shape id
  26393. */
  26394. idxInShape: number;
  26395. /**
  26396. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26397. */
  26398. _modelBoundingInfo: BoundingInfo;
  26399. /**
  26400. * @hidden Particle BoundingInfo object (Internal use)
  26401. */
  26402. _boundingInfo: BoundingInfo;
  26403. /**
  26404. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26405. */
  26406. _sps: SolidParticleSystem;
  26407. /**
  26408. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26409. */
  26410. _stillInvisible: boolean;
  26411. /**
  26412. * @hidden Last computed particle rotation matrix
  26413. */
  26414. _rotationMatrix: number[];
  26415. /**
  26416. * Parent particle Id, if any.
  26417. * Default null.
  26418. */
  26419. parentId: Nullable<number>;
  26420. /**
  26421. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26422. * The possible values are :
  26423. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26424. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26425. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26426. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26427. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26428. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26429. * */
  26430. cullingStrategy: number;
  26431. /**
  26432. * @hidden Internal global position in the SPS.
  26433. */
  26434. _globalPosition: Vector3;
  26435. /**
  26436. * Creates a Solid Particle object.
  26437. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26438. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26439. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26440. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26441. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26442. * @param shapeId (integer) is the model shape identifier in the SPS.
  26443. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26444. * @param sps defines the sps it is associated to
  26445. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26446. */
  26447. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26448. /**
  26449. * Legacy support, changed scale to scaling
  26450. */
  26451. /**
  26452. * Legacy support, changed scale to scaling
  26453. */
  26454. scale: Vector3;
  26455. /**
  26456. * Legacy support, changed quaternion to rotationQuaternion
  26457. */
  26458. /**
  26459. * Legacy support, changed quaternion to rotationQuaternion
  26460. */
  26461. quaternion: Nullable<Quaternion>;
  26462. /**
  26463. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26464. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26465. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26466. * @returns true if it intersects
  26467. */
  26468. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26469. /**
  26470. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26471. * A particle is in the frustum if its bounding box intersects the frustum
  26472. * @param frustumPlanes defines the frustum to test
  26473. * @returns true if the particle is in the frustum planes
  26474. */
  26475. isInFrustum(frustumPlanes: Plane[]): boolean;
  26476. /**
  26477. * get the rotation matrix of the particle
  26478. * @hidden
  26479. */
  26480. getRotationMatrix(m: Matrix): void;
  26481. }
  26482. /**
  26483. * Represents the shape of the model used by one particle of a solid particle system.
  26484. * SPS internal tool, don't use it manually.
  26485. */
  26486. export class ModelShape {
  26487. /**
  26488. * The shape id
  26489. * @hidden
  26490. */
  26491. shapeID: number;
  26492. /**
  26493. * flat array of model positions (internal use)
  26494. * @hidden
  26495. */
  26496. _shape: Vector3[];
  26497. /**
  26498. * flat array of model UVs (internal use)
  26499. * @hidden
  26500. */
  26501. _shapeUV: number[];
  26502. /**
  26503. * length of the shape in the model indices array (internal use)
  26504. * @hidden
  26505. */
  26506. _indicesLength: number;
  26507. /**
  26508. * Custom position function (internal use)
  26509. * @hidden
  26510. */
  26511. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26512. /**
  26513. * Custom vertex function (internal use)
  26514. * @hidden
  26515. */
  26516. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26517. /**
  26518. * 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.
  26519. * SPS internal tool, don't use it manually.
  26520. * @hidden
  26521. */
  26522. 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>);
  26523. }
  26524. /**
  26525. * Represents a Depth Sorted Particle in the solid particle system.
  26526. */
  26527. export class DepthSortedParticle {
  26528. /**
  26529. * Index of the particle in the "indices" array
  26530. */
  26531. ind: number;
  26532. /**
  26533. * Length of the particle shape in the "indices" array
  26534. */
  26535. indicesLength: number;
  26536. /**
  26537. * Squared distance from the particle to the camera
  26538. */
  26539. sqDistance: number;
  26540. }
  26541. }
  26542. declare module "babylonjs/Collisions/meshCollisionData" {
  26543. import { Collider } from "babylonjs/Collisions/collider";
  26544. import { Vector3 } from "babylonjs/Maths/math.vector";
  26545. import { Nullable } from "babylonjs/types";
  26546. import { Observer } from "babylonjs/Misc/observable";
  26547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26548. /**
  26549. * @hidden
  26550. */
  26551. export class _MeshCollisionData {
  26552. _checkCollisions: boolean;
  26553. _collisionMask: number;
  26554. _collisionGroup: number;
  26555. _collider: Nullable<Collider>;
  26556. _oldPositionForCollisions: Vector3;
  26557. _diffPositionForCollisions: Vector3;
  26558. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26559. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26560. }
  26561. }
  26562. declare module "babylonjs/Meshes/abstractMesh" {
  26563. import { Observable } from "babylonjs/Misc/observable";
  26564. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26565. import { Camera } from "babylonjs/Cameras/camera";
  26566. import { Scene, IDisposable } from "babylonjs/scene";
  26567. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26568. import { Node } from "babylonjs/node";
  26569. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26573. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26574. import { Material } from "babylonjs/Materials/material";
  26575. import { Light } from "babylonjs/Lights/light";
  26576. import { Skeleton } from "babylonjs/Bones/skeleton";
  26577. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26578. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26579. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26580. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26581. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26582. import { Plane } from "babylonjs/Maths/math.plane";
  26583. import { Ray } from "babylonjs/Culling/ray";
  26584. import { Collider } from "babylonjs/Collisions/collider";
  26585. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26586. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26587. /** @hidden */
  26588. class _FacetDataStorage {
  26589. facetPositions: Vector3[];
  26590. facetNormals: Vector3[];
  26591. facetPartitioning: number[][];
  26592. facetNb: number;
  26593. partitioningSubdivisions: number;
  26594. partitioningBBoxRatio: number;
  26595. facetDataEnabled: boolean;
  26596. facetParameters: any;
  26597. bbSize: Vector3;
  26598. subDiv: {
  26599. max: number;
  26600. X: number;
  26601. Y: number;
  26602. Z: number;
  26603. };
  26604. facetDepthSort: boolean;
  26605. facetDepthSortEnabled: boolean;
  26606. depthSortedIndices: IndicesArray;
  26607. depthSortedFacets: {
  26608. ind: number;
  26609. sqDistance: number;
  26610. }[];
  26611. facetDepthSortFunction: (f1: {
  26612. ind: number;
  26613. sqDistance: number;
  26614. }, f2: {
  26615. ind: number;
  26616. sqDistance: number;
  26617. }) => number;
  26618. facetDepthSortFrom: Vector3;
  26619. facetDepthSortOrigin: Vector3;
  26620. invertedMatrix: Matrix;
  26621. }
  26622. /**
  26623. * @hidden
  26624. **/
  26625. class _InternalAbstractMeshDataInfo {
  26626. _hasVertexAlpha: boolean;
  26627. _useVertexColors: boolean;
  26628. _numBoneInfluencers: number;
  26629. _applyFog: boolean;
  26630. _receiveShadows: boolean;
  26631. _facetData: _FacetDataStorage;
  26632. _visibility: number;
  26633. _skeleton: Nullable<Skeleton>;
  26634. _layerMask: number;
  26635. _computeBonesUsingShaders: boolean;
  26636. _isActive: boolean;
  26637. _onlyForInstances: boolean;
  26638. _isActiveIntermediate: boolean;
  26639. _onlyForInstancesIntermediate: boolean;
  26640. }
  26641. /**
  26642. * Class used to store all common mesh properties
  26643. */
  26644. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26645. /** No occlusion */
  26646. static OCCLUSION_TYPE_NONE: number;
  26647. /** Occlusion set to optimisitic */
  26648. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26649. /** Occlusion set to strict */
  26650. static OCCLUSION_TYPE_STRICT: number;
  26651. /** Use an accurante occlusion algorithm */
  26652. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26653. /** Use a conservative occlusion algorithm */
  26654. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26655. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26656. * Test order :
  26657. * Is the bounding sphere outside the frustum ?
  26658. * If not, are the bounding box vertices outside the frustum ?
  26659. * It not, then the cullable object is in the frustum.
  26660. */
  26661. static readonly CULLINGSTRATEGY_STANDARD: number;
  26662. /** Culling strategy : Bounding Sphere Only.
  26663. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26664. * It's also less accurate than the standard because some not visible objects can still be selected.
  26665. * Test : is the bounding sphere outside the frustum ?
  26666. * If not, then the cullable object is in the frustum.
  26667. */
  26668. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26669. /** Culling strategy : Optimistic Inclusion.
  26670. * This in an inclusion test first, then the standard exclusion test.
  26671. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26672. * 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.
  26673. * Anyway, it's as accurate as the standard strategy.
  26674. * Test :
  26675. * Is the cullable object bounding sphere center in the frustum ?
  26676. * If not, apply the default culling strategy.
  26677. */
  26678. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26679. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26680. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26681. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26682. * 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.
  26683. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26684. * Test :
  26685. * Is the cullable object bounding sphere center in the frustum ?
  26686. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26687. */
  26688. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26689. /**
  26690. * No billboard
  26691. */
  26692. static readonly BILLBOARDMODE_NONE: number;
  26693. /** Billboard on X axis */
  26694. static readonly BILLBOARDMODE_X: number;
  26695. /** Billboard on Y axis */
  26696. static readonly BILLBOARDMODE_Y: number;
  26697. /** Billboard on Z axis */
  26698. static readonly BILLBOARDMODE_Z: number;
  26699. /** Billboard on all axes */
  26700. static readonly BILLBOARDMODE_ALL: number;
  26701. /** Billboard on using position instead of orientation */
  26702. static readonly BILLBOARDMODE_USE_POSITION: number;
  26703. /** @hidden */
  26704. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26705. /**
  26706. * The culling strategy to use to check whether the mesh must be rendered or not.
  26707. * This value can be changed at any time and will be used on the next render mesh selection.
  26708. * The possible values are :
  26709. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26710. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26711. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26713. * Please read each static variable documentation to get details about the culling process.
  26714. * */
  26715. cullingStrategy: number;
  26716. /**
  26717. * Gets the number of facets in the mesh
  26718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26719. */
  26720. readonly facetNb: number;
  26721. /**
  26722. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26724. */
  26725. partitioningSubdivisions: number;
  26726. /**
  26727. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26728. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26730. */
  26731. partitioningBBoxRatio: number;
  26732. /**
  26733. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26734. * Works only for updatable meshes.
  26735. * Doesn't work with multi-materials
  26736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26737. */
  26738. mustDepthSortFacets: boolean;
  26739. /**
  26740. * The location (Vector3) where the facet depth sort must be computed from.
  26741. * By default, the active camera position.
  26742. * Used only when facet depth sort is enabled
  26743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26744. */
  26745. facetDepthSortFrom: Vector3;
  26746. /**
  26747. * gets a boolean indicating if facetData is enabled
  26748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26749. */
  26750. readonly isFacetDataEnabled: boolean;
  26751. /** @hidden */
  26752. _updateNonUniformScalingState(value: boolean): boolean;
  26753. /**
  26754. * An event triggered when this mesh collides with another one
  26755. */
  26756. onCollideObservable: Observable<AbstractMesh>;
  26757. /** Set a function to call when this mesh collides with another one */
  26758. onCollide: () => void;
  26759. /**
  26760. * An event triggered when the collision's position changes
  26761. */
  26762. onCollisionPositionChangeObservable: Observable<Vector3>;
  26763. /** Set a function to call when the collision's position changes */
  26764. onCollisionPositionChange: () => void;
  26765. /**
  26766. * An event triggered when material is changed
  26767. */
  26768. onMaterialChangedObservable: Observable<AbstractMesh>;
  26769. /**
  26770. * Gets or sets the orientation for POV movement & rotation
  26771. */
  26772. definedFacingForward: boolean;
  26773. /** @hidden */
  26774. _occlusionQuery: Nullable<WebGLQuery>;
  26775. /** @hidden */
  26776. _renderingGroup: Nullable<RenderingGroup>;
  26777. /**
  26778. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26779. */
  26780. /**
  26781. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26782. */
  26783. visibility: number;
  26784. /** Gets or sets the alpha index used to sort transparent meshes
  26785. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26786. */
  26787. alphaIndex: number;
  26788. /**
  26789. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26790. */
  26791. isVisible: boolean;
  26792. /**
  26793. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26794. */
  26795. isPickable: boolean;
  26796. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26797. showSubMeshesBoundingBox: boolean;
  26798. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26800. */
  26801. isBlocker: boolean;
  26802. /**
  26803. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26804. */
  26805. enablePointerMoveEvents: boolean;
  26806. /**
  26807. * Specifies the rendering group id for this mesh (0 by default)
  26808. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26809. */
  26810. renderingGroupId: number;
  26811. private _material;
  26812. /** Gets or sets current material */
  26813. material: Nullable<Material>;
  26814. /**
  26815. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26816. * @see http://doc.babylonjs.com/babylon101/shadows
  26817. */
  26818. receiveShadows: boolean;
  26819. /** Defines color to use when rendering outline */
  26820. outlineColor: Color3;
  26821. /** Define width to use when rendering outline */
  26822. outlineWidth: number;
  26823. /** Defines color to use when rendering overlay */
  26824. overlayColor: Color3;
  26825. /** Defines alpha to use when rendering overlay */
  26826. overlayAlpha: number;
  26827. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26828. hasVertexAlpha: boolean;
  26829. /** 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) */
  26830. useVertexColors: boolean;
  26831. /**
  26832. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26833. */
  26834. computeBonesUsingShaders: boolean;
  26835. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26836. numBoneInfluencers: number;
  26837. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26838. applyFog: boolean;
  26839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26840. useOctreeForRenderingSelection: boolean;
  26841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26842. useOctreeForPicking: boolean;
  26843. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26844. useOctreeForCollisions: boolean;
  26845. /**
  26846. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26847. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26848. */
  26849. layerMask: number;
  26850. /**
  26851. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26852. */
  26853. alwaysSelectAsActiveMesh: boolean;
  26854. /**
  26855. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26856. */
  26857. doNotSyncBoundingInfo: boolean;
  26858. /**
  26859. * Gets or sets the current action manager
  26860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26861. */
  26862. actionManager: Nullable<AbstractActionManager>;
  26863. private _meshCollisionData;
  26864. /**
  26865. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26867. */
  26868. ellipsoid: Vector3;
  26869. /**
  26870. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26872. */
  26873. ellipsoidOffset: Vector3;
  26874. /**
  26875. * Gets or sets a collision mask used to mask collisions (default is -1).
  26876. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26877. */
  26878. collisionMask: number;
  26879. /**
  26880. * Gets or sets the current collision group mask (-1 by default).
  26881. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26882. */
  26883. collisionGroup: number;
  26884. /**
  26885. * Defines edge width used when edgesRenderer is enabled
  26886. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26887. */
  26888. edgesWidth: number;
  26889. /**
  26890. * Defines edge color used when edgesRenderer is enabled
  26891. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26892. */
  26893. edgesColor: Color4;
  26894. /** @hidden */
  26895. _edgesRenderer: Nullable<IEdgesRenderer>;
  26896. /** @hidden */
  26897. _masterMesh: Nullable<AbstractMesh>;
  26898. /** @hidden */
  26899. _boundingInfo: Nullable<BoundingInfo>;
  26900. /** @hidden */
  26901. _renderId: number;
  26902. /**
  26903. * Gets or sets the list of subMeshes
  26904. * @see http://doc.babylonjs.com/how_to/multi_materials
  26905. */
  26906. subMeshes: SubMesh[];
  26907. /** @hidden */
  26908. _intersectionsInProgress: AbstractMesh[];
  26909. /** @hidden */
  26910. _unIndexed: boolean;
  26911. /** @hidden */
  26912. _lightSources: Light[];
  26913. /** Gets the list of lights affecting that mesh */
  26914. readonly lightSources: Light[];
  26915. /** @hidden */
  26916. readonly _positions: Nullable<Vector3[]>;
  26917. /** @hidden */
  26918. _waitingData: {
  26919. lods: Nullable<any>;
  26920. actions: Nullable<any>;
  26921. freezeWorldMatrix: Nullable<boolean>;
  26922. };
  26923. /** @hidden */
  26924. _bonesTransformMatrices: Nullable<Float32Array>;
  26925. /** @hidden */
  26926. _transformMatrixTexture: Nullable<RawTexture>;
  26927. /**
  26928. * Gets or sets a skeleton to apply skining transformations
  26929. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26930. */
  26931. skeleton: Nullable<Skeleton>;
  26932. /**
  26933. * An event triggered when the mesh is rebuilt.
  26934. */
  26935. onRebuildObservable: Observable<AbstractMesh>;
  26936. /**
  26937. * Creates a new AbstractMesh
  26938. * @param name defines the name of the mesh
  26939. * @param scene defines the hosting scene
  26940. */
  26941. constructor(name: string, scene?: Nullable<Scene>);
  26942. /**
  26943. * Returns the string "AbstractMesh"
  26944. * @returns "AbstractMesh"
  26945. */
  26946. getClassName(): string;
  26947. /**
  26948. * Gets a string representation of the current mesh
  26949. * @param fullDetails defines a boolean indicating if full details must be included
  26950. * @returns a string representation of the current mesh
  26951. */
  26952. toString(fullDetails?: boolean): string;
  26953. /**
  26954. * @hidden
  26955. */
  26956. protected _getEffectiveParent(): Nullable<Node>;
  26957. /** @hidden */
  26958. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26959. /** @hidden */
  26960. _rebuild(): void;
  26961. /** @hidden */
  26962. _resyncLightSources(): void;
  26963. /** @hidden */
  26964. _resyncLighSource(light: Light): void;
  26965. /** @hidden */
  26966. _unBindEffect(): void;
  26967. /** @hidden */
  26968. _removeLightSource(light: Light, dispose: boolean): void;
  26969. private _markSubMeshesAsDirty;
  26970. /** @hidden */
  26971. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26972. /** @hidden */
  26973. _markSubMeshesAsAttributesDirty(): void;
  26974. /** @hidden */
  26975. _markSubMeshesAsMiscDirty(): void;
  26976. /**
  26977. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26978. */
  26979. scaling: Vector3;
  26980. /**
  26981. * Returns true if the mesh is blocked. Implemented by child classes
  26982. */
  26983. readonly isBlocked: boolean;
  26984. /**
  26985. * Returns the mesh itself by default. Implemented by child classes
  26986. * @param camera defines the camera to use to pick the right LOD level
  26987. * @returns the currentAbstractMesh
  26988. */
  26989. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26990. /**
  26991. * Returns 0 by default. Implemented by child classes
  26992. * @returns an integer
  26993. */
  26994. getTotalVertices(): number;
  26995. /**
  26996. * Returns a positive integer : the total number of indices in this mesh geometry.
  26997. * @returns the numner of indices or zero if the mesh has no geometry.
  26998. */
  26999. getTotalIndices(): number;
  27000. /**
  27001. * Returns null by default. Implemented by child classes
  27002. * @returns null
  27003. */
  27004. getIndices(): Nullable<IndicesArray>;
  27005. /**
  27006. * Returns the array of the requested vertex data kind. Implemented by child classes
  27007. * @param kind defines the vertex data kind to use
  27008. * @returns null
  27009. */
  27010. getVerticesData(kind: string): Nullable<FloatArray>;
  27011. /**
  27012. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27013. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27014. * Note that a new underlying VertexBuffer object is created each call.
  27015. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27016. * @param kind defines vertex data kind:
  27017. * * VertexBuffer.PositionKind
  27018. * * VertexBuffer.UVKind
  27019. * * VertexBuffer.UV2Kind
  27020. * * VertexBuffer.UV3Kind
  27021. * * VertexBuffer.UV4Kind
  27022. * * VertexBuffer.UV5Kind
  27023. * * VertexBuffer.UV6Kind
  27024. * * VertexBuffer.ColorKind
  27025. * * VertexBuffer.MatricesIndicesKind
  27026. * * VertexBuffer.MatricesIndicesExtraKind
  27027. * * VertexBuffer.MatricesWeightsKind
  27028. * * VertexBuffer.MatricesWeightsExtraKind
  27029. * @param data defines the data source
  27030. * @param updatable defines if the data must be flagged as updatable (or static)
  27031. * @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
  27032. * @returns the current mesh
  27033. */
  27034. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27035. /**
  27036. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27037. * If the mesh has no geometry, it is simply returned as it is.
  27038. * @param kind defines vertex data kind:
  27039. * * VertexBuffer.PositionKind
  27040. * * VertexBuffer.UVKind
  27041. * * VertexBuffer.UV2Kind
  27042. * * VertexBuffer.UV3Kind
  27043. * * VertexBuffer.UV4Kind
  27044. * * VertexBuffer.UV5Kind
  27045. * * VertexBuffer.UV6Kind
  27046. * * VertexBuffer.ColorKind
  27047. * * VertexBuffer.MatricesIndicesKind
  27048. * * VertexBuffer.MatricesIndicesExtraKind
  27049. * * VertexBuffer.MatricesWeightsKind
  27050. * * VertexBuffer.MatricesWeightsExtraKind
  27051. * @param data defines the data source
  27052. * @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
  27053. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27054. * @returns the current mesh
  27055. */
  27056. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27057. /**
  27058. * Sets the mesh indices,
  27059. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27060. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27061. * @param totalVertices Defines the total number of vertices
  27062. * @returns the current mesh
  27063. */
  27064. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27065. /**
  27066. * Gets a boolean indicating if specific vertex data is present
  27067. * @param kind defines the vertex data kind to use
  27068. * @returns true is data kind is present
  27069. */
  27070. isVerticesDataPresent(kind: string): boolean;
  27071. /**
  27072. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27073. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27074. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27075. * @returns a BoundingInfo
  27076. */
  27077. getBoundingInfo(): BoundingInfo;
  27078. /**
  27079. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27080. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27081. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27082. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27083. * @returns the current mesh
  27084. */
  27085. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27086. /**
  27087. * Overwrite the current bounding info
  27088. * @param boundingInfo defines the new bounding info
  27089. * @returns the current mesh
  27090. */
  27091. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27092. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27093. readonly useBones: boolean;
  27094. /** @hidden */
  27095. _preActivate(): void;
  27096. /** @hidden */
  27097. _preActivateForIntermediateRendering(renderId: number): void;
  27098. /** @hidden */
  27099. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27100. /** @hidden */
  27101. _postActivate(): void;
  27102. /** @hidden */
  27103. _freeze(): void;
  27104. /** @hidden */
  27105. _unFreeze(): void;
  27106. /**
  27107. * Gets the current world matrix
  27108. * @returns a Matrix
  27109. */
  27110. getWorldMatrix(): Matrix;
  27111. /** @hidden */
  27112. _getWorldMatrixDeterminant(): number;
  27113. /**
  27114. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27115. */
  27116. readonly isAnInstance: boolean;
  27117. /**
  27118. * Gets a boolean indicating if this mesh has instances
  27119. */
  27120. readonly hasInstances: boolean;
  27121. /**
  27122. * Perform relative position change from the point of view of behind the front of the mesh.
  27123. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27124. * Supports definition of mesh facing forward or backward
  27125. * @param amountRight defines the distance on the right axis
  27126. * @param amountUp defines the distance on the up axis
  27127. * @param amountForward defines the distance on the forward axis
  27128. * @returns the current mesh
  27129. */
  27130. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27131. /**
  27132. * Calculate relative position change from the point of view of behind the front of the mesh.
  27133. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27134. * Supports definition of mesh facing forward or backward
  27135. * @param amountRight defines the distance on the right axis
  27136. * @param amountUp defines the distance on the up axis
  27137. * @param amountForward defines the distance on the forward axis
  27138. * @returns the new displacement vector
  27139. */
  27140. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27141. /**
  27142. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27143. * Supports definition of mesh facing forward or backward
  27144. * @param flipBack defines the flip
  27145. * @param twirlClockwise defines the twirl
  27146. * @param tiltRight defines the tilt
  27147. * @returns the current mesh
  27148. */
  27149. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27150. /**
  27151. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27152. * Supports definition of mesh facing forward or backward.
  27153. * @param flipBack defines the flip
  27154. * @param twirlClockwise defines the twirl
  27155. * @param tiltRight defines the tilt
  27156. * @returns the new rotation vector
  27157. */
  27158. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27159. /**
  27160. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27161. * This means the mesh underlying bounding box and sphere are recomputed.
  27162. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27163. * @returns the current mesh
  27164. */
  27165. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27166. /** @hidden */
  27167. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27168. /** @hidden */
  27169. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27170. /** @hidden */
  27171. _updateBoundingInfo(): AbstractMesh;
  27172. /** @hidden */
  27173. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27174. /** @hidden */
  27175. protected _afterComputeWorldMatrix(): void;
  27176. /** @hidden */
  27177. readonly _effectiveMesh: AbstractMesh;
  27178. /**
  27179. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27180. * A mesh is in the frustum if its bounding box intersects the frustum
  27181. * @param frustumPlanes defines the frustum to test
  27182. * @returns true if the mesh is in the frustum planes
  27183. */
  27184. isInFrustum(frustumPlanes: Plane[]): boolean;
  27185. /**
  27186. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27187. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27188. * @param frustumPlanes defines the frustum to test
  27189. * @returns true if the mesh is completely in the frustum planes
  27190. */
  27191. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27192. /**
  27193. * True if the mesh intersects another mesh or a SolidParticle object
  27194. * @param mesh defines a target mesh or SolidParticle to test
  27195. * @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)
  27196. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27197. * @returns true if there is an intersection
  27198. */
  27199. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27200. /**
  27201. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27202. * @param point defines the point to test
  27203. * @returns true if there is an intersection
  27204. */
  27205. intersectsPoint(point: Vector3): boolean;
  27206. /**
  27207. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27209. */
  27210. checkCollisions: boolean;
  27211. /**
  27212. * Gets Collider object used to compute collisions (not physics)
  27213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27214. */
  27215. readonly collider: Nullable<Collider>;
  27216. /**
  27217. * Move the mesh using collision engine
  27218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27219. * @param displacement defines the requested displacement vector
  27220. * @returns the current mesh
  27221. */
  27222. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27223. private _onCollisionPositionChange;
  27224. /** @hidden */
  27225. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27226. /** @hidden */
  27227. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27228. /** @hidden */
  27229. _checkCollision(collider: Collider): AbstractMesh;
  27230. /** @hidden */
  27231. _generatePointsArray(): boolean;
  27232. /**
  27233. * Checks if the passed Ray intersects with the mesh
  27234. * @param ray defines the ray to use
  27235. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27236. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27237. * @returns the picking info
  27238. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27239. */
  27240. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27241. /**
  27242. * Clones the current mesh
  27243. * @param name defines the mesh name
  27244. * @param newParent defines the new mesh parent
  27245. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27246. * @returns the new mesh
  27247. */
  27248. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27249. /**
  27250. * Disposes all the submeshes of the current meshnp
  27251. * @returns the current mesh
  27252. */
  27253. releaseSubMeshes(): AbstractMesh;
  27254. /**
  27255. * Releases resources associated with this abstract mesh.
  27256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27258. */
  27259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27260. /**
  27261. * Adds the passed mesh as a child to the current mesh
  27262. * @param mesh defines the child mesh
  27263. * @returns the current mesh
  27264. */
  27265. addChild(mesh: AbstractMesh): AbstractMesh;
  27266. /**
  27267. * Removes the passed mesh from the current mesh children list
  27268. * @param mesh defines the child mesh
  27269. * @returns the current mesh
  27270. */
  27271. removeChild(mesh: AbstractMesh): AbstractMesh;
  27272. /** @hidden */
  27273. private _initFacetData;
  27274. /**
  27275. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27276. * This method can be called within the render loop.
  27277. * 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
  27278. * @returns the current mesh
  27279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27280. */
  27281. updateFacetData(): AbstractMesh;
  27282. /**
  27283. * Returns the facetLocalNormals array.
  27284. * The normals are expressed in the mesh local spac
  27285. * @returns an array of Vector3
  27286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27287. */
  27288. getFacetLocalNormals(): Vector3[];
  27289. /**
  27290. * Returns the facetLocalPositions array.
  27291. * The facet positions are expressed in the mesh local space
  27292. * @returns an array of Vector3
  27293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27294. */
  27295. getFacetLocalPositions(): Vector3[];
  27296. /**
  27297. * Returns the facetLocalPartioning array
  27298. * @returns an array of array of numbers
  27299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27300. */
  27301. getFacetLocalPartitioning(): number[][];
  27302. /**
  27303. * Returns the i-th facet position in the world system.
  27304. * This method allocates a new Vector3 per call
  27305. * @param i defines the facet index
  27306. * @returns a new Vector3
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27308. */
  27309. getFacetPosition(i: number): Vector3;
  27310. /**
  27311. * Sets the reference Vector3 with the i-th facet position in the world system
  27312. * @param i defines the facet index
  27313. * @param ref defines the target vector
  27314. * @returns the current mesh
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27316. */
  27317. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27318. /**
  27319. * Returns the i-th facet normal in the world system.
  27320. * This method allocates a new Vector3 per call
  27321. * @param i defines the facet index
  27322. * @returns a new Vector3
  27323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27324. */
  27325. getFacetNormal(i: number): Vector3;
  27326. /**
  27327. * Sets the reference Vector3 with the i-th facet normal in the world system
  27328. * @param i defines the facet index
  27329. * @param ref defines the target vector
  27330. * @returns the current mesh
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27332. */
  27333. getFacetNormalToRef(i: number, ref: Vector3): this;
  27334. /**
  27335. * 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)
  27336. * @param x defines x coordinate
  27337. * @param y defines y coordinate
  27338. * @param z defines z coordinate
  27339. * @returns the array of facet indexes
  27340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27341. */
  27342. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27343. /**
  27344. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27345. * @param projected sets as the (x,y,z) world projection on the facet
  27346. * @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
  27347. * @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
  27348. * @param x defines x coordinate
  27349. * @param y defines y coordinate
  27350. * @param z defines z coordinate
  27351. * @returns the face index if found (or null instead)
  27352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27353. */
  27354. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27355. /**
  27356. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27357. * @param projected sets as the (x,y,z) local projection on the facet
  27358. * @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
  27359. * @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
  27360. * @param x defines x coordinate
  27361. * @param y defines y coordinate
  27362. * @param z defines z coordinate
  27363. * @returns the face index if found (or null instead)
  27364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27365. */
  27366. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27367. /**
  27368. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27369. * @returns the parameters
  27370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27371. */
  27372. getFacetDataParameters(): any;
  27373. /**
  27374. * Disables the feature FacetData and frees the related memory
  27375. * @returns the current mesh
  27376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27377. */
  27378. disableFacetData(): AbstractMesh;
  27379. /**
  27380. * Updates the AbstractMesh indices array
  27381. * @param indices defines the data source
  27382. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27383. * @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)
  27384. * @returns the current mesh
  27385. */
  27386. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27387. /**
  27388. * Creates new normals data for the mesh
  27389. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27390. * @returns the current mesh
  27391. */
  27392. createNormals(updatable: boolean): AbstractMesh;
  27393. /**
  27394. * Align the mesh with a normal
  27395. * @param normal defines the normal to use
  27396. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27397. * @returns the current mesh
  27398. */
  27399. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27400. /** @hidden */
  27401. _checkOcclusionQuery(): boolean;
  27402. /**
  27403. * Disables the mesh edge rendering mode
  27404. * @returns the currentAbstractMesh
  27405. */
  27406. disableEdgesRendering(): AbstractMesh;
  27407. /**
  27408. * Enables the edge rendering mode on the mesh.
  27409. * This mode makes the mesh edges visible
  27410. * @param epsilon defines the maximal distance between two angles to detect a face
  27411. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27412. * @returns the currentAbstractMesh
  27413. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27414. */
  27415. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27416. }
  27417. }
  27418. declare module "babylonjs/Actions/actionEvent" {
  27419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27420. import { Nullable } from "babylonjs/types";
  27421. import { Sprite } from "babylonjs/Sprites/sprite";
  27422. import { Scene } from "babylonjs/scene";
  27423. import { Vector2 } from "babylonjs/Maths/math.vector";
  27424. /**
  27425. * Interface used to define ActionEvent
  27426. */
  27427. export interface IActionEvent {
  27428. /** The mesh or sprite that triggered the action */
  27429. source: any;
  27430. /** The X mouse cursor position at the time of the event */
  27431. pointerX: number;
  27432. /** The Y mouse cursor position at the time of the event */
  27433. pointerY: number;
  27434. /** The mesh that is currently pointed at (can be null) */
  27435. meshUnderPointer: Nullable<AbstractMesh>;
  27436. /** the original (browser) event that triggered the ActionEvent */
  27437. sourceEvent?: any;
  27438. /** additional data for the event */
  27439. additionalData?: any;
  27440. }
  27441. /**
  27442. * ActionEvent is the event being sent when an action is triggered.
  27443. */
  27444. export class ActionEvent implements IActionEvent {
  27445. /** The mesh or sprite that triggered the action */
  27446. source: any;
  27447. /** The X mouse cursor position at the time of the event */
  27448. pointerX: number;
  27449. /** The Y mouse cursor position at the time of the event */
  27450. pointerY: number;
  27451. /** The mesh that is currently pointed at (can be null) */
  27452. meshUnderPointer: Nullable<AbstractMesh>;
  27453. /** the original (browser) event that triggered the ActionEvent */
  27454. sourceEvent?: any;
  27455. /** additional data for the event */
  27456. additionalData?: any;
  27457. /**
  27458. * Creates a new ActionEvent
  27459. * @param source The mesh or sprite that triggered the action
  27460. * @param pointerX The X mouse cursor position at the time of the event
  27461. * @param pointerY The Y mouse cursor position at the time of the event
  27462. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27463. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27464. * @param additionalData additional data for the event
  27465. */
  27466. constructor(
  27467. /** The mesh or sprite that triggered the action */
  27468. source: any,
  27469. /** The X mouse cursor position at the time of the event */
  27470. pointerX: number,
  27471. /** The Y mouse cursor position at the time of the event */
  27472. pointerY: number,
  27473. /** The mesh that is currently pointed at (can be null) */
  27474. meshUnderPointer: Nullable<AbstractMesh>,
  27475. /** the original (browser) event that triggered the ActionEvent */
  27476. sourceEvent?: any,
  27477. /** additional data for the event */
  27478. additionalData?: any);
  27479. /**
  27480. * Helper function to auto-create an ActionEvent from a source mesh.
  27481. * @param source The source mesh that triggered the event
  27482. * @param evt The original (browser) event
  27483. * @param additionalData additional data for the event
  27484. * @returns the new ActionEvent
  27485. */
  27486. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27487. /**
  27488. * Helper function to auto-create an ActionEvent from a source sprite
  27489. * @param source The source sprite that triggered the event
  27490. * @param scene Scene associated with the sprite
  27491. * @param evt The original (browser) event
  27492. * @param additionalData additional data for the event
  27493. * @returns the new ActionEvent
  27494. */
  27495. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27496. /**
  27497. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27498. * @param scene the scene where the event occurred
  27499. * @param evt The original (browser) event
  27500. * @returns the new ActionEvent
  27501. */
  27502. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27503. /**
  27504. * Helper function to auto-create an ActionEvent from a primitive
  27505. * @param prim defines the target primitive
  27506. * @param pointerPos defines the pointer position
  27507. * @param evt The original (browser) event
  27508. * @param additionalData additional data for the event
  27509. * @returns the new ActionEvent
  27510. */
  27511. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27512. }
  27513. }
  27514. declare module "babylonjs/Actions/abstractActionManager" {
  27515. import { IDisposable } from "babylonjs/scene";
  27516. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27517. import { IAction } from "babylonjs/Actions/action";
  27518. import { Nullable } from "babylonjs/types";
  27519. /**
  27520. * Abstract class used to decouple action Manager from scene and meshes.
  27521. * Do not instantiate.
  27522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27523. */
  27524. export abstract class AbstractActionManager implements IDisposable {
  27525. /** Gets the list of active triggers */
  27526. static Triggers: {
  27527. [key: string]: number;
  27528. };
  27529. /** Gets the cursor to use when hovering items */
  27530. hoverCursor: string;
  27531. /** Gets the list of actions */
  27532. actions: IAction[];
  27533. /**
  27534. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27535. */
  27536. isRecursive: boolean;
  27537. /**
  27538. * Releases all associated resources
  27539. */
  27540. abstract dispose(): void;
  27541. /**
  27542. * Does this action manager has pointer triggers
  27543. */
  27544. abstract readonly hasPointerTriggers: boolean;
  27545. /**
  27546. * Does this action manager has pick triggers
  27547. */
  27548. abstract readonly hasPickTriggers: boolean;
  27549. /**
  27550. * Process a specific trigger
  27551. * @param trigger defines the trigger to process
  27552. * @param evt defines the event details to be processed
  27553. */
  27554. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27555. /**
  27556. * Does this action manager handles actions of any of the given triggers
  27557. * @param triggers defines the triggers to be tested
  27558. * @return a boolean indicating whether one (or more) of the triggers is handled
  27559. */
  27560. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27561. /**
  27562. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27563. * speed.
  27564. * @param triggerA defines the trigger to be tested
  27565. * @param triggerB defines the trigger to be tested
  27566. * @return a boolean indicating whether one (or more) of the triggers is handled
  27567. */
  27568. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27569. /**
  27570. * Does this action manager handles actions of a given trigger
  27571. * @param trigger defines the trigger to be tested
  27572. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27573. * @return whether the trigger is handled
  27574. */
  27575. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27576. /**
  27577. * Serialize this manager to a JSON object
  27578. * @param name defines the property name to store this manager
  27579. * @returns a JSON representation of this manager
  27580. */
  27581. abstract serialize(name: string): any;
  27582. /**
  27583. * Registers an action to this action manager
  27584. * @param action defines the action to be registered
  27585. * @return the action amended (prepared) after registration
  27586. */
  27587. abstract registerAction(action: IAction): Nullable<IAction>;
  27588. /**
  27589. * Unregisters an action to this action manager
  27590. * @param action defines the action to be unregistered
  27591. * @return a boolean indicating whether the action has been unregistered
  27592. */
  27593. abstract unregisterAction(action: IAction): Boolean;
  27594. /**
  27595. * Does exist one action manager with at least one trigger
  27596. **/
  27597. static readonly HasTriggers: boolean;
  27598. /**
  27599. * Does exist one action manager with at least one pick trigger
  27600. **/
  27601. static readonly HasPickTriggers: boolean;
  27602. /**
  27603. * Does exist one action manager that handles actions of a given trigger
  27604. * @param trigger defines the trigger to be tested
  27605. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27606. **/
  27607. static HasSpecificTrigger(trigger: number): boolean;
  27608. }
  27609. }
  27610. declare module "babylonjs/node" {
  27611. import { Scene } from "babylonjs/scene";
  27612. import { Nullable } from "babylonjs/types";
  27613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27614. import { Engine } from "babylonjs/Engines/engine";
  27615. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27616. import { Observable } from "babylonjs/Misc/observable";
  27617. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27618. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27619. import { Animatable } from "babylonjs/Animations/animatable";
  27620. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27621. import { Animation } from "babylonjs/Animations/animation";
  27622. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27624. /**
  27625. * Defines how a node can be built from a string name.
  27626. */
  27627. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27628. /**
  27629. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27630. */
  27631. export class Node implements IBehaviorAware<Node> {
  27632. /** @hidden */
  27633. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27634. private static _NodeConstructors;
  27635. /**
  27636. * Add a new node constructor
  27637. * @param type defines the type name of the node to construct
  27638. * @param constructorFunc defines the constructor function
  27639. */
  27640. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27641. /**
  27642. * Returns a node constructor based on type name
  27643. * @param type defines the type name
  27644. * @param name defines the new node name
  27645. * @param scene defines the hosting scene
  27646. * @param options defines optional options to transmit to constructors
  27647. * @returns the new constructor or null
  27648. */
  27649. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27650. /**
  27651. * Gets or sets the name of the node
  27652. */
  27653. name: string;
  27654. /**
  27655. * Gets or sets the id of the node
  27656. */
  27657. id: string;
  27658. /**
  27659. * Gets or sets the unique id of the node
  27660. */
  27661. uniqueId: number;
  27662. /**
  27663. * Gets or sets a string used to store user defined state for the node
  27664. */
  27665. state: string;
  27666. /**
  27667. * Gets or sets an object used to store user defined information for the node
  27668. */
  27669. metadata: any;
  27670. /**
  27671. * For internal use only. Please do not use.
  27672. */
  27673. reservedDataStore: any;
  27674. /**
  27675. * List of inspectable custom properties (used by the Inspector)
  27676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27677. */
  27678. inspectableCustomProperties: IInspectable[];
  27679. /**
  27680. * Gets or sets a boolean used to define if the node must be serialized
  27681. */
  27682. doNotSerialize: boolean;
  27683. /** @hidden */
  27684. _isDisposed: boolean;
  27685. /**
  27686. * Gets a list of Animations associated with the node
  27687. */
  27688. animations: import("babylonjs/Animations/animation").Animation[];
  27689. protected _ranges: {
  27690. [name: string]: Nullable<AnimationRange>;
  27691. };
  27692. /**
  27693. * Callback raised when the node is ready to be used
  27694. */
  27695. onReady: Nullable<(node: Node) => void>;
  27696. private _isEnabled;
  27697. private _isParentEnabled;
  27698. private _isReady;
  27699. /** @hidden */
  27700. _currentRenderId: number;
  27701. private _parentUpdateId;
  27702. /** @hidden */
  27703. _childUpdateId: number;
  27704. /** @hidden */
  27705. _waitingParentId: Nullable<string>;
  27706. /** @hidden */
  27707. _scene: Scene;
  27708. /** @hidden */
  27709. _cache: any;
  27710. private _parentNode;
  27711. private _children;
  27712. /** @hidden */
  27713. _worldMatrix: Matrix;
  27714. /** @hidden */
  27715. _worldMatrixDeterminant: number;
  27716. /** @hidden */
  27717. _worldMatrixDeterminantIsDirty: boolean;
  27718. /** @hidden */
  27719. private _sceneRootNodesIndex;
  27720. /**
  27721. * Gets a boolean indicating if the node has been disposed
  27722. * @returns true if the node was disposed
  27723. */
  27724. isDisposed(): boolean;
  27725. /**
  27726. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27727. * @see https://doc.babylonjs.com/how_to/parenting
  27728. */
  27729. parent: Nullable<Node>;
  27730. private addToSceneRootNodes;
  27731. private removeFromSceneRootNodes;
  27732. private _animationPropertiesOverride;
  27733. /**
  27734. * Gets or sets the animation properties override
  27735. */
  27736. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27737. /**
  27738. * Gets a string idenfifying the name of the class
  27739. * @returns "Node" string
  27740. */
  27741. getClassName(): string;
  27742. /** @hidden */
  27743. readonly _isNode: boolean;
  27744. /**
  27745. * An event triggered when the mesh is disposed
  27746. */
  27747. onDisposeObservable: Observable<Node>;
  27748. private _onDisposeObserver;
  27749. /**
  27750. * Sets a callback that will be raised when the node will be disposed
  27751. */
  27752. onDispose: () => void;
  27753. /**
  27754. * Creates a new Node
  27755. * @param name the name and id to be given to this node
  27756. * @param scene the scene this node will be added to
  27757. * @param addToRootNodes the node will be added to scene.rootNodes
  27758. */
  27759. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27760. /**
  27761. * Gets the scene of the node
  27762. * @returns a scene
  27763. */
  27764. getScene(): Scene;
  27765. /**
  27766. * Gets the engine of the node
  27767. * @returns a Engine
  27768. */
  27769. getEngine(): Engine;
  27770. private _behaviors;
  27771. /**
  27772. * Attach a behavior to the node
  27773. * @see http://doc.babylonjs.com/features/behaviour
  27774. * @param behavior defines the behavior to attach
  27775. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27776. * @returns the current Node
  27777. */
  27778. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27779. /**
  27780. * Remove an attached behavior
  27781. * @see http://doc.babylonjs.com/features/behaviour
  27782. * @param behavior defines the behavior to attach
  27783. * @returns the current Node
  27784. */
  27785. removeBehavior(behavior: Behavior<Node>): Node;
  27786. /**
  27787. * Gets the list of attached behaviors
  27788. * @see http://doc.babylonjs.com/features/behaviour
  27789. */
  27790. readonly behaviors: Behavior<Node>[];
  27791. /**
  27792. * Gets an attached behavior by name
  27793. * @param name defines the name of the behavior to look for
  27794. * @see http://doc.babylonjs.com/features/behaviour
  27795. * @returns null if behavior was not found else the requested behavior
  27796. */
  27797. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27798. /**
  27799. * Returns the latest update of the World matrix
  27800. * @returns a Matrix
  27801. */
  27802. getWorldMatrix(): Matrix;
  27803. /** @hidden */
  27804. _getWorldMatrixDeterminant(): number;
  27805. /**
  27806. * Returns directly the latest state of the mesh World matrix.
  27807. * A Matrix is returned.
  27808. */
  27809. readonly worldMatrixFromCache: Matrix;
  27810. /** @hidden */
  27811. _initCache(): void;
  27812. /** @hidden */
  27813. updateCache(force?: boolean): void;
  27814. /** @hidden */
  27815. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27816. /** @hidden */
  27817. _updateCache(ignoreParentClass?: boolean): void;
  27818. /** @hidden */
  27819. _isSynchronized(): boolean;
  27820. /** @hidden */
  27821. _markSyncedWithParent(): void;
  27822. /** @hidden */
  27823. isSynchronizedWithParent(): boolean;
  27824. /** @hidden */
  27825. isSynchronized(): boolean;
  27826. /**
  27827. * Is this node ready to be used/rendered
  27828. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27829. * @return true if the node is ready
  27830. */
  27831. isReady(completeCheck?: boolean): boolean;
  27832. /**
  27833. * Is this node enabled?
  27834. * 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
  27835. * @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
  27836. * @return whether this node (and its parent) is enabled
  27837. */
  27838. isEnabled(checkAncestors?: boolean): boolean;
  27839. /** @hidden */
  27840. protected _syncParentEnabledState(): void;
  27841. /**
  27842. * Set the enabled state of this node
  27843. * @param value defines the new enabled state
  27844. */
  27845. setEnabled(value: boolean): void;
  27846. /**
  27847. * Is this node a descendant of the given node?
  27848. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27849. * @param ancestor defines the parent node to inspect
  27850. * @returns a boolean indicating if this node is a descendant of the given node
  27851. */
  27852. isDescendantOf(ancestor: Node): boolean;
  27853. /** @hidden */
  27854. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27855. /**
  27856. * Will return all nodes that have this node as ascendant
  27857. * @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
  27858. * @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
  27859. * @return all children nodes of all types
  27860. */
  27861. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27862. /**
  27863. * Get all child-meshes of this node
  27864. * @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)
  27865. * @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
  27866. * @returns an array of AbstractMesh
  27867. */
  27868. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27869. /**
  27870. * Get all direct children of this node
  27871. * @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
  27872. * @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)
  27873. * @returns an array of Node
  27874. */
  27875. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27876. /** @hidden */
  27877. _setReady(state: boolean): void;
  27878. /**
  27879. * Get an animation by name
  27880. * @param name defines the name of the animation to look for
  27881. * @returns null if not found else the requested animation
  27882. */
  27883. getAnimationByName(name: string): Nullable<Animation>;
  27884. /**
  27885. * Creates an animation range for this node
  27886. * @param name defines the name of the range
  27887. * @param from defines the starting key
  27888. * @param to defines the end key
  27889. */
  27890. createAnimationRange(name: string, from: number, to: number): void;
  27891. /**
  27892. * Delete a specific animation range
  27893. * @param name defines the name of the range to delete
  27894. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27895. */
  27896. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27897. /**
  27898. * Get an animation range by name
  27899. * @param name defines the name of the animation range to look for
  27900. * @returns null if not found else the requested animation range
  27901. */
  27902. getAnimationRange(name: string): Nullable<AnimationRange>;
  27903. /**
  27904. * Gets the list of all animation ranges defined on this node
  27905. * @returns an array
  27906. */
  27907. getAnimationRanges(): Nullable<AnimationRange>[];
  27908. /**
  27909. * Will start the animation sequence
  27910. * @param name defines the range frames for animation sequence
  27911. * @param loop defines if the animation should loop (false by default)
  27912. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27913. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27914. * @returns the object created for this animation. If range does not exist, it will return null
  27915. */
  27916. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27917. /**
  27918. * Serialize animation ranges into a JSON compatible object
  27919. * @returns serialization object
  27920. */
  27921. serializeAnimationRanges(): any;
  27922. /**
  27923. * Computes the world matrix of the node
  27924. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27925. * @returns the world matrix
  27926. */
  27927. computeWorldMatrix(force?: boolean): Matrix;
  27928. /**
  27929. * Releases resources associated with this node.
  27930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27932. */
  27933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27934. /**
  27935. * Parse animation range data from a serialization object and store them into a given node
  27936. * @param node defines where to store the animation ranges
  27937. * @param parsedNode defines the serialization object to read data from
  27938. * @param scene defines the hosting scene
  27939. */
  27940. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27941. /**
  27942. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27943. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27944. * @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
  27945. * @returns the new bounding vectors
  27946. */
  27947. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27948. min: Vector3;
  27949. max: Vector3;
  27950. };
  27951. }
  27952. }
  27953. declare module "babylonjs/Animations/animation" {
  27954. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27955. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27956. import { Color3 } from "babylonjs/Maths/math.color";
  27957. import { Nullable } from "babylonjs/types";
  27958. import { Scene } from "babylonjs/scene";
  27959. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27960. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27961. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27962. import { Node } from "babylonjs/node";
  27963. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27964. import { Size } from "babylonjs/Maths/math.size";
  27965. import { Animatable } from "babylonjs/Animations/animatable";
  27966. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27967. /**
  27968. * @hidden
  27969. */
  27970. export class _IAnimationState {
  27971. key: number;
  27972. repeatCount: number;
  27973. workValue?: any;
  27974. loopMode?: number;
  27975. offsetValue?: any;
  27976. highLimitValue?: any;
  27977. }
  27978. /**
  27979. * Class used to store any kind of animation
  27980. */
  27981. export class Animation {
  27982. /**Name of the animation */
  27983. name: string;
  27984. /**Property to animate */
  27985. targetProperty: string;
  27986. /**The frames per second of the animation */
  27987. framePerSecond: number;
  27988. /**The data type of the animation */
  27989. dataType: number;
  27990. /**The loop mode of the animation */
  27991. loopMode?: number | undefined;
  27992. /**Specifies if blending should be enabled */
  27993. enableBlending?: boolean | undefined;
  27994. /**
  27995. * Use matrix interpolation instead of using direct key value when animating matrices
  27996. */
  27997. static AllowMatricesInterpolation: boolean;
  27998. /**
  27999. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28000. */
  28001. static AllowMatrixDecomposeForInterpolation: boolean;
  28002. /**
  28003. * Stores the key frames of the animation
  28004. */
  28005. private _keys;
  28006. /**
  28007. * Stores the easing function of the animation
  28008. */
  28009. private _easingFunction;
  28010. /**
  28011. * @hidden Internal use only
  28012. */
  28013. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28014. /**
  28015. * The set of event that will be linked to this animation
  28016. */
  28017. private _events;
  28018. /**
  28019. * Stores an array of target property paths
  28020. */
  28021. targetPropertyPath: string[];
  28022. /**
  28023. * Stores the blending speed of the animation
  28024. */
  28025. blendingSpeed: number;
  28026. /**
  28027. * Stores the animation ranges for the animation
  28028. */
  28029. private _ranges;
  28030. /**
  28031. * @hidden Internal use
  28032. */
  28033. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28034. /**
  28035. * Sets up an animation
  28036. * @param property The property to animate
  28037. * @param animationType The animation type to apply
  28038. * @param framePerSecond The frames per second of the animation
  28039. * @param easingFunction The easing function used in the animation
  28040. * @returns The created animation
  28041. */
  28042. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28043. /**
  28044. * Create and start an animation on a node
  28045. * @param name defines the name of the global animation that will be run on all nodes
  28046. * @param node defines the root node where the animation will take place
  28047. * @param targetProperty defines property to animate
  28048. * @param framePerSecond defines the number of frame per second yo use
  28049. * @param totalFrame defines the number of frames in total
  28050. * @param from defines the initial value
  28051. * @param to defines the final value
  28052. * @param loopMode defines which loop mode you want to use (off by default)
  28053. * @param easingFunction defines the easing function to use (linear by default)
  28054. * @param onAnimationEnd defines the callback to call when animation end
  28055. * @returns the animatable created for this animation
  28056. */
  28057. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28058. /**
  28059. * Create and start an animation on a node and its descendants
  28060. * @param name defines the name of the global animation that will be run on all nodes
  28061. * @param node defines the root node where the animation will take place
  28062. * @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
  28063. * @param targetProperty defines property to animate
  28064. * @param framePerSecond defines the number of frame per second to use
  28065. * @param totalFrame defines the number of frames in total
  28066. * @param from defines the initial value
  28067. * @param to defines the final value
  28068. * @param loopMode defines which loop mode you want to use (off by default)
  28069. * @param easingFunction defines the easing function to use (linear by default)
  28070. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28071. * @returns the list of animatables created for all nodes
  28072. * @example https://www.babylonjs-playground.com/#MH0VLI
  28073. */
  28074. 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[]>;
  28075. /**
  28076. * Creates a new animation, merges it with the existing animations and starts it
  28077. * @param name Name of the animation
  28078. * @param node Node which contains the scene that begins the animations
  28079. * @param targetProperty Specifies which property to animate
  28080. * @param framePerSecond The frames per second of the animation
  28081. * @param totalFrame The total number of frames
  28082. * @param from The frame at the beginning of the animation
  28083. * @param to The frame at the end of the animation
  28084. * @param loopMode Specifies the loop mode of the animation
  28085. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28086. * @param onAnimationEnd Callback to run once the animation is complete
  28087. * @returns Nullable animation
  28088. */
  28089. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28090. /**
  28091. * Transition property of an host to the target Value
  28092. * @param property The property to transition
  28093. * @param targetValue The target Value of the property
  28094. * @param host The object where the property to animate belongs
  28095. * @param scene Scene used to run the animation
  28096. * @param frameRate Framerate (in frame/s) to use
  28097. * @param transition The transition type we want to use
  28098. * @param duration The duration of the animation, in milliseconds
  28099. * @param onAnimationEnd Callback trigger at the end of the animation
  28100. * @returns Nullable animation
  28101. */
  28102. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28103. /**
  28104. * Return the array of runtime animations currently using this animation
  28105. */
  28106. readonly runtimeAnimations: RuntimeAnimation[];
  28107. /**
  28108. * Specifies if any of the runtime animations are currently running
  28109. */
  28110. readonly hasRunningRuntimeAnimations: boolean;
  28111. /**
  28112. * Initializes the animation
  28113. * @param name Name of the animation
  28114. * @param targetProperty Property to animate
  28115. * @param framePerSecond The frames per second of the animation
  28116. * @param dataType The data type of the animation
  28117. * @param loopMode The loop mode of the animation
  28118. * @param enableBlending Specifies if blending should be enabled
  28119. */
  28120. constructor(
  28121. /**Name of the animation */
  28122. name: string,
  28123. /**Property to animate */
  28124. targetProperty: string,
  28125. /**The frames per second of the animation */
  28126. framePerSecond: number,
  28127. /**The data type of the animation */
  28128. dataType: number,
  28129. /**The loop mode of the animation */
  28130. loopMode?: number | undefined,
  28131. /**Specifies if blending should be enabled */
  28132. enableBlending?: boolean | undefined);
  28133. /**
  28134. * Converts the animation to a string
  28135. * @param fullDetails support for multiple levels of logging within scene loading
  28136. * @returns String form of the animation
  28137. */
  28138. toString(fullDetails?: boolean): string;
  28139. /**
  28140. * Add an event to this animation
  28141. * @param event Event to add
  28142. */
  28143. addEvent(event: AnimationEvent): void;
  28144. /**
  28145. * Remove all events found at the given frame
  28146. * @param frame The frame to remove events from
  28147. */
  28148. removeEvents(frame: number): void;
  28149. /**
  28150. * Retrieves all the events from the animation
  28151. * @returns Events from the animation
  28152. */
  28153. getEvents(): AnimationEvent[];
  28154. /**
  28155. * Creates an animation range
  28156. * @param name Name of the animation range
  28157. * @param from Starting frame of the animation range
  28158. * @param to Ending frame of the animation
  28159. */
  28160. createRange(name: string, from: number, to: number): void;
  28161. /**
  28162. * Deletes an animation range by name
  28163. * @param name Name of the animation range to delete
  28164. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28165. */
  28166. deleteRange(name: string, deleteFrames?: boolean): void;
  28167. /**
  28168. * Gets the animation range by name, or null if not defined
  28169. * @param name Name of the animation range
  28170. * @returns Nullable animation range
  28171. */
  28172. getRange(name: string): Nullable<AnimationRange>;
  28173. /**
  28174. * Gets the key frames from the animation
  28175. * @returns The key frames of the animation
  28176. */
  28177. getKeys(): Array<IAnimationKey>;
  28178. /**
  28179. * Gets the highest frame rate of the animation
  28180. * @returns Highest frame rate of the animation
  28181. */
  28182. getHighestFrame(): number;
  28183. /**
  28184. * Gets the easing function of the animation
  28185. * @returns Easing function of the animation
  28186. */
  28187. getEasingFunction(): IEasingFunction;
  28188. /**
  28189. * Sets the easing function of the animation
  28190. * @param easingFunction A custom mathematical formula for animation
  28191. */
  28192. setEasingFunction(easingFunction: EasingFunction): void;
  28193. /**
  28194. * Interpolates a scalar linearly
  28195. * @param startValue Start value of the animation curve
  28196. * @param endValue End value of the animation curve
  28197. * @param gradient Scalar amount to interpolate
  28198. * @returns Interpolated scalar value
  28199. */
  28200. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28201. /**
  28202. * Interpolates a scalar cubically
  28203. * @param startValue Start value of the animation curve
  28204. * @param outTangent End tangent of the animation
  28205. * @param endValue End value of the animation curve
  28206. * @param inTangent Start tangent of the animation curve
  28207. * @param gradient Scalar amount to interpolate
  28208. * @returns Interpolated scalar value
  28209. */
  28210. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28211. /**
  28212. * Interpolates a quaternion using a spherical linear interpolation
  28213. * @param startValue Start value of the animation curve
  28214. * @param endValue End value of the animation curve
  28215. * @param gradient Scalar amount to interpolate
  28216. * @returns Interpolated quaternion value
  28217. */
  28218. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28219. /**
  28220. * Interpolates a quaternion cubically
  28221. * @param startValue Start value of the animation curve
  28222. * @param outTangent End tangent of the animation curve
  28223. * @param endValue End value of the animation curve
  28224. * @param inTangent Start tangent of the animation curve
  28225. * @param gradient Scalar amount to interpolate
  28226. * @returns Interpolated quaternion value
  28227. */
  28228. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28229. /**
  28230. * Interpolates a Vector3 linearl
  28231. * @param startValue Start value of the animation curve
  28232. * @param endValue End value of the animation curve
  28233. * @param gradient Scalar amount to interpolate
  28234. * @returns Interpolated scalar value
  28235. */
  28236. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28237. /**
  28238. * Interpolates a Vector3 cubically
  28239. * @param startValue Start value of the animation curve
  28240. * @param outTangent End tangent of the animation
  28241. * @param endValue End value of the animation curve
  28242. * @param inTangent Start tangent of the animation curve
  28243. * @param gradient Scalar amount to interpolate
  28244. * @returns InterpolatedVector3 value
  28245. */
  28246. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28247. /**
  28248. * Interpolates a Vector2 linearly
  28249. * @param startValue Start value of the animation curve
  28250. * @param endValue End value of the animation curve
  28251. * @param gradient Scalar amount to interpolate
  28252. * @returns Interpolated Vector2 value
  28253. */
  28254. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28255. /**
  28256. * Interpolates a Vector2 cubically
  28257. * @param startValue Start value of the animation curve
  28258. * @param outTangent End tangent of the animation
  28259. * @param endValue End value of the animation curve
  28260. * @param inTangent Start tangent of the animation curve
  28261. * @param gradient Scalar amount to interpolate
  28262. * @returns Interpolated Vector2 value
  28263. */
  28264. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28265. /**
  28266. * Interpolates a size linearly
  28267. * @param startValue Start value of the animation curve
  28268. * @param endValue End value of the animation curve
  28269. * @param gradient Scalar amount to interpolate
  28270. * @returns Interpolated Size value
  28271. */
  28272. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28273. /**
  28274. * Interpolates a Color3 linearly
  28275. * @param startValue Start value of the animation curve
  28276. * @param endValue End value of the animation curve
  28277. * @param gradient Scalar amount to interpolate
  28278. * @returns Interpolated Color3 value
  28279. */
  28280. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28281. /**
  28282. * @hidden Internal use only
  28283. */
  28284. _getKeyValue(value: any): any;
  28285. /**
  28286. * @hidden Internal use only
  28287. */
  28288. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28289. /**
  28290. * Defines the function to use to interpolate matrices
  28291. * @param startValue defines the start matrix
  28292. * @param endValue defines the end matrix
  28293. * @param gradient defines the gradient between both matrices
  28294. * @param result defines an optional target matrix where to store the interpolation
  28295. * @returns the interpolated matrix
  28296. */
  28297. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28298. /**
  28299. * Makes a copy of the animation
  28300. * @returns Cloned animation
  28301. */
  28302. clone(): Animation;
  28303. /**
  28304. * Sets the key frames of the animation
  28305. * @param values The animation key frames to set
  28306. */
  28307. setKeys(values: Array<IAnimationKey>): void;
  28308. /**
  28309. * Serializes the animation to an object
  28310. * @returns Serialized object
  28311. */
  28312. serialize(): any;
  28313. /**
  28314. * Float animation type
  28315. */
  28316. private static _ANIMATIONTYPE_FLOAT;
  28317. /**
  28318. * Vector3 animation type
  28319. */
  28320. private static _ANIMATIONTYPE_VECTOR3;
  28321. /**
  28322. * Quaternion animation type
  28323. */
  28324. private static _ANIMATIONTYPE_QUATERNION;
  28325. /**
  28326. * Matrix animation type
  28327. */
  28328. private static _ANIMATIONTYPE_MATRIX;
  28329. /**
  28330. * Color3 animation type
  28331. */
  28332. private static _ANIMATIONTYPE_COLOR3;
  28333. /**
  28334. * Vector2 animation type
  28335. */
  28336. private static _ANIMATIONTYPE_VECTOR2;
  28337. /**
  28338. * Size animation type
  28339. */
  28340. private static _ANIMATIONTYPE_SIZE;
  28341. /**
  28342. * Relative Loop Mode
  28343. */
  28344. private static _ANIMATIONLOOPMODE_RELATIVE;
  28345. /**
  28346. * Cycle Loop Mode
  28347. */
  28348. private static _ANIMATIONLOOPMODE_CYCLE;
  28349. /**
  28350. * Constant Loop Mode
  28351. */
  28352. private static _ANIMATIONLOOPMODE_CONSTANT;
  28353. /**
  28354. * Get the float animation type
  28355. */
  28356. static readonly ANIMATIONTYPE_FLOAT: number;
  28357. /**
  28358. * Get the Vector3 animation type
  28359. */
  28360. static readonly ANIMATIONTYPE_VECTOR3: number;
  28361. /**
  28362. * Get the Vector2 animation type
  28363. */
  28364. static readonly ANIMATIONTYPE_VECTOR2: number;
  28365. /**
  28366. * Get the Size animation type
  28367. */
  28368. static readonly ANIMATIONTYPE_SIZE: number;
  28369. /**
  28370. * Get the Quaternion animation type
  28371. */
  28372. static readonly ANIMATIONTYPE_QUATERNION: number;
  28373. /**
  28374. * Get the Matrix animation type
  28375. */
  28376. static readonly ANIMATIONTYPE_MATRIX: number;
  28377. /**
  28378. * Get the Color3 animation type
  28379. */
  28380. static readonly ANIMATIONTYPE_COLOR3: number;
  28381. /**
  28382. * Get the Relative Loop Mode
  28383. */
  28384. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28385. /**
  28386. * Get the Cycle Loop Mode
  28387. */
  28388. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28389. /**
  28390. * Get the Constant Loop Mode
  28391. */
  28392. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28393. /** @hidden */
  28394. static _UniversalLerp(left: any, right: any, amount: number): any;
  28395. /**
  28396. * Parses an animation object and creates an animation
  28397. * @param parsedAnimation Parsed animation object
  28398. * @returns Animation object
  28399. */
  28400. static Parse(parsedAnimation: any): Animation;
  28401. /**
  28402. * Appends the serialized animations from the source animations
  28403. * @param source Source containing the animations
  28404. * @param destination Target to store the animations
  28405. */
  28406. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28407. }
  28408. }
  28409. declare module "babylonjs/Animations/animatable.interface" {
  28410. import { Nullable } from "babylonjs/types";
  28411. import { Animation } from "babylonjs/Animations/animation";
  28412. /**
  28413. * Interface containing an array of animations
  28414. */
  28415. export interface IAnimatable {
  28416. /**
  28417. * Array of animations
  28418. */
  28419. animations: Nullable<Array<Animation>>;
  28420. }
  28421. }
  28422. declare module "babylonjs/Materials/fresnelParameters" {
  28423. import { Color3 } from "babylonjs/Maths/math.color";
  28424. /**
  28425. * This represents all the required information to add a fresnel effect on a material:
  28426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28427. */
  28428. export class FresnelParameters {
  28429. private _isEnabled;
  28430. /**
  28431. * Define if the fresnel effect is enable or not.
  28432. */
  28433. isEnabled: boolean;
  28434. /**
  28435. * Define the color used on edges (grazing angle)
  28436. */
  28437. leftColor: Color3;
  28438. /**
  28439. * Define the color used on center
  28440. */
  28441. rightColor: Color3;
  28442. /**
  28443. * Define bias applied to computed fresnel term
  28444. */
  28445. bias: number;
  28446. /**
  28447. * Defined the power exponent applied to fresnel term
  28448. */
  28449. power: number;
  28450. /**
  28451. * Clones the current fresnel and its valuues
  28452. * @returns a clone fresnel configuration
  28453. */
  28454. clone(): FresnelParameters;
  28455. /**
  28456. * Serializes the current fresnel parameters to a JSON representation.
  28457. * @return the JSON serialization
  28458. */
  28459. serialize(): any;
  28460. /**
  28461. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28462. * @param parsedFresnelParameters Define the JSON representation
  28463. * @returns the parsed parameters
  28464. */
  28465. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28466. }
  28467. }
  28468. declare module "babylonjs/Misc/decorators" {
  28469. import { Nullable } from "babylonjs/types";
  28470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28471. import { Scene } from "babylonjs/scene";
  28472. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28473. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28474. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28475. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28476. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28477. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28478. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28479. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28480. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28481. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28482. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28483. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28484. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28485. /**
  28486. * Decorator used to define property that can be serialized as reference to a camera
  28487. * @param sourceName defines the name of the property to decorate
  28488. */
  28489. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28490. /**
  28491. * Class used to help serialization objects
  28492. */
  28493. export class SerializationHelper {
  28494. /** @hidden */
  28495. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28496. /** @hidden */
  28497. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28498. /** @hidden */
  28499. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28500. /** @hidden */
  28501. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28502. /**
  28503. * Appends the serialized animations from the source animations
  28504. * @param source Source containing the animations
  28505. * @param destination Target to store the animations
  28506. */
  28507. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28508. /**
  28509. * Static function used to serialized a specific entity
  28510. * @param entity defines the entity to serialize
  28511. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28512. * @returns a JSON compatible object representing the serialization of the entity
  28513. */
  28514. static Serialize<T>(entity: T, serializationObject?: any): any;
  28515. /**
  28516. * Creates a new entity from a serialization data object
  28517. * @param creationFunction defines a function used to instanciated the new entity
  28518. * @param source defines the source serialization data
  28519. * @param scene defines the hosting scene
  28520. * @param rootUrl defines the root url for resources
  28521. * @returns a new entity
  28522. */
  28523. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28524. /**
  28525. * Clones an object
  28526. * @param creationFunction defines the function used to instanciate the new object
  28527. * @param source defines the source object
  28528. * @returns the cloned object
  28529. */
  28530. static Clone<T>(creationFunction: () => T, source: T): T;
  28531. /**
  28532. * Instanciates a new object based on a source one (some data will be shared between both object)
  28533. * @param creationFunction defines the function used to instanciate the new object
  28534. * @param source defines the source object
  28535. * @returns the new object
  28536. */
  28537. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28538. }
  28539. }
  28540. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28541. import { Nullable } from "babylonjs/types";
  28542. /**
  28543. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28544. */
  28545. export interface CubeMapInfo {
  28546. /**
  28547. * The pixel array for the front face.
  28548. * This is stored in format, left to right, up to down format.
  28549. */
  28550. front: Nullable<ArrayBufferView>;
  28551. /**
  28552. * The pixel array for the back face.
  28553. * This is stored in format, left to right, up to down format.
  28554. */
  28555. back: Nullable<ArrayBufferView>;
  28556. /**
  28557. * The pixel array for the left face.
  28558. * This is stored in format, left to right, up to down format.
  28559. */
  28560. left: Nullable<ArrayBufferView>;
  28561. /**
  28562. * The pixel array for the right face.
  28563. * This is stored in format, left to right, up to down format.
  28564. */
  28565. right: Nullable<ArrayBufferView>;
  28566. /**
  28567. * The pixel array for the up face.
  28568. * This is stored in format, left to right, up to down format.
  28569. */
  28570. up: Nullable<ArrayBufferView>;
  28571. /**
  28572. * The pixel array for the down face.
  28573. * This is stored in format, left to right, up to down format.
  28574. */
  28575. down: Nullable<ArrayBufferView>;
  28576. /**
  28577. * The size of the cubemap stored.
  28578. *
  28579. * Each faces will be size * size pixels.
  28580. */
  28581. size: number;
  28582. /**
  28583. * The format of the texture.
  28584. *
  28585. * RGBA, RGB.
  28586. */
  28587. format: number;
  28588. /**
  28589. * The type of the texture data.
  28590. *
  28591. * UNSIGNED_INT, FLOAT.
  28592. */
  28593. type: number;
  28594. /**
  28595. * Specifies whether the texture is in gamma space.
  28596. */
  28597. gammaSpace: boolean;
  28598. }
  28599. /**
  28600. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28601. */
  28602. export class PanoramaToCubeMapTools {
  28603. private static FACE_FRONT;
  28604. private static FACE_BACK;
  28605. private static FACE_RIGHT;
  28606. private static FACE_LEFT;
  28607. private static FACE_DOWN;
  28608. private static FACE_UP;
  28609. /**
  28610. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28611. *
  28612. * @param float32Array The source data.
  28613. * @param inputWidth The width of the input panorama.
  28614. * @param inputHeight The height of the input panorama.
  28615. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28616. * @return The cubemap data
  28617. */
  28618. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28619. private static CreateCubemapTexture;
  28620. private static CalcProjectionSpherical;
  28621. }
  28622. }
  28623. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28624. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28626. import { Nullable } from "babylonjs/types";
  28627. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28628. /**
  28629. * Helper class dealing with the extraction of spherical polynomial dataArray
  28630. * from a cube map.
  28631. */
  28632. export class CubeMapToSphericalPolynomialTools {
  28633. private static FileFaces;
  28634. /**
  28635. * Converts a texture to the according Spherical Polynomial data.
  28636. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28637. *
  28638. * @param texture The texture to extract the information from.
  28639. * @return The Spherical Polynomial data.
  28640. */
  28641. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28642. /**
  28643. * Converts a cubemap to the according Spherical Polynomial data.
  28644. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28645. *
  28646. * @param cubeInfo The Cube map to extract the information from.
  28647. * @return The Spherical Polynomial data.
  28648. */
  28649. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28650. }
  28651. }
  28652. declare module "babylonjs/Misc/guid" {
  28653. /**
  28654. * Class used to manipulate GUIDs
  28655. */
  28656. export class GUID {
  28657. /**
  28658. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28659. * Be aware Math.random() could cause collisions, but:
  28660. * "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"
  28661. * @returns a pseudo random id
  28662. */
  28663. static RandomId(): string;
  28664. }
  28665. }
  28666. declare module "babylonjs/Materials/Textures/baseTexture" {
  28667. import { Observable } from "babylonjs/Misc/observable";
  28668. import { Nullable } from "babylonjs/types";
  28669. import { Scene } from "babylonjs/scene";
  28670. import { Matrix } from "babylonjs/Maths/math.vector";
  28671. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28673. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28674. import { ISize } from "babylonjs/Maths/math.size";
  28675. /**
  28676. * Base class of all the textures in babylon.
  28677. * It groups all the common properties the materials, post process, lights... might need
  28678. * in order to make a correct use of the texture.
  28679. */
  28680. export class BaseTexture implements IAnimatable {
  28681. /**
  28682. * Default anisotropic filtering level for the application.
  28683. * It is set to 4 as a good tradeoff between perf and quality.
  28684. */
  28685. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28686. /**
  28687. * Gets or sets the unique id of the texture
  28688. */
  28689. uniqueId: number;
  28690. /**
  28691. * Define the name of the texture.
  28692. */
  28693. name: string;
  28694. /**
  28695. * Gets or sets an object used to store user defined information.
  28696. */
  28697. metadata: any;
  28698. /**
  28699. * For internal use only. Please do not use.
  28700. */
  28701. reservedDataStore: any;
  28702. private _hasAlpha;
  28703. /**
  28704. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28705. */
  28706. hasAlpha: boolean;
  28707. /**
  28708. * Defines if the alpha value should be determined via the rgb values.
  28709. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28710. */
  28711. getAlphaFromRGB: boolean;
  28712. /**
  28713. * Intensity or strength of the texture.
  28714. * It is commonly used by materials to fine tune the intensity of the texture
  28715. */
  28716. level: number;
  28717. /**
  28718. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28719. * This is part of the texture as textures usually maps to one uv set.
  28720. */
  28721. coordinatesIndex: number;
  28722. private _coordinatesMode;
  28723. /**
  28724. * How a texture is mapped.
  28725. *
  28726. * | Value | Type | Description |
  28727. * | ----- | ----------------------------------- | ----------- |
  28728. * | 0 | EXPLICIT_MODE | |
  28729. * | 1 | SPHERICAL_MODE | |
  28730. * | 2 | PLANAR_MODE | |
  28731. * | 3 | CUBIC_MODE | |
  28732. * | 4 | PROJECTION_MODE | |
  28733. * | 5 | SKYBOX_MODE | |
  28734. * | 6 | INVCUBIC_MODE | |
  28735. * | 7 | EQUIRECTANGULAR_MODE | |
  28736. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28737. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28738. */
  28739. coordinatesMode: number;
  28740. /**
  28741. * | Value | Type | Description |
  28742. * | ----- | ------------------ | ----------- |
  28743. * | 0 | CLAMP_ADDRESSMODE | |
  28744. * | 1 | WRAP_ADDRESSMODE | |
  28745. * | 2 | MIRROR_ADDRESSMODE | |
  28746. */
  28747. wrapU: number;
  28748. /**
  28749. * | Value | Type | Description |
  28750. * | ----- | ------------------ | ----------- |
  28751. * | 0 | CLAMP_ADDRESSMODE | |
  28752. * | 1 | WRAP_ADDRESSMODE | |
  28753. * | 2 | MIRROR_ADDRESSMODE | |
  28754. */
  28755. wrapV: number;
  28756. /**
  28757. * | Value | Type | Description |
  28758. * | ----- | ------------------ | ----------- |
  28759. * | 0 | CLAMP_ADDRESSMODE | |
  28760. * | 1 | WRAP_ADDRESSMODE | |
  28761. * | 2 | MIRROR_ADDRESSMODE | |
  28762. */
  28763. wrapR: number;
  28764. /**
  28765. * With compliant hardware and browser (supporting anisotropic filtering)
  28766. * this defines the level of anisotropic filtering in the texture.
  28767. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28768. */
  28769. anisotropicFilteringLevel: number;
  28770. /**
  28771. * Define if the texture is a cube texture or if false a 2d texture.
  28772. */
  28773. isCube: boolean;
  28774. /**
  28775. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28776. */
  28777. is3D: boolean;
  28778. /**
  28779. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28780. * HDR texture are usually stored in linear space.
  28781. * This only impacts the PBR and Background materials
  28782. */
  28783. gammaSpace: boolean;
  28784. /**
  28785. * Gets or sets whether or not the texture contains RGBD data.
  28786. */
  28787. isRGBD: boolean;
  28788. /**
  28789. * Is Z inverted in the texture (useful in a cube texture).
  28790. */
  28791. invertZ: boolean;
  28792. /**
  28793. * Are mip maps generated for this texture or not.
  28794. */
  28795. readonly noMipmap: boolean;
  28796. /**
  28797. * @hidden
  28798. */
  28799. lodLevelInAlpha: boolean;
  28800. /**
  28801. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28802. */
  28803. lodGenerationOffset: number;
  28804. /**
  28805. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28806. */
  28807. lodGenerationScale: number;
  28808. /**
  28809. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28810. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28811. * average roughness values.
  28812. */
  28813. linearSpecularLOD: boolean;
  28814. /**
  28815. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28816. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28817. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28818. */
  28819. irradianceTexture: Nullable<BaseTexture>;
  28820. /**
  28821. * Define if the texture is a render target.
  28822. */
  28823. isRenderTarget: boolean;
  28824. /**
  28825. * Define the unique id of the texture in the scene.
  28826. */
  28827. readonly uid: string;
  28828. /**
  28829. * Return a string representation of the texture.
  28830. * @returns the texture as a string
  28831. */
  28832. toString(): string;
  28833. /**
  28834. * Get the class name of the texture.
  28835. * @returns "BaseTexture"
  28836. */
  28837. getClassName(): string;
  28838. /**
  28839. * Define the list of animation attached to the texture.
  28840. */
  28841. animations: import("babylonjs/Animations/animation").Animation[];
  28842. /**
  28843. * An event triggered when the texture is disposed.
  28844. */
  28845. onDisposeObservable: Observable<BaseTexture>;
  28846. private _onDisposeObserver;
  28847. /**
  28848. * Callback triggered when the texture has been disposed.
  28849. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28850. */
  28851. onDispose: () => void;
  28852. /**
  28853. * Define the current state of the loading sequence when in delayed load mode.
  28854. */
  28855. delayLoadState: number;
  28856. private _scene;
  28857. /** @hidden */
  28858. _texture: Nullable<InternalTexture>;
  28859. private _uid;
  28860. /**
  28861. * Define if the texture is preventinga material to render or not.
  28862. * If not and the texture is not ready, the engine will use a default black texture instead.
  28863. */
  28864. readonly isBlocking: boolean;
  28865. /**
  28866. * Instantiates a new BaseTexture.
  28867. * Base class of all the textures in babylon.
  28868. * It groups all the common properties the materials, post process, lights... might need
  28869. * in order to make a correct use of the texture.
  28870. * @param scene Define the scene the texture blongs to
  28871. */
  28872. constructor(scene: Nullable<Scene>);
  28873. /**
  28874. * Get the scene the texture belongs to.
  28875. * @returns the scene or null if undefined
  28876. */
  28877. getScene(): Nullable<Scene>;
  28878. /**
  28879. * Get the texture transform matrix used to offset tile the texture for istance.
  28880. * @returns the transformation matrix
  28881. */
  28882. getTextureMatrix(): Matrix;
  28883. /**
  28884. * Get the texture reflection matrix used to rotate/transform the reflection.
  28885. * @returns the reflection matrix
  28886. */
  28887. getReflectionTextureMatrix(): Matrix;
  28888. /**
  28889. * Get the underlying lower level texture from Babylon.
  28890. * @returns the insternal texture
  28891. */
  28892. getInternalTexture(): Nullable<InternalTexture>;
  28893. /**
  28894. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28895. * @returns true if ready or not blocking
  28896. */
  28897. isReadyOrNotBlocking(): boolean;
  28898. /**
  28899. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28900. * @returns true if fully ready
  28901. */
  28902. isReady(): boolean;
  28903. private _cachedSize;
  28904. /**
  28905. * Get the size of the texture.
  28906. * @returns the texture size.
  28907. */
  28908. getSize(): ISize;
  28909. /**
  28910. * Get the base size of the texture.
  28911. * It can be different from the size if the texture has been resized for POT for instance
  28912. * @returns the base size
  28913. */
  28914. getBaseSize(): ISize;
  28915. /**
  28916. * Update the sampling mode of the texture.
  28917. * Default is Trilinear mode.
  28918. *
  28919. * | Value | Type | Description |
  28920. * | ----- | ------------------ | ----------- |
  28921. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28922. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28923. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28924. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28925. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28926. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28927. * | 7 | NEAREST_LINEAR | |
  28928. * | 8 | NEAREST_NEAREST | |
  28929. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28930. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28931. * | 11 | LINEAR_LINEAR | |
  28932. * | 12 | LINEAR_NEAREST | |
  28933. *
  28934. * > _mag_: magnification filter (close to the viewer)
  28935. * > _min_: minification filter (far from the viewer)
  28936. * > _mip_: filter used between mip map levels
  28937. *@param samplingMode Define the new sampling mode of the texture
  28938. */
  28939. updateSamplingMode(samplingMode: number): void;
  28940. /**
  28941. * Scales the texture if is `canRescale()`
  28942. * @param ratio the resize factor we want to use to rescale
  28943. */
  28944. scale(ratio: number): void;
  28945. /**
  28946. * Get if the texture can rescale.
  28947. */
  28948. readonly canRescale: boolean;
  28949. /** @hidden */
  28950. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28951. /** @hidden */
  28952. _rebuild(): void;
  28953. /**
  28954. * Triggers the load sequence in delayed load mode.
  28955. */
  28956. delayLoad(): void;
  28957. /**
  28958. * Clones the texture.
  28959. * @returns the cloned texture
  28960. */
  28961. clone(): Nullable<BaseTexture>;
  28962. /**
  28963. * Get the texture underlying type (INT, FLOAT...)
  28964. */
  28965. readonly textureType: number;
  28966. /**
  28967. * Get the texture underlying format (RGB, RGBA...)
  28968. */
  28969. readonly textureFormat: number;
  28970. /**
  28971. * Indicates that textures need to be re-calculated for all materials
  28972. */
  28973. protected _markAllSubMeshesAsTexturesDirty(): void;
  28974. /**
  28975. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28976. * This will returns an RGBA array buffer containing either in values (0-255) or
  28977. * float values (0-1) depending of the underlying buffer type.
  28978. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28979. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28980. * @param buffer defines a user defined buffer to fill with data (can be null)
  28981. * @returns The Array buffer containing the pixels data.
  28982. */
  28983. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28984. /**
  28985. * Release and destroy the underlying lower level texture aka internalTexture.
  28986. */
  28987. releaseInternalTexture(): void;
  28988. /**
  28989. * Get the polynomial representation of the texture data.
  28990. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28991. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28992. */
  28993. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28994. /** @hidden */
  28995. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28996. /** @hidden */
  28997. readonly _lodTextureMid: Nullable<BaseTexture>;
  28998. /** @hidden */
  28999. readonly _lodTextureLow: Nullable<BaseTexture>;
  29000. /**
  29001. * Dispose the texture and release its associated resources.
  29002. */
  29003. dispose(): void;
  29004. /**
  29005. * Serialize the texture into a JSON representation that can be parsed later on.
  29006. * @returns the JSON representation of the texture
  29007. */
  29008. serialize(): any;
  29009. /**
  29010. * Helper function to be called back once a list of texture contains only ready textures.
  29011. * @param textures Define the list of textures to wait for
  29012. * @param callback Define the callback triggered once the entire list will be ready
  29013. */
  29014. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29015. }
  29016. }
  29017. declare module "babylonjs/Materials/effect" {
  29018. import { Observable } from "babylonjs/Misc/observable";
  29019. import { Nullable } from "babylonjs/types";
  29020. import { IDisposable } from "babylonjs/scene";
  29021. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29022. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29023. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29024. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29025. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29026. import { Engine } from "babylonjs/Engines/engine";
  29027. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29029. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29030. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29031. /**
  29032. * Options to be used when creating an effect.
  29033. */
  29034. export class EffectCreationOptions {
  29035. /**
  29036. * Atrributes that will be used in the shader.
  29037. */
  29038. attributes: string[];
  29039. /**
  29040. * Uniform varible names that will be set in the shader.
  29041. */
  29042. uniformsNames: string[];
  29043. /**
  29044. * Uniform buffer varible names that will be set in the shader.
  29045. */
  29046. uniformBuffersNames: string[];
  29047. /**
  29048. * Sampler texture variable names that will be set in the shader.
  29049. */
  29050. samplers: string[];
  29051. /**
  29052. * Define statements that will be set in the shader.
  29053. */
  29054. defines: any;
  29055. /**
  29056. * Possible fallbacks for this effect to improve performance when needed.
  29057. */
  29058. fallbacks: Nullable<IEffectFallbacks>;
  29059. /**
  29060. * Callback that will be called when the shader is compiled.
  29061. */
  29062. onCompiled: Nullable<(effect: Effect) => void>;
  29063. /**
  29064. * Callback that will be called if an error occurs during shader compilation.
  29065. */
  29066. onError: Nullable<(effect: Effect, errors: string) => void>;
  29067. /**
  29068. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29069. */
  29070. indexParameters?: any;
  29071. /**
  29072. * Max number of lights that can be used in the shader.
  29073. */
  29074. maxSimultaneousLights?: number;
  29075. /**
  29076. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29077. */
  29078. transformFeedbackVaryings?: Nullable<string[]>;
  29079. }
  29080. /**
  29081. * Effect containing vertex and fragment shader that can be executed on an object.
  29082. */
  29083. export class Effect implements IDisposable {
  29084. /**
  29085. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29086. */
  29087. static ShadersRepository: string;
  29088. /**
  29089. * Name of the effect.
  29090. */
  29091. name: any;
  29092. /**
  29093. * String container all the define statements that should be set on the shader.
  29094. */
  29095. defines: string;
  29096. /**
  29097. * Callback that will be called when the shader is compiled.
  29098. */
  29099. onCompiled: Nullable<(effect: Effect) => void>;
  29100. /**
  29101. * Callback that will be called if an error occurs during shader compilation.
  29102. */
  29103. onError: Nullable<(effect: Effect, errors: string) => void>;
  29104. /**
  29105. * Callback that will be called when effect is bound.
  29106. */
  29107. onBind: Nullable<(effect: Effect) => void>;
  29108. /**
  29109. * Unique ID of the effect.
  29110. */
  29111. uniqueId: number;
  29112. /**
  29113. * Observable that will be called when the shader is compiled.
  29114. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29115. */
  29116. onCompileObservable: Observable<Effect>;
  29117. /**
  29118. * Observable that will be called if an error occurs during shader compilation.
  29119. */
  29120. onErrorObservable: Observable<Effect>;
  29121. /** @hidden */
  29122. _onBindObservable: Nullable<Observable<Effect>>;
  29123. /**
  29124. * Observable that will be called when effect is bound.
  29125. */
  29126. readonly onBindObservable: Observable<Effect>;
  29127. /** @hidden */
  29128. _bonesComputationForcedToCPU: boolean;
  29129. private static _uniqueIdSeed;
  29130. private _engine;
  29131. private _uniformBuffersNames;
  29132. private _uniformsNames;
  29133. private _samplerList;
  29134. private _samplers;
  29135. private _isReady;
  29136. private _compilationError;
  29137. private _attributesNames;
  29138. private _attributes;
  29139. private _uniforms;
  29140. /**
  29141. * Key for the effect.
  29142. * @hidden
  29143. */
  29144. _key: string;
  29145. private _indexParameters;
  29146. private _fallbacks;
  29147. private _vertexSourceCode;
  29148. private _fragmentSourceCode;
  29149. private _vertexSourceCodeOverride;
  29150. private _fragmentSourceCodeOverride;
  29151. private _transformFeedbackVaryings;
  29152. /**
  29153. * Compiled shader to webGL program.
  29154. * @hidden
  29155. */
  29156. _pipelineContext: Nullable<IPipelineContext>;
  29157. private _valueCache;
  29158. private static _baseCache;
  29159. /**
  29160. * Instantiates an effect.
  29161. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29162. * @param baseName Name of the effect.
  29163. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29164. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29165. * @param samplers List of sampler variables that will be passed to the shader.
  29166. * @param engine Engine to be used to render the effect
  29167. * @param defines Define statements to be added to the shader.
  29168. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29169. * @param onCompiled Callback that will be called when the shader is compiled.
  29170. * @param onError Callback that will be called if an error occurs during shader compilation.
  29171. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29172. */
  29173. 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);
  29174. private _useFinalCode;
  29175. /**
  29176. * Unique key for this effect
  29177. */
  29178. readonly key: string;
  29179. /**
  29180. * If the effect has been compiled and prepared.
  29181. * @returns if the effect is compiled and prepared.
  29182. */
  29183. isReady(): boolean;
  29184. private _isReadyInternal;
  29185. /**
  29186. * The engine the effect was initialized with.
  29187. * @returns the engine.
  29188. */
  29189. getEngine(): Engine;
  29190. /**
  29191. * The pipeline context for this effect
  29192. * @returns the associated pipeline context
  29193. */
  29194. getPipelineContext(): Nullable<IPipelineContext>;
  29195. /**
  29196. * The set of names of attribute variables for the shader.
  29197. * @returns An array of attribute names.
  29198. */
  29199. getAttributesNames(): string[];
  29200. /**
  29201. * Returns the attribute at the given index.
  29202. * @param index The index of the attribute.
  29203. * @returns The location of the attribute.
  29204. */
  29205. getAttributeLocation(index: number): number;
  29206. /**
  29207. * Returns the attribute based on the name of the variable.
  29208. * @param name of the attribute to look up.
  29209. * @returns the attribute location.
  29210. */
  29211. getAttributeLocationByName(name: string): number;
  29212. /**
  29213. * The number of attributes.
  29214. * @returns the numnber of attributes.
  29215. */
  29216. getAttributesCount(): number;
  29217. /**
  29218. * Gets the index of a uniform variable.
  29219. * @param uniformName of the uniform to look up.
  29220. * @returns the index.
  29221. */
  29222. getUniformIndex(uniformName: string): number;
  29223. /**
  29224. * Returns the attribute based on the name of the variable.
  29225. * @param uniformName of the uniform to look up.
  29226. * @returns the location of the uniform.
  29227. */
  29228. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29229. /**
  29230. * Returns an array of sampler variable names
  29231. * @returns The array of sampler variable neames.
  29232. */
  29233. getSamplers(): string[];
  29234. /**
  29235. * The error from the last compilation.
  29236. * @returns the error string.
  29237. */
  29238. getCompilationError(): string;
  29239. /**
  29240. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29241. * @param func The callback to be used.
  29242. */
  29243. executeWhenCompiled(func: (effect: Effect) => void): void;
  29244. private _checkIsReady;
  29245. /** @hidden */
  29246. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29247. /** @hidden */
  29248. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29249. /** @hidden */
  29250. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29251. /**
  29252. * Recompiles the webGL program
  29253. * @param vertexSourceCode The source code for the vertex shader.
  29254. * @param fragmentSourceCode The source code for the fragment shader.
  29255. * @param onCompiled Callback called when completed.
  29256. * @param onError Callback called on error.
  29257. * @hidden
  29258. */
  29259. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29260. /**
  29261. * Prepares the effect
  29262. * @hidden
  29263. */
  29264. _prepareEffect(): void;
  29265. private _processCompilationErrors;
  29266. /**
  29267. * Checks if the effect is supported. (Must be called after compilation)
  29268. */
  29269. readonly isSupported: boolean;
  29270. /**
  29271. * Binds a texture to the engine to be used as output of the shader.
  29272. * @param channel Name of the output variable.
  29273. * @param texture Texture to bind.
  29274. * @hidden
  29275. */
  29276. _bindTexture(channel: string, texture: InternalTexture): void;
  29277. /**
  29278. * Sets a texture on the engine to be used in the shader.
  29279. * @param channel Name of the sampler variable.
  29280. * @param texture Texture to set.
  29281. */
  29282. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29283. /**
  29284. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29285. * @param channel Name of the sampler variable.
  29286. * @param texture Texture to set.
  29287. */
  29288. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29289. /**
  29290. * Sets an array of textures on the engine to be used in the shader.
  29291. * @param channel Name of the variable.
  29292. * @param textures Textures to set.
  29293. */
  29294. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29295. /**
  29296. * 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)
  29297. * @param channel Name of the sampler variable.
  29298. * @param postProcess Post process to get the input texture from.
  29299. */
  29300. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29301. /**
  29302. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29303. * 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)
  29304. * @param channel Name of the sampler variable.
  29305. * @param postProcess Post process to get the output texture from.
  29306. */
  29307. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29308. /** @hidden */
  29309. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29310. /** @hidden */
  29311. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29312. /** @hidden */
  29313. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29314. /** @hidden */
  29315. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29316. /**
  29317. * Binds a buffer to a uniform.
  29318. * @param buffer Buffer to bind.
  29319. * @param name Name of the uniform variable to bind to.
  29320. */
  29321. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29322. /**
  29323. * Binds block to a uniform.
  29324. * @param blockName Name of the block to bind.
  29325. * @param index Index to bind.
  29326. */
  29327. bindUniformBlock(blockName: string, index: number): void;
  29328. /**
  29329. * Sets an interger value on a uniform variable.
  29330. * @param uniformName Name of the variable.
  29331. * @param value Value to be set.
  29332. * @returns this effect.
  29333. */
  29334. setInt(uniformName: string, value: number): Effect;
  29335. /**
  29336. * Sets an int array on a uniform variable.
  29337. * @param uniformName Name of the variable.
  29338. * @param array array to be set.
  29339. * @returns this effect.
  29340. */
  29341. setIntArray(uniformName: string, array: Int32Array): Effect;
  29342. /**
  29343. * 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)
  29344. * @param uniformName Name of the variable.
  29345. * @param array array to be set.
  29346. * @returns this effect.
  29347. */
  29348. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29349. /**
  29350. * 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)
  29351. * @param uniformName Name of the variable.
  29352. * @param array array to be set.
  29353. * @returns this effect.
  29354. */
  29355. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29356. /**
  29357. * 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)
  29358. * @param uniformName Name of the variable.
  29359. * @param array array to be set.
  29360. * @returns this effect.
  29361. */
  29362. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29363. /**
  29364. * Sets an float array on a uniform variable.
  29365. * @param uniformName Name of the variable.
  29366. * @param array array to be set.
  29367. * @returns this effect.
  29368. */
  29369. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29370. /**
  29371. * 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)
  29372. * @param uniformName Name of the variable.
  29373. * @param array array to be set.
  29374. * @returns this effect.
  29375. */
  29376. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29377. /**
  29378. * 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)
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29384. /**
  29385. * 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)
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29391. /**
  29392. * Sets an array on a uniform variable.
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setArray(uniformName: string, array: number[]): Effect;
  29398. /**
  29399. * 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)
  29400. * @param uniformName Name of the variable.
  29401. * @param array array to be set.
  29402. * @returns this effect.
  29403. */
  29404. setArray2(uniformName: string, array: number[]): Effect;
  29405. /**
  29406. * 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)
  29407. * @param uniformName Name of the variable.
  29408. * @param array array to be set.
  29409. * @returns this effect.
  29410. */
  29411. setArray3(uniformName: string, array: number[]): Effect;
  29412. /**
  29413. * 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)
  29414. * @param uniformName Name of the variable.
  29415. * @param array array to be set.
  29416. * @returns this effect.
  29417. */
  29418. setArray4(uniformName: string, array: number[]): Effect;
  29419. /**
  29420. * Sets matrices on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param matrices matrices to be set.
  29423. * @returns this effect.
  29424. */
  29425. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29426. /**
  29427. * Sets matrix on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param matrix matrix to be set.
  29430. * @returns this effect.
  29431. */
  29432. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29433. /**
  29434. * 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)
  29435. * @param uniformName Name of the variable.
  29436. * @param matrix matrix to be set.
  29437. * @returns this effect.
  29438. */
  29439. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29440. /**
  29441. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29442. * @param uniformName Name of the variable.
  29443. * @param matrix matrix to be set.
  29444. * @returns this effect.
  29445. */
  29446. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29447. /**
  29448. * Sets a float on a uniform variable.
  29449. * @param uniformName Name of the variable.
  29450. * @param value value to be set.
  29451. * @returns this effect.
  29452. */
  29453. setFloat(uniformName: string, value: number): Effect;
  29454. /**
  29455. * Sets a boolean on a uniform variable.
  29456. * @param uniformName Name of the variable.
  29457. * @param bool value to be set.
  29458. * @returns this effect.
  29459. */
  29460. setBool(uniformName: string, bool: boolean): Effect;
  29461. /**
  29462. * Sets a Vector2 on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param vector2 vector2 to be set.
  29465. * @returns this effect.
  29466. */
  29467. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29468. /**
  29469. * Sets a float2 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param x First float in float2.
  29472. * @param y Second float in float2.
  29473. * @returns this effect.
  29474. */
  29475. setFloat2(uniformName: string, x: number, y: number): Effect;
  29476. /**
  29477. * Sets a Vector3 on a uniform variable.
  29478. * @param uniformName Name of the variable.
  29479. * @param vector3 Value to be set.
  29480. * @returns this effect.
  29481. */
  29482. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29483. /**
  29484. * Sets a float3 on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param x First float in float3.
  29487. * @param y Second float in float3.
  29488. * @param z Third float in float3.
  29489. * @returns this effect.
  29490. */
  29491. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29492. /**
  29493. * Sets a Vector4 on a uniform variable.
  29494. * @param uniformName Name of the variable.
  29495. * @param vector4 Value to be set.
  29496. * @returns this effect.
  29497. */
  29498. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29499. /**
  29500. * Sets a float4 on a uniform variable.
  29501. * @param uniformName Name of the variable.
  29502. * @param x First float in float4.
  29503. * @param y Second float in float4.
  29504. * @param z Third float in float4.
  29505. * @param w Fourth float in float4.
  29506. * @returns this effect.
  29507. */
  29508. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29509. /**
  29510. * Sets a Color3 on a uniform variable.
  29511. * @param uniformName Name of the variable.
  29512. * @param color3 Value to be set.
  29513. * @returns this effect.
  29514. */
  29515. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29516. /**
  29517. * Sets a Color4 on a uniform variable.
  29518. * @param uniformName Name of the variable.
  29519. * @param color3 Value to be set.
  29520. * @param alpha Alpha value to be set.
  29521. * @returns this effect.
  29522. */
  29523. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29524. /**
  29525. * Sets a Color4 on a uniform variable
  29526. * @param uniformName defines the name of the variable
  29527. * @param color4 defines the value to be set
  29528. * @returns this effect.
  29529. */
  29530. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29531. /** Release all associated resources */
  29532. dispose(): void;
  29533. /**
  29534. * This function will add a new shader to the shader store
  29535. * @param name the name of the shader
  29536. * @param pixelShader optional pixel shader content
  29537. * @param vertexShader optional vertex shader content
  29538. */
  29539. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29540. /**
  29541. * Store of each shader (The can be looked up using effect.key)
  29542. */
  29543. static ShadersStore: {
  29544. [key: string]: string;
  29545. };
  29546. /**
  29547. * Store of each included file for a shader (The can be looked up using effect.key)
  29548. */
  29549. static IncludesShadersStore: {
  29550. [key: string]: string;
  29551. };
  29552. /**
  29553. * Resets the cache of effects.
  29554. */
  29555. static ResetCache(): void;
  29556. }
  29557. }
  29558. declare module "babylonjs/Engines/engineCapabilities" {
  29559. import { Nullable } from "babylonjs/types";
  29560. /**
  29561. * Class used to describe the capabilities of the engine relatively to the current browser
  29562. */
  29563. export class EngineCapabilities {
  29564. /** Maximum textures units per fragment shader */
  29565. maxTexturesImageUnits: number;
  29566. /** Maximum texture units per vertex shader */
  29567. maxVertexTextureImageUnits: number;
  29568. /** Maximum textures units in the entire pipeline */
  29569. maxCombinedTexturesImageUnits: number;
  29570. /** Maximum texture size */
  29571. maxTextureSize: number;
  29572. /** Maximum cube texture size */
  29573. maxCubemapTextureSize: number;
  29574. /** Maximum render texture size */
  29575. maxRenderTextureSize: number;
  29576. /** Maximum number of vertex attributes */
  29577. maxVertexAttribs: number;
  29578. /** Maximum number of varyings */
  29579. maxVaryingVectors: number;
  29580. /** Maximum number of uniforms per vertex shader */
  29581. maxVertexUniformVectors: number;
  29582. /** Maximum number of uniforms per fragment shader */
  29583. maxFragmentUniformVectors: number;
  29584. /** Defines if standard derivates (dx/dy) are supported */
  29585. standardDerivatives: boolean;
  29586. /** Defines if s3tc texture compression is supported */
  29587. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29588. /** Defines if pvrtc texture compression is supported */
  29589. pvrtc: any;
  29590. /** Defines if etc1 texture compression is supported */
  29591. etc1: any;
  29592. /** Defines if etc2 texture compression is supported */
  29593. etc2: any;
  29594. /** Defines if astc texture compression is supported */
  29595. astc: any;
  29596. /** Defines if float textures are supported */
  29597. textureFloat: boolean;
  29598. /** Defines if vertex array objects are supported */
  29599. vertexArrayObject: boolean;
  29600. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29601. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29602. /** Gets the maximum level of anisotropy supported */
  29603. maxAnisotropy: number;
  29604. /** Defines if instancing is supported */
  29605. instancedArrays: boolean;
  29606. /** Defines if 32 bits indices are supported */
  29607. uintIndices: boolean;
  29608. /** Defines if high precision shaders are supported */
  29609. highPrecisionShaderSupported: boolean;
  29610. /** Defines if depth reading in the fragment shader is supported */
  29611. fragmentDepthSupported: boolean;
  29612. /** Defines if float texture linear filtering is supported*/
  29613. textureFloatLinearFiltering: boolean;
  29614. /** Defines if rendering to float textures is supported */
  29615. textureFloatRender: boolean;
  29616. /** Defines if half float textures are supported*/
  29617. textureHalfFloat: boolean;
  29618. /** Defines if half float texture linear filtering is supported*/
  29619. textureHalfFloatLinearFiltering: boolean;
  29620. /** Defines if rendering to half float textures is supported */
  29621. textureHalfFloatRender: boolean;
  29622. /** Defines if textureLOD shader command is supported */
  29623. textureLOD: boolean;
  29624. /** Defines if draw buffers extension is supported */
  29625. drawBuffersExtension: boolean;
  29626. /** Defines if depth textures are supported */
  29627. depthTextureExtension: boolean;
  29628. /** Defines if float color buffer are supported */
  29629. colorBufferFloat: boolean;
  29630. /** Gets disjoint timer query extension (null if not supported) */
  29631. timerQuery: EXT_disjoint_timer_query;
  29632. /** Defines if timestamp can be used with timer query */
  29633. canUseTimestampForTimerQuery: boolean;
  29634. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29635. multiview: any;
  29636. /** Function used to let the system compiles shaders in background */
  29637. parallelShaderCompile: {
  29638. COMPLETION_STATUS_KHR: number;
  29639. };
  29640. /** Max number of texture samples for MSAA */
  29641. maxMSAASamples: number;
  29642. /** Defines if the blend min max extension is supported */
  29643. blendMinMax: boolean;
  29644. }
  29645. }
  29646. declare module "babylonjs/Misc/perfCounter" {
  29647. /**
  29648. * This class is used to track a performance counter which is number based.
  29649. * The user has access to many properties which give statistics of different nature.
  29650. *
  29651. * The implementer can track two kinds of Performance Counter: time and count.
  29652. * 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.
  29653. * 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.
  29654. */
  29655. export class PerfCounter {
  29656. /**
  29657. * Gets or sets a global boolean to turn on and off all the counters
  29658. */
  29659. static Enabled: boolean;
  29660. /**
  29661. * Returns the smallest value ever
  29662. */
  29663. readonly min: number;
  29664. /**
  29665. * Returns the biggest value ever
  29666. */
  29667. readonly max: number;
  29668. /**
  29669. * Returns the average value since the performance counter is running
  29670. */
  29671. readonly average: number;
  29672. /**
  29673. * Returns the average value of the last second the counter was monitored
  29674. */
  29675. readonly lastSecAverage: number;
  29676. /**
  29677. * Returns the current value
  29678. */
  29679. readonly current: number;
  29680. /**
  29681. * Gets the accumulated total
  29682. */
  29683. readonly total: number;
  29684. /**
  29685. * Gets the total value count
  29686. */
  29687. readonly count: number;
  29688. /**
  29689. * Creates a new counter
  29690. */
  29691. constructor();
  29692. /**
  29693. * Call this method to start monitoring a new frame.
  29694. * 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.
  29695. */
  29696. fetchNewFrame(): void;
  29697. /**
  29698. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29699. * @param newCount the count value to add to the monitored count
  29700. * @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.
  29701. */
  29702. addCount(newCount: number, fetchResult: boolean): void;
  29703. /**
  29704. * Start monitoring this performance counter
  29705. */
  29706. beginMonitoring(): void;
  29707. /**
  29708. * Compute the time lapsed since the previous beginMonitoring() call.
  29709. * @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
  29710. */
  29711. endMonitoring(newFrame?: boolean): void;
  29712. private _fetchResult;
  29713. private _startMonitoringTime;
  29714. private _min;
  29715. private _max;
  29716. private _average;
  29717. private _current;
  29718. private _totalValueCount;
  29719. private _totalAccumulated;
  29720. private _lastSecAverage;
  29721. private _lastSecAccumulated;
  29722. private _lastSecTime;
  29723. private _lastSecValueCount;
  29724. }
  29725. }
  29726. declare module "babylonjs/States/depthCullingState" {
  29727. import { Nullable } from "babylonjs/types";
  29728. /**
  29729. * @hidden
  29730. **/
  29731. export class DepthCullingState {
  29732. private _isDepthTestDirty;
  29733. private _isDepthMaskDirty;
  29734. private _isDepthFuncDirty;
  29735. private _isCullFaceDirty;
  29736. private _isCullDirty;
  29737. private _isZOffsetDirty;
  29738. private _isFrontFaceDirty;
  29739. private _depthTest;
  29740. private _depthMask;
  29741. private _depthFunc;
  29742. private _cull;
  29743. private _cullFace;
  29744. private _zOffset;
  29745. private _frontFace;
  29746. /**
  29747. * Initializes the state.
  29748. */
  29749. constructor();
  29750. readonly isDirty: boolean;
  29751. zOffset: number;
  29752. cullFace: Nullable<number>;
  29753. cull: Nullable<boolean>;
  29754. depthFunc: Nullable<number>;
  29755. depthMask: boolean;
  29756. depthTest: boolean;
  29757. frontFace: Nullable<number>;
  29758. reset(): void;
  29759. apply(gl: WebGLRenderingContext): void;
  29760. }
  29761. }
  29762. declare module "babylonjs/States/stencilState" {
  29763. /**
  29764. * @hidden
  29765. **/
  29766. export class StencilState {
  29767. /** 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 */
  29768. static readonly ALWAYS: number;
  29769. /** Passed to stencilOperation to specify that stencil value must be kept */
  29770. static readonly KEEP: number;
  29771. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29772. static readonly REPLACE: number;
  29773. private _isStencilTestDirty;
  29774. private _isStencilMaskDirty;
  29775. private _isStencilFuncDirty;
  29776. private _isStencilOpDirty;
  29777. private _stencilTest;
  29778. private _stencilMask;
  29779. private _stencilFunc;
  29780. private _stencilFuncRef;
  29781. private _stencilFuncMask;
  29782. private _stencilOpStencilFail;
  29783. private _stencilOpDepthFail;
  29784. private _stencilOpStencilDepthPass;
  29785. readonly isDirty: boolean;
  29786. stencilFunc: number;
  29787. stencilFuncRef: number;
  29788. stencilFuncMask: number;
  29789. stencilOpStencilFail: number;
  29790. stencilOpDepthFail: number;
  29791. stencilOpStencilDepthPass: number;
  29792. stencilMask: number;
  29793. stencilTest: boolean;
  29794. constructor();
  29795. reset(): void;
  29796. apply(gl: WebGLRenderingContext): void;
  29797. }
  29798. }
  29799. declare module "babylonjs/States/alphaCullingState" {
  29800. /**
  29801. * @hidden
  29802. **/
  29803. export class AlphaState {
  29804. private _isAlphaBlendDirty;
  29805. private _isBlendFunctionParametersDirty;
  29806. private _isBlendEquationParametersDirty;
  29807. private _isBlendConstantsDirty;
  29808. private _alphaBlend;
  29809. private _blendFunctionParameters;
  29810. private _blendEquationParameters;
  29811. private _blendConstants;
  29812. /**
  29813. * Initializes the state.
  29814. */
  29815. constructor();
  29816. readonly isDirty: boolean;
  29817. alphaBlend: boolean;
  29818. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29819. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29820. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29821. reset(): void;
  29822. apply(gl: WebGLRenderingContext): void;
  29823. }
  29824. }
  29825. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29826. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29827. /** @hidden */
  29828. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29829. attributeProcessor(attribute: string): string;
  29830. varyingProcessor(varying: string, isFragment: boolean): string;
  29831. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29832. }
  29833. }
  29834. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29835. /**
  29836. * Interface for attribute information associated with buffer instanciation
  29837. */
  29838. export class InstancingAttributeInfo {
  29839. /**
  29840. * Index/offset of the attribute in the vertex shader
  29841. */
  29842. index: number;
  29843. /**
  29844. * size of the attribute, 1, 2, 3 or 4
  29845. */
  29846. attributeSize: number;
  29847. /**
  29848. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29849. * default is FLOAT
  29850. */
  29851. attribyteType: number;
  29852. /**
  29853. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29854. */
  29855. normalized: boolean;
  29856. /**
  29857. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29858. */
  29859. offset: number;
  29860. /**
  29861. * Name of the GLSL attribute, for debugging purpose only
  29862. */
  29863. attributeName: string;
  29864. }
  29865. }
  29866. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29868. import { Nullable } from "babylonjs/types";
  29869. module "babylonjs/Engines/thinEngine" {
  29870. interface ThinEngine {
  29871. /**
  29872. * Update a video texture
  29873. * @param texture defines the texture to update
  29874. * @param video defines the video element to use
  29875. * @param invertY defines if data must be stored with Y axis inverted
  29876. */
  29877. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29878. }
  29879. }
  29880. }
  29881. declare module "babylonjs/Materials/Textures/videoTexture" {
  29882. import { Observable } from "babylonjs/Misc/observable";
  29883. import { Nullable } from "babylonjs/types";
  29884. import { Scene } from "babylonjs/scene";
  29885. import { Texture } from "babylonjs/Materials/Textures/texture";
  29886. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29887. /**
  29888. * Settings for finer control over video usage
  29889. */
  29890. export interface VideoTextureSettings {
  29891. /**
  29892. * Applies `autoplay` to video, if specified
  29893. */
  29894. autoPlay?: boolean;
  29895. /**
  29896. * Applies `loop` to video, if specified
  29897. */
  29898. loop?: boolean;
  29899. /**
  29900. * Automatically updates internal texture from video at every frame in the render loop
  29901. */
  29902. autoUpdateTexture: boolean;
  29903. /**
  29904. * Image src displayed during the video loading or until the user interacts with the video.
  29905. */
  29906. poster?: string;
  29907. }
  29908. /**
  29909. * If you want to display a video in your scene, this is the special texture for that.
  29910. * This special texture works similar to other textures, with the exception of a few parameters.
  29911. * @see https://doc.babylonjs.com/how_to/video_texture
  29912. */
  29913. export class VideoTexture extends Texture {
  29914. /**
  29915. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29916. */
  29917. readonly autoUpdateTexture: boolean;
  29918. /**
  29919. * The video instance used by the texture internally
  29920. */
  29921. readonly video: HTMLVideoElement;
  29922. private _onUserActionRequestedObservable;
  29923. /**
  29924. * Event triggerd when a dom action is required by the user to play the video.
  29925. * This happens due to recent changes in browser policies preventing video to auto start.
  29926. */
  29927. readonly onUserActionRequestedObservable: Observable<Texture>;
  29928. private _generateMipMaps;
  29929. private _engine;
  29930. private _stillImageCaptured;
  29931. private _displayingPosterTexture;
  29932. private _settings;
  29933. private _createInternalTextureOnEvent;
  29934. private _frameId;
  29935. /**
  29936. * Creates a video texture.
  29937. * If you want to display a video in your scene, this is the special texture for that.
  29938. * This special texture works similar to other textures, with the exception of a few parameters.
  29939. * @see https://doc.babylonjs.com/how_to/video_texture
  29940. * @param name optional name, will detect from video source, if not defined
  29941. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29942. * @param scene is obviously the current scene.
  29943. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29944. * @param invertY is false by default but can be used to invert video on Y axis
  29945. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29946. * @param settings allows finer control over video usage
  29947. */
  29948. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29949. private _getName;
  29950. private _getVideo;
  29951. private _createInternalTexture;
  29952. private reset;
  29953. /**
  29954. * @hidden Internal method to initiate `update`.
  29955. */
  29956. _rebuild(): void;
  29957. /**
  29958. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29959. */
  29960. update(): void;
  29961. /**
  29962. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29963. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29964. */
  29965. updateTexture(isVisible: boolean): void;
  29966. protected _updateInternalTexture: () => void;
  29967. /**
  29968. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29969. * @param url New url.
  29970. */
  29971. updateURL(url: string): void;
  29972. /**
  29973. * Dispose the texture and release its associated resources.
  29974. */
  29975. dispose(): void;
  29976. /**
  29977. * Creates a video texture straight from a stream.
  29978. * @param scene Define the scene the texture should be created in
  29979. * @param stream Define the stream the texture should be created from
  29980. * @returns The created video texture as a promise
  29981. */
  29982. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29983. /**
  29984. * Creates a video texture straight from your WebCam video feed.
  29985. * @param scene Define the scene the texture should be created in
  29986. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29987. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29988. * @returns The created video texture as a promise
  29989. */
  29990. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29991. minWidth: number;
  29992. maxWidth: number;
  29993. minHeight: number;
  29994. maxHeight: number;
  29995. deviceId: string;
  29996. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29997. /**
  29998. * Creates a video texture straight from your WebCam video feed.
  29999. * @param scene Define the scene the texture should be created in
  30000. * @param onReady Define a callback to triggered once the texture will be ready
  30001. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30002. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30003. */
  30004. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30005. minWidth: number;
  30006. maxWidth: number;
  30007. minHeight: number;
  30008. maxHeight: number;
  30009. deviceId: string;
  30010. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30011. }
  30012. }
  30013. declare module "babylonjs/Engines/thinEngine" {
  30014. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30015. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  30016. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30017. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30018. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30019. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30020. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30021. import { Observable } from "babylonjs/Misc/observable";
  30022. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30023. import { StencilState } from "babylonjs/States/stencilState";
  30024. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30026. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30027. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30028. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30029. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30030. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30031. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30032. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30033. import { WebRequest } from "babylonjs/Misc/webRequest";
  30034. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  30035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30036. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30037. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30038. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30039. /**
  30040. * Defines the interface used by objects working like Scene
  30041. * @hidden
  30042. */
  30043. interface ISceneLike {
  30044. _addPendingData(data: any): void;
  30045. _removePendingData(data: any): void;
  30046. offlineProvider: IOfflineProvider;
  30047. }
  30048. /** Interface defining initialization parameters for Engine class */
  30049. export interface EngineOptions extends WebGLContextAttributes {
  30050. /**
  30051. * Defines if the engine should no exceed a specified device ratio
  30052. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30053. */
  30054. limitDeviceRatio?: number;
  30055. /**
  30056. * Defines if webvr should be enabled automatically
  30057. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30058. */
  30059. autoEnableWebVR?: boolean;
  30060. /**
  30061. * Defines if webgl2 should be turned off even if supported
  30062. * @see http://doc.babylonjs.com/features/webgl2
  30063. */
  30064. disableWebGL2Support?: boolean;
  30065. /**
  30066. * Defines if webaudio should be initialized as well
  30067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30068. */
  30069. audioEngine?: boolean;
  30070. /**
  30071. * Defines if animations should run using a deterministic lock step
  30072. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30073. */
  30074. deterministicLockstep?: boolean;
  30075. /** Defines the maximum steps to use with deterministic lock step mode */
  30076. lockstepMaxSteps?: number;
  30077. /**
  30078. * Defines that engine should ignore context lost events
  30079. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30080. */
  30081. doNotHandleContextLost?: boolean;
  30082. /**
  30083. * Defines that engine should ignore modifying touch action attribute and style
  30084. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30085. */
  30086. doNotHandleTouchAction?: boolean;
  30087. /**
  30088. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30089. */
  30090. useHighPrecisionFloats?: boolean;
  30091. }
  30092. /**
  30093. * The base engine class (root of all engines)
  30094. */
  30095. export class ThinEngine {
  30096. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30097. static ExceptionList: ({
  30098. key: string;
  30099. capture: string;
  30100. captureConstraint: number;
  30101. targets: string[];
  30102. } | {
  30103. key: string;
  30104. capture: null;
  30105. captureConstraint: null;
  30106. targets: string[];
  30107. })[];
  30108. /** @hidden */
  30109. static _TextureLoaders: IInternalTextureLoader[];
  30110. /**
  30111. * Returns the current npm package of the sdk
  30112. */
  30113. static readonly NpmPackage: string;
  30114. /**
  30115. * Returns the current version of the framework
  30116. */
  30117. static readonly Version: string;
  30118. /**
  30119. * Returns a string describing the current engine
  30120. */
  30121. readonly description: string;
  30122. /**
  30123. * Gets or sets the epsilon value used by collision engine
  30124. */
  30125. static CollisionsEpsilon: number;
  30126. /**
  30127. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30128. */
  30129. static ShadersRepository: string;
  30130. /** @hidden */
  30131. _shaderProcessor: IShaderProcessor;
  30132. /**
  30133. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30134. */
  30135. forcePOTTextures: boolean;
  30136. /**
  30137. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30138. */
  30139. isFullscreen: boolean;
  30140. /**
  30141. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30142. */
  30143. cullBackFaces: boolean;
  30144. /**
  30145. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30146. */
  30147. renderEvenInBackground: boolean;
  30148. /**
  30149. * Gets or sets a boolean indicating that cache can be kept between frames
  30150. */
  30151. preventCacheWipeBetweenFrames: boolean;
  30152. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30153. validateShaderPrograms: boolean;
  30154. /**
  30155. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30156. */
  30157. disableUniformBuffers: boolean;
  30158. /** @hidden */
  30159. _uniformBuffers: UniformBuffer[];
  30160. /**
  30161. * Gets a boolean indicating that the engine supports uniform buffers
  30162. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30163. */
  30164. readonly supportsUniformBuffers: boolean;
  30165. /** @hidden */
  30166. _gl: WebGLRenderingContext;
  30167. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30168. protected _windowIsBackground: boolean;
  30169. protected _webGLVersion: number;
  30170. protected _highPrecisionShadersAllowed: boolean;
  30171. /** @hidden */
  30172. readonly _shouldUseHighPrecisionShader: boolean;
  30173. /**
  30174. * Gets a boolean indicating that only power of 2 textures are supported
  30175. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30176. */
  30177. readonly needPOTTextures: boolean;
  30178. /** @hidden */
  30179. _badOS: boolean;
  30180. /** @hidden */
  30181. _badDesktopOS: boolean;
  30182. private _hardwareScalingLevel;
  30183. /** @hidden */
  30184. _caps: EngineCapabilities;
  30185. private _isStencilEnable;
  30186. protected _colorWrite: boolean;
  30187. /** @hidden */
  30188. _drawCalls: PerfCounter;
  30189. private _glVersion;
  30190. private _glRenderer;
  30191. private _glVendor;
  30192. /** @hidden */
  30193. _videoTextureSupported: boolean;
  30194. protected _renderingQueueLaunched: boolean;
  30195. protected _activeRenderLoops: (() => void)[];
  30196. /**
  30197. * Observable signaled when a context lost event is raised
  30198. */
  30199. onContextLostObservable: Observable<ThinEngine>;
  30200. /**
  30201. * Observable signaled when a context restored event is raised
  30202. */
  30203. onContextRestoredObservable: Observable<ThinEngine>;
  30204. private _onContextLost;
  30205. private _onContextRestored;
  30206. protected _contextWasLost: boolean;
  30207. /** @hidden */
  30208. _doNotHandleContextLost: boolean;
  30209. /**
  30210. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30212. */
  30213. doNotHandleContextLost: boolean;
  30214. /**
  30215. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30216. */
  30217. disableVertexArrayObjects: boolean;
  30218. /** @hidden */
  30219. protected _depthCullingState: DepthCullingState;
  30220. /** @hidden */
  30221. protected _stencilState: StencilState;
  30222. /** @hidden */
  30223. protected _alphaState: AlphaState;
  30224. /** @hidden */
  30225. _internalTexturesCache: InternalTexture[];
  30226. /** @hidden */
  30227. protected _activeChannel: number;
  30228. private _currentTextureChannel;
  30229. /** @hidden */
  30230. protected _boundTexturesCache: {
  30231. [key: string]: Nullable<InternalTexture>;
  30232. };
  30233. /** @hidden */
  30234. protected _currentEffect: Nullable<Effect>;
  30235. /** @hidden */
  30236. protected _currentProgram: Nullable<WebGLProgram>;
  30237. private _compiledEffects;
  30238. private _vertexAttribArraysEnabled;
  30239. /** @hidden */
  30240. protected _cachedViewport: Nullable<IViewportLike>;
  30241. private _cachedVertexArrayObject;
  30242. /** @hidden */
  30243. protected _cachedVertexBuffers: any;
  30244. /** @hidden */
  30245. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30246. /** @hidden */
  30247. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30248. /** @hidden */
  30249. _currentRenderTarget: Nullable<InternalTexture>;
  30250. private _uintIndicesCurrentlySet;
  30251. private _currentBoundBuffer;
  30252. /** @hidden */
  30253. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30254. private _currentBufferPointers;
  30255. private _currentInstanceLocations;
  30256. private _currentInstanceBuffers;
  30257. private _textureUnits;
  30258. /** @hidden */
  30259. _workingCanvas: Nullable<HTMLCanvasElement>;
  30260. /** @hidden */
  30261. _workingContext: Nullable<CanvasRenderingContext2D>;
  30262. /** @hidden */
  30263. _bindedRenderFunction: any;
  30264. private _vaoRecordInProgress;
  30265. private _mustWipeVertexAttributes;
  30266. private _emptyTexture;
  30267. private _emptyCubeTexture;
  30268. private _emptyTexture3D;
  30269. /** @hidden */
  30270. _frameHandler: number;
  30271. private _nextFreeTextureSlots;
  30272. private _maxSimultaneousTextures;
  30273. private _activeRequests;
  30274. protected _texturesSupported: string[];
  30275. /** @hidden */
  30276. _textureFormatInUse: Nullable<string>;
  30277. protected readonly _supportsHardwareTextureRescaling: boolean;
  30278. /**
  30279. * Gets the list of texture formats supported
  30280. */
  30281. readonly texturesSupported: Array<string>;
  30282. /**
  30283. * Gets the list of texture formats in use
  30284. */
  30285. readonly textureFormatInUse: Nullable<string>;
  30286. /**
  30287. * Gets the current viewport
  30288. */
  30289. readonly currentViewport: Nullable<IViewportLike>;
  30290. /**
  30291. * Gets the default empty texture
  30292. */
  30293. readonly emptyTexture: InternalTexture;
  30294. /**
  30295. * Gets the default empty 3D texture
  30296. */
  30297. readonly emptyTexture3D: InternalTexture;
  30298. /**
  30299. * Gets the default empty cube texture
  30300. */
  30301. readonly emptyCubeTexture: InternalTexture;
  30302. /**
  30303. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30304. */
  30305. readonly premultipliedAlpha: boolean;
  30306. /**
  30307. * Creates a new engine
  30308. * @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
  30309. * @param antialias defines enable antialiasing (default: false)
  30310. * @param options defines further options to be sent to the getContext() function
  30311. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30312. */
  30313. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30314. private _rebuildInternalTextures;
  30315. private _rebuildEffects;
  30316. /**
  30317. * Gets a boolean indicating if all created effects are ready
  30318. * @returns true if all effects are ready
  30319. */
  30320. areAllEffectsReady(): boolean;
  30321. protected _rebuildBuffers(): void;
  30322. private _initGLContext;
  30323. /**
  30324. * Gets version of the current webGL context
  30325. */
  30326. readonly webGLVersion: number;
  30327. /**
  30328. * Gets a string idenfifying the name of the class
  30329. * @returns "Engine" string
  30330. */
  30331. getClassName(): string;
  30332. /**
  30333. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30334. */
  30335. readonly isStencilEnable: boolean;
  30336. /** @hidden */
  30337. _prepareWorkingCanvas(): void;
  30338. /**
  30339. * Reset the texture cache to empty state
  30340. */
  30341. resetTextureCache(): void;
  30342. /**
  30343. * Gets an object containing information about the current webGL context
  30344. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30345. */
  30346. getGlInfo(): {
  30347. vendor: string;
  30348. renderer: string;
  30349. version: string;
  30350. };
  30351. /**
  30352. * Defines the hardware scaling level.
  30353. * By default the hardware scaling level is computed from the window device ratio.
  30354. * 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.
  30355. * @param level defines the level to use
  30356. */
  30357. setHardwareScalingLevel(level: number): void;
  30358. /**
  30359. * Gets the current hardware scaling level.
  30360. * By default the hardware scaling level is computed from the window device ratio.
  30361. * 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.
  30362. * @returns a number indicating the current hardware scaling level
  30363. */
  30364. getHardwareScalingLevel(): number;
  30365. /**
  30366. * Gets the list of loaded textures
  30367. * @returns an array containing all loaded textures
  30368. */
  30369. getLoadedTexturesCache(): InternalTexture[];
  30370. /**
  30371. * Gets the object containing all engine capabilities
  30372. * @returns the EngineCapabilities object
  30373. */
  30374. getCaps(): EngineCapabilities;
  30375. /**
  30376. * stop executing a render loop function and remove it from the execution array
  30377. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30378. */
  30379. stopRenderLoop(renderFunction?: () => void): void;
  30380. /** @hidden */
  30381. _renderLoop(): void;
  30382. /**
  30383. * Gets the HTML canvas attached with the current webGL context
  30384. * @returns a HTML canvas
  30385. */
  30386. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30387. /**
  30388. * Gets host window
  30389. * @returns the host window object
  30390. */
  30391. getHostWindow(): Window;
  30392. /**
  30393. * Gets the current render width
  30394. * @param useScreen defines if screen size must be used (or the current render target if any)
  30395. * @returns a number defining the current render width
  30396. */
  30397. getRenderWidth(useScreen?: boolean): number;
  30398. /**
  30399. * Gets the current render height
  30400. * @param useScreen defines if screen size must be used (or the current render target if any)
  30401. * @returns a number defining the current render height
  30402. */
  30403. getRenderHeight(useScreen?: boolean): number;
  30404. /**
  30405. * Can be used to override the current requestAnimationFrame requester.
  30406. * @hidden
  30407. */
  30408. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30409. /**
  30410. * Register and execute a render loop. The engine can have more than one render function
  30411. * @param renderFunction defines the function to continuously execute
  30412. */
  30413. runRenderLoop(renderFunction: () => void): void;
  30414. /**
  30415. * Clear the current render buffer or the current render target (if any is set up)
  30416. * @param color defines the color to use
  30417. * @param backBuffer defines if the back buffer must be cleared
  30418. * @param depth defines if the depth buffer must be cleared
  30419. * @param stencil defines if the stencil buffer must be cleared
  30420. */
  30421. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30422. private _viewportCached;
  30423. /** @hidden */
  30424. _viewport(x: number, y: number, width: number, height: number): void;
  30425. /**
  30426. * Set the WebGL's viewport
  30427. * @param viewport defines the viewport element to be used
  30428. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30429. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30430. */
  30431. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30432. /**
  30433. * Begin a new frame
  30434. */
  30435. beginFrame(): void;
  30436. /**
  30437. * Enf the current frame
  30438. */
  30439. endFrame(): void;
  30440. /**
  30441. * Resize the view according to the canvas' size
  30442. */
  30443. resize(): void;
  30444. /**
  30445. * Force a specific size of the canvas
  30446. * @param width defines the new canvas' width
  30447. * @param height defines the new canvas' height
  30448. */
  30449. setSize(width: number, height: number): void;
  30450. /**
  30451. * Binds the frame buffer to the specified texture.
  30452. * @param texture The texture to render to or null for the default canvas
  30453. * @param faceIndex The face of the texture to render to in case of cube texture
  30454. * @param requiredWidth The width of the target to render to
  30455. * @param requiredHeight The height of the target to render to
  30456. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30457. * @param depthStencilTexture The depth stencil texture to use to render
  30458. * @param lodLevel defines le lod level to bind to the frame buffer
  30459. */
  30460. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30461. /** @hidden */
  30462. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30463. /**
  30464. * Unbind the current render target texture from the webGL context
  30465. * @param texture defines the render target texture to unbind
  30466. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30467. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30468. */
  30469. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30470. /**
  30471. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30472. */
  30473. flushFramebuffer(): void;
  30474. /**
  30475. * Unbind the current render target and bind the default framebuffer
  30476. */
  30477. restoreDefaultFramebuffer(): void;
  30478. private _resetVertexBufferBinding;
  30479. /**
  30480. * Creates a vertex buffer
  30481. * @param data the data for the vertex buffer
  30482. * @returns the new WebGL static buffer
  30483. */
  30484. createVertexBuffer(data: DataArray): DataBuffer;
  30485. private _createVertexBuffer;
  30486. /**
  30487. * Creates a dynamic vertex buffer
  30488. * @param data the data for the dynamic vertex buffer
  30489. * @returns the new WebGL dynamic buffer
  30490. */
  30491. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30492. /**
  30493. * Update a dynamic index buffer
  30494. * @param indexBuffer defines the target index buffer
  30495. * @param indices defines the data to update
  30496. * @param offset defines the offset in the target index buffer where update should start
  30497. */
  30498. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30499. /**
  30500. * Updates a dynamic vertex buffer.
  30501. * @param vertexBuffer the vertex buffer to update
  30502. * @param data the data used to update the vertex buffer
  30503. * @param byteOffset the byte offset of the data
  30504. * @param byteLength the byte length of the data
  30505. */
  30506. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30507. private _resetIndexBufferBinding;
  30508. /**
  30509. * Creates a new index buffer
  30510. * @param indices defines the content of the index buffer
  30511. * @param updatable defines if the index buffer must be updatable
  30512. * @returns a new webGL buffer
  30513. */
  30514. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30515. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30516. /**
  30517. * Bind a webGL buffer to the webGL context
  30518. * @param buffer defines the buffer to bind
  30519. */
  30520. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30521. private bindIndexBuffer;
  30522. private bindBuffer;
  30523. /**
  30524. * update the bound buffer with the given data
  30525. * @param data defines the data to update
  30526. */
  30527. updateArrayBuffer(data: Float32Array): void;
  30528. private _vertexAttribPointer;
  30529. private _bindIndexBufferWithCache;
  30530. private _bindVertexBuffersAttributes;
  30531. /**
  30532. * Records a vertex array object
  30533. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30534. * @param vertexBuffers defines the list of vertex buffers to store
  30535. * @param indexBuffer defines the index buffer to store
  30536. * @param effect defines the effect to store
  30537. * @returns the new vertex array object
  30538. */
  30539. recordVertexArrayObject(vertexBuffers: {
  30540. [key: string]: VertexBuffer;
  30541. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30542. /**
  30543. * Bind a specific vertex array object
  30544. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30545. * @param vertexArrayObject defines the vertex array object to bind
  30546. * @param indexBuffer defines the index buffer to bind
  30547. */
  30548. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30549. /**
  30550. * Bind webGl buffers directly to the webGL context
  30551. * @param vertexBuffer defines the vertex buffer to bind
  30552. * @param indexBuffer defines the index buffer to bind
  30553. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30554. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30555. * @param effect defines the effect associated with the vertex buffer
  30556. */
  30557. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30558. private _unbindVertexArrayObject;
  30559. /**
  30560. * Bind a list of vertex buffers to the webGL context
  30561. * @param vertexBuffers defines the list of vertex buffers to bind
  30562. * @param indexBuffer defines the index buffer to bind
  30563. * @param effect defines the effect associated with the vertex buffers
  30564. */
  30565. bindBuffers(vertexBuffers: {
  30566. [key: string]: Nullable<VertexBuffer>;
  30567. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30568. /**
  30569. * Unbind all instance attributes
  30570. */
  30571. unbindInstanceAttributes(): void;
  30572. /**
  30573. * Release and free the memory of a vertex array object
  30574. * @param vao defines the vertex array object to delete
  30575. */
  30576. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30577. /** @hidden */
  30578. _releaseBuffer(buffer: DataBuffer): boolean;
  30579. protected _deleteBuffer(buffer: DataBuffer): void;
  30580. /**
  30581. * Creates a webGL buffer to use with instanciation
  30582. * @param capacity defines the size of the buffer
  30583. * @returns the webGL buffer
  30584. */
  30585. createInstancesBuffer(capacity: number): DataBuffer;
  30586. /**
  30587. * Delete a webGL buffer used with instanciation
  30588. * @param buffer defines the webGL buffer to delete
  30589. */
  30590. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30591. /**
  30592. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30593. * @param instancesBuffer defines the webGL buffer to update and bind
  30594. * @param data defines the data to store in the buffer
  30595. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30596. */
  30597. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30598. /**
  30599. * Apply all cached states (depth, culling, stencil and alpha)
  30600. */
  30601. applyStates(): void;
  30602. /**
  30603. * Send a draw order
  30604. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30605. * @param indexStart defines the starting index
  30606. * @param indexCount defines the number of index to draw
  30607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30608. */
  30609. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30610. /**
  30611. * Draw a list of points
  30612. * @param verticesStart defines the index of first vertex to draw
  30613. * @param verticesCount defines the count of vertices to draw
  30614. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30615. */
  30616. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30617. /**
  30618. * Draw a list of unindexed primitives
  30619. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30620. * @param verticesStart defines the index of first vertex to draw
  30621. * @param verticesCount defines the count of vertices to draw
  30622. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30623. */
  30624. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30625. /**
  30626. * Draw a list of indexed primitives
  30627. * @param fillMode defines the primitive to use
  30628. * @param indexStart defines the starting index
  30629. * @param indexCount defines the number of index to draw
  30630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30631. */
  30632. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30633. /**
  30634. * Draw a list of unindexed primitives
  30635. * @param fillMode defines the primitive to use
  30636. * @param verticesStart defines the index of first vertex to draw
  30637. * @param verticesCount defines the count of vertices to draw
  30638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30639. */
  30640. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30641. private _drawMode;
  30642. /** @hidden */
  30643. _releaseEffect(effect: Effect): void;
  30644. /** @hidden */
  30645. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30646. /**
  30647. * Create a new effect (used to store vertex/fragment shaders)
  30648. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30649. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30650. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30651. * @param samplers defines an array of string used to represent textures
  30652. * @param defines defines the string containing the defines to use to compile the shaders
  30653. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30654. * @param onCompiled defines a function to call when the effect creation is successful
  30655. * @param onError defines a function to call when the effect creation has failed
  30656. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30657. * @returns the new Effect
  30658. */
  30659. 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;
  30660. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30661. private _compileShader;
  30662. private _compileRawShader;
  30663. /**
  30664. * Directly creates a webGL program
  30665. * @param pipelineContext defines the pipeline context to attach to
  30666. * @param vertexCode defines the vertex shader code to use
  30667. * @param fragmentCode defines the fragment shader code to use
  30668. * @param context defines the webGL context to use (if not set, the current one will be used)
  30669. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30670. * @returns the new webGL program
  30671. */
  30672. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30673. /**
  30674. * Creates a webGL program
  30675. * @param pipelineContext defines the pipeline context to attach to
  30676. * @param vertexCode defines the vertex shader code to use
  30677. * @param fragmentCode defines the fragment shader code to use
  30678. * @param defines defines the string containing the defines to use to compile the shaders
  30679. * @param context defines the webGL context to use (if not set, the current one will be used)
  30680. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30681. * @returns the new webGL program
  30682. */
  30683. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30684. /**
  30685. * Creates a new pipeline context
  30686. * @returns the new pipeline
  30687. */
  30688. createPipelineContext(): IPipelineContext;
  30689. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30690. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30691. /** @hidden */
  30692. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30693. /** @hidden */
  30694. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30695. /** @hidden */
  30696. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30697. /**
  30698. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30699. * @param pipelineContext defines the pipeline context to use
  30700. * @param uniformsNames defines the list of uniform names
  30701. * @returns an array of webGL uniform locations
  30702. */
  30703. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30704. /**
  30705. * Gets the lsit of active attributes for a given webGL program
  30706. * @param pipelineContext defines the pipeline context to use
  30707. * @param attributesNames defines the list of attribute names to get
  30708. * @returns an array of indices indicating the offset of each attribute
  30709. */
  30710. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30711. /**
  30712. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30713. * @param effect defines the effect to activate
  30714. */
  30715. enableEffect(effect: Nullable<Effect>): void;
  30716. /**
  30717. * Set the value of an uniform to an array of int32
  30718. * @param uniform defines the webGL uniform location where to store the value
  30719. * @param array defines the array of int32 to store
  30720. */
  30721. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30722. /**
  30723. * Set the value of an uniform to an array of int32 (stored as vec2)
  30724. * @param uniform defines the webGL uniform location where to store the value
  30725. * @param array defines the array of int32 to store
  30726. */
  30727. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30728. /**
  30729. * Set the value of an uniform to an array of int32 (stored as vec3)
  30730. * @param uniform defines the webGL uniform location where to store the value
  30731. * @param array defines the array of int32 to store
  30732. */
  30733. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30734. /**
  30735. * Set the value of an uniform to an array of int32 (stored as vec4)
  30736. * @param uniform defines the webGL uniform location where to store the value
  30737. * @param array defines the array of int32 to store
  30738. */
  30739. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30740. /**
  30741. * Set the value of an uniform to an array of float32
  30742. * @param uniform defines the webGL uniform location where to store the value
  30743. * @param array defines the array of float32 to store
  30744. */
  30745. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30746. /**
  30747. * Set the value of an uniform to an array of float32 (stored as vec2)
  30748. * @param uniform defines the webGL uniform location where to store the value
  30749. * @param array defines the array of float32 to store
  30750. */
  30751. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30752. /**
  30753. * Set the value of an uniform to an array of float32 (stored as vec3)
  30754. * @param uniform defines the webGL uniform location where to store the value
  30755. * @param array defines the array of float32 to store
  30756. */
  30757. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30758. /**
  30759. * Set the value of an uniform to an array of float32 (stored as vec4)
  30760. * @param uniform defines the webGL uniform location where to store the value
  30761. * @param array defines the array of float32 to store
  30762. */
  30763. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30764. /**
  30765. * Set the value of an uniform to an array of number
  30766. * @param uniform defines the webGL uniform location where to store the value
  30767. * @param array defines the array of number to store
  30768. */
  30769. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30770. /**
  30771. * Set the value of an uniform to an array of number (stored as vec2)
  30772. * @param uniform defines the webGL uniform location where to store the value
  30773. * @param array defines the array of number to store
  30774. */
  30775. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30776. /**
  30777. * Set the value of an uniform to an array of number (stored as vec3)
  30778. * @param uniform defines the webGL uniform location where to store the value
  30779. * @param array defines the array of number to store
  30780. */
  30781. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30782. /**
  30783. * Set the value of an uniform to an array of number (stored as vec4)
  30784. * @param uniform defines the webGL uniform location where to store the value
  30785. * @param array defines the array of number to store
  30786. */
  30787. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30788. /**
  30789. * Set the value of an uniform to an array of float32 (stored as matrices)
  30790. * @param uniform defines the webGL uniform location where to store the value
  30791. * @param matrices defines the array of float32 to store
  30792. */
  30793. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30794. /**
  30795. * Set the value of an uniform to a matrix (3x3)
  30796. * @param uniform defines the webGL uniform location where to store the value
  30797. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30798. */
  30799. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30800. /**
  30801. * Set the value of an uniform to a matrix (2x2)
  30802. * @param uniform defines the webGL uniform location where to store the value
  30803. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30804. */
  30805. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30806. /**
  30807. * Set the value of an uniform to a number (int)
  30808. * @param uniform defines the webGL uniform location where to store the value
  30809. * @param value defines the int number to store
  30810. */
  30811. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30812. /**
  30813. * Set the value of an uniform to a number (float)
  30814. * @param uniform defines the webGL uniform location where to store the value
  30815. * @param value defines the float number to store
  30816. */
  30817. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30818. /**
  30819. * Set the value of an uniform to a vec2
  30820. * @param uniform defines the webGL uniform location where to store the value
  30821. * @param x defines the 1st component of the value
  30822. * @param y defines the 2nd component of the value
  30823. */
  30824. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30825. /**
  30826. * Set the value of an uniform to a vec3
  30827. * @param uniform defines the webGL uniform location where to store the value
  30828. * @param x defines the 1st component of the value
  30829. * @param y defines the 2nd component of the value
  30830. * @param z defines the 3rd component of the value
  30831. */
  30832. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30833. /**
  30834. * Set the value of an uniform to a boolean
  30835. * @param uniform defines the webGL uniform location where to store the value
  30836. * @param bool defines the boolean to store
  30837. */
  30838. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30839. /**
  30840. * Set the value of an uniform to a vec4
  30841. * @param uniform defines the webGL uniform location where to store the value
  30842. * @param x defines the 1st component of the value
  30843. * @param y defines the 2nd component of the value
  30844. * @param z defines the 3rd component of the value
  30845. * @param w defines the 4th component of the value
  30846. */
  30847. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30848. /**
  30849. * Sets a Color4 on a uniform variable
  30850. * @param uniform defines the uniform location
  30851. * @param color4 defines the value to be set
  30852. */
  30853. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30854. /**
  30855. * Gets the depth culling state manager
  30856. */
  30857. readonly depthCullingState: DepthCullingState;
  30858. /**
  30859. * Gets the alpha state manager
  30860. */
  30861. readonly alphaState: AlphaState;
  30862. /**
  30863. * Gets the stencil state manager
  30864. */
  30865. readonly stencilState: StencilState;
  30866. /**
  30867. * Clears the list of texture accessible through engine.
  30868. * This can help preventing texture load conflict due to name collision.
  30869. */
  30870. clearInternalTexturesCache(): void;
  30871. /**
  30872. * Force the entire cache to be cleared
  30873. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30874. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30875. */
  30876. wipeCaches(bruteForce?: boolean): void;
  30877. /** @hidden */
  30878. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30879. min: number;
  30880. mag: number;
  30881. };
  30882. /** @hidden */
  30883. _createTexture(): WebGLTexture;
  30884. /**
  30885. * Usually called from Texture.ts.
  30886. * Passed information to create a WebGLTexture
  30887. * @param urlArg defines a value which contains one of the following:
  30888. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30889. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30890. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30891. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30892. * @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)
  30893. * @param scene needed for loading to the correct scene
  30894. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30895. * @param onLoad optional callback to be called upon successful completion
  30896. * @param onError optional callback to be called upon failure
  30897. * @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
  30898. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30899. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30900. * @param forcedExtension defines the extension to use to pick the right loader
  30901. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30902. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30903. */
  30904. 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;
  30905. /**
  30906. * @hidden
  30907. */
  30908. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30909. /**
  30910. * Creates a raw texture
  30911. * @param data defines the data to store in the texture
  30912. * @param width defines the width of the texture
  30913. * @param height defines the height of the texture
  30914. * @param format defines the format of the data
  30915. * @param generateMipMaps defines if the engine should generate the mip levels
  30916. * @param invertY defines if data must be stored with Y axis inverted
  30917. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30918. * @param compression defines the compression used (null by default)
  30919. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30920. * @returns the raw texture inside an InternalTexture
  30921. */
  30922. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30923. /**
  30924. * Creates a new raw cube texture
  30925. * @param data defines the array of data to use to create each face
  30926. * @param size defines the size of the textures
  30927. * @param format defines the format of the data
  30928. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30929. * @param generateMipMaps defines if the engine should generate the mip levels
  30930. * @param invertY defines if data must be stored with Y axis inverted
  30931. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30932. * @param compression defines the compression used (null by default)
  30933. * @returns the cube texture as an InternalTexture
  30934. */
  30935. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30936. /**
  30937. * Creates a new raw 3D texture
  30938. * @param data defines the data used to create the texture
  30939. * @param width defines the width of the texture
  30940. * @param height defines the height of the texture
  30941. * @param depth defines the depth of the texture
  30942. * @param format defines the format of the texture
  30943. * @param generateMipMaps defines if the engine must generate mip levels
  30944. * @param invertY defines if data must be stored with Y axis inverted
  30945. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30946. * @param compression defines the compressed used (can be null)
  30947. * @param textureType defines the compressed used (can be null)
  30948. * @returns a new raw 3D texture (stored in an InternalTexture)
  30949. */
  30950. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30951. private _unpackFlipYCached;
  30952. /**
  30953. * In case you are sharing the context with other applications, it might
  30954. * be interested to not cache the unpack flip y state to ensure a consistent
  30955. * value would be set.
  30956. */
  30957. enableUnpackFlipYCached: boolean;
  30958. /** @hidden */
  30959. _unpackFlipY(value: boolean): void;
  30960. /** @hidden */
  30961. _getUnpackAlignement(): number;
  30962. /**
  30963. * Update the sampling mode of a given texture
  30964. * @param samplingMode defines the required sampling mode
  30965. * @param texture defines the texture to update
  30966. */
  30967. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30968. /**
  30969. * Updates a depth texture Comparison Mode and Function.
  30970. * If the comparison Function is equal to 0, the mode will be set to none.
  30971. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30972. * @param texture The texture to set the comparison function for
  30973. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30974. */
  30975. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30976. /** @hidden */
  30977. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30978. width: number;
  30979. height: number;
  30980. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30981. /**
  30982. * Creates a depth stencil texture.
  30983. * This is only available in WebGL 2 or with the depth texture extension available.
  30984. * @param size The size of face edge in the texture.
  30985. * @param options The options defining the texture.
  30986. * @returns The texture
  30987. */
  30988. createDepthStencilTexture(size: number | {
  30989. width: number;
  30990. height: number;
  30991. }, options: DepthTextureCreationOptions): InternalTexture;
  30992. /**
  30993. * Creates a depth stencil texture.
  30994. * This is only available in WebGL 2 or with the depth texture extension available.
  30995. * @param size The size of face edge in the texture.
  30996. * @param options The options defining the texture.
  30997. * @returns The texture
  30998. */
  30999. private _createDepthStencilTexture;
  31000. /**
  31001. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31002. * @param renderTarget The render target to set the frame buffer for
  31003. */
  31004. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31005. /** @hidden */
  31006. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31007. /** @hidden */
  31008. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31009. /** @hidden */
  31010. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31011. /** @hidden */
  31012. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31013. /** @hidden */
  31014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31015. /**
  31016. * @hidden
  31017. */
  31018. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31019. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31020. private _prepareWebGLTexture;
  31021. /** @hidden */
  31022. _releaseFramebufferObjects(texture: InternalTexture): void;
  31023. /** @hidden */
  31024. _releaseTexture(texture: InternalTexture): void;
  31025. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31026. protected _setProgram(program: WebGLProgram): void;
  31027. protected _boundUniforms: {
  31028. [key: number]: WebGLUniformLocation;
  31029. };
  31030. /**
  31031. * Binds an effect to the webGL context
  31032. * @param effect defines the effect to bind
  31033. */
  31034. bindSamplers(effect: Effect): void;
  31035. private _activateCurrentTexture;
  31036. /** @hidden */
  31037. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31038. /** @hidden */
  31039. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31040. /**
  31041. * Unbind all textures from the webGL context
  31042. */
  31043. unbindAllTextures(): void;
  31044. /**
  31045. * Sets a texture to the according uniform.
  31046. * @param channel The texture channel
  31047. * @param uniform The uniform to set
  31048. * @param texture The texture to apply
  31049. */
  31050. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31051. private _bindSamplerUniformToChannel;
  31052. private _getTextureWrapMode;
  31053. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31054. /**
  31055. * Sets an array of texture to the webGL context
  31056. * @param channel defines the channel where the texture array must be set
  31057. * @param uniform defines the associated uniform location
  31058. * @param textures defines the array of textures to bind
  31059. */
  31060. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31061. /** @hidden */
  31062. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31063. private _setTextureParameterFloat;
  31064. private _setTextureParameterInteger;
  31065. /**
  31066. * Unbind all vertex attributes from the webGL context
  31067. */
  31068. unbindAllAttributes(): void;
  31069. /**
  31070. * 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
  31071. */
  31072. releaseEffects(): void;
  31073. /**
  31074. * Dispose and release all associated resources
  31075. */
  31076. dispose(): void;
  31077. /**
  31078. * Attach a new callback raised when context lost event is fired
  31079. * @param callback defines the callback to call
  31080. */
  31081. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31082. /**
  31083. * Attach a new callback raised when context restored event is fired
  31084. * @param callback defines the callback to call
  31085. */
  31086. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31087. /**
  31088. * Get the current error code of the webGL context
  31089. * @returns the error code
  31090. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31091. */
  31092. getError(): number;
  31093. private _canRenderToFloatFramebuffer;
  31094. private _canRenderToHalfFloatFramebuffer;
  31095. private _canRenderToFramebuffer;
  31096. /** @hidden */
  31097. _getWebGLTextureType(type: number): number;
  31098. /** @hidden */
  31099. _getInternalFormat(format: number): number;
  31100. /** @hidden */
  31101. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31102. /** @hidden */
  31103. _getRGBAMultiSampleBufferFormat(type: number): number;
  31104. /** @hidden */
  31105. _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;
  31106. /**
  31107. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31108. * @returns true if the engine can be created
  31109. * @ignorenaming
  31110. */
  31111. static isSupported(): boolean;
  31112. /**
  31113. * Find the next highest power of two.
  31114. * @param x Number to start search from.
  31115. * @return Next highest power of two.
  31116. */
  31117. static CeilingPOT(x: number): number;
  31118. /**
  31119. * Find the next lowest power of two.
  31120. * @param x Number to start search from.
  31121. * @return Next lowest power of two.
  31122. */
  31123. static FloorPOT(x: number): number;
  31124. /**
  31125. * Find the nearest power of two.
  31126. * @param x Number to start search from.
  31127. * @return Next nearest power of two.
  31128. */
  31129. static NearestPOT(x: number): number;
  31130. /**
  31131. * Get the closest exponent of two
  31132. * @param value defines the value to approximate
  31133. * @param max defines the maximum value to return
  31134. * @param mode defines how to define the closest value
  31135. * @returns closest exponent of two of the given value
  31136. */
  31137. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31138. /**
  31139. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31140. * @param func - the function to be called
  31141. * @param requester - the object that will request the next frame. Falls back to window.
  31142. * @returns frame number
  31143. */
  31144. static QueueNewFrame(func: () => void, requester?: any): number;
  31145. }
  31146. }
  31147. declare module "babylonjs/Materials/Textures/internalTexture" {
  31148. import { Observable } from "babylonjs/Misc/observable";
  31149. import { Nullable, int } from "babylonjs/types";
  31150. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31151. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31153. /**
  31154. * Class used to store data associated with WebGL texture data for the engine
  31155. * This class should not be used directly
  31156. */
  31157. export class InternalTexture {
  31158. /** @hidden */
  31159. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31160. /**
  31161. * The source of the texture data is unknown
  31162. */
  31163. static DATASOURCE_UNKNOWN: number;
  31164. /**
  31165. * Texture data comes from an URL
  31166. */
  31167. static DATASOURCE_URL: number;
  31168. /**
  31169. * Texture data is only used for temporary storage
  31170. */
  31171. static DATASOURCE_TEMP: number;
  31172. /**
  31173. * Texture data comes from raw data (ArrayBuffer)
  31174. */
  31175. static DATASOURCE_RAW: number;
  31176. /**
  31177. * Texture content is dynamic (video or dynamic texture)
  31178. */
  31179. static DATASOURCE_DYNAMIC: number;
  31180. /**
  31181. * Texture content is generated by rendering to it
  31182. */
  31183. static DATASOURCE_RENDERTARGET: number;
  31184. /**
  31185. * Texture content is part of a multi render target process
  31186. */
  31187. static DATASOURCE_MULTIRENDERTARGET: number;
  31188. /**
  31189. * Texture data comes from a cube data file
  31190. */
  31191. static DATASOURCE_CUBE: number;
  31192. /**
  31193. * Texture data comes from a raw cube data
  31194. */
  31195. static DATASOURCE_CUBERAW: number;
  31196. /**
  31197. * Texture data come from a prefiltered cube data file
  31198. */
  31199. static DATASOURCE_CUBEPREFILTERED: number;
  31200. /**
  31201. * Texture content is raw 3D data
  31202. */
  31203. static DATASOURCE_RAW3D: number;
  31204. /**
  31205. * Texture content is a depth texture
  31206. */
  31207. static DATASOURCE_DEPTHTEXTURE: number;
  31208. /**
  31209. * Texture data comes from a raw cube data encoded with RGBD
  31210. */
  31211. static DATASOURCE_CUBERAW_RGBD: number;
  31212. /**
  31213. * Defines if the texture is ready
  31214. */
  31215. isReady: boolean;
  31216. /**
  31217. * Defines if the texture is a cube texture
  31218. */
  31219. isCube: boolean;
  31220. /**
  31221. * Defines if the texture contains 3D data
  31222. */
  31223. is3D: boolean;
  31224. /**
  31225. * Defines if the texture contains multiview data
  31226. */
  31227. isMultiview: boolean;
  31228. /**
  31229. * Gets the URL used to load this texture
  31230. */
  31231. url: string;
  31232. /**
  31233. * Gets the sampling mode of the texture
  31234. */
  31235. samplingMode: number;
  31236. /**
  31237. * Gets a boolean indicating if the texture needs mipmaps generation
  31238. */
  31239. generateMipMaps: boolean;
  31240. /**
  31241. * Gets the number of samples used by the texture (WebGL2+ only)
  31242. */
  31243. samples: number;
  31244. /**
  31245. * Gets the type of the texture (int, float...)
  31246. */
  31247. type: number;
  31248. /**
  31249. * Gets the format of the texture (RGB, RGBA...)
  31250. */
  31251. format: number;
  31252. /**
  31253. * Observable called when the texture is loaded
  31254. */
  31255. onLoadedObservable: Observable<InternalTexture>;
  31256. /**
  31257. * Gets the width of the texture
  31258. */
  31259. width: number;
  31260. /**
  31261. * Gets the height of the texture
  31262. */
  31263. height: number;
  31264. /**
  31265. * Gets the depth of the texture
  31266. */
  31267. depth: number;
  31268. /**
  31269. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31270. */
  31271. baseWidth: number;
  31272. /**
  31273. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31274. */
  31275. baseHeight: number;
  31276. /**
  31277. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31278. */
  31279. baseDepth: number;
  31280. /**
  31281. * Gets a boolean indicating if the texture is inverted on Y axis
  31282. */
  31283. invertY: boolean;
  31284. /** @hidden */
  31285. _invertVScale: boolean;
  31286. /** @hidden */
  31287. _associatedChannel: number;
  31288. /** @hidden */
  31289. _dataSource: number;
  31290. /** @hidden */
  31291. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31292. /** @hidden */
  31293. _bufferView: Nullable<ArrayBufferView>;
  31294. /** @hidden */
  31295. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31296. /** @hidden */
  31297. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31298. /** @hidden */
  31299. _size: number;
  31300. /** @hidden */
  31301. _extension: string;
  31302. /** @hidden */
  31303. _files: Nullable<string[]>;
  31304. /** @hidden */
  31305. _workingCanvas: Nullable<HTMLCanvasElement>;
  31306. /** @hidden */
  31307. _workingContext: Nullable<CanvasRenderingContext2D>;
  31308. /** @hidden */
  31309. _framebuffer: Nullable<WebGLFramebuffer>;
  31310. /** @hidden */
  31311. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31312. /** @hidden */
  31313. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31314. /** @hidden */
  31315. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31316. /** @hidden */
  31317. _attachments: Nullable<number[]>;
  31318. /** @hidden */
  31319. _cachedCoordinatesMode: Nullable<number>;
  31320. /** @hidden */
  31321. _cachedWrapU: Nullable<number>;
  31322. /** @hidden */
  31323. _cachedWrapV: Nullable<number>;
  31324. /** @hidden */
  31325. _cachedWrapR: Nullable<number>;
  31326. /** @hidden */
  31327. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31328. /** @hidden */
  31329. _isDisabled: boolean;
  31330. /** @hidden */
  31331. _compression: Nullable<string>;
  31332. /** @hidden */
  31333. _generateStencilBuffer: boolean;
  31334. /** @hidden */
  31335. _generateDepthBuffer: boolean;
  31336. /** @hidden */
  31337. _comparisonFunction: number;
  31338. /** @hidden */
  31339. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31340. /** @hidden */
  31341. _lodGenerationScale: number;
  31342. /** @hidden */
  31343. _lodGenerationOffset: number;
  31344. /** @hidden */
  31345. _colorTextureArray: Nullable<WebGLTexture>;
  31346. /** @hidden */
  31347. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31348. /** @hidden */
  31349. _lodTextureHigh: Nullable<BaseTexture>;
  31350. /** @hidden */
  31351. _lodTextureMid: Nullable<BaseTexture>;
  31352. /** @hidden */
  31353. _lodTextureLow: Nullable<BaseTexture>;
  31354. /** @hidden */
  31355. _isRGBD: boolean;
  31356. /** @hidden */
  31357. _linearSpecularLOD: boolean;
  31358. /** @hidden */
  31359. _irradianceTexture: Nullable<BaseTexture>;
  31360. /** @hidden */
  31361. _webGLTexture: Nullable<WebGLTexture>;
  31362. /** @hidden */
  31363. _references: number;
  31364. private _engine;
  31365. /**
  31366. * Gets the Engine the texture belongs to.
  31367. * @returns The babylon engine
  31368. */
  31369. getEngine(): ThinEngine;
  31370. /**
  31371. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  31372. */
  31373. readonly dataSource: number;
  31374. /**
  31375. * Creates a new InternalTexture
  31376. * @param engine defines the engine to use
  31377. * @param dataSource defines the type of data that will be used
  31378. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31379. */
  31380. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  31381. /**
  31382. * Increments the number of references (ie. the number of Texture that point to it)
  31383. */
  31384. incrementReferences(): void;
  31385. /**
  31386. * Change the size of the texture (not the size of the content)
  31387. * @param width defines the new width
  31388. * @param height defines the new height
  31389. * @param depth defines the new depth (1 by default)
  31390. */
  31391. updateSize(width: int, height: int, depth?: int): void;
  31392. /** @hidden */
  31393. _rebuild(): void;
  31394. /** @hidden */
  31395. _swapAndDie(target: InternalTexture): void;
  31396. /**
  31397. * Dispose the current allocated resources
  31398. */
  31399. dispose(): void;
  31400. }
  31401. }
  31402. declare module "babylonjs/Audio/analyser" {
  31403. import { Scene } from "babylonjs/scene";
  31404. /**
  31405. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31407. */
  31408. export class Analyser {
  31409. /**
  31410. * Gets or sets the smoothing
  31411. * @ignorenaming
  31412. */
  31413. SMOOTHING: number;
  31414. /**
  31415. * Gets or sets the FFT table size
  31416. * @ignorenaming
  31417. */
  31418. FFT_SIZE: number;
  31419. /**
  31420. * Gets or sets the bar graph amplitude
  31421. * @ignorenaming
  31422. */
  31423. BARGRAPHAMPLITUDE: number;
  31424. /**
  31425. * Gets or sets the position of the debug canvas
  31426. * @ignorenaming
  31427. */
  31428. DEBUGCANVASPOS: {
  31429. x: number;
  31430. y: number;
  31431. };
  31432. /**
  31433. * Gets or sets the debug canvas size
  31434. * @ignorenaming
  31435. */
  31436. DEBUGCANVASSIZE: {
  31437. width: number;
  31438. height: number;
  31439. };
  31440. private _byteFreqs;
  31441. private _byteTime;
  31442. private _floatFreqs;
  31443. private _webAudioAnalyser;
  31444. private _debugCanvas;
  31445. private _debugCanvasContext;
  31446. private _scene;
  31447. private _registerFunc;
  31448. private _audioEngine;
  31449. /**
  31450. * Creates a new analyser
  31451. * @param scene defines hosting scene
  31452. */
  31453. constructor(scene: Scene);
  31454. /**
  31455. * Get the number of data values you will have to play with for the visualization
  31456. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31457. * @returns a number
  31458. */
  31459. getFrequencyBinCount(): number;
  31460. /**
  31461. * Gets the current frequency data as a byte array
  31462. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31463. * @returns a Uint8Array
  31464. */
  31465. getByteFrequencyData(): Uint8Array;
  31466. /**
  31467. * Gets the current waveform as a byte array
  31468. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31469. * @returns a Uint8Array
  31470. */
  31471. getByteTimeDomainData(): Uint8Array;
  31472. /**
  31473. * Gets the current frequency data as a float array
  31474. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31475. * @returns a Float32Array
  31476. */
  31477. getFloatFrequencyData(): Float32Array;
  31478. /**
  31479. * Renders the debug canvas
  31480. */
  31481. drawDebugCanvas(): void;
  31482. /**
  31483. * Stops rendering the debug canvas and removes it
  31484. */
  31485. stopDebugCanvas(): void;
  31486. /**
  31487. * Connects two audio nodes
  31488. * @param inputAudioNode defines first node to connect
  31489. * @param outputAudioNode defines second node to connect
  31490. */
  31491. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31492. /**
  31493. * Releases all associated resources
  31494. */
  31495. dispose(): void;
  31496. }
  31497. }
  31498. declare module "babylonjs/Audio/audioEngine" {
  31499. import { IDisposable } from "babylonjs/scene";
  31500. import { Analyser } from "babylonjs/Audio/analyser";
  31501. import { Nullable } from "babylonjs/types";
  31502. import { Observable } from "babylonjs/Misc/observable";
  31503. /**
  31504. * This represents an audio engine and it is responsible
  31505. * to play, synchronize and analyse sounds throughout the application.
  31506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31507. */
  31508. export interface IAudioEngine extends IDisposable {
  31509. /**
  31510. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31511. */
  31512. readonly canUseWebAudio: boolean;
  31513. /**
  31514. * Gets the current AudioContext if available.
  31515. */
  31516. readonly audioContext: Nullable<AudioContext>;
  31517. /**
  31518. * The master gain node defines the global audio volume of your audio engine.
  31519. */
  31520. readonly masterGain: GainNode;
  31521. /**
  31522. * Gets whether or not mp3 are supported by your browser.
  31523. */
  31524. readonly isMP3supported: boolean;
  31525. /**
  31526. * Gets whether or not ogg are supported by your browser.
  31527. */
  31528. readonly isOGGsupported: boolean;
  31529. /**
  31530. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31531. * @ignoreNaming
  31532. */
  31533. WarnedWebAudioUnsupported: boolean;
  31534. /**
  31535. * Defines if the audio engine relies on a custom unlocked button.
  31536. * In this case, the embedded button will not be displayed.
  31537. */
  31538. useCustomUnlockedButton: boolean;
  31539. /**
  31540. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31541. */
  31542. readonly unlocked: boolean;
  31543. /**
  31544. * Event raised when audio has been unlocked on the browser.
  31545. */
  31546. onAudioUnlockedObservable: Observable<AudioEngine>;
  31547. /**
  31548. * Event raised when audio has been locked on the browser.
  31549. */
  31550. onAudioLockedObservable: Observable<AudioEngine>;
  31551. /**
  31552. * Flags the audio engine in Locked state.
  31553. * This happens due to new browser policies preventing audio to autoplay.
  31554. */
  31555. lock(): void;
  31556. /**
  31557. * Unlocks the audio engine once a user action has been done on the dom.
  31558. * This is helpful to resume play once browser policies have been satisfied.
  31559. */
  31560. unlock(): void;
  31561. }
  31562. /**
  31563. * This represents the default audio engine used in babylon.
  31564. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31566. */
  31567. export class AudioEngine implements IAudioEngine {
  31568. private _audioContext;
  31569. private _audioContextInitialized;
  31570. private _muteButton;
  31571. private _hostElement;
  31572. /**
  31573. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31574. */
  31575. canUseWebAudio: boolean;
  31576. /**
  31577. * The master gain node defines the global audio volume of your audio engine.
  31578. */
  31579. masterGain: GainNode;
  31580. /**
  31581. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31582. * @ignoreNaming
  31583. */
  31584. WarnedWebAudioUnsupported: boolean;
  31585. /**
  31586. * Gets whether or not mp3 are supported by your browser.
  31587. */
  31588. isMP3supported: boolean;
  31589. /**
  31590. * Gets whether or not ogg are supported by your browser.
  31591. */
  31592. isOGGsupported: boolean;
  31593. /**
  31594. * Gets whether audio has been unlocked on the device.
  31595. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31596. * a user interaction has happened.
  31597. */
  31598. unlocked: boolean;
  31599. /**
  31600. * Defines if the audio engine relies on a custom unlocked button.
  31601. * In this case, the embedded button will not be displayed.
  31602. */
  31603. useCustomUnlockedButton: boolean;
  31604. /**
  31605. * Event raised when audio has been unlocked on the browser.
  31606. */
  31607. onAudioUnlockedObservable: Observable<AudioEngine>;
  31608. /**
  31609. * Event raised when audio has been locked on the browser.
  31610. */
  31611. onAudioLockedObservable: Observable<AudioEngine>;
  31612. /**
  31613. * Gets the current AudioContext if available.
  31614. */
  31615. readonly audioContext: Nullable<AudioContext>;
  31616. private _connectedAnalyser;
  31617. /**
  31618. * Instantiates a new audio engine.
  31619. *
  31620. * There should be only one per page as some browsers restrict the number
  31621. * of audio contexts you can create.
  31622. * @param hostElement defines the host element where to display the mute icon if necessary
  31623. */
  31624. constructor(hostElement?: Nullable<HTMLElement>);
  31625. /**
  31626. * Flags the audio engine in Locked state.
  31627. * This happens due to new browser policies preventing audio to autoplay.
  31628. */
  31629. lock(): void;
  31630. /**
  31631. * Unlocks the audio engine once a user action has been done on the dom.
  31632. * This is helpful to resume play once browser policies have been satisfied.
  31633. */
  31634. unlock(): void;
  31635. private _resumeAudioContext;
  31636. private _initializeAudioContext;
  31637. private _tryToRun;
  31638. private _triggerRunningState;
  31639. private _triggerSuspendedState;
  31640. private _displayMuteButton;
  31641. private _moveButtonToTopLeft;
  31642. private _onResize;
  31643. private _hideMuteButton;
  31644. /**
  31645. * Destroy and release the resources associated with the audio ccontext.
  31646. */
  31647. dispose(): void;
  31648. /**
  31649. * Gets the global volume sets on the master gain.
  31650. * @returns the global volume if set or -1 otherwise
  31651. */
  31652. getGlobalVolume(): number;
  31653. /**
  31654. * Sets the global volume of your experience (sets on the master gain).
  31655. * @param newVolume Defines the new global volume of the application
  31656. */
  31657. setGlobalVolume(newVolume: number): void;
  31658. /**
  31659. * Connect the audio engine to an audio analyser allowing some amazing
  31660. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31662. * @param analyser The analyser to connect to the engine
  31663. */
  31664. connectToAnalyser(analyser: Analyser): void;
  31665. }
  31666. }
  31667. declare module "babylonjs/Loading/loadingScreen" {
  31668. /**
  31669. * Interface used to present a loading screen while loading a scene
  31670. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31671. */
  31672. export interface ILoadingScreen {
  31673. /**
  31674. * Function called to display the loading screen
  31675. */
  31676. displayLoadingUI: () => void;
  31677. /**
  31678. * Function called to hide the loading screen
  31679. */
  31680. hideLoadingUI: () => void;
  31681. /**
  31682. * Gets or sets the color to use for the background
  31683. */
  31684. loadingUIBackgroundColor: string;
  31685. /**
  31686. * Gets or sets the text to display while loading
  31687. */
  31688. loadingUIText: string;
  31689. }
  31690. /**
  31691. * Class used for the default loading screen
  31692. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31693. */
  31694. export class DefaultLoadingScreen implements ILoadingScreen {
  31695. private _renderingCanvas;
  31696. private _loadingText;
  31697. private _loadingDivBackgroundColor;
  31698. private _loadingDiv;
  31699. private _loadingTextDiv;
  31700. /** Gets or sets the logo url to use for the default loading screen */
  31701. static DefaultLogoUrl: string;
  31702. /** Gets or sets the spinner url to use for the default loading screen */
  31703. static DefaultSpinnerUrl: string;
  31704. /**
  31705. * Creates a new default loading screen
  31706. * @param _renderingCanvas defines the canvas used to render the scene
  31707. * @param _loadingText defines the default text to display
  31708. * @param _loadingDivBackgroundColor defines the default background color
  31709. */
  31710. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31711. /**
  31712. * Function called to display the loading screen
  31713. */
  31714. displayLoadingUI(): void;
  31715. /**
  31716. * Function called to hide the loading screen
  31717. */
  31718. hideLoadingUI(): void;
  31719. /**
  31720. * Gets or sets the text to display while loading
  31721. */
  31722. loadingUIText: string;
  31723. /**
  31724. * Gets or sets the color to use for the background
  31725. */
  31726. loadingUIBackgroundColor: string;
  31727. private _resizeLoadingUI;
  31728. }
  31729. }
  31730. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31731. /**
  31732. * Interface for any object that can request an animation frame
  31733. */
  31734. export interface ICustomAnimationFrameRequester {
  31735. /**
  31736. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31737. */
  31738. renderFunction?: Function;
  31739. /**
  31740. * Called to request the next frame to render to
  31741. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31742. */
  31743. requestAnimationFrame: Function;
  31744. /**
  31745. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31746. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31747. */
  31748. requestID?: number;
  31749. }
  31750. }
  31751. declare module "babylonjs/Misc/performanceMonitor" {
  31752. /**
  31753. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31754. */
  31755. export class PerformanceMonitor {
  31756. private _enabled;
  31757. private _rollingFrameTime;
  31758. private _lastFrameTimeMs;
  31759. /**
  31760. * constructor
  31761. * @param frameSampleSize The number of samples required to saturate the sliding window
  31762. */
  31763. constructor(frameSampleSize?: number);
  31764. /**
  31765. * Samples current frame
  31766. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31767. */
  31768. sampleFrame(timeMs?: number): void;
  31769. /**
  31770. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31771. */
  31772. readonly averageFrameTime: number;
  31773. /**
  31774. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31775. */
  31776. readonly averageFrameTimeVariance: number;
  31777. /**
  31778. * Returns the frame time of the most recent frame
  31779. */
  31780. readonly instantaneousFrameTime: number;
  31781. /**
  31782. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31783. */
  31784. readonly averageFPS: number;
  31785. /**
  31786. * Returns the average framerate in frames per second using the most recent frame time
  31787. */
  31788. readonly instantaneousFPS: number;
  31789. /**
  31790. * Returns true if enough samples have been taken to completely fill the sliding window
  31791. */
  31792. readonly isSaturated: boolean;
  31793. /**
  31794. * Enables contributions to the sliding window sample set
  31795. */
  31796. enable(): void;
  31797. /**
  31798. * Disables contributions to the sliding window sample set
  31799. * Samples will not be interpolated over the disabled period
  31800. */
  31801. disable(): void;
  31802. /**
  31803. * Returns true if sampling is enabled
  31804. */
  31805. readonly isEnabled: boolean;
  31806. /**
  31807. * Resets performance monitor
  31808. */
  31809. reset(): void;
  31810. }
  31811. /**
  31812. * RollingAverage
  31813. *
  31814. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31815. */
  31816. export class RollingAverage {
  31817. /**
  31818. * Current average
  31819. */
  31820. average: number;
  31821. /**
  31822. * Current variance
  31823. */
  31824. variance: number;
  31825. protected _samples: Array<number>;
  31826. protected _sampleCount: number;
  31827. protected _pos: number;
  31828. protected _m2: number;
  31829. /**
  31830. * constructor
  31831. * @param length The number of samples required to saturate the sliding window
  31832. */
  31833. constructor(length: number);
  31834. /**
  31835. * Adds a sample to the sample set
  31836. * @param v The sample value
  31837. */
  31838. add(v: number): void;
  31839. /**
  31840. * Returns previously added values or null if outside of history or outside the sliding window domain
  31841. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31842. * @return Value previously recorded with add() or null if outside of range
  31843. */
  31844. history(i: number): number;
  31845. /**
  31846. * Returns true if enough samples have been taken to completely fill the sliding window
  31847. * @return true if sample-set saturated
  31848. */
  31849. isSaturated(): boolean;
  31850. /**
  31851. * Resets the rolling average (equivalent to 0 samples taken so far)
  31852. */
  31853. reset(): void;
  31854. /**
  31855. * Wraps a value around the sample range boundaries
  31856. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31857. * @return Wrapped position in sample range
  31858. */
  31859. protected _wrapPosition(i: number): number;
  31860. }
  31861. }
  31862. declare module "babylonjs/Engines/engine" {
  31863. import { Observable } from "babylonjs/Misc/observable";
  31864. import { Nullable } from "babylonjs/types";
  31865. import { Scene } from "babylonjs/scene";
  31866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31867. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31868. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31869. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31870. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31871. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31872. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31873. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31874. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31875. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  31876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31877. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31878. import { Material } from "babylonjs/Materials/material";
  31879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31880. /**
  31881. * Defines the interface used by display changed events
  31882. */
  31883. export interface IDisplayChangedEventArgs {
  31884. /** Gets the vrDisplay object (if any) */
  31885. vrDisplay: Nullable<any>;
  31886. /** Gets a boolean indicating if webVR is supported */
  31887. vrSupported: boolean;
  31888. }
  31889. /**
  31890. * Defines the interface used by objects containing a viewport (like a camera)
  31891. */
  31892. interface IViewportOwnerLike {
  31893. /**
  31894. * Gets or sets the viewport
  31895. */
  31896. viewport: IViewportLike;
  31897. }
  31898. /**
  31899. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31900. */
  31901. export class Engine extends ThinEngine {
  31902. /** Defines that alpha blending is disabled */
  31903. static readonly ALPHA_DISABLE: number;
  31904. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31905. static readonly ALPHA_ADD: number;
  31906. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31907. static readonly ALPHA_COMBINE: number;
  31908. /** Defines that alpha blending to DEST - SRC * DEST */
  31909. static readonly ALPHA_SUBTRACT: number;
  31910. /** Defines that alpha blending to SRC * DEST */
  31911. static readonly ALPHA_MULTIPLY: number;
  31912. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31913. static readonly ALPHA_MAXIMIZED: number;
  31914. /** Defines that alpha blending to SRC + DEST */
  31915. static readonly ALPHA_ONEONE: number;
  31916. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31917. static readonly ALPHA_PREMULTIPLIED: number;
  31918. /**
  31919. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31920. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31921. */
  31922. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31923. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31924. static readonly ALPHA_INTERPOLATE: number;
  31925. /**
  31926. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31927. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31928. */
  31929. static readonly ALPHA_SCREENMODE: number;
  31930. /** Defines that the ressource is not delayed*/
  31931. static readonly DELAYLOADSTATE_NONE: number;
  31932. /** Defines that the ressource was successfully delay loaded */
  31933. static readonly DELAYLOADSTATE_LOADED: number;
  31934. /** Defines that the ressource is currently delay loading */
  31935. static readonly DELAYLOADSTATE_LOADING: number;
  31936. /** Defines that the ressource is delayed and has not started loading */
  31937. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31939. static readonly NEVER: number;
  31940. /** 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 */
  31941. static readonly ALWAYS: number;
  31942. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31943. static readonly LESS: number;
  31944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31945. static readonly EQUAL: number;
  31946. /** 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 */
  31947. static readonly LEQUAL: number;
  31948. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31949. static readonly GREATER: number;
  31950. /** 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 */
  31951. static readonly GEQUAL: number;
  31952. /** 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 */
  31953. static readonly NOTEQUAL: number;
  31954. /** Passed to stencilOperation to specify that stencil value must be kept */
  31955. static readonly KEEP: number;
  31956. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31957. static readonly REPLACE: number;
  31958. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31959. static readonly INCR: number;
  31960. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31961. static readonly DECR: number;
  31962. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31963. static readonly INVERT: number;
  31964. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31965. static readonly INCR_WRAP: number;
  31966. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31967. static readonly DECR_WRAP: number;
  31968. /** Texture is not repeating outside of 0..1 UVs */
  31969. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31970. /** Texture is repeating outside of 0..1 UVs */
  31971. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31972. /** Texture is repeating and mirrored */
  31973. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31974. /** ALPHA */
  31975. static readonly TEXTUREFORMAT_ALPHA: number;
  31976. /** LUMINANCE */
  31977. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31978. /** LUMINANCE_ALPHA */
  31979. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31980. /** RGB */
  31981. static readonly TEXTUREFORMAT_RGB: number;
  31982. /** RGBA */
  31983. static readonly TEXTUREFORMAT_RGBA: number;
  31984. /** RED */
  31985. static readonly TEXTUREFORMAT_RED: number;
  31986. /** RED (2nd reference) */
  31987. static readonly TEXTUREFORMAT_R: number;
  31988. /** RG */
  31989. static readonly TEXTUREFORMAT_RG: number;
  31990. /** RED_INTEGER */
  31991. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31992. /** RED_INTEGER (2nd reference) */
  31993. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31994. /** RG_INTEGER */
  31995. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31996. /** RGB_INTEGER */
  31997. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31998. /** RGBA_INTEGER */
  31999. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32000. /** UNSIGNED_BYTE */
  32001. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32002. /** UNSIGNED_BYTE (2nd reference) */
  32003. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32004. /** FLOAT */
  32005. static readonly TEXTURETYPE_FLOAT: number;
  32006. /** HALF_FLOAT */
  32007. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32008. /** BYTE */
  32009. static readonly TEXTURETYPE_BYTE: number;
  32010. /** SHORT */
  32011. static readonly TEXTURETYPE_SHORT: number;
  32012. /** UNSIGNED_SHORT */
  32013. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32014. /** INT */
  32015. static readonly TEXTURETYPE_INT: number;
  32016. /** UNSIGNED_INT */
  32017. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32018. /** UNSIGNED_SHORT_4_4_4_4 */
  32019. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32020. /** UNSIGNED_SHORT_5_5_5_1 */
  32021. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32022. /** UNSIGNED_SHORT_5_6_5 */
  32023. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32024. /** UNSIGNED_INT_2_10_10_10_REV */
  32025. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32026. /** UNSIGNED_INT_24_8 */
  32027. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32028. /** UNSIGNED_INT_10F_11F_11F_REV */
  32029. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32030. /** UNSIGNED_INT_5_9_9_9_REV */
  32031. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32032. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32033. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32034. /** nearest is mag = nearest and min = nearest and mip = linear */
  32035. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32036. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32037. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32038. /** Trilinear is mag = linear and min = linear and mip = linear */
  32039. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32040. /** nearest is mag = nearest and min = nearest and mip = linear */
  32041. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32042. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32043. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32044. /** Trilinear is mag = linear and min = linear and mip = linear */
  32045. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32046. /** mag = nearest and min = nearest and mip = nearest */
  32047. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32048. /** mag = nearest and min = linear and mip = nearest */
  32049. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32050. /** mag = nearest and min = linear and mip = linear */
  32051. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32052. /** mag = nearest and min = linear and mip = none */
  32053. static readonly TEXTURE_NEAREST_LINEAR: number;
  32054. /** mag = nearest and min = nearest and mip = none */
  32055. static readonly TEXTURE_NEAREST_NEAREST: number;
  32056. /** mag = linear and min = nearest and mip = nearest */
  32057. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32058. /** mag = linear and min = nearest and mip = linear */
  32059. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32060. /** mag = linear and min = linear and mip = none */
  32061. static readonly TEXTURE_LINEAR_LINEAR: number;
  32062. /** mag = linear and min = nearest and mip = none */
  32063. static readonly TEXTURE_LINEAR_NEAREST: number;
  32064. /** Explicit coordinates mode */
  32065. static readonly TEXTURE_EXPLICIT_MODE: number;
  32066. /** Spherical coordinates mode */
  32067. static readonly TEXTURE_SPHERICAL_MODE: number;
  32068. /** Planar coordinates mode */
  32069. static readonly TEXTURE_PLANAR_MODE: number;
  32070. /** Cubic coordinates mode */
  32071. static readonly TEXTURE_CUBIC_MODE: number;
  32072. /** Projection coordinates mode */
  32073. static readonly TEXTURE_PROJECTION_MODE: number;
  32074. /** Skybox coordinates mode */
  32075. static readonly TEXTURE_SKYBOX_MODE: number;
  32076. /** Inverse Cubic coordinates mode */
  32077. static readonly TEXTURE_INVCUBIC_MODE: number;
  32078. /** Equirectangular coordinates mode */
  32079. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32080. /** Equirectangular Fixed coordinates mode */
  32081. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32082. /** Equirectangular Fixed Mirrored coordinates mode */
  32083. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32084. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32085. static readonly SCALEMODE_FLOOR: number;
  32086. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32087. static readonly SCALEMODE_NEAREST: number;
  32088. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32089. static readonly SCALEMODE_CEILING: number;
  32090. /**
  32091. * Returns the current npm package of the sdk
  32092. */
  32093. static readonly NpmPackage: string;
  32094. /**
  32095. * Returns the current version of the framework
  32096. */
  32097. static readonly Version: string;
  32098. /** Gets the list of created engines */
  32099. static readonly Instances: Engine[];
  32100. /**
  32101. * Gets the latest created engine
  32102. */
  32103. static readonly LastCreatedEngine: Nullable<Engine>;
  32104. /**
  32105. * Gets the latest created scene
  32106. */
  32107. static readonly LastCreatedScene: Nullable<Scene>;
  32108. /**
  32109. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32110. * @param flag defines which part of the materials must be marked as dirty
  32111. * @param predicate defines a predicate used to filter which materials should be affected
  32112. */
  32113. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32114. /**
  32115. * Method called to create the default loading screen.
  32116. * This can be overriden in your own app.
  32117. * @param canvas The rendering canvas element
  32118. * @returns The loading screen
  32119. */
  32120. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32121. /**
  32122. * Method called to create the default rescale post process on each engine.
  32123. */
  32124. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32125. /**
  32126. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32127. **/
  32128. enableOfflineSupport: boolean;
  32129. /**
  32130. * 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)
  32131. **/
  32132. disableManifestCheck: boolean;
  32133. /**
  32134. * Gets the list of created scenes
  32135. */
  32136. scenes: Scene[];
  32137. /**
  32138. * Event raised when a new scene is created
  32139. */
  32140. onNewSceneAddedObservable: Observable<Scene>;
  32141. /**
  32142. * Gets the list of created postprocesses
  32143. */
  32144. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32145. /**
  32146. * Gets a boolean indicating if the pointer is currently locked
  32147. */
  32148. isPointerLock: boolean;
  32149. /**
  32150. * Observable event triggered each time the rendering canvas is resized
  32151. */
  32152. onResizeObservable: Observable<Engine>;
  32153. /**
  32154. * Observable event triggered each time the canvas loses focus
  32155. */
  32156. onCanvasBlurObservable: Observable<Engine>;
  32157. /**
  32158. * Observable event triggered each time the canvas gains focus
  32159. */
  32160. onCanvasFocusObservable: Observable<Engine>;
  32161. /**
  32162. * Observable event triggered each time the canvas receives pointerout event
  32163. */
  32164. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32165. /**
  32166. * Observable event triggered before each texture is initialized
  32167. */
  32168. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32169. /**
  32170. * Observable raised when the engine begins a new frame
  32171. */
  32172. onBeginFrameObservable: Observable<Engine>;
  32173. /**
  32174. * If set, will be used to request the next animation frame for the render loop
  32175. */
  32176. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32177. /**
  32178. * Observable raised when the engine ends the current frame
  32179. */
  32180. onEndFrameObservable: Observable<Engine>;
  32181. /**
  32182. * Observable raised when the engine is about to compile a shader
  32183. */
  32184. onBeforeShaderCompilationObservable: Observable<Engine>;
  32185. /**
  32186. * Observable raised when the engine has jsut compiled a shader
  32187. */
  32188. onAfterShaderCompilationObservable: Observable<Engine>;
  32189. /**
  32190. * Gets the audio engine
  32191. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32192. * @ignorenaming
  32193. */
  32194. static audioEngine: IAudioEngine;
  32195. /**
  32196. * Default AudioEngine factory responsible of creating the Audio Engine.
  32197. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32198. */
  32199. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32200. /**
  32201. * Default offline support factory responsible of creating a tool used to store data locally.
  32202. * By default, this will create a Database object if the workload has been embedded.
  32203. */
  32204. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32205. private _loadingScreen;
  32206. private _pointerLockRequested;
  32207. private _dummyFramebuffer;
  32208. private _rescalePostProcess;
  32209. /** @hidden */
  32210. protected _alphaMode: number;
  32211. /** @hidden */
  32212. protected _alphaEquation: number;
  32213. private _deterministicLockstep;
  32214. private _lockstepMaxSteps;
  32215. protected readonly _supportsHardwareTextureRescaling: boolean;
  32216. private _fps;
  32217. private _deltaTime;
  32218. /**
  32219. * Turn this value on if you want to pause FPS computation when in background
  32220. */
  32221. disablePerformanceMonitorInBackground: boolean;
  32222. private _performanceMonitor;
  32223. /**
  32224. * Gets the performance monitor attached to this engine
  32225. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32226. */
  32227. readonly performanceMonitor: PerformanceMonitor;
  32228. private _onFocus;
  32229. private _onBlur;
  32230. private _onCanvasPointerOut;
  32231. private _onCanvasBlur;
  32232. private _onCanvasFocus;
  32233. private _onFullscreenChange;
  32234. private _onPointerLockChange;
  32235. /**
  32236. * Creates a new engine
  32237. * @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
  32238. * @param antialias defines enable antialiasing (default: false)
  32239. * @param options defines further options to be sent to the getContext() function
  32240. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32241. */
  32242. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32243. /**
  32244. * Gets current aspect ratio
  32245. * @param viewportOwner defines the camera to use to get the aspect ratio
  32246. * @param useScreen defines if screen size must be used (or the current render target if any)
  32247. * @returns a number defining the aspect ratio
  32248. */
  32249. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32250. /**
  32251. * Gets current screen aspect ratio
  32252. * @returns a number defining the aspect ratio
  32253. */
  32254. getScreenAspectRatio(): number;
  32255. /**
  32256. * Gets host document
  32257. * @returns the host document object
  32258. */
  32259. getHostDocument(): Document;
  32260. /**
  32261. * Gets the client rect of the HTML canvas attached with the current webGL context
  32262. * @returns a client rectanglee
  32263. */
  32264. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32265. /**
  32266. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32267. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32268. * @returns true if engine is in deterministic lock step mode
  32269. */
  32270. isDeterministicLockStep(): boolean;
  32271. /**
  32272. * Gets the max steps when engine is running in deterministic lock step
  32273. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32274. * @returns the max steps
  32275. */
  32276. getLockstepMaxSteps(): number;
  32277. /**
  32278. * Force the mipmap generation for the given render target texture
  32279. * @param texture defines the render target texture to use
  32280. */
  32281. generateMipMapsForCubemap(texture: InternalTexture): void;
  32282. /** States */
  32283. /**
  32284. * Set various states to the webGL context
  32285. * @param culling defines backface culling state
  32286. * @param zOffset defines the value to apply to zOffset (0 by default)
  32287. * @param force defines if states must be applied even if cache is up to date
  32288. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32289. */
  32290. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32291. /**
  32292. * Set the z offset to apply to current rendering
  32293. * @param value defines the offset to apply
  32294. */
  32295. setZOffset(value: number): void;
  32296. /**
  32297. * Gets the current value of the zOffset
  32298. * @returns the current zOffset state
  32299. */
  32300. getZOffset(): number;
  32301. /**
  32302. * Enable or disable depth buffering
  32303. * @param enable defines the state to set
  32304. */
  32305. setDepthBuffer(enable: boolean): void;
  32306. /**
  32307. * Gets a boolean indicating if depth writing is enabled
  32308. * @returns the current depth writing state
  32309. */
  32310. getDepthWrite(): boolean;
  32311. /**
  32312. * Enable or disable depth writing
  32313. * @param enable defines the state to set
  32314. */
  32315. setDepthWrite(enable: boolean): void;
  32316. /**
  32317. * Enable or disable color writing
  32318. * @param enable defines the state to set
  32319. */
  32320. setColorWrite(enable: boolean): void;
  32321. /**
  32322. * Gets a boolean indicating if color writing is enabled
  32323. * @returns the current color writing state
  32324. */
  32325. getColorWrite(): boolean;
  32326. /**
  32327. * Sets alpha constants used by some alpha blending modes
  32328. * @param r defines the red component
  32329. * @param g defines the green component
  32330. * @param b defines the blue component
  32331. * @param a defines the alpha component
  32332. */
  32333. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32334. /**
  32335. * Sets the current alpha mode
  32336. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32337. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32338. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32339. */
  32340. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32341. /**
  32342. * Gets the current alpha mode
  32343. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32344. * @returns the current alpha mode
  32345. */
  32346. getAlphaMode(): number;
  32347. /**
  32348. * Sets the current alpha equation
  32349. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32350. */
  32351. setAlphaEquation(equation: number): void;
  32352. /**
  32353. * Gets the current alpha equation.
  32354. * @returns the current alpha equation
  32355. */
  32356. getAlphaEquation(): number;
  32357. /**
  32358. * Gets a boolean indicating if stencil buffer is enabled
  32359. * @returns the current stencil buffer state
  32360. */
  32361. getStencilBuffer(): boolean;
  32362. /**
  32363. * Enable or disable the stencil buffer
  32364. * @param enable defines if the stencil buffer must be enabled or disabled
  32365. */
  32366. setStencilBuffer(enable: boolean): void;
  32367. /**
  32368. * Gets the current stencil mask
  32369. * @returns a number defining the new stencil mask to use
  32370. */
  32371. getStencilMask(): number;
  32372. /**
  32373. * Sets the current stencil mask
  32374. * @param mask defines the new stencil mask to use
  32375. */
  32376. setStencilMask(mask: number): void;
  32377. /**
  32378. * Gets the current stencil function
  32379. * @returns a number defining the stencil function to use
  32380. */
  32381. getStencilFunction(): number;
  32382. /**
  32383. * Gets the current stencil reference value
  32384. * @returns a number defining the stencil reference value to use
  32385. */
  32386. getStencilFunctionReference(): number;
  32387. /**
  32388. * Gets the current stencil mask
  32389. * @returns a number defining the stencil mask to use
  32390. */
  32391. getStencilFunctionMask(): number;
  32392. /**
  32393. * Sets the current stencil function
  32394. * @param stencilFunc defines the new stencil function to use
  32395. */
  32396. setStencilFunction(stencilFunc: number): void;
  32397. /**
  32398. * Sets the current stencil reference
  32399. * @param reference defines the new stencil reference to use
  32400. */
  32401. setStencilFunctionReference(reference: number): void;
  32402. /**
  32403. * Sets the current stencil mask
  32404. * @param mask defines the new stencil mask to use
  32405. */
  32406. setStencilFunctionMask(mask: number): void;
  32407. /**
  32408. * Gets the current stencil operation when stencil fails
  32409. * @returns a number defining stencil operation to use when stencil fails
  32410. */
  32411. getStencilOperationFail(): number;
  32412. /**
  32413. * Gets the current stencil operation when depth fails
  32414. * @returns a number defining stencil operation to use when depth fails
  32415. */
  32416. getStencilOperationDepthFail(): number;
  32417. /**
  32418. * Gets the current stencil operation when stencil passes
  32419. * @returns a number defining stencil operation to use when stencil passes
  32420. */
  32421. getStencilOperationPass(): number;
  32422. /**
  32423. * Sets the stencil operation to use when stencil fails
  32424. * @param operation defines the stencil operation to use when stencil fails
  32425. */
  32426. setStencilOperationFail(operation: number): void;
  32427. /**
  32428. * Sets the stencil operation to use when depth fails
  32429. * @param operation defines the stencil operation to use when depth fails
  32430. */
  32431. setStencilOperationDepthFail(operation: number): void;
  32432. /**
  32433. * Sets the stencil operation to use when stencil passes
  32434. * @param operation defines the stencil operation to use when stencil passes
  32435. */
  32436. setStencilOperationPass(operation: number): void;
  32437. /**
  32438. * Sets a boolean indicating if the dithering state is enabled or disabled
  32439. * @param value defines the dithering state
  32440. */
  32441. setDitheringState(value: boolean): void;
  32442. /**
  32443. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32444. * @param value defines the rasterizer state
  32445. */
  32446. setRasterizerState(value: boolean): void;
  32447. /**
  32448. * Gets the current depth function
  32449. * @returns a number defining the depth function
  32450. */
  32451. getDepthFunction(): Nullable<number>;
  32452. /**
  32453. * Sets the current depth function
  32454. * @param depthFunc defines the function to use
  32455. */
  32456. setDepthFunction(depthFunc: number): void;
  32457. /**
  32458. * Sets the current depth function to GREATER
  32459. */
  32460. setDepthFunctionToGreater(): void;
  32461. /**
  32462. * Sets the current depth function to GEQUAL
  32463. */
  32464. setDepthFunctionToGreaterOrEqual(): void;
  32465. /**
  32466. * Sets the current depth function to LESS
  32467. */
  32468. setDepthFunctionToLess(): void;
  32469. /**
  32470. * Sets the current depth function to LEQUAL
  32471. */
  32472. setDepthFunctionToLessOrEqual(): void;
  32473. private _cachedStencilBuffer;
  32474. private _cachedStencilFunction;
  32475. private _cachedStencilMask;
  32476. private _cachedStencilOperationPass;
  32477. private _cachedStencilOperationFail;
  32478. private _cachedStencilOperationDepthFail;
  32479. private _cachedStencilReference;
  32480. /**
  32481. * Caches the the state of the stencil buffer
  32482. */
  32483. cacheStencilState(): void;
  32484. /**
  32485. * Restores the state of the stencil buffer
  32486. */
  32487. restoreStencilState(): void;
  32488. /**
  32489. * Directly set the WebGL Viewport
  32490. * @param x defines the x coordinate of the viewport (in screen space)
  32491. * @param y defines the y coordinate of the viewport (in screen space)
  32492. * @param width defines the width of the viewport (in screen space)
  32493. * @param height defines the height of the viewport (in screen space)
  32494. * @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
  32495. */
  32496. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32497. /**
  32498. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32499. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32500. * @param y defines the y-coordinate of the corner of the clear rectangle
  32501. * @param width defines the width of the clear rectangle
  32502. * @param height defines the height of the clear rectangle
  32503. * @param clearColor defines the clear color
  32504. */
  32505. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32506. /**
  32507. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32508. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32509. * @param y defines the y-coordinate of the corner of the clear rectangle
  32510. * @param width defines the width of the clear rectangle
  32511. * @param height defines the height of the clear rectangle
  32512. */
  32513. enableScissor(x: number, y: number, width: number, height: number): void;
  32514. /**
  32515. * Disable previously set scissor test rectangle
  32516. */
  32517. disableScissor(): void;
  32518. /**
  32519. * Initializes a webVR display and starts listening to display change events
  32520. * The onVRDisplayChangedObservable will be notified upon these changes
  32521. * @returns The onVRDisplayChangedObservable
  32522. */
  32523. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32524. /** @hidden */
  32525. _prepareVRComponent(): void;
  32526. /** @hidden */
  32527. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32528. /** @hidden */
  32529. _submitVRFrame(): void;
  32530. /**
  32531. * Call this function to leave webVR mode
  32532. * Will do nothing if webVR is not supported or if there is no webVR device
  32533. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32534. */
  32535. disableVR(): void;
  32536. /**
  32537. * Gets a boolean indicating that the system is in VR mode and is presenting
  32538. * @returns true if VR mode is engaged
  32539. */
  32540. isVRPresenting(): boolean;
  32541. /** @hidden */
  32542. _requestVRFrame(): void;
  32543. /** @hidden */
  32544. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32545. /**
  32546. * Gets the source code of the vertex shader associated with a specific webGL program
  32547. * @param program defines the program to use
  32548. * @returns a string containing the source code of the vertex shader associated with the program
  32549. */
  32550. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32551. /**
  32552. * Gets the source code of the fragment shader associated with a specific webGL program
  32553. * @param program defines the program to use
  32554. * @returns a string containing the source code of the fragment shader associated with the program
  32555. */
  32556. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32557. /**
  32558. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32559. * @param x defines the x coordinate of the rectangle where pixels must be read
  32560. * @param y defines the y coordinate of the rectangle where pixels must be read
  32561. * @param width defines the width of the rectangle where pixels must be read
  32562. * @param height defines the height of the rectangle where pixels must be read
  32563. * @returns a Uint8Array containing RGBA colors
  32564. */
  32565. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32566. /**
  32567. * Sets a depth stencil texture from a render target to the according uniform.
  32568. * @param channel The texture channel
  32569. * @param uniform The uniform to set
  32570. * @param texture The render target texture containing the depth stencil texture to apply
  32571. */
  32572. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32573. /**
  32574. * Sets a texture to the webGL context from a postprocess
  32575. * @param channel defines the channel to use
  32576. * @param postProcess defines the source postprocess
  32577. */
  32578. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32579. /**
  32580. * Binds the output of the passed in post process to the texture channel specified
  32581. * @param channel The channel the texture should be bound to
  32582. * @param postProcess The post process which's output should be bound
  32583. */
  32584. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32585. /** @hidden */
  32586. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32587. protected _rebuildBuffers(): void;
  32588. _renderLoop(): void;
  32589. /**
  32590. * Toggle full screen mode
  32591. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32592. */
  32593. switchFullscreen(requestPointerLock: boolean): void;
  32594. /**
  32595. * Enters full screen mode
  32596. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32597. */
  32598. enterFullscreen(requestPointerLock: boolean): void;
  32599. /**
  32600. * Exits full screen mode
  32601. */
  32602. exitFullscreen(): void;
  32603. /**
  32604. * Enters Pointerlock mode
  32605. */
  32606. enterPointerlock(): void;
  32607. /**
  32608. * Exits Pointerlock mode
  32609. */
  32610. exitPointerlock(): void;
  32611. /**
  32612. * Begin a new frame
  32613. */
  32614. beginFrame(): void;
  32615. /**
  32616. * Enf the current frame
  32617. */
  32618. endFrame(): void;
  32619. resize(): void;
  32620. /**
  32621. * Set the compressed texture format to use, based on the formats you have, and the formats
  32622. * supported by the hardware / browser.
  32623. *
  32624. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32625. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32626. * to API arguments needed to compressed textures. This puts the burden on the container
  32627. * generator to house the arcane code for determining these for current & future formats.
  32628. *
  32629. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32630. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32631. *
  32632. * Note: The result of this call is not taken into account when a texture is base64.
  32633. *
  32634. * @param formatsAvailable defines the list of those format families you have created
  32635. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32636. *
  32637. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32638. * @returns The extension selected.
  32639. */
  32640. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32641. /**
  32642. * Force a specific size of the canvas
  32643. * @param width defines the new canvas' width
  32644. * @param height defines the new canvas' height
  32645. */
  32646. setSize(width: number, height: number): void;
  32647. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32648. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32649. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32650. _releaseTexture(texture: InternalTexture): void;
  32651. /**
  32652. * @hidden
  32653. * Rescales a texture
  32654. * @param source input texutre
  32655. * @param destination destination texture
  32656. * @param scene scene to use to render the resize
  32657. * @param internalFormat format to use when resizing
  32658. * @param onComplete callback to be called when resize has completed
  32659. */
  32660. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32661. /**
  32662. * Gets the current framerate
  32663. * @returns a number representing the framerate
  32664. */
  32665. getFps(): number;
  32666. /**
  32667. * Gets the time spent between current and previous frame
  32668. * @returns a number representing the delta time in ms
  32669. */
  32670. getDeltaTime(): number;
  32671. private _measureFps;
  32672. /**
  32673. * Creates a new render target texture
  32674. * @param size defines the size of the texture
  32675. * @param options defines the options used to create the texture
  32676. * @returns a new render target texture stored in an InternalTexture
  32677. */
  32678. createRenderTargetTexture(size: number | {
  32679. width: number;
  32680. height: number;
  32681. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32682. /**
  32683. * Updates the sample count of a render target texture
  32684. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32685. * @param texture defines the texture to update
  32686. * @param samples defines the sample count to set
  32687. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32688. */
  32689. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32690. /** @hidden */
  32691. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32692. dispose(): void;
  32693. private _disableTouchAction;
  32694. /**
  32695. * Display the loading screen
  32696. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32697. */
  32698. displayLoadingUI(): void;
  32699. /**
  32700. * Hide the loading screen
  32701. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32702. */
  32703. hideLoadingUI(): void;
  32704. /**
  32705. * Gets the current loading screen object
  32706. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32707. */
  32708. /**
  32709. * Sets the current loading screen object
  32710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32711. */
  32712. loadingScreen: ILoadingScreen;
  32713. /**
  32714. * Sets the current loading screen text
  32715. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32716. */
  32717. loadingUIText: string;
  32718. /**
  32719. * Sets the current loading screen background color
  32720. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32721. */
  32722. loadingUIBackgroundColor: string;
  32723. /** Pointerlock and fullscreen */
  32724. /**
  32725. * Ask the browser to promote the current element to pointerlock mode
  32726. * @param element defines the DOM element to promote
  32727. */
  32728. static _RequestPointerlock(element: HTMLElement): void;
  32729. /**
  32730. * Asks the browser to exit pointerlock mode
  32731. */
  32732. static _ExitPointerlock(): void;
  32733. /**
  32734. * Ask the browser to promote the current element to fullscreen rendering mode
  32735. * @param element defines the DOM element to promote
  32736. */
  32737. static _RequestFullscreen(element: HTMLElement): void;
  32738. /**
  32739. * Asks the browser to exit fullscreen mode
  32740. */
  32741. static _ExitFullscreen(): void;
  32742. }
  32743. }
  32744. declare module "babylonjs/Engines/engineStore" {
  32745. import { Nullable } from "babylonjs/types";
  32746. import { Engine } from "babylonjs/Engines/engine";
  32747. import { Scene } from "babylonjs/scene";
  32748. /**
  32749. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32750. * during the life time of the application.
  32751. */
  32752. export class EngineStore {
  32753. /** Gets the list of created engines */
  32754. static Instances: import("babylonjs/Engines/engine").Engine[];
  32755. /** @hidden */
  32756. static _LastCreatedScene: Nullable<Scene>;
  32757. /**
  32758. * Gets the latest created engine
  32759. */
  32760. static readonly LastCreatedEngine: Nullable<Engine>;
  32761. /**
  32762. * Gets the latest created scene
  32763. */
  32764. static readonly LastCreatedScene: Nullable<Scene>;
  32765. /**
  32766. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32767. * @ignorenaming
  32768. */
  32769. static UseFallbackTexture: boolean;
  32770. /**
  32771. * Texture content used if a texture cannot loaded
  32772. * @ignorenaming
  32773. */
  32774. static FallbackTexture: string;
  32775. }
  32776. }
  32777. declare module "babylonjs/Misc/promise" {
  32778. /**
  32779. * Helper class that provides a small promise polyfill
  32780. */
  32781. export class PromisePolyfill {
  32782. /**
  32783. * Static function used to check if the polyfill is required
  32784. * If this is the case then the function will inject the polyfill to window.Promise
  32785. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32786. */
  32787. static Apply(force?: boolean): void;
  32788. }
  32789. }
  32790. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32791. /**
  32792. * Interface for screenshot methods with describe argument called `size` as object with options
  32793. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32794. */
  32795. export interface IScreenshotSize {
  32796. /**
  32797. * number in pixels for canvas height
  32798. */
  32799. height?: number;
  32800. /**
  32801. * multiplier allowing render at a higher or lower resolution
  32802. * If value is defined then height and width will be ignored and taken from camera
  32803. */
  32804. precision?: number;
  32805. /**
  32806. * number in pixels for canvas width
  32807. */
  32808. width?: number;
  32809. }
  32810. }
  32811. declare module "babylonjs/Misc/tools" {
  32812. import { Nullable, float } from "babylonjs/types";
  32813. import { DomManagement } from "babylonjs/Misc/domManagement";
  32814. import { WebRequest } from "babylonjs/Misc/webRequest";
  32815. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32816. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32817. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32818. import { Camera } from "babylonjs/Cameras/camera";
  32819. import { Engine } from "babylonjs/Engines/engine";
  32820. interface IColor4Like {
  32821. r: float;
  32822. g: float;
  32823. b: float;
  32824. a: float;
  32825. }
  32826. /**
  32827. * Class containing a set of static utilities functions
  32828. */
  32829. export class Tools {
  32830. /**
  32831. * Gets or sets the base URL to use to load assets
  32832. */
  32833. static BaseUrl: string;
  32834. /**
  32835. * Enable/Disable Custom HTTP Request Headers globally.
  32836. * default = false
  32837. * @see CustomRequestHeaders
  32838. */
  32839. static UseCustomRequestHeaders: boolean;
  32840. /**
  32841. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32842. * i.e. when loading files, where the server/service expects an Authorization header
  32843. */
  32844. static CustomRequestHeaders: {
  32845. [key: string]: string;
  32846. };
  32847. /**
  32848. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32849. */
  32850. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32851. /**
  32852. * Default behaviour for cors in the application.
  32853. * It can be a string if the expected behavior is identical in the entire app.
  32854. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32855. */
  32856. static CorsBehavior: string | ((url: string | string[]) => string);
  32857. /**
  32858. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32859. * @ignorenaming
  32860. */
  32861. static UseFallbackTexture: boolean;
  32862. /**
  32863. * Use this object to register external classes like custom textures or material
  32864. * to allow the laoders to instantiate them
  32865. */
  32866. static RegisteredExternalClasses: {
  32867. [key: string]: Object;
  32868. };
  32869. /**
  32870. * Texture content used if a texture cannot loaded
  32871. * @ignorenaming
  32872. */
  32873. static fallbackTexture: string;
  32874. /**
  32875. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32876. * @param u defines the coordinate on X axis
  32877. * @param v defines the coordinate on Y axis
  32878. * @param width defines the width of the source data
  32879. * @param height defines the height of the source data
  32880. * @param pixels defines the source byte array
  32881. * @param color defines the output color
  32882. */
  32883. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32884. /**
  32885. * Interpolates between a and b via alpha
  32886. * @param a The lower value (returned when alpha = 0)
  32887. * @param b The upper value (returned when alpha = 1)
  32888. * @param alpha The interpolation-factor
  32889. * @return The mixed value
  32890. */
  32891. static Mix(a: number, b: number, alpha: number): number;
  32892. /**
  32893. * Tries to instantiate a new object from a given class name
  32894. * @param className defines the class name to instantiate
  32895. * @returns the new object or null if the system was not able to do the instantiation
  32896. */
  32897. static Instantiate(className: string): any;
  32898. /**
  32899. * Provides a slice function that will work even on IE
  32900. * @param data defines the array to slice
  32901. * @param start defines the start of the data (optional)
  32902. * @param end defines the end of the data (optional)
  32903. * @returns the new sliced array
  32904. */
  32905. static Slice<T>(data: T, start?: number, end?: number): T;
  32906. /**
  32907. * Polyfill for setImmediate
  32908. * @param action defines the action to execute after the current execution block
  32909. */
  32910. static SetImmediate(action: () => void): void;
  32911. /**
  32912. * Function indicating if a number is an exponent of 2
  32913. * @param value defines the value to test
  32914. * @returns true if the value is an exponent of 2
  32915. */
  32916. static IsExponentOfTwo(value: number): boolean;
  32917. private static _tmpFloatArray;
  32918. /**
  32919. * Returns the nearest 32-bit single precision float representation of a Number
  32920. * @param value A Number. If the parameter is of a different type, it will get converted
  32921. * to a number or to NaN if it cannot be converted
  32922. * @returns number
  32923. */
  32924. static FloatRound(value: number): number;
  32925. /**
  32926. * Extracts the filename from a path
  32927. * @param path defines the path to use
  32928. * @returns the filename
  32929. */
  32930. static GetFilename(path: string): string;
  32931. /**
  32932. * Extracts the "folder" part of a path (everything before the filename).
  32933. * @param uri The URI to extract the info from
  32934. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32935. * @returns The "folder" part of the path
  32936. */
  32937. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32938. /**
  32939. * Extracts text content from a DOM element hierarchy
  32940. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32941. */
  32942. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32943. /**
  32944. * Convert an angle in radians to degrees
  32945. * @param angle defines the angle to convert
  32946. * @returns the angle in degrees
  32947. */
  32948. static ToDegrees(angle: number): number;
  32949. /**
  32950. * Convert an angle in degrees to radians
  32951. * @param angle defines the angle to convert
  32952. * @returns the angle in radians
  32953. */
  32954. static ToRadians(angle: number): number;
  32955. /**
  32956. * Encode a buffer to a base64 string
  32957. * @param buffer defines the buffer to encode
  32958. * @returns the encoded string
  32959. */
  32960. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32961. /**
  32962. * Returns an array if obj is not an array
  32963. * @param obj defines the object to evaluate as an array
  32964. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32965. * @returns either obj directly if obj is an array or a new array containing obj
  32966. */
  32967. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32968. /**
  32969. * Gets the pointer prefix to use
  32970. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32971. */
  32972. static GetPointerPrefix(): string;
  32973. /**
  32974. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32975. * @param url define the url we are trying
  32976. * @param element define the dom element where to configure the cors policy
  32977. */
  32978. static SetCorsBehavior(url: string | string[], element: {
  32979. crossOrigin: string | null;
  32980. }): void;
  32981. /**
  32982. * Removes unwanted characters from an url
  32983. * @param url defines the url to clean
  32984. * @returns the cleaned url
  32985. */
  32986. static CleanUrl(url: string): string;
  32987. /**
  32988. * Gets or sets a function used to pre-process url before using them to load assets
  32989. */
  32990. static PreprocessUrl: (url: string) => string;
  32991. /**
  32992. * Loads an image as an HTMLImageElement.
  32993. * @param input url string, ArrayBuffer, or Blob to load
  32994. * @param onLoad callback called when the image successfully loads
  32995. * @param onError callback called when the image fails to load
  32996. * @param offlineProvider offline provider for caching
  32997. * @returns the HTMLImageElement of the loaded image
  32998. */
  32999. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  33000. /**
  33001. * Loads a file
  33002. * @param url url string, ArrayBuffer, or Blob to load
  33003. * @param onSuccess callback called when the file successfully loads
  33004. * @param onProgress callback called while file is loading (if the server supports this mode)
  33005. * @param offlineProvider defines the offline provider for caching
  33006. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33007. * @param onError callback called when the file fails to load
  33008. * @returns a file request object
  33009. */
  33010. 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;
  33011. /**
  33012. * Loads a file from a url
  33013. * @param url the file url to load
  33014. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33015. */
  33016. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33017. /**
  33018. * Load a script (identified by an url). When the url returns, the
  33019. * content of this file is added into a new script element, attached to the DOM (body element)
  33020. * @param scriptUrl defines the url of the script to laod
  33021. * @param onSuccess defines the callback called when the script is loaded
  33022. * @param onError defines the callback to call if an error occurs
  33023. * @param scriptId defines the id of the script element
  33024. */
  33025. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33026. /**
  33027. * Load an asynchronous script (identified by an url). When the url returns, the
  33028. * content of this file is added into a new script element, attached to the DOM (body element)
  33029. * @param scriptUrl defines the url of the script to laod
  33030. * @param scriptId defines the id of the script element
  33031. * @returns a promise request object
  33032. */
  33033. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33034. /**
  33035. * Loads a file from a blob
  33036. * @param fileToLoad defines the blob to use
  33037. * @param callback defines the callback to call when data is loaded
  33038. * @param progressCallback defines the callback to call during loading process
  33039. * @returns a file request object
  33040. */
  33041. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33042. /**
  33043. * Loads a file
  33044. * @param fileToLoad defines the file to load
  33045. * @param callback defines the callback to call when data is loaded
  33046. * @param progressCallBack defines the callback to call during loading process
  33047. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33048. * @returns a file request object
  33049. */
  33050. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33051. /**
  33052. * Creates a data url from a given string content
  33053. * @param content defines the content to convert
  33054. * @returns the new data url link
  33055. */
  33056. static FileAsURL(content: string): string;
  33057. /**
  33058. * Format the given number to a specific decimal format
  33059. * @param value defines the number to format
  33060. * @param decimals defines the number of decimals to use
  33061. * @returns the formatted string
  33062. */
  33063. static Format(value: number, decimals?: number): string;
  33064. /**
  33065. * Tries to copy an object by duplicating every property
  33066. * @param source defines the source object
  33067. * @param destination defines the target object
  33068. * @param doNotCopyList defines a list of properties to avoid
  33069. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33070. */
  33071. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33072. /**
  33073. * Gets a boolean indicating if the given object has no own property
  33074. * @param obj defines the object to test
  33075. * @returns true if object has no own property
  33076. */
  33077. static IsEmpty(obj: any): boolean;
  33078. /**
  33079. * Function used to register events at window level
  33080. * @param windowElement defines the Window object to use
  33081. * @param events defines the events to register
  33082. */
  33083. static RegisterTopRootEvents(windowElement: Window, events: {
  33084. name: string;
  33085. handler: Nullable<(e: FocusEvent) => any>;
  33086. }[]): void;
  33087. /**
  33088. * Function used to unregister events from window level
  33089. * @param windowElement defines the Window object to use
  33090. * @param events defines the events to unregister
  33091. */
  33092. static UnregisterTopRootEvents(windowElement: Window, events: {
  33093. name: string;
  33094. handler: Nullable<(e: FocusEvent) => any>;
  33095. }[]): void;
  33096. /**
  33097. * @ignore
  33098. */
  33099. static _ScreenshotCanvas: HTMLCanvasElement;
  33100. /**
  33101. * Dumps the current bound framebuffer
  33102. * @param width defines the rendering width
  33103. * @param height defines the rendering height
  33104. * @param engine defines the hosting engine
  33105. * @param successCallback defines the callback triggered once the data are available
  33106. * @param mimeType defines the mime type of the result
  33107. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33108. */
  33109. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33110. /**
  33111. * Converts the canvas data to blob.
  33112. * This acts as a polyfill for browsers not supporting the to blob function.
  33113. * @param canvas Defines the canvas to extract the data from
  33114. * @param successCallback Defines the callback triggered once the data are available
  33115. * @param mimeType Defines the mime type of the result
  33116. */
  33117. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33118. /**
  33119. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33120. * @param successCallback defines the callback triggered once the data are available
  33121. * @param mimeType defines the mime type of the result
  33122. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33123. */
  33124. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33125. /**
  33126. * Downloads a blob in the browser
  33127. * @param blob defines the blob to download
  33128. * @param fileName defines the name of the downloaded file
  33129. */
  33130. static Download(blob: Blob, fileName: string): void;
  33131. /**
  33132. * Captures a screenshot of the current rendering
  33133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33134. * @param engine defines the rendering engine
  33135. * @param camera defines the source camera
  33136. * @param size This parameter can be set to a single number or to an object with the
  33137. * following (optional) properties: precision, width, height. If a single number is passed,
  33138. * it will be used for both width and height. If an object is passed, the screenshot size
  33139. * will be derived from the parameters. The precision property is a multiplier allowing
  33140. * rendering at a higher or lower resolution
  33141. * @param successCallback defines the callback receives a single parameter which contains the
  33142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33143. * src parameter of an <img> to display it
  33144. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33145. * Check your browser for supported MIME types
  33146. */
  33147. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33148. /**
  33149. * Captures a screenshot of the current rendering
  33150. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33151. * @param engine defines the rendering engine
  33152. * @param camera defines the source camera
  33153. * @param size This parameter can be set to a single number or to an object with the
  33154. * following (optional) properties: precision, width, height. If a single number is passed,
  33155. * it will be used for both width and height. If an object is passed, the screenshot size
  33156. * will be derived from the parameters. The precision property is a multiplier allowing
  33157. * rendering at a higher or lower resolution
  33158. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33159. * Check your browser for supported MIME types
  33160. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33161. * to the src parameter of an <img> to display it
  33162. */
  33163. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33164. /**
  33165. * Generates an image screenshot from the specified camera.
  33166. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33167. * @param engine The engine to use for rendering
  33168. * @param camera The camera to use for rendering
  33169. * @param size This parameter can be set to a single number or to an object with the
  33170. * following (optional) properties: precision, width, height. If a single number is passed,
  33171. * it will be used for both width and height. If an object is passed, the screenshot size
  33172. * will be derived from the parameters. The precision property is a multiplier allowing
  33173. * rendering at a higher or lower resolution
  33174. * @param successCallback The callback receives a single parameter which contains the
  33175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33176. * src parameter of an <img> to display it
  33177. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33178. * Check your browser for supported MIME types
  33179. * @param samples Texture samples (default: 1)
  33180. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33181. * @param fileName A name for for the downloaded file.
  33182. */
  33183. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33184. /**
  33185. * Generates an image screenshot from the specified camera.
  33186. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33187. * @param engine The engine to use for rendering
  33188. * @param camera The camera to use for rendering
  33189. * @param size This parameter can be set to a single number or to an object with the
  33190. * following (optional) properties: precision, width, height. If a single number is passed,
  33191. * it will be used for both width and height. If an object is passed, the screenshot size
  33192. * will be derived from the parameters. The precision property is a multiplier allowing
  33193. * rendering at a higher or lower resolution
  33194. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33195. * Check your browser for supported MIME types
  33196. * @param samples Texture samples (default: 1)
  33197. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33198. * @param fileName A name for for the downloaded file.
  33199. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33200. * to the src parameter of an <img> to display it
  33201. */
  33202. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33203. /**
  33204. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33205. * Be aware Math.random() could cause collisions, but:
  33206. * "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"
  33207. * @returns a pseudo random id
  33208. */
  33209. static RandomId(): string;
  33210. /**
  33211. * Test if the given uri is a base64 string
  33212. * @param uri The uri to test
  33213. * @return True if the uri is a base64 string or false otherwise
  33214. */
  33215. static IsBase64(uri: string): boolean;
  33216. /**
  33217. * Decode the given base64 uri.
  33218. * @param uri The uri to decode
  33219. * @return The decoded base64 data.
  33220. */
  33221. static DecodeBase64(uri: string): ArrayBuffer;
  33222. /**
  33223. * Gets the absolute url.
  33224. * @param url the input url
  33225. * @return the absolute url
  33226. */
  33227. static GetAbsoluteUrl(url: string): string;
  33228. /**
  33229. * No log
  33230. */
  33231. static readonly NoneLogLevel: number;
  33232. /**
  33233. * Only message logs
  33234. */
  33235. static readonly MessageLogLevel: number;
  33236. /**
  33237. * Only warning logs
  33238. */
  33239. static readonly WarningLogLevel: number;
  33240. /**
  33241. * Only error logs
  33242. */
  33243. static readonly ErrorLogLevel: number;
  33244. /**
  33245. * All logs
  33246. */
  33247. static readonly AllLogLevel: number;
  33248. /**
  33249. * Gets a value indicating the number of loading errors
  33250. * @ignorenaming
  33251. */
  33252. static readonly errorsCount: number;
  33253. /**
  33254. * Callback called when a new log is added
  33255. */
  33256. static OnNewCacheEntry: (entry: string) => void;
  33257. /**
  33258. * Log a message to the console
  33259. * @param message defines the message to log
  33260. */
  33261. static Log(message: string): void;
  33262. /**
  33263. * Write a warning message to the console
  33264. * @param message defines the message to log
  33265. */
  33266. static Warn(message: string): void;
  33267. /**
  33268. * Write an error message to the console
  33269. * @param message defines the message to log
  33270. */
  33271. static Error(message: string): void;
  33272. /**
  33273. * Gets current log cache (list of logs)
  33274. */
  33275. static readonly LogCache: string;
  33276. /**
  33277. * Clears the log cache
  33278. */
  33279. static ClearLogCache(): void;
  33280. /**
  33281. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33282. */
  33283. static LogLevels: number;
  33284. /**
  33285. * Checks if the window object exists
  33286. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33287. */
  33288. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33289. /**
  33290. * No performance log
  33291. */
  33292. static readonly PerformanceNoneLogLevel: number;
  33293. /**
  33294. * Use user marks to log performance
  33295. */
  33296. static readonly PerformanceUserMarkLogLevel: number;
  33297. /**
  33298. * Log performance to the console
  33299. */
  33300. static readonly PerformanceConsoleLogLevel: number;
  33301. private static _performance;
  33302. /**
  33303. * Sets the current performance log level
  33304. */
  33305. static PerformanceLogLevel: number;
  33306. private static _StartPerformanceCounterDisabled;
  33307. private static _EndPerformanceCounterDisabled;
  33308. private static _StartUserMark;
  33309. private static _EndUserMark;
  33310. private static _StartPerformanceConsole;
  33311. private static _EndPerformanceConsole;
  33312. /**
  33313. * Starts a performance counter
  33314. */
  33315. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33316. /**
  33317. * Ends a specific performance coutner
  33318. */
  33319. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33320. /**
  33321. * Gets either window.performance.now() if supported or Date.now() else
  33322. */
  33323. static readonly Now: number;
  33324. /**
  33325. * This method will return the name of the class used to create the instance of the given object.
  33326. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33327. * @param object the object to get the class name from
  33328. * @param isType defines if the object is actually a type
  33329. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33330. */
  33331. static GetClassName(object: any, isType?: boolean): string;
  33332. /**
  33333. * Gets the first element of an array satisfying a given predicate
  33334. * @param array defines the array to browse
  33335. * @param predicate defines the predicate to use
  33336. * @returns null if not found or the element
  33337. */
  33338. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33339. /**
  33340. * This method will return the name of the full name of the class, including its owning module (if any).
  33341. * 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).
  33342. * @param object the object to get the class name from
  33343. * @param isType defines if the object is actually a type
  33344. * @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.
  33345. * @ignorenaming
  33346. */
  33347. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33348. /**
  33349. * Returns a promise that resolves after the given amount of time.
  33350. * @param delay Number of milliseconds to delay
  33351. * @returns Promise that resolves after the given amount of time
  33352. */
  33353. static DelayAsync(delay: number): Promise<void>;
  33354. }
  33355. /**
  33356. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33357. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33358. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33359. * @param name The name of the class, case should be preserved
  33360. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33361. */
  33362. export function className(name: string, module?: string): (target: Object) => void;
  33363. /**
  33364. * An implementation of a loop for asynchronous functions.
  33365. */
  33366. export class AsyncLoop {
  33367. /**
  33368. * Defines the number of iterations for the loop
  33369. */
  33370. iterations: number;
  33371. /**
  33372. * Defines the current index of the loop.
  33373. */
  33374. index: number;
  33375. private _done;
  33376. private _fn;
  33377. private _successCallback;
  33378. /**
  33379. * Constructor.
  33380. * @param iterations the number of iterations.
  33381. * @param func the function to run each iteration
  33382. * @param successCallback the callback that will be called upon succesful execution
  33383. * @param offset starting offset.
  33384. */
  33385. constructor(
  33386. /**
  33387. * Defines the number of iterations for the loop
  33388. */
  33389. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33390. /**
  33391. * Execute the next iteration. Must be called after the last iteration was finished.
  33392. */
  33393. executeNext(): void;
  33394. /**
  33395. * Break the loop and run the success callback.
  33396. */
  33397. breakLoop(): void;
  33398. /**
  33399. * Create and run an async loop.
  33400. * @param iterations the number of iterations.
  33401. * @param fn the function to run each iteration
  33402. * @param successCallback the callback that will be called upon succesful execution
  33403. * @param offset starting offset.
  33404. * @returns the created async loop object
  33405. */
  33406. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33407. /**
  33408. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33409. * @param iterations total number of iterations
  33410. * @param syncedIterations number of synchronous iterations in each async iteration.
  33411. * @param fn the function to call each iteration.
  33412. * @param callback a success call back that will be called when iterating stops.
  33413. * @param breakFunction a break condition (optional)
  33414. * @param timeout timeout settings for the setTimeout function. default - 0.
  33415. * @returns the created async loop object
  33416. */
  33417. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33418. }
  33419. }
  33420. declare module "babylonjs/Misc/stringDictionary" {
  33421. import { Nullable } from "babylonjs/types";
  33422. /**
  33423. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33424. * The underlying implementation relies on an associative array to ensure the best performances.
  33425. * The value can be anything including 'null' but except 'undefined'
  33426. */
  33427. export class StringDictionary<T> {
  33428. /**
  33429. * This will clear this dictionary and copy the content from the 'source' one.
  33430. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33431. * @param source the dictionary to take the content from and copy to this dictionary
  33432. */
  33433. copyFrom(source: StringDictionary<T>): void;
  33434. /**
  33435. * Get a value based from its key
  33436. * @param key the given key to get the matching value from
  33437. * @return the value if found, otherwise undefined is returned
  33438. */
  33439. get(key: string): T | undefined;
  33440. /**
  33441. * Get a value from its key or add it if it doesn't exist.
  33442. * This method will ensure you that a given key/data will be present in the dictionary.
  33443. * @param key the given key to get the matching value from
  33444. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33445. * The factory will only be invoked if there's no data for the given key.
  33446. * @return the value corresponding to the key.
  33447. */
  33448. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33449. /**
  33450. * Get a value from its key if present in the dictionary otherwise add it
  33451. * @param key the key to get the value from
  33452. * @param val if there's no such key/value pair in the dictionary add it with this value
  33453. * @return the value corresponding to the key
  33454. */
  33455. getOrAdd(key: string, val: T): T;
  33456. /**
  33457. * Check if there's a given key in the dictionary
  33458. * @param key the key to check for
  33459. * @return true if the key is present, false otherwise
  33460. */
  33461. contains(key: string): boolean;
  33462. /**
  33463. * Add a new key and its corresponding value
  33464. * @param key the key to add
  33465. * @param value the value corresponding to the key
  33466. * @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
  33467. */
  33468. add(key: string, value: T): boolean;
  33469. /**
  33470. * Update a specific value associated to a key
  33471. * @param key defines the key to use
  33472. * @param value defines the value to store
  33473. * @returns true if the value was updated (or false if the key was not found)
  33474. */
  33475. set(key: string, value: T): boolean;
  33476. /**
  33477. * Get the element of the given key and remove it from the dictionary
  33478. * @param key defines the key to search
  33479. * @returns the value associated with the key or null if not found
  33480. */
  33481. getAndRemove(key: string): Nullable<T>;
  33482. /**
  33483. * Remove a key/value from the dictionary.
  33484. * @param key the key to remove
  33485. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33486. */
  33487. remove(key: string): boolean;
  33488. /**
  33489. * Clear the whole content of the dictionary
  33490. */
  33491. clear(): void;
  33492. /**
  33493. * Gets the current count
  33494. */
  33495. readonly count: number;
  33496. /**
  33497. * Execute a callback on each key/val of the dictionary.
  33498. * Note that you can remove any element in this dictionary in the callback implementation
  33499. * @param callback the callback to execute on a given key/value pair
  33500. */
  33501. forEach(callback: (key: string, val: T) => void): void;
  33502. /**
  33503. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33504. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33505. * Note that you can remove any element in this dictionary in the callback implementation
  33506. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33507. * @returns the first item
  33508. */
  33509. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33510. private _count;
  33511. private _data;
  33512. }
  33513. }
  33514. declare module "babylonjs/Collisions/collisionCoordinator" {
  33515. import { Nullable } from "babylonjs/types";
  33516. import { Scene } from "babylonjs/scene";
  33517. import { Vector3 } from "babylonjs/Maths/math.vector";
  33518. import { Collider } from "babylonjs/Collisions/collider";
  33519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33520. /** @hidden */
  33521. export interface ICollisionCoordinator {
  33522. createCollider(): Collider;
  33523. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33524. init(scene: Scene): void;
  33525. }
  33526. /** @hidden */
  33527. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33528. private _scene;
  33529. private _scaledPosition;
  33530. private _scaledVelocity;
  33531. private _finalPosition;
  33532. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33533. createCollider(): Collider;
  33534. init(scene: Scene): void;
  33535. private _collideWithWorld;
  33536. }
  33537. }
  33538. declare module "babylonjs/Inputs/scene.inputManager" {
  33539. import { Nullable } from "babylonjs/types";
  33540. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33541. import { Vector2 } from "babylonjs/Maths/math.vector";
  33542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33543. import { Scene } from "babylonjs/scene";
  33544. /**
  33545. * Class used to manage all inputs for the scene.
  33546. */
  33547. export class InputManager {
  33548. /** The distance in pixel that you have to move to prevent some events */
  33549. static DragMovementThreshold: number;
  33550. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33551. static LongPressDelay: number;
  33552. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33553. static DoubleClickDelay: number;
  33554. /** If you need to check double click without raising a single click at first click, enable this flag */
  33555. static ExclusiveDoubleClickMode: boolean;
  33556. private _wheelEventName;
  33557. private _onPointerMove;
  33558. private _onPointerDown;
  33559. private _onPointerUp;
  33560. private _initClickEvent;
  33561. private _initActionManager;
  33562. private _delayedSimpleClick;
  33563. private _delayedSimpleClickTimeout;
  33564. private _previousDelayedSimpleClickTimeout;
  33565. private _meshPickProceed;
  33566. private _previousButtonPressed;
  33567. private _currentPickResult;
  33568. private _previousPickResult;
  33569. private _totalPointersPressed;
  33570. private _doubleClickOccured;
  33571. private _pointerOverMesh;
  33572. private _pickedDownMesh;
  33573. private _pickedUpMesh;
  33574. private _pointerX;
  33575. private _pointerY;
  33576. private _unTranslatedPointerX;
  33577. private _unTranslatedPointerY;
  33578. private _startingPointerPosition;
  33579. private _previousStartingPointerPosition;
  33580. private _startingPointerTime;
  33581. private _previousStartingPointerTime;
  33582. private _pointerCaptures;
  33583. private _onKeyDown;
  33584. private _onKeyUp;
  33585. private _onCanvasFocusObserver;
  33586. private _onCanvasBlurObserver;
  33587. private _scene;
  33588. /**
  33589. * Creates a new InputManager
  33590. * @param scene defines the hosting scene
  33591. */
  33592. constructor(scene: Scene);
  33593. /**
  33594. * Gets the mesh that is currently under the pointer
  33595. */
  33596. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33597. /**
  33598. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33599. */
  33600. readonly unTranslatedPointer: Vector2;
  33601. /**
  33602. * Gets or sets the current on-screen X position of the pointer
  33603. */
  33604. pointerX: number;
  33605. /**
  33606. * Gets or sets the current on-screen Y position of the pointer
  33607. */
  33608. pointerY: number;
  33609. private _updatePointerPosition;
  33610. private _processPointerMove;
  33611. private _setRayOnPointerInfo;
  33612. private _checkPrePointerObservable;
  33613. /**
  33614. * Use this method to simulate a pointer move on a mesh
  33615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33618. */
  33619. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33620. /**
  33621. * Use this method to simulate a pointer down on a mesh
  33622. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33623. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33624. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33625. */
  33626. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33627. private _processPointerDown;
  33628. /** @hidden */
  33629. _isPointerSwiping(): boolean;
  33630. /**
  33631. * Use this method to simulate a pointer up on a mesh
  33632. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33633. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33634. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33635. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33636. */
  33637. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33638. private _processPointerUp;
  33639. /**
  33640. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33641. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33642. * @returns true if the pointer was captured
  33643. */
  33644. isPointerCaptured(pointerId?: number): boolean;
  33645. /**
  33646. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33647. * @param attachUp defines if you want to attach events to pointerup
  33648. * @param attachDown defines if you want to attach events to pointerdown
  33649. * @param attachMove defines if you want to attach events to pointermove
  33650. */
  33651. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33652. /**
  33653. * Detaches all event handlers
  33654. */
  33655. detachControl(): void;
  33656. /**
  33657. * Force the value of meshUnderPointer
  33658. * @param mesh defines the mesh to use
  33659. */
  33660. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33661. /**
  33662. * Gets the mesh under the pointer
  33663. * @returns a Mesh or null if no mesh is under the pointer
  33664. */
  33665. getPointerOverMesh(): Nullable<AbstractMesh>;
  33666. }
  33667. }
  33668. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33669. /**
  33670. * Helper class used to generate session unique ID
  33671. */
  33672. export class UniqueIdGenerator {
  33673. private static _UniqueIdCounter;
  33674. /**
  33675. * Gets an unique (relatively to the current scene) Id
  33676. */
  33677. static readonly UniqueId: number;
  33678. }
  33679. }
  33680. declare module "babylonjs/Animations/animationGroup" {
  33681. import { Animatable } from "babylonjs/Animations/animatable";
  33682. import { Animation } from "babylonjs/Animations/animation";
  33683. import { Scene, IDisposable } from "babylonjs/scene";
  33684. import { Observable } from "babylonjs/Misc/observable";
  33685. import { Nullable } from "babylonjs/types";
  33686. import "babylonjs/Animations/animatable";
  33687. /**
  33688. * This class defines the direct association between an animation and a target
  33689. */
  33690. export class TargetedAnimation {
  33691. /**
  33692. * Animation to perform
  33693. */
  33694. animation: Animation;
  33695. /**
  33696. * Target to animate
  33697. */
  33698. target: any;
  33699. /**
  33700. * Serialize the object
  33701. * @returns the JSON object representing the current entity
  33702. */
  33703. serialize(): any;
  33704. }
  33705. /**
  33706. * Use this class to create coordinated animations on multiple targets
  33707. */
  33708. export class AnimationGroup implements IDisposable {
  33709. /** The name of the animation group */
  33710. name: string;
  33711. private _scene;
  33712. private _targetedAnimations;
  33713. private _animatables;
  33714. private _from;
  33715. private _to;
  33716. private _isStarted;
  33717. private _isPaused;
  33718. private _speedRatio;
  33719. private _loopAnimation;
  33720. /**
  33721. * Gets or sets the unique id of the node
  33722. */
  33723. uniqueId: number;
  33724. /**
  33725. * This observable will notify when one animation have ended
  33726. */
  33727. onAnimationEndObservable: Observable<TargetedAnimation>;
  33728. /**
  33729. * Observer raised when one animation loops
  33730. */
  33731. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33732. /**
  33733. * This observable will notify when all animations have ended.
  33734. */
  33735. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33736. /**
  33737. * This observable will notify when all animations have paused.
  33738. */
  33739. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33740. /**
  33741. * This observable will notify when all animations are playing.
  33742. */
  33743. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33744. /**
  33745. * Gets the first frame
  33746. */
  33747. readonly from: number;
  33748. /**
  33749. * Gets the last frame
  33750. */
  33751. readonly to: number;
  33752. /**
  33753. * Define if the animations are started
  33754. */
  33755. readonly isStarted: boolean;
  33756. /**
  33757. * Gets a value indicating that the current group is playing
  33758. */
  33759. readonly isPlaying: boolean;
  33760. /**
  33761. * Gets or sets the speed ratio to use for all animations
  33762. */
  33763. /**
  33764. * Gets or sets the speed ratio to use for all animations
  33765. */
  33766. speedRatio: number;
  33767. /**
  33768. * Gets or sets if all animations should loop or not
  33769. */
  33770. loopAnimation: boolean;
  33771. /**
  33772. * Gets the targeted animations for this animation group
  33773. */
  33774. readonly targetedAnimations: Array<TargetedAnimation>;
  33775. /**
  33776. * returning the list of animatables controlled by this animation group.
  33777. */
  33778. readonly animatables: Array<Animatable>;
  33779. /**
  33780. * Instantiates a new Animation Group.
  33781. * This helps managing several animations at once.
  33782. * @see http://doc.babylonjs.com/how_to/group
  33783. * @param name Defines the name of the group
  33784. * @param scene Defines the scene the group belongs to
  33785. */
  33786. constructor(
  33787. /** The name of the animation group */
  33788. name: string, scene?: Nullable<Scene>);
  33789. /**
  33790. * Add an animation (with its target) in the group
  33791. * @param animation defines the animation we want to add
  33792. * @param target defines the target of the animation
  33793. * @returns the TargetedAnimation object
  33794. */
  33795. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33796. /**
  33797. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33798. * It can add constant keys at begin or end
  33799. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33800. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33801. * @returns the animation group
  33802. */
  33803. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33804. /**
  33805. * Start all animations on given targets
  33806. * @param loop defines if animations must loop
  33807. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33808. * @param from defines the from key (optional)
  33809. * @param to defines the to key (optional)
  33810. * @returns the current animation group
  33811. */
  33812. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33813. /**
  33814. * Pause all animations
  33815. * @returns the animation group
  33816. */
  33817. pause(): AnimationGroup;
  33818. /**
  33819. * Play all animations to initial state
  33820. * This function will start() the animations if they were not started or will restart() them if they were paused
  33821. * @param loop defines if animations must loop
  33822. * @returns the animation group
  33823. */
  33824. play(loop?: boolean): AnimationGroup;
  33825. /**
  33826. * Reset all animations to initial state
  33827. * @returns the animation group
  33828. */
  33829. reset(): AnimationGroup;
  33830. /**
  33831. * Restart animations from key 0
  33832. * @returns the animation group
  33833. */
  33834. restart(): AnimationGroup;
  33835. /**
  33836. * Stop all animations
  33837. * @returns the animation group
  33838. */
  33839. stop(): AnimationGroup;
  33840. /**
  33841. * Set animation weight for all animatables
  33842. * @param weight defines the weight to use
  33843. * @return the animationGroup
  33844. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33845. */
  33846. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33847. /**
  33848. * Synchronize and normalize all animatables with a source animatable
  33849. * @param root defines the root animatable to synchronize with
  33850. * @return the animationGroup
  33851. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33852. */
  33853. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33854. /**
  33855. * Goes to a specific frame in this animation group
  33856. * @param frame the frame number to go to
  33857. * @return the animationGroup
  33858. */
  33859. goToFrame(frame: number): AnimationGroup;
  33860. /**
  33861. * Dispose all associated resources
  33862. */
  33863. dispose(): void;
  33864. private _checkAnimationGroupEnded;
  33865. /**
  33866. * Clone the current animation group and returns a copy
  33867. * @param newName defines the name of the new group
  33868. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33869. * @returns the new aniamtion group
  33870. */
  33871. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33872. /**
  33873. * Serializes the animationGroup to an object
  33874. * @returns Serialized object
  33875. */
  33876. serialize(): any;
  33877. /**
  33878. * Returns a new AnimationGroup object parsed from the source provided.
  33879. * @param parsedAnimationGroup defines the source
  33880. * @param scene defines the scene that will receive the animationGroup
  33881. * @returns a new AnimationGroup
  33882. */
  33883. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33884. /**
  33885. * Returns the string "AnimationGroup"
  33886. * @returns "AnimationGroup"
  33887. */
  33888. getClassName(): string;
  33889. /**
  33890. * Creates a detailled string about the object
  33891. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33892. * @returns a string representing the object
  33893. */
  33894. toString(fullDetails?: boolean): string;
  33895. }
  33896. }
  33897. declare module "babylonjs/scene" {
  33898. import { Nullable } from "babylonjs/types";
  33899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33900. import { Observable } from "babylonjs/Misc/observable";
  33901. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33902. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33903. import { Geometry } from "babylonjs/Meshes/geometry";
  33904. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33907. import { Mesh } from "babylonjs/Meshes/mesh";
  33908. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33909. import { Bone } from "babylonjs/Bones/bone";
  33910. import { Skeleton } from "babylonjs/Bones/skeleton";
  33911. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33912. import { Camera } from "babylonjs/Cameras/camera";
  33913. import { AbstractScene } from "babylonjs/abstractScene";
  33914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33915. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33916. import { Material } from "babylonjs/Materials/material";
  33917. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33918. import { Effect } from "babylonjs/Materials/effect";
  33919. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33920. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33921. import { Light } from "babylonjs/Lights/light";
  33922. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33923. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33924. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33925. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33926. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33927. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33928. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33929. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33930. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33931. import { Engine } from "babylonjs/Engines/engine";
  33932. import { Node } from "babylonjs/node";
  33933. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33934. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33935. import { WebRequest } from "babylonjs/Misc/webRequest";
  33936. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33937. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33938. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33939. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33940. import { Plane } from "babylonjs/Maths/math.plane";
  33941. import { Ray } from "babylonjs/Culling/ray";
  33942. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33943. import { Animation } from "babylonjs/Animations/animation";
  33944. import { Animatable } from "babylonjs/Animations/animatable";
  33945. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33946. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33947. import { Collider } from "babylonjs/Collisions/collider";
  33948. /**
  33949. * Define an interface for all classes that will hold resources
  33950. */
  33951. export interface IDisposable {
  33952. /**
  33953. * Releases all held resources
  33954. */
  33955. dispose(): void;
  33956. }
  33957. /** Interface defining initialization parameters for Scene class */
  33958. export interface SceneOptions {
  33959. /**
  33960. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33961. * It will improve performance when the number of geometries becomes important.
  33962. */
  33963. useGeometryUniqueIdsMap?: boolean;
  33964. /**
  33965. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33966. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33967. */
  33968. useMaterialMeshMap?: boolean;
  33969. /**
  33970. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33971. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33972. */
  33973. useClonedMeshhMap?: boolean;
  33974. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33975. virtual?: boolean;
  33976. }
  33977. /**
  33978. * Represents a scene to be rendered by the engine.
  33979. * @see http://doc.babylonjs.com/features/scene
  33980. */
  33981. export class Scene extends AbstractScene implements IAnimatable {
  33982. /** The fog is deactivated */
  33983. static readonly FOGMODE_NONE: number;
  33984. /** The fog density is following an exponential function */
  33985. static readonly FOGMODE_EXP: number;
  33986. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33987. static readonly FOGMODE_EXP2: number;
  33988. /** The fog density is following a linear function. */
  33989. static readonly FOGMODE_LINEAR: number;
  33990. /**
  33991. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33993. */
  33994. static MinDeltaTime: number;
  33995. /**
  33996. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33997. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33998. */
  33999. static MaxDeltaTime: number;
  34000. /**
  34001. * Factory used to create the default material.
  34002. * @param name The name of the material to create
  34003. * @param scene The scene to create the material for
  34004. * @returns The default material
  34005. */
  34006. static DefaultMaterialFactory(scene: Scene): Material;
  34007. /**
  34008. * Factory used to create the a collision coordinator.
  34009. * @returns The collision coordinator
  34010. */
  34011. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34012. /** @hidden */
  34013. _inputManager: InputManager;
  34014. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34015. cameraToUseForPointers: Nullable<Camera>;
  34016. /** @hidden */
  34017. readonly _isScene: boolean;
  34018. /**
  34019. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34020. */
  34021. autoClear: boolean;
  34022. /**
  34023. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34024. */
  34025. autoClearDepthAndStencil: boolean;
  34026. /**
  34027. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34028. */
  34029. clearColor: Color4;
  34030. /**
  34031. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34032. */
  34033. ambientColor: Color3;
  34034. /**
  34035. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34036. * It should only be one of the following (if not the default embedded one):
  34037. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34038. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34039. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34040. * The material properties need to be setup according to the type of texture in use.
  34041. */
  34042. environmentBRDFTexture: BaseTexture;
  34043. /** @hidden */
  34044. protected _environmentTexture: Nullable<BaseTexture>;
  34045. /**
  34046. * Texture used in all pbr material as the reflection texture.
  34047. * As in the majority of the scene they are the same (exception for multi room and so on),
  34048. * this is easier to reference from here than from all the materials.
  34049. */
  34050. /**
  34051. * Texture used in all pbr material as the reflection texture.
  34052. * As in the majority of the scene they are the same (exception for multi room and so on),
  34053. * this is easier to set here than in all the materials.
  34054. */
  34055. environmentTexture: Nullable<BaseTexture>;
  34056. /** @hidden */
  34057. protected _environmentIntensity: number;
  34058. /**
  34059. * Intensity of the environment in all pbr material.
  34060. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34061. * As in the majority of the scene they are the same (exception for multi room and so on),
  34062. * this is easier to reference from here than from all the materials.
  34063. */
  34064. /**
  34065. * Intensity of the environment in all pbr material.
  34066. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34067. * As in the majority of the scene they are the same (exception for multi room and so on),
  34068. * this is easier to set here than in all the materials.
  34069. */
  34070. environmentIntensity: number;
  34071. /** @hidden */
  34072. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34073. /**
  34074. * Default image processing configuration used either in the rendering
  34075. * Forward main pass or through the imageProcessingPostProcess if present.
  34076. * As in the majority of the scene they are the same (exception for multi camera),
  34077. * this is easier to reference from here than from all the materials and post process.
  34078. *
  34079. * No setter as we it is a shared configuration, you can set the values instead.
  34080. */
  34081. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34082. private _forceWireframe;
  34083. /**
  34084. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34085. */
  34086. forceWireframe: boolean;
  34087. private _forcePointsCloud;
  34088. /**
  34089. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34090. */
  34091. forcePointsCloud: boolean;
  34092. /**
  34093. * Gets or sets the active clipplane 1
  34094. */
  34095. clipPlane: Nullable<Plane>;
  34096. /**
  34097. * Gets or sets the active clipplane 2
  34098. */
  34099. clipPlane2: Nullable<Plane>;
  34100. /**
  34101. * Gets or sets the active clipplane 3
  34102. */
  34103. clipPlane3: Nullable<Plane>;
  34104. /**
  34105. * Gets or sets the active clipplane 4
  34106. */
  34107. clipPlane4: Nullable<Plane>;
  34108. /**
  34109. * Gets or sets a boolean indicating if animations are enabled
  34110. */
  34111. animationsEnabled: boolean;
  34112. private _animationPropertiesOverride;
  34113. /**
  34114. * Gets or sets the animation properties override
  34115. */
  34116. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34117. /**
  34118. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34119. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34120. */
  34121. useConstantAnimationDeltaTime: boolean;
  34122. /**
  34123. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34124. * Please note that it requires to run a ray cast through the scene on every frame
  34125. */
  34126. constantlyUpdateMeshUnderPointer: boolean;
  34127. /**
  34128. * Defines the HTML cursor to use when hovering over interactive elements
  34129. */
  34130. hoverCursor: string;
  34131. /**
  34132. * Defines the HTML default cursor to use (empty by default)
  34133. */
  34134. defaultCursor: string;
  34135. /**
  34136. * This is used to call preventDefault() on pointer down
  34137. * in order to block unwanted artifacts like system double clicks
  34138. */
  34139. preventDefaultOnPointerDown: boolean;
  34140. /**
  34141. * This is used to call preventDefault() on pointer up
  34142. * in order to block unwanted artifacts like system double clicks
  34143. */
  34144. preventDefaultOnPointerUp: boolean;
  34145. /**
  34146. * Gets or sets user defined metadata
  34147. */
  34148. metadata: any;
  34149. /**
  34150. * For internal use only. Please do not use.
  34151. */
  34152. reservedDataStore: any;
  34153. /**
  34154. * Gets the name of the plugin used to load this scene (null by default)
  34155. */
  34156. loadingPluginName: string;
  34157. /**
  34158. * Use this array to add regular expressions used to disable offline support for specific urls
  34159. */
  34160. disableOfflineSupportExceptionRules: RegExp[];
  34161. /**
  34162. * An event triggered when the scene is disposed.
  34163. */
  34164. onDisposeObservable: Observable<Scene>;
  34165. private _onDisposeObserver;
  34166. /** Sets a function to be executed when this scene is disposed. */
  34167. onDispose: () => void;
  34168. /**
  34169. * An event triggered before rendering the scene (right after animations and physics)
  34170. */
  34171. onBeforeRenderObservable: Observable<Scene>;
  34172. private _onBeforeRenderObserver;
  34173. /** Sets a function to be executed before rendering this scene */
  34174. beforeRender: Nullable<() => void>;
  34175. /**
  34176. * An event triggered after rendering the scene
  34177. */
  34178. onAfterRenderObservable: Observable<Scene>;
  34179. /**
  34180. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34181. */
  34182. onAfterRenderCameraObservable: Observable<Camera>;
  34183. private _onAfterRenderObserver;
  34184. /** Sets a function to be executed after rendering this scene */
  34185. afterRender: Nullable<() => void>;
  34186. /**
  34187. * An event triggered before animating the scene
  34188. */
  34189. onBeforeAnimationsObservable: Observable<Scene>;
  34190. /**
  34191. * An event triggered after animations processing
  34192. */
  34193. onAfterAnimationsObservable: Observable<Scene>;
  34194. /**
  34195. * An event triggered before draw calls are ready to be sent
  34196. */
  34197. onBeforeDrawPhaseObservable: Observable<Scene>;
  34198. /**
  34199. * An event triggered after draw calls have been sent
  34200. */
  34201. onAfterDrawPhaseObservable: Observable<Scene>;
  34202. /**
  34203. * An event triggered when the scene is ready
  34204. */
  34205. onReadyObservable: Observable<Scene>;
  34206. /**
  34207. * An event triggered before rendering a camera
  34208. */
  34209. onBeforeCameraRenderObservable: Observable<Camera>;
  34210. private _onBeforeCameraRenderObserver;
  34211. /** Sets a function to be executed before rendering a camera*/
  34212. beforeCameraRender: () => void;
  34213. /**
  34214. * An event triggered after rendering a camera
  34215. */
  34216. onAfterCameraRenderObservable: Observable<Camera>;
  34217. private _onAfterCameraRenderObserver;
  34218. /** Sets a function to be executed after rendering a camera*/
  34219. afterCameraRender: () => void;
  34220. /**
  34221. * An event triggered when active meshes evaluation is about to start
  34222. */
  34223. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34224. /**
  34225. * An event triggered when active meshes evaluation is done
  34226. */
  34227. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34228. /**
  34229. * An event triggered when particles rendering is about to start
  34230. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34231. */
  34232. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34233. /**
  34234. * An event triggered when particles rendering is done
  34235. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34236. */
  34237. onAfterParticlesRenderingObservable: Observable<Scene>;
  34238. /**
  34239. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34240. */
  34241. onDataLoadedObservable: Observable<Scene>;
  34242. /**
  34243. * An event triggered when a camera is created
  34244. */
  34245. onNewCameraAddedObservable: Observable<Camera>;
  34246. /**
  34247. * An event triggered when a camera is removed
  34248. */
  34249. onCameraRemovedObservable: Observable<Camera>;
  34250. /**
  34251. * An event triggered when a light is created
  34252. */
  34253. onNewLightAddedObservable: Observable<Light>;
  34254. /**
  34255. * An event triggered when a light is removed
  34256. */
  34257. onLightRemovedObservable: Observable<Light>;
  34258. /**
  34259. * An event triggered when a geometry is created
  34260. */
  34261. onNewGeometryAddedObservable: Observable<Geometry>;
  34262. /**
  34263. * An event triggered when a geometry is removed
  34264. */
  34265. onGeometryRemovedObservable: Observable<Geometry>;
  34266. /**
  34267. * An event triggered when a transform node is created
  34268. */
  34269. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34270. /**
  34271. * An event triggered when a transform node is removed
  34272. */
  34273. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34274. /**
  34275. * An event triggered when a mesh is created
  34276. */
  34277. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34278. /**
  34279. * An event triggered when a mesh is removed
  34280. */
  34281. onMeshRemovedObservable: Observable<AbstractMesh>;
  34282. /**
  34283. * An event triggered when a skeleton is created
  34284. */
  34285. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34286. /**
  34287. * An event triggered when a skeleton is removed
  34288. */
  34289. onSkeletonRemovedObservable: Observable<Skeleton>;
  34290. /**
  34291. * An event triggered when a material is created
  34292. */
  34293. onNewMaterialAddedObservable: Observable<Material>;
  34294. /**
  34295. * An event triggered when a material is removed
  34296. */
  34297. onMaterialRemovedObservable: Observable<Material>;
  34298. /**
  34299. * An event triggered when a texture is created
  34300. */
  34301. onNewTextureAddedObservable: Observable<BaseTexture>;
  34302. /**
  34303. * An event triggered when a texture is removed
  34304. */
  34305. onTextureRemovedObservable: Observable<BaseTexture>;
  34306. /**
  34307. * An event triggered when render targets are about to be rendered
  34308. * Can happen multiple times per frame.
  34309. */
  34310. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34311. /**
  34312. * An event triggered when render targets were rendered.
  34313. * Can happen multiple times per frame.
  34314. */
  34315. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34316. /**
  34317. * An event triggered before calculating deterministic simulation step
  34318. */
  34319. onBeforeStepObservable: Observable<Scene>;
  34320. /**
  34321. * An event triggered after calculating deterministic simulation step
  34322. */
  34323. onAfterStepObservable: Observable<Scene>;
  34324. /**
  34325. * An event triggered when the activeCamera property is updated
  34326. */
  34327. onActiveCameraChanged: Observable<Scene>;
  34328. /**
  34329. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34330. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34331. * 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)
  34332. */
  34333. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34334. /**
  34335. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34336. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34337. * 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)
  34338. */
  34339. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34340. /**
  34341. * This Observable will when a mesh has been imported into the scene.
  34342. */
  34343. onMeshImportedObservable: Observable<AbstractMesh>;
  34344. /**
  34345. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34346. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34347. */
  34348. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34349. /** @hidden */
  34350. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34351. /**
  34352. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34353. */
  34354. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34355. /**
  34356. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34357. */
  34358. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34359. /**
  34360. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34361. */
  34362. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34363. /** Callback called when a pointer move is detected */
  34364. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34365. /** Callback called when a pointer down is detected */
  34366. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34367. /** Callback called when a pointer up is detected */
  34368. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34369. /** Callback called when a pointer pick is detected */
  34370. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34371. /**
  34372. * 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).
  34373. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34374. */
  34375. onPrePointerObservable: Observable<PointerInfoPre>;
  34376. /**
  34377. * Observable event triggered each time an input event is received from the rendering canvas
  34378. */
  34379. onPointerObservable: Observable<PointerInfo>;
  34380. /**
  34381. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34382. */
  34383. readonly unTranslatedPointer: Vector2;
  34384. /**
  34385. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34386. */
  34387. static DragMovementThreshold: number;
  34388. /**
  34389. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34390. */
  34391. static LongPressDelay: number;
  34392. /**
  34393. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34394. */
  34395. static DoubleClickDelay: number;
  34396. /** If you need to check double click without raising a single click at first click, enable this flag */
  34397. static ExclusiveDoubleClickMode: boolean;
  34398. /** @hidden */
  34399. _mirroredCameraPosition: Nullable<Vector3>;
  34400. /**
  34401. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34402. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34403. */
  34404. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34405. /**
  34406. * Observable event triggered each time an keyboard event is received from the hosting window
  34407. */
  34408. onKeyboardObservable: Observable<KeyboardInfo>;
  34409. private _useRightHandedSystem;
  34410. /**
  34411. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34412. */
  34413. useRightHandedSystem: boolean;
  34414. private _timeAccumulator;
  34415. private _currentStepId;
  34416. private _currentInternalStep;
  34417. /**
  34418. * Sets the step Id used by deterministic lock step
  34419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34420. * @param newStepId defines the step Id
  34421. */
  34422. setStepId(newStepId: number): void;
  34423. /**
  34424. * Gets the step Id used by deterministic lock step
  34425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34426. * @returns the step Id
  34427. */
  34428. getStepId(): number;
  34429. /**
  34430. * Gets the internal step used by deterministic lock step
  34431. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34432. * @returns the internal step
  34433. */
  34434. getInternalStep(): number;
  34435. private _fogEnabled;
  34436. /**
  34437. * Gets or sets a boolean indicating if fog is enabled on this scene
  34438. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34439. * (Default is true)
  34440. */
  34441. fogEnabled: boolean;
  34442. private _fogMode;
  34443. /**
  34444. * Gets or sets the fog mode to use
  34445. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34446. * | mode | value |
  34447. * | --- | --- |
  34448. * | FOGMODE_NONE | 0 |
  34449. * | FOGMODE_EXP | 1 |
  34450. * | FOGMODE_EXP2 | 2 |
  34451. * | FOGMODE_LINEAR | 3 |
  34452. */
  34453. fogMode: number;
  34454. /**
  34455. * Gets or sets the fog color to use
  34456. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34457. * (Default is Color3(0.2, 0.2, 0.3))
  34458. */
  34459. fogColor: Color3;
  34460. /**
  34461. * Gets or sets the fog density to use
  34462. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34463. * (Default is 0.1)
  34464. */
  34465. fogDensity: number;
  34466. /**
  34467. * Gets or sets the fog start distance to use
  34468. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34469. * (Default is 0)
  34470. */
  34471. fogStart: number;
  34472. /**
  34473. * Gets or sets the fog end distance to use
  34474. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34475. * (Default is 1000)
  34476. */
  34477. fogEnd: number;
  34478. private _shadowsEnabled;
  34479. /**
  34480. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34481. */
  34482. shadowsEnabled: boolean;
  34483. private _lightsEnabled;
  34484. /**
  34485. * Gets or sets a boolean indicating if lights are enabled on this scene
  34486. */
  34487. lightsEnabled: boolean;
  34488. /** All of the active cameras added to this scene. */
  34489. activeCameras: Camera[];
  34490. /** @hidden */
  34491. _activeCamera: Nullable<Camera>;
  34492. /** Gets or sets the current active camera */
  34493. activeCamera: Nullable<Camera>;
  34494. private _defaultMaterial;
  34495. /** The default material used on meshes when no material is affected */
  34496. /** The default material used on meshes when no material is affected */
  34497. defaultMaterial: Material;
  34498. private _texturesEnabled;
  34499. /**
  34500. * Gets or sets a boolean indicating if textures are enabled on this scene
  34501. */
  34502. texturesEnabled: boolean;
  34503. /**
  34504. * Gets or sets a boolean indicating if particles are enabled on this scene
  34505. */
  34506. particlesEnabled: boolean;
  34507. /**
  34508. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34509. */
  34510. spritesEnabled: boolean;
  34511. private _skeletonsEnabled;
  34512. /**
  34513. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34514. */
  34515. skeletonsEnabled: boolean;
  34516. /**
  34517. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34518. */
  34519. lensFlaresEnabled: boolean;
  34520. /**
  34521. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34522. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34523. */
  34524. collisionsEnabled: boolean;
  34525. private _collisionCoordinator;
  34526. /** @hidden */
  34527. readonly collisionCoordinator: ICollisionCoordinator;
  34528. /**
  34529. * Defines the gravity applied to this scene (used only for collisions)
  34530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34531. */
  34532. gravity: Vector3;
  34533. /**
  34534. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34535. */
  34536. postProcessesEnabled: boolean;
  34537. /**
  34538. * The list of postprocesses added to the scene
  34539. */
  34540. postProcesses: PostProcess[];
  34541. /**
  34542. * Gets the current postprocess manager
  34543. */
  34544. postProcessManager: PostProcessManager;
  34545. /**
  34546. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34547. */
  34548. renderTargetsEnabled: boolean;
  34549. /**
  34550. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34551. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34552. */
  34553. dumpNextRenderTargets: boolean;
  34554. /**
  34555. * The list of user defined render targets added to the scene
  34556. */
  34557. customRenderTargets: RenderTargetTexture[];
  34558. /**
  34559. * Defines if texture loading must be delayed
  34560. * If true, textures will only be loaded when they need to be rendered
  34561. */
  34562. useDelayedTextureLoading: boolean;
  34563. /**
  34564. * Gets the list of meshes imported to the scene through SceneLoader
  34565. */
  34566. importedMeshesFiles: String[];
  34567. /**
  34568. * Gets or sets a boolean indicating if probes are enabled on this scene
  34569. */
  34570. probesEnabled: boolean;
  34571. /**
  34572. * Gets or sets the current offline provider to use to store scene data
  34573. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34574. */
  34575. offlineProvider: IOfflineProvider;
  34576. /**
  34577. * Gets or sets the action manager associated with the scene
  34578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34579. */
  34580. actionManager: AbstractActionManager;
  34581. private _meshesForIntersections;
  34582. /**
  34583. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34584. */
  34585. proceduralTexturesEnabled: boolean;
  34586. private _engine;
  34587. private _totalVertices;
  34588. /** @hidden */
  34589. _activeIndices: PerfCounter;
  34590. /** @hidden */
  34591. _activeParticles: PerfCounter;
  34592. /** @hidden */
  34593. _activeBones: PerfCounter;
  34594. private _animationRatio;
  34595. /** @hidden */
  34596. _animationTimeLast: number;
  34597. /** @hidden */
  34598. _animationTime: number;
  34599. /**
  34600. * Gets or sets a general scale for animation speed
  34601. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34602. */
  34603. animationTimeScale: number;
  34604. /** @hidden */
  34605. _cachedMaterial: Nullable<Material>;
  34606. /** @hidden */
  34607. _cachedEffect: Nullable<Effect>;
  34608. /** @hidden */
  34609. _cachedVisibility: Nullable<number>;
  34610. private _renderId;
  34611. private _frameId;
  34612. private _executeWhenReadyTimeoutId;
  34613. private _intermediateRendering;
  34614. private _viewUpdateFlag;
  34615. private _projectionUpdateFlag;
  34616. /** @hidden */
  34617. _toBeDisposed: Nullable<IDisposable>[];
  34618. private _activeRequests;
  34619. /** @hidden */
  34620. _pendingData: any[];
  34621. private _isDisposed;
  34622. /**
  34623. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34624. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34625. */
  34626. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34627. private _activeMeshes;
  34628. private _processedMaterials;
  34629. private _renderTargets;
  34630. /** @hidden */
  34631. _activeParticleSystems: SmartArray<IParticleSystem>;
  34632. private _activeSkeletons;
  34633. private _softwareSkinnedMeshes;
  34634. private _renderingManager;
  34635. /** @hidden */
  34636. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34637. private _transformMatrix;
  34638. private _sceneUbo;
  34639. /** @hidden */
  34640. _viewMatrix: Matrix;
  34641. private _projectionMatrix;
  34642. /** @hidden */
  34643. _forcedViewPosition: Nullable<Vector3>;
  34644. /** @hidden */
  34645. _frustumPlanes: Plane[];
  34646. /**
  34647. * Gets the list of frustum planes (built from the active camera)
  34648. */
  34649. readonly frustumPlanes: Plane[];
  34650. /**
  34651. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34652. * This is useful if there are more lights that the maximum simulteanous authorized
  34653. */
  34654. requireLightSorting: boolean;
  34655. /** @hidden */
  34656. readonly useMaterialMeshMap: boolean;
  34657. /** @hidden */
  34658. readonly useClonedMeshhMap: boolean;
  34659. private _externalData;
  34660. private _uid;
  34661. /**
  34662. * @hidden
  34663. * Backing store of defined scene components.
  34664. */
  34665. _components: ISceneComponent[];
  34666. /**
  34667. * @hidden
  34668. * Backing store of defined scene components.
  34669. */
  34670. _serializableComponents: ISceneSerializableComponent[];
  34671. /**
  34672. * List of components to register on the next registration step.
  34673. */
  34674. private _transientComponents;
  34675. /**
  34676. * Registers the transient components if needed.
  34677. */
  34678. private _registerTransientComponents;
  34679. /**
  34680. * @hidden
  34681. * Add a component to the scene.
  34682. * Note that the ccomponent could be registered on th next frame if this is called after
  34683. * the register component stage.
  34684. * @param component Defines the component to add to the scene
  34685. */
  34686. _addComponent(component: ISceneComponent): void;
  34687. /**
  34688. * @hidden
  34689. * Gets a component from the scene.
  34690. * @param name defines the name of the component to retrieve
  34691. * @returns the component or null if not present
  34692. */
  34693. _getComponent(name: string): Nullable<ISceneComponent>;
  34694. /**
  34695. * @hidden
  34696. * Defines the actions happening before camera updates.
  34697. */
  34698. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34699. /**
  34700. * @hidden
  34701. * Defines the actions happening before clear the canvas.
  34702. */
  34703. _beforeClearStage: Stage<SimpleStageAction>;
  34704. /**
  34705. * @hidden
  34706. * Defines the actions when collecting render targets for the frame.
  34707. */
  34708. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34709. /**
  34710. * @hidden
  34711. * Defines the actions happening for one camera in the frame.
  34712. */
  34713. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34714. /**
  34715. * @hidden
  34716. * Defines the actions happening during the per mesh ready checks.
  34717. */
  34718. _isReadyForMeshStage: Stage<MeshStageAction>;
  34719. /**
  34720. * @hidden
  34721. * Defines the actions happening before evaluate active mesh checks.
  34722. */
  34723. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34724. /**
  34725. * @hidden
  34726. * Defines the actions happening during the evaluate sub mesh checks.
  34727. */
  34728. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34729. /**
  34730. * @hidden
  34731. * Defines the actions happening during the active mesh stage.
  34732. */
  34733. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34734. /**
  34735. * @hidden
  34736. * Defines the actions happening during the per camera render target step.
  34737. */
  34738. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34739. /**
  34740. * @hidden
  34741. * Defines the actions happening just before the active camera is drawing.
  34742. */
  34743. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34744. /**
  34745. * @hidden
  34746. * Defines the actions happening just before a render target is drawing.
  34747. */
  34748. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34749. /**
  34750. * @hidden
  34751. * Defines the actions happening just before a rendering group is drawing.
  34752. */
  34753. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34754. /**
  34755. * @hidden
  34756. * Defines the actions happening just before a mesh is drawing.
  34757. */
  34758. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34759. /**
  34760. * @hidden
  34761. * Defines the actions happening just after a mesh has been drawn.
  34762. */
  34763. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34764. /**
  34765. * @hidden
  34766. * Defines the actions happening just after a rendering group has been drawn.
  34767. */
  34768. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34769. /**
  34770. * @hidden
  34771. * Defines the actions happening just after the active camera has been drawn.
  34772. */
  34773. _afterCameraDrawStage: Stage<CameraStageAction>;
  34774. /**
  34775. * @hidden
  34776. * Defines the actions happening just after a render target has been drawn.
  34777. */
  34778. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34779. /**
  34780. * @hidden
  34781. * Defines the actions happening just after rendering all cameras and computing intersections.
  34782. */
  34783. _afterRenderStage: Stage<SimpleStageAction>;
  34784. /**
  34785. * @hidden
  34786. * Defines the actions happening when a pointer move event happens.
  34787. */
  34788. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34789. /**
  34790. * @hidden
  34791. * Defines the actions happening when a pointer down event happens.
  34792. */
  34793. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34794. /**
  34795. * @hidden
  34796. * Defines the actions happening when a pointer up event happens.
  34797. */
  34798. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34799. /**
  34800. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34801. */
  34802. private geometriesByUniqueId;
  34803. /**
  34804. * Creates a new Scene
  34805. * @param engine defines the engine to use to render this scene
  34806. * @param options defines the scene options
  34807. */
  34808. constructor(engine: Engine, options?: SceneOptions);
  34809. /**
  34810. * Gets a string idenfifying the name of the class
  34811. * @returns "Scene" string
  34812. */
  34813. getClassName(): string;
  34814. private _defaultMeshCandidates;
  34815. /**
  34816. * @hidden
  34817. */
  34818. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34819. private _defaultSubMeshCandidates;
  34820. /**
  34821. * @hidden
  34822. */
  34823. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34824. /**
  34825. * Sets the default candidate providers for the scene.
  34826. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34827. * and getCollidingSubMeshCandidates to their default function
  34828. */
  34829. setDefaultCandidateProviders(): void;
  34830. /**
  34831. * Gets the mesh that is currently under the pointer
  34832. */
  34833. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34834. /**
  34835. * Gets or sets the current on-screen X position of the pointer
  34836. */
  34837. pointerX: number;
  34838. /**
  34839. * Gets or sets the current on-screen Y position of the pointer
  34840. */
  34841. pointerY: number;
  34842. /**
  34843. * Gets the cached material (ie. the latest rendered one)
  34844. * @returns the cached material
  34845. */
  34846. getCachedMaterial(): Nullable<Material>;
  34847. /**
  34848. * Gets the cached effect (ie. the latest rendered one)
  34849. * @returns the cached effect
  34850. */
  34851. getCachedEffect(): Nullable<Effect>;
  34852. /**
  34853. * Gets the cached visibility state (ie. the latest rendered one)
  34854. * @returns the cached visibility state
  34855. */
  34856. getCachedVisibility(): Nullable<number>;
  34857. /**
  34858. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34859. * @param material defines the current material
  34860. * @param effect defines the current effect
  34861. * @param visibility defines the current visibility state
  34862. * @returns true if one parameter is not cached
  34863. */
  34864. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34865. /**
  34866. * Gets the engine associated with the scene
  34867. * @returns an Engine
  34868. */
  34869. getEngine(): Engine;
  34870. /**
  34871. * Gets the total number of vertices rendered per frame
  34872. * @returns the total number of vertices rendered per frame
  34873. */
  34874. getTotalVertices(): number;
  34875. /**
  34876. * Gets the performance counter for total vertices
  34877. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34878. */
  34879. readonly totalVerticesPerfCounter: PerfCounter;
  34880. /**
  34881. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34882. * @returns the total number of active indices rendered per frame
  34883. */
  34884. getActiveIndices(): number;
  34885. /**
  34886. * Gets the performance counter for active indices
  34887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34888. */
  34889. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34890. /**
  34891. * Gets the total number of active particles rendered per frame
  34892. * @returns the total number of active particles rendered per frame
  34893. */
  34894. getActiveParticles(): number;
  34895. /**
  34896. * Gets the performance counter for active particles
  34897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34898. */
  34899. readonly activeParticlesPerfCounter: PerfCounter;
  34900. /**
  34901. * Gets the total number of active bones rendered per frame
  34902. * @returns the total number of active bones rendered per frame
  34903. */
  34904. getActiveBones(): number;
  34905. /**
  34906. * Gets the performance counter for active bones
  34907. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34908. */
  34909. readonly activeBonesPerfCounter: PerfCounter;
  34910. /**
  34911. * Gets the array of active meshes
  34912. * @returns an array of AbstractMesh
  34913. */
  34914. getActiveMeshes(): SmartArray<AbstractMesh>;
  34915. /**
  34916. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34917. * @returns a number
  34918. */
  34919. getAnimationRatio(): number;
  34920. /**
  34921. * Gets an unique Id for the current render phase
  34922. * @returns a number
  34923. */
  34924. getRenderId(): number;
  34925. /**
  34926. * Gets an unique Id for the current frame
  34927. * @returns a number
  34928. */
  34929. getFrameId(): number;
  34930. /** Call this function if you want to manually increment the render Id*/
  34931. incrementRenderId(): void;
  34932. private _createUbo;
  34933. /**
  34934. * Use this method to simulate a pointer move on a mesh
  34935. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34936. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34937. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34938. * @returns the current scene
  34939. */
  34940. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34941. /**
  34942. * Use this method to simulate a pointer down on a mesh
  34943. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34944. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34945. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34946. * @returns the current scene
  34947. */
  34948. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34949. /**
  34950. * Use this method to simulate a pointer up on a mesh
  34951. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34952. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34953. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34954. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34955. * @returns the current scene
  34956. */
  34957. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34958. /**
  34959. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34960. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34961. * @returns true if the pointer was captured
  34962. */
  34963. isPointerCaptured(pointerId?: number): boolean;
  34964. /**
  34965. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34966. * @param attachUp defines if you want to attach events to pointerup
  34967. * @param attachDown defines if you want to attach events to pointerdown
  34968. * @param attachMove defines if you want to attach events to pointermove
  34969. */
  34970. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34971. /** Detaches all event handlers*/
  34972. detachControl(): void;
  34973. /**
  34974. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34975. * Delay loaded resources are not taking in account
  34976. * @return true if all required resources are ready
  34977. */
  34978. isReady(): boolean;
  34979. /** Resets all cached information relative to material (including effect and visibility) */
  34980. resetCachedMaterial(): void;
  34981. /**
  34982. * Registers a function to be called before every frame render
  34983. * @param func defines the function to register
  34984. */
  34985. registerBeforeRender(func: () => void): void;
  34986. /**
  34987. * Unregisters a function called before every frame render
  34988. * @param func defines the function to unregister
  34989. */
  34990. unregisterBeforeRender(func: () => void): void;
  34991. /**
  34992. * Registers a function to be called after every frame render
  34993. * @param func defines the function to register
  34994. */
  34995. registerAfterRender(func: () => void): void;
  34996. /**
  34997. * Unregisters a function called after every frame render
  34998. * @param func defines the function to unregister
  34999. */
  35000. unregisterAfterRender(func: () => void): void;
  35001. private _executeOnceBeforeRender;
  35002. /**
  35003. * The provided function will run before render once and will be disposed afterwards.
  35004. * A timeout delay can be provided so that the function will be executed in N ms.
  35005. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35006. * @param func The function to be executed.
  35007. * @param timeout optional delay in ms
  35008. */
  35009. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35010. /** @hidden */
  35011. _addPendingData(data: any): void;
  35012. /** @hidden */
  35013. _removePendingData(data: any): void;
  35014. /**
  35015. * Returns the number of items waiting to be loaded
  35016. * @returns the number of items waiting to be loaded
  35017. */
  35018. getWaitingItemsCount(): number;
  35019. /**
  35020. * Returns a boolean indicating if the scene is still loading data
  35021. */
  35022. readonly isLoading: boolean;
  35023. /**
  35024. * Registers a function to be executed when the scene is ready
  35025. * @param {Function} func - the function to be executed
  35026. */
  35027. executeWhenReady(func: () => void): void;
  35028. /**
  35029. * Returns a promise that resolves when the scene is ready
  35030. * @returns A promise that resolves when the scene is ready
  35031. */
  35032. whenReadyAsync(): Promise<void>;
  35033. /** @hidden */
  35034. _checkIsReady(): void;
  35035. /**
  35036. * Gets all animatable attached to the scene
  35037. */
  35038. readonly animatables: Animatable[];
  35039. /**
  35040. * Resets the last animation time frame.
  35041. * Useful to override when animations start running when loading a scene for the first time.
  35042. */
  35043. resetLastAnimationTimeFrame(): void;
  35044. /**
  35045. * Gets the current view matrix
  35046. * @returns a Matrix
  35047. */
  35048. getViewMatrix(): Matrix;
  35049. /**
  35050. * Gets the current projection matrix
  35051. * @returns a Matrix
  35052. */
  35053. getProjectionMatrix(): Matrix;
  35054. /**
  35055. * Gets the current transform matrix
  35056. * @returns a Matrix made of View * Projection
  35057. */
  35058. getTransformMatrix(): Matrix;
  35059. /**
  35060. * Sets the current transform matrix
  35061. * @param viewL defines the View matrix to use
  35062. * @param projectionL defines the Projection matrix to use
  35063. * @param viewR defines the right View matrix to use (if provided)
  35064. * @param projectionR defines the right Projection matrix to use (if provided)
  35065. */
  35066. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35067. /**
  35068. * Gets the uniform buffer used to store scene data
  35069. * @returns a UniformBuffer
  35070. */
  35071. getSceneUniformBuffer(): UniformBuffer;
  35072. /**
  35073. * Gets an unique (relatively to the current scene) Id
  35074. * @returns an unique number for the scene
  35075. */
  35076. getUniqueId(): number;
  35077. /**
  35078. * Add a mesh to the list of scene's meshes
  35079. * @param newMesh defines the mesh to add
  35080. * @param recursive if all child meshes should also be added to the scene
  35081. */
  35082. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35083. /**
  35084. * Remove a mesh for the list of scene's meshes
  35085. * @param toRemove defines the mesh to remove
  35086. * @param recursive if all child meshes should also be removed from the scene
  35087. * @returns the index where the mesh was in the mesh list
  35088. */
  35089. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35090. /**
  35091. * Add a transform node to the list of scene's transform nodes
  35092. * @param newTransformNode defines the transform node to add
  35093. */
  35094. addTransformNode(newTransformNode: TransformNode): void;
  35095. /**
  35096. * Remove a transform node for the list of scene's transform nodes
  35097. * @param toRemove defines the transform node to remove
  35098. * @returns the index where the transform node was in the transform node list
  35099. */
  35100. removeTransformNode(toRemove: TransformNode): number;
  35101. /**
  35102. * Remove a skeleton for the list of scene's skeletons
  35103. * @param toRemove defines the skeleton to remove
  35104. * @returns the index where the skeleton was in the skeleton list
  35105. */
  35106. removeSkeleton(toRemove: Skeleton): number;
  35107. /**
  35108. * Remove a morph target for the list of scene's morph targets
  35109. * @param toRemove defines the morph target to remove
  35110. * @returns the index where the morph target was in the morph target list
  35111. */
  35112. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35113. /**
  35114. * Remove a light for the list of scene's lights
  35115. * @param toRemove defines the light to remove
  35116. * @returns the index where the light was in the light list
  35117. */
  35118. removeLight(toRemove: Light): number;
  35119. /**
  35120. * Remove a camera for the list of scene's cameras
  35121. * @param toRemove defines the camera to remove
  35122. * @returns the index where the camera was in the camera list
  35123. */
  35124. removeCamera(toRemove: Camera): number;
  35125. /**
  35126. * Remove a particle system for the list of scene's particle systems
  35127. * @param toRemove defines the particle system to remove
  35128. * @returns the index where the particle system was in the particle system list
  35129. */
  35130. removeParticleSystem(toRemove: IParticleSystem): number;
  35131. /**
  35132. * Remove a animation for the list of scene's animations
  35133. * @param toRemove defines the animation to remove
  35134. * @returns the index where the animation was in the animation list
  35135. */
  35136. removeAnimation(toRemove: Animation): number;
  35137. /**
  35138. * Will stop the animation of the given target
  35139. * @param target - the target
  35140. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35141. * @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)
  35142. */
  35143. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35144. /**
  35145. * Removes the given animation group from this scene.
  35146. * @param toRemove The animation group to remove
  35147. * @returns The index of the removed animation group
  35148. */
  35149. removeAnimationGroup(toRemove: AnimationGroup): number;
  35150. /**
  35151. * Removes the given multi-material from this scene.
  35152. * @param toRemove The multi-material to remove
  35153. * @returns The index of the removed multi-material
  35154. */
  35155. removeMultiMaterial(toRemove: MultiMaterial): number;
  35156. /**
  35157. * Removes the given material from this scene.
  35158. * @param toRemove The material to remove
  35159. * @returns The index of the removed material
  35160. */
  35161. removeMaterial(toRemove: Material): number;
  35162. /**
  35163. * Removes the given action manager from this scene.
  35164. * @param toRemove The action manager to remove
  35165. * @returns The index of the removed action manager
  35166. */
  35167. removeActionManager(toRemove: AbstractActionManager): number;
  35168. /**
  35169. * Removes the given texture from this scene.
  35170. * @param toRemove The texture to remove
  35171. * @returns The index of the removed texture
  35172. */
  35173. removeTexture(toRemove: BaseTexture): number;
  35174. /**
  35175. * Adds the given light to this scene
  35176. * @param newLight The light to add
  35177. */
  35178. addLight(newLight: Light): void;
  35179. /**
  35180. * Sorts the list list based on light priorities
  35181. */
  35182. sortLightsByPriority(): void;
  35183. /**
  35184. * Adds the given camera to this scene
  35185. * @param newCamera The camera to add
  35186. */
  35187. addCamera(newCamera: Camera): void;
  35188. /**
  35189. * Adds the given skeleton to this scene
  35190. * @param newSkeleton The skeleton to add
  35191. */
  35192. addSkeleton(newSkeleton: Skeleton): void;
  35193. /**
  35194. * Adds the given particle system to this scene
  35195. * @param newParticleSystem The particle system to add
  35196. */
  35197. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35198. /**
  35199. * Adds the given animation to this scene
  35200. * @param newAnimation The animation to add
  35201. */
  35202. addAnimation(newAnimation: Animation): void;
  35203. /**
  35204. * Adds the given animation group to this scene.
  35205. * @param newAnimationGroup The animation group to add
  35206. */
  35207. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35208. /**
  35209. * Adds the given multi-material to this scene
  35210. * @param newMultiMaterial The multi-material to add
  35211. */
  35212. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35213. /**
  35214. * Adds the given material to this scene
  35215. * @param newMaterial The material to add
  35216. */
  35217. addMaterial(newMaterial: Material): void;
  35218. /**
  35219. * Adds the given morph target to this scene
  35220. * @param newMorphTargetManager The morph target to add
  35221. */
  35222. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35223. /**
  35224. * Adds the given geometry to this scene
  35225. * @param newGeometry The geometry to add
  35226. */
  35227. addGeometry(newGeometry: Geometry): void;
  35228. /**
  35229. * Adds the given action manager to this scene
  35230. * @param newActionManager The action manager to add
  35231. */
  35232. addActionManager(newActionManager: AbstractActionManager): void;
  35233. /**
  35234. * Adds the given texture to this scene.
  35235. * @param newTexture The texture to add
  35236. */
  35237. addTexture(newTexture: BaseTexture): void;
  35238. /**
  35239. * Switch active camera
  35240. * @param newCamera defines the new active camera
  35241. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35242. */
  35243. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35244. /**
  35245. * sets the active camera of the scene using its ID
  35246. * @param id defines the camera's ID
  35247. * @return the new active camera or null if none found.
  35248. */
  35249. setActiveCameraByID(id: string): Nullable<Camera>;
  35250. /**
  35251. * sets the active camera of the scene using its name
  35252. * @param name defines the camera's name
  35253. * @returns the new active camera or null if none found.
  35254. */
  35255. setActiveCameraByName(name: string): Nullable<Camera>;
  35256. /**
  35257. * get an animation group using its name
  35258. * @param name defines the material's name
  35259. * @return the animation group or null if none found.
  35260. */
  35261. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35262. /**
  35263. * Get a material using its unique id
  35264. * @param uniqueId defines the material's unique id
  35265. * @return the material or null if none found.
  35266. */
  35267. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35268. /**
  35269. * get a material using its id
  35270. * @param id defines the material's ID
  35271. * @return the material or null if none found.
  35272. */
  35273. getMaterialByID(id: string): Nullable<Material>;
  35274. /**
  35275. * Gets a the last added material using a given id
  35276. * @param id defines the material's ID
  35277. * @return the last material with the given id or null if none found.
  35278. */
  35279. getLastMaterialByID(id: string): Nullable<Material>;
  35280. /**
  35281. * Gets a material using its name
  35282. * @param name defines the material's name
  35283. * @return the material or null if none found.
  35284. */
  35285. getMaterialByName(name: string): Nullable<Material>;
  35286. /**
  35287. * Get a texture using its unique id
  35288. * @param uniqueId defines the texture's unique id
  35289. * @return the texture or null if none found.
  35290. */
  35291. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35292. /**
  35293. * Gets a camera using its id
  35294. * @param id defines the id to look for
  35295. * @returns the camera or null if not found
  35296. */
  35297. getCameraByID(id: string): Nullable<Camera>;
  35298. /**
  35299. * Gets a camera using its unique id
  35300. * @param uniqueId defines the unique id to look for
  35301. * @returns the camera or null if not found
  35302. */
  35303. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35304. /**
  35305. * Gets a camera using its name
  35306. * @param name defines the camera's name
  35307. * @return the camera or null if none found.
  35308. */
  35309. getCameraByName(name: string): Nullable<Camera>;
  35310. /**
  35311. * Gets a bone using its id
  35312. * @param id defines the bone's id
  35313. * @return the bone or null if not found
  35314. */
  35315. getBoneByID(id: string): Nullable<Bone>;
  35316. /**
  35317. * Gets a bone using its id
  35318. * @param name defines the bone's name
  35319. * @return the bone or null if not found
  35320. */
  35321. getBoneByName(name: string): Nullable<Bone>;
  35322. /**
  35323. * Gets a light node using its name
  35324. * @param name defines the the light's name
  35325. * @return the light or null if none found.
  35326. */
  35327. getLightByName(name: string): Nullable<Light>;
  35328. /**
  35329. * Gets a light node using its id
  35330. * @param id defines the light's id
  35331. * @return the light or null if none found.
  35332. */
  35333. getLightByID(id: string): Nullable<Light>;
  35334. /**
  35335. * Gets a light node using its scene-generated unique ID
  35336. * @param uniqueId defines the light's unique id
  35337. * @return the light or null if none found.
  35338. */
  35339. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35340. /**
  35341. * Gets a particle system by id
  35342. * @param id defines the particle system id
  35343. * @return the corresponding system or null if none found
  35344. */
  35345. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35346. /**
  35347. * Gets a geometry using its ID
  35348. * @param id defines the geometry's id
  35349. * @return the geometry or null if none found.
  35350. */
  35351. getGeometryByID(id: string): Nullable<Geometry>;
  35352. private _getGeometryByUniqueID;
  35353. /**
  35354. * Add a new geometry to this scene
  35355. * @param geometry defines the geometry to be added to the scene.
  35356. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35357. * @return a boolean defining if the geometry was added or not
  35358. */
  35359. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35360. /**
  35361. * Removes an existing geometry
  35362. * @param geometry defines the geometry to be removed from the scene
  35363. * @return a boolean defining if the geometry was removed or not
  35364. */
  35365. removeGeometry(geometry: Geometry): boolean;
  35366. /**
  35367. * Gets the list of geometries attached to the scene
  35368. * @returns an array of Geometry
  35369. */
  35370. getGeometries(): Geometry[];
  35371. /**
  35372. * Gets the first added mesh found of a given ID
  35373. * @param id defines the id to search for
  35374. * @return the mesh found or null if not found at all
  35375. */
  35376. getMeshByID(id: string): Nullable<AbstractMesh>;
  35377. /**
  35378. * Gets a list of meshes using their id
  35379. * @param id defines the id to search for
  35380. * @returns a list of meshes
  35381. */
  35382. getMeshesByID(id: string): Array<AbstractMesh>;
  35383. /**
  35384. * Gets the first added transform node found of a given ID
  35385. * @param id defines the id to search for
  35386. * @return the found transform node or null if not found at all.
  35387. */
  35388. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35389. /**
  35390. * Gets a transform node with its auto-generated unique id
  35391. * @param uniqueId efines the unique id to search for
  35392. * @return the found transform node or null if not found at all.
  35393. */
  35394. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35395. /**
  35396. * Gets a list of transform nodes using their id
  35397. * @param id defines the id to search for
  35398. * @returns a list of transform nodes
  35399. */
  35400. getTransformNodesByID(id: string): Array<TransformNode>;
  35401. /**
  35402. * Gets a mesh with its auto-generated unique id
  35403. * @param uniqueId defines the unique id to search for
  35404. * @return the found mesh or null if not found at all.
  35405. */
  35406. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35407. /**
  35408. * Gets a the last added mesh using a given id
  35409. * @param id defines the id to search for
  35410. * @return the found mesh or null if not found at all.
  35411. */
  35412. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35413. /**
  35414. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35415. * @param id defines the id to search for
  35416. * @return the found node or null if not found at all
  35417. */
  35418. getLastEntryByID(id: string): Nullable<Node>;
  35419. /**
  35420. * Gets a node (Mesh, Camera, Light) using a given id
  35421. * @param id defines the id to search for
  35422. * @return the found node or null if not found at all
  35423. */
  35424. getNodeByID(id: string): Nullable<Node>;
  35425. /**
  35426. * Gets a node (Mesh, Camera, Light) using a given name
  35427. * @param name defines the name to search for
  35428. * @return the found node or null if not found at all.
  35429. */
  35430. getNodeByName(name: string): Nullable<Node>;
  35431. /**
  35432. * Gets a mesh using a given name
  35433. * @param name defines the name to search for
  35434. * @return the found mesh or null if not found at all.
  35435. */
  35436. getMeshByName(name: string): Nullable<AbstractMesh>;
  35437. /**
  35438. * Gets a transform node using a given name
  35439. * @param name defines the name to search for
  35440. * @return the found transform node or null if not found at all.
  35441. */
  35442. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35443. /**
  35444. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35445. * @param id defines the id to search for
  35446. * @return the found skeleton or null if not found at all.
  35447. */
  35448. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35449. /**
  35450. * Gets a skeleton using a given auto generated unique id
  35451. * @param uniqueId defines the unique id to search for
  35452. * @return the found skeleton or null if not found at all.
  35453. */
  35454. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35455. /**
  35456. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35457. * @param id defines the id to search for
  35458. * @return the found skeleton or null if not found at all.
  35459. */
  35460. getSkeletonById(id: string): Nullable<Skeleton>;
  35461. /**
  35462. * Gets a skeleton using a given name
  35463. * @param name defines the name to search for
  35464. * @return the found skeleton or null if not found at all.
  35465. */
  35466. getSkeletonByName(name: string): Nullable<Skeleton>;
  35467. /**
  35468. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35469. * @param id defines the id to search for
  35470. * @return the found morph target manager or null if not found at all.
  35471. */
  35472. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35473. /**
  35474. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35475. * @param id defines the id to search for
  35476. * @return the found morph target or null if not found at all.
  35477. */
  35478. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35479. /**
  35480. * Gets a boolean indicating if the given mesh is active
  35481. * @param mesh defines the mesh to look for
  35482. * @returns true if the mesh is in the active list
  35483. */
  35484. isActiveMesh(mesh: AbstractMesh): boolean;
  35485. /**
  35486. * Return a unique id as a string which can serve as an identifier for the scene
  35487. */
  35488. readonly uid: string;
  35489. /**
  35490. * Add an externaly attached data from its key.
  35491. * This method call will fail and return false, if such key already exists.
  35492. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35493. * @param key the unique key that identifies the data
  35494. * @param data the data object to associate to the key for this Engine instance
  35495. * @return true if no such key were already present and the data was added successfully, false otherwise
  35496. */
  35497. addExternalData<T>(key: string, data: T): boolean;
  35498. /**
  35499. * Get an externaly attached data from its key
  35500. * @param key the unique key that identifies the data
  35501. * @return the associated data, if present (can be null), or undefined if not present
  35502. */
  35503. getExternalData<T>(key: string): Nullable<T>;
  35504. /**
  35505. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35506. * @param key the unique key that identifies the data
  35507. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35508. * @return the associated data, can be null if the factory returned null.
  35509. */
  35510. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35511. /**
  35512. * Remove an externaly attached data from the Engine instance
  35513. * @param key the unique key that identifies the data
  35514. * @return true if the data was successfully removed, false if it doesn't exist
  35515. */
  35516. removeExternalData(key: string): boolean;
  35517. private _evaluateSubMesh;
  35518. /**
  35519. * Clear the processed materials smart array preventing retention point in material dispose.
  35520. */
  35521. freeProcessedMaterials(): void;
  35522. private _preventFreeActiveMeshesAndRenderingGroups;
  35523. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35524. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35525. * when disposing several meshes in a row or a hierarchy of meshes.
  35526. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35527. */
  35528. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35529. /**
  35530. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35531. */
  35532. freeActiveMeshes(): void;
  35533. /**
  35534. * Clear the info related to rendering groups preventing retention points during dispose.
  35535. */
  35536. freeRenderingGroups(): void;
  35537. /** @hidden */
  35538. _isInIntermediateRendering(): boolean;
  35539. /**
  35540. * Lambda returning the list of potentially active meshes.
  35541. */
  35542. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35543. /**
  35544. * Lambda returning the list of potentially active sub meshes.
  35545. */
  35546. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35547. /**
  35548. * Lambda returning the list of potentially intersecting sub meshes.
  35549. */
  35550. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35551. /**
  35552. * Lambda returning the list of potentially colliding sub meshes.
  35553. */
  35554. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35555. private _activeMeshesFrozen;
  35556. /**
  35557. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35558. * @returns the current scene
  35559. */
  35560. freezeActiveMeshes(): Scene;
  35561. /**
  35562. * Use this function to restart evaluating active meshes on every frame
  35563. * @returns the current scene
  35564. */
  35565. unfreezeActiveMeshes(): Scene;
  35566. private _evaluateActiveMeshes;
  35567. private _activeMesh;
  35568. /**
  35569. * Update the transform matrix to update from the current active camera
  35570. * @param force defines a boolean used to force the update even if cache is up to date
  35571. */
  35572. updateTransformMatrix(force?: boolean): void;
  35573. private _bindFrameBuffer;
  35574. /** @hidden */
  35575. _allowPostProcessClearColor: boolean;
  35576. /** @hidden */
  35577. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35578. private _processSubCameras;
  35579. private _checkIntersections;
  35580. /** @hidden */
  35581. _advancePhysicsEngineStep(step: number): void;
  35582. /**
  35583. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35584. */
  35585. getDeterministicFrameTime: () => number;
  35586. /** @hidden */
  35587. _animate(): void;
  35588. /** Execute all animations (for a frame) */
  35589. animate(): void;
  35590. /**
  35591. * Render the scene
  35592. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35593. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35594. */
  35595. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35596. /**
  35597. * Freeze all materials
  35598. * A frozen material will not be updatable but should be faster to render
  35599. */
  35600. freezeMaterials(): void;
  35601. /**
  35602. * Unfreeze all materials
  35603. * A frozen material will not be updatable but should be faster to render
  35604. */
  35605. unfreezeMaterials(): void;
  35606. /**
  35607. * Releases all held ressources
  35608. */
  35609. dispose(): void;
  35610. /**
  35611. * Gets if the scene is already disposed
  35612. */
  35613. readonly isDisposed: boolean;
  35614. /**
  35615. * Call this function to reduce memory footprint of the scene.
  35616. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35617. */
  35618. clearCachedVertexData(): void;
  35619. /**
  35620. * This function will remove the local cached buffer data from texture.
  35621. * It will save memory but will prevent the texture from being rebuilt
  35622. */
  35623. cleanCachedTextureBuffer(): void;
  35624. /**
  35625. * Get the world extend vectors with an optional filter
  35626. *
  35627. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35628. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35629. */
  35630. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35631. min: Vector3;
  35632. max: Vector3;
  35633. };
  35634. /**
  35635. * Creates a ray that can be used to pick in the scene
  35636. * @param x defines the x coordinate of the origin (on-screen)
  35637. * @param y defines the y coordinate of the origin (on-screen)
  35638. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35639. * @param camera defines the camera to use for the picking
  35640. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35641. * @returns a Ray
  35642. */
  35643. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35644. /**
  35645. * Creates a ray that can be used to pick in the scene
  35646. * @param x defines the x coordinate of the origin (on-screen)
  35647. * @param y defines the y coordinate of the origin (on-screen)
  35648. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35649. * @param result defines the ray where to store the picking ray
  35650. * @param camera defines the camera to use for the picking
  35651. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35652. * @returns the current scene
  35653. */
  35654. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35655. /**
  35656. * Creates a ray that can be used to pick in the scene
  35657. * @param x defines the x coordinate of the origin (on-screen)
  35658. * @param y defines the y coordinate of the origin (on-screen)
  35659. * @param camera defines the camera to use for the picking
  35660. * @returns a Ray
  35661. */
  35662. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35663. /**
  35664. * Creates a ray that can be used to pick in the scene
  35665. * @param x defines the x coordinate of the origin (on-screen)
  35666. * @param y defines the y coordinate of the origin (on-screen)
  35667. * @param result defines the ray where to store the picking ray
  35668. * @param camera defines the camera to use for the picking
  35669. * @returns the current scene
  35670. */
  35671. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35672. /** Launch a ray to try to pick a mesh in the scene
  35673. * @param x position on screen
  35674. * @param y position on screen
  35675. * @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
  35676. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35677. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35678. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35679. * @returns a PickingInfo
  35680. */
  35681. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35682. /** Use the given ray to pick a mesh in the scene
  35683. * @param ray The ray to use to pick meshes
  35684. * @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
  35685. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35687. * @returns a PickingInfo
  35688. */
  35689. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35690. /**
  35691. * Launch a ray to try to pick a mesh in the scene
  35692. * @param x X position on screen
  35693. * @param y Y position on screen
  35694. * @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
  35695. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35696. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35697. * @returns an array of PickingInfo
  35698. */
  35699. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35700. /**
  35701. * Launch a ray to try to pick a mesh in the scene
  35702. * @param ray Ray to use
  35703. * @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
  35704. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35705. * @returns an array of PickingInfo
  35706. */
  35707. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35708. /**
  35709. * Force the value of meshUnderPointer
  35710. * @param mesh defines the mesh to use
  35711. */
  35712. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35713. /**
  35714. * Gets the mesh under the pointer
  35715. * @returns a Mesh or null if no mesh is under the pointer
  35716. */
  35717. getPointerOverMesh(): Nullable<AbstractMesh>;
  35718. /** @hidden */
  35719. _rebuildGeometries(): void;
  35720. /** @hidden */
  35721. _rebuildTextures(): void;
  35722. private _getByTags;
  35723. /**
  35724. * Get a list of meshes by tags
  35725. * @param tagsQuery defines the tags query to use
  35726. * @param forEach defines a predicate used to filter results
  35727. * @returns an array of Mesh
  35728. */
  35729. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35730. /**
  35731. * Get a list of cameras by tags
  35732. * @param tagsQuery defines the tags query to use
  35733. * @param forEach defines a predicate used to filter results
  35734. * @returns an array of Camera
  35735. */
  35736. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35737. /**
  35738. * Get a list of lights by tags
  35739. * @param tagsQuery defines the tags query to use
  35740. * @param forEach defines a predicate used to filter results
  35741. * @returns an array of Light
  35742. */
  35743. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35744. /**
  35745. * Get a list of materials by tags
  35746. * @param tagsQuery defines the tags query to use
  35747. * @param forEach defines a predicate used to filter results
  35748. * @returns an array of Material
  35749. */
  35750. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35751. /**
  35752. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35753. * This allowed control for front to back rendering or reversly depending of the special needs.
  35754. *
  35755. * @param renderingGroupId The rendering group id corresponding to its index
  35756. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35757. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35758. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35759. */
  35760. 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;
  35761. /**
  35762. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35763. *
  35764. * @param renderingGroupId The rendering group id corresponding to its index
  35765. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35766. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35767. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35768. */
  35769. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35770. /**
  35771. * Gets the current auto clear configuration for one rendering group of the rendering
  35772. * manager.
  35773. * @param index the rendering group index to get the information for
  35774. * @returns The auto clear setup for the requested rendering group
  35775. */
  35776. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35777. private _blockMaterialDirtyMechanism;
  35778. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35779. blockMaterialDirtyMechanism: boolean;
  35780. /**
  35781. * Will flag all materials as dirty to trigger new shader compilation
  35782. * @param flag defines the flag used to specify which material part must be marked as dirty
  35783. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35784. */
  35785. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35786. /** @hidden */
  35787. _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;
  35788. /** @hidden */
  35789. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35790. }
  35791. }
  35792. declare module "babylonjs/assetContainer" {
  35793. import { AbstractScene } from "babylonjs/abstractScene";
  35794. import { Scene } from "babylonjs/scene";
  35795. import { Mesh } from "babylonjs/Meshes/mesh";
  35796. /**
  35797. * Set of assets to keep when moving a scene into an asset container.
  35798. */
  35799. export class KeepAssets extends AbstractScene {
  35800. }
  35801. /**
  35802. * Container with a set of assets that can be added or removed from a scene.
  35803. */
  35804. export class AssetContainer extends AbstractScene {
  35805. /**
  35806. * The scene the AssetContainer belongs to.
  35807. */
  35808. scene: Scene;
  35809. /**
  35810. * Instantiates an AssetContainer.
  35811. * @param scene The scene the AssetContainer belongs to.
  35812. */
  35813. constructor(scene: Scene);
  35814. /**
  35815. * Adds all the assets from the container to the scene.
  35816. */
  35817. addAllToScene(): void;
  35818. /**
  35819. * Removes all the assets in the container from the scene
  35820. */
  35821. removeAllFromScene(): void;
  35822. /**
  35823. * Disposes all the assets in the container
  35824. */
  35825. dispose(): void;
  35826. private _moveAssets;
  35827. /**
  35828. * Removes all the assets contained in the scene and adds them to the container.
  35829. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35830. */
  35831. moveAllFromScene(keepAssets?: KeepAssets): void;
  35832. /**
  35833. * 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.
  35834. * @returns the root mesh
  35835. */
  35836. createRootMesh(): Mesh;
  35837. }
  35838. }
  35839. declare module "babylonjs/abstractScene" {
  35840. import { Scene } from "babylonjs/scene";
  35841. import { Nullable } from "babylonjs/types";
  35842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35843. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35844. import { Geometry } from "babylonjs/Meshes/geometry";
  35845. import { Skeleton } from "babylonjs/Bones/skeleton";
  35846. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35847. import { AssetContainer } from "babylonjs/assetContainer";
  35848. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35849. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35850. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35851. import { Material } from "babylonjs/Materials/material";
  35852. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35853. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35854. import { Camera } from "babylonjs/Cameras/camera";
  35855. import { Light } from "babylonjs/Lights/light";
  35856. import { Node } from "babylonjs/node";
  35857. import { Animation } from "babylonjs/Animations/animation";
  35858. /**
  35859. * Defines how the parser contract is defined.
  35860. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35861. */
  35862. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35863. /**
  35864. * Defines how the individual parser contract is defined.
  35865. * These parser can parse an individual asset
  35866. */
  35867. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35868. /**
  35869. * Base class of the scene acting as a container for the different elements composing a scene.
  35870. * This class is dynamically extended by the different components of the scene increasing
  35871. * flexibility and reducing coupling
  35872. */
  35873. export abstract class AbstractScene {
  35874. /**
  35875. * Stores the list of available parsers in the application.
  35876. */
  35877. private static _BabylonFileParsers;
  35878. /**
  35879. * Stores the list of available individual parsers in the application.
  35880. */
  35881. private static _IndividualBabylonFileParsers;
  35882. /**
  35883. * Adds a parser in the list of available ones
  35884. * @param name Defines the name of the parser
  35885. * @param parser Defines the parser to add
  35886. */
  35887. static AddParser(name: string, parser: BabylonFileParser): void;
  35888. /**
  35889. * Gets a general parser from the list of avaialble ones
  35890. * @param name Defines the name of the parser
  35891. * @returns the requested parser or null
  35892. */
  35893. static GetParser(name: string): Nullable<BabylonFileParser>;
  35894. /**
  35895. * Adds n individual parser in the list of available ones
  35896. * @param name Defines the name of the parser
  35897. * @param parser Defines the parser to add
  35898. */
  35899. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35900. /**
  35901. * Gets an individual parser from the list of avaialble ones
  35902. * @param name Defines the name of the parser
  35903. * @returns the requested parser or null
  35904. */
  35905. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35906. /**
  35907. * Parser json data and populate both a scene and its associated container object
  35908. * @param jsonData Defines the data to parse
  35909. * @param scene Defines the scene to parse the data for
  35910. * @param container Defines the container attached to the parsing sequence
  35911. * @param rootUrl Defines the root url of the data
  35912. */
  35913. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35914. /**
  35915. * Gets the list of root nodes (ie. nodes with no parent)
  35916. */
  35917. rootNodes: Node[];
  35918. /** All of the cameras added to this scene
  35919. * @see http://doc.babylonjs.com/babylon101/cameras
  35920. */
  35921. cameras: Camera[];
  35922. /**
  35923. * All of the lights added to this scene
  35924. * @see http://doc.babylonjs.com/babylon101/lights
  35925. */
  35926. lights: Light[];
  35927. /**
  35928. * All of the (abstract) meshes added to this scene
  35929. */
  35930. meshes: AbstractMesh[];
  35931. /**
  35932. * The list of skeletons added to the scene
  35933. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35934. */
  35935. skeletons: Skeleton[];
  35936. /**
  35937. * All of the particle systems added to this scene
  35938. * @see http://doc.babylonjs.com/babylon101/particles
  35939. */
  35940. particleSystems: IParticleSystem[];
  35941. /**
  35942. * Gets a list of Animations associated with the scene
  35943. */
  35944. animations: Animation[];
  35945. /**
  35946. * All of the animation groups added to this scene
  35947. * @see http://doc.babylonjs.com/how_to/group
  35948. */
  35949. animationGroups: AnimationGroup[];
  35950. /**
  35951. * All of the multi-materials added to this scene
  35952. * @see http://doc.babylonjs.com/how_to/multi_materials
  35953. */
  35954. multiMaterials: MultiMaterial[];
  35955. /**
  35956. * All of the materials added to this scene
  35957. * In the context of a Scene, it is not supposed to be modified manually.
  35958. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35959. * Note also that the order of the Material wihin the array is not significant and might change.
  35960. * @see http://doc.babylonjs.com/babylon101/materials
  35961. */
  35962. materials: Material[];
  35963. /**
  35964. * The list of morph target managers added to the scene
  35965. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35966. */
  35967. morphTargetManagers: MorphTargetManager[];
  35968. /**
  35969. * The list of geometries used in the scene.
  35970. */
  35971. geometries: Geometry[];
  35972. /**
  35973. * All of the tranform nodes added to this scene
  35974. * In the context of a Scene, it is not supposed to be modified manually.
  35975. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35976. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35977. * @see http://doc.babylonjs.com/how_to/transformnode
  35978. */
  35979. transformNodes: TransformNode[];
  35980. /**
  35981. * ActionManagers available on the scene.
  35982. */
  35983. actionManagers: AbstractActionManager[];
  35984. /**
  35985. * Textures to keep.
  35986. */
  35987. textures: BaseTexture[];
  35988. /**
  35989. * Environment texture for the scene
  35990. */
  35991. environmentTexture: Nullable<BaseTexture>;
  35992. }
  35993. }
  35994. declare module "babylonjs/Audio/sound" {
  35995. import { Observable } from "babylonjs/Misc/observable";
  35996. import { Vector3 } from "babylonjs/Maths/math.vector";
  35997. import { Nullable } from "babylonjs/types";
  35998. import { Scene } from "babylonjs/scene";
  35999. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36000. /**
  36001. * Interface used to define options for Sound class
  36002. */
  36003. export interface ISoundOptions {
  36004. /**
  36005. * Does the sound autoplay once loaded.
  36006. */
  36007. autoplay?: boolean;
  36008. /**
  36009. * Does the sound loop after it finishes playing once.
  36010. */
  36011. loop?: boolean;
  36012. /**
  36013. * Sound's volume
  36014. */
  36015. volume?: number;
  36016. /**
  36017. * Is it a spatial sound?
  36018. */
  36019. spatialSound?: boolean;
  36020. /**
  36021. * Maximum distance to hear that sound
  36022. */
  36023. maxDistance?: number;
  36024. /**
  36025. * Uses user defined attenuation function
  36026. */
  36027. useCustomAttenuation?: boolean;
  36028. /**
  36029. * Define the roll off factor of spatial sounds.
  36030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36031. */
  36032. rolloffFactor?: number;
  36033. /**
  36034. * Define the reference distance the sound should be heard perfectly.
  36035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36036. */
  36037. refDistance?: number;
  36038. /**
  36039. * Define the distance attenuation model the sound will follow.
  36040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36041. */
  36042. distanceModel?: string;
  36043. /**
  36044. * Defines the playback speed (1 by default)
  36045. */
  36046. playbackRate?: number;
  36047. /**
  36048. * Defines if the sound is from a streaming source
  36049. */
  36050. streaming?: boolean;
  36051. /**
  36052. * Defines an optional length (in seconds) inside the sound file
  36053. */
  36054. length?: number;
  36055. /**
  36056. * Defines an optional offset (in seconds) inside the sound file
  36057. */
  36058. offset?: number;
  36059. /**
  36060. * If true, URLs will not be required to state the audio file codec to use.
  36061. */
  36062. skipCodecCheck?: boolean;
  36063. }
  36064. /**
  36065. * Defines a sound that can be played in the application.
  36066. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36068. */
  36069. export class Sound {
  36070. /**
  36071. * The name of the sound in the scene.
  36072. */
  36073. name: string;
  36074. /**
  36075. * Does the sound autoplay once loaded.
  36076. */
  36077. autoplay: boolean;
  36078. /**
  36079. * Does the sound loop after it finishes playing once.
  36080. */
  36081. loop: boolean;
  36082. /**
  36083. * Does the sound use a custom attenuation curve to simulate the falloff
  36084. * happening when the source gets further away from the camera.
  36085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36086. */
  36087. useCustomAttenuation: boolean;
  36088. /**
  36089. * The sound track id this sound belongs to.
  36090. */
  36091. soundTrackId: number;
  36092. /**
  36093. * Is this sound currently played.
  36094. */
  36095. isPlaying: boolean;
  36096. /**
  36097. * Is this sound currently paused.
  36098. */
  36099. isPaused: boolean;
  36100. /**
  36101. * Does this sound enables spatial sound.
  36102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36103. */
  36104. spatialSound: boolean;
  36105. /**
  36106. * Define the reference distance the sound should be heard perfectly.
  36107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36108. */
  36109. refDistance: number;
  36110. /**
  36111. * Define the roll off factor of spatial sounds.
  36112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36113. */
  36114. rolloffFactor: number;
  36115. /**
  36116. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36118. */
  36119. maxDistance: number;
  36120. /**
  36121. * Define the distance attenuation model the sound will follow.
  36122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36123. */
  36124. distanceModel: string;
  36125. /**
  36126. * @hidden
  36127. * Back Compat
  36128. **/
  36129. onended: () => any;
  36130. /**
  36131. * Observable event when the current playing sound finishes.
  36132. */
  36133. onEndedObservable: Observable<Sound>;
  36134. private _panningModel;
  36135. private _playbackRate;
  36136. private _streaming;
  36137. private _startTime;
  36138. private _startOffset;
  36139. private _position;
  36140. /** @hidden */
  36141. _positionInEmitterSpace: boolean;
  36142. private _localDirection;
  36143. private _volume;
  36144. private _isReadyToPlay;
  36145. private _isDirectional;
  36146. private _readyToPlayCallback;
  36147. private _audioBuffer;
  36148. private _soundSource;
  36149. private _streamingSource;
  36150. private _soundPanner;
  36151. private _soundGain;
  36152. private _inputAudioNode;
  36153. private _outputAudioNode;
  36154. private _coneInnerAngle;
  36155. private _coneOuterAngle;
  36156. private _coneOuterGain;
  36157. private _scene;
  36158. private _connectedTransformNode;
  36159. private _customAttenuationFunction;
  36160. private _registerFunc;
  36161. private _isOutputConnected;
  36162. private _htmlAudioElement;
  36163. private _urlType;
  36164. private _length?;
  36165. private _offset?;
  36166. /** @hidden */
  36167. static _SceneComponentInitialization: (scene: Scene) => void;
  36168. /**
  36169. * Create a sound and attach it to a scene
  36170. * @param name Name of your sound
  36171. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36172. * @param scene defines the scene the sound belongs to
  36173. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36174. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36175. */
  36176. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36177. /**
  36178. * Release the sound and its associated resources
  36179. */
  36180. dispose(): void;
  36181. /**
  36182. * Gets if the sounds is ready to be played or not.
  36183. * @returns true if ready, otherwise false
  36184. */
  36185. isReady(): boolean;
  36186. private _soundLoaded;
  36187. /**
  36188. * Sets the data of the sound from an audiobuffer
  36189. * @param audioBuffer The audioBuffer containing the data
  36190. */
  36191. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36192. /**
  36193. * Updates the current sounds options such as maxdistance, loop...
  36194. * @param options A JSON object containing values named as the object properties
  36195. */
  36196. updateOptions(options: ISoundOptions): void;
  36197. private _createSpatialParameters;
  36198. private _updateSpatialParameters;
  36199. /**
  36200. * Switch the panning model to HRTF:
  36201. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36203. */
  36204. switchPanningModelToHRTF(): void;
  36205. /**
  36206. * Switch the panning model to Equal Power:
  36207. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36209. */
  36210. switchPanningModelToEqualPower(): void;
  36211. private _switchPanningModel;
  36212. /**
  36213. * Connect this sound to a sound track audio node like gain...
  36214. * @param soundTrackAudioNode the sound track audio node to connect to
  36215. */
  36216. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36217. /**
  36218. * Transform this sound into a directional source
  36219. * @param coneInnerAngle Size of the inner cone in degree
  36220. * @param coneOuterAngle Size of the outer cone in degree
  36221. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36222. */
  36223. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36224. /**
  36225. * Gets or sets the inner angle for the directional cone.
  36226. */
  36227. /**
  36228. * Gets or sets the inner angle for the directional cone.
  36229. */
  36230. directionalConeInnerAngle: number;
  36231. /**
  36232. * Gets or sets the outer angle for the directional cone.
  36233. */
  36234. /**
  36235. * Gets or sets the outer angle for the directional cone.
  36236. */
  36237. directionalConeOuterAngle: number;
  36238. /**
  36239. * Sets the position of the emitter if spatial sound is enabled
  36240. * @param newPosition Defines the new posisiton
  36241. */
  36242. setPosition(newPosition: Vector3): void;
  36243. /**
  36244. * Sets the local direction of the emitter if spatial sound is enabled
  36245. * @param newLocalDirection Defines the new local direction
  36246. */
  36247. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36248. private _updateDirection;
  36249. /** @hidden */
  36250. updateDistanceFromListener(): void;
  36251. /**
  36252. * Sets a new custom attenuation function for the sound.
  36253. * @param callback Defines the function used for the attenuation
  36254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36255. */
  36256. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36257. /**
  36258. * Play the sound
  36259. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36260. * @param offset (optional) Start the sound at a specific time in seconds
  36261. * @param length (optional) Sound duration (in seconds)
  36262. */
  36263. play(time?: number, offset?: number, length?: number): void;
  36264. private _onended;
  36265. /**
  36266. * Stop the sound
  36267. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36268. */
  36269. stop(time?: number): void;
  36270. /**
  36271. * Put the sound in pause
  36272. */
  36273. pause(): void;
  36274. /**
  36275. * Sets a dedicated volume for this sounds
  36276. * @param newVolume Define the new volume of the sound
  36277. * @param time Define time for gradual change to new volume
  36278. */
  36279. setVolume(newVolume: number, time?: number): void;
  36280. /**
  36281. * Set the sound play back rate
  36282. * @param newPlaybackRate Define the playback rate the sound should be played at
  36283. */
  36284. setPlaybackRate(newPlaybackRate: number): void;
  36285. /**
  36286. * Gets the volume of the sound.
  36287. * @returns the volume of the sound
  36288. */
  36289. getVolume(): number;
  36290. /**
  36291. * Attach the sound to a dedicated mesh
  36292. * @param transformNode The transform node to connect the sound with
  36293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36294. */
  36295. attachToMesh(transformNode: TransformNode): void;
  36296. /**
  36297. * Detach the sound from the previously attached mesh
  36298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36299. */
  36300. detachFromMesh(): void;
  36301. private _onRegisterAfterWorldMatrixUpdate;
  36302. /**
  36303. * Clone the current sound in the scene.
  36304. * @returns the new sound clone
  36305. */
  36306. clone(): Nullable<Sound>;
  36307. /**
  36308. * Gets the current underlying audio buffer containing the data
  36309. * @returns the audio buffer
  36310. */
  36311. getAudioBuffer(): Nullable<AudioBuffer>;
  36312. /**
  36313. * Serializes the Sound in a JSON representation
  36314. * @returns the JSON representation of the sound
  36315. */
  36316. serialize(): any;
  36317. /**
  36318. * Parse a JSON representation of a sound to innstantiate in a given scene
  36319. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36320. * @param scene Define the scene the new parsed sound should be created in
  36321. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36322. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36323. * @returns the newly parsed sound
  36324. */
  36325. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36326. }
  36327. }
  36328. declare module "babylonjs/Actions/directAudioActions" {
  36329. import { Action } from "babylonjs/Actions/action";
  36330. import { Condition } from "babylonjs/Actions/condition";
  36331. import { Sound } from "babylonjs/Audio/sound";
  36332. /**
  36333. * This defines an action helpful to play a defined sound on a triggered action.
  36334. */
  36335. export class PlaySoundAction extends Action {
  36336. private _sound;
  36337. /**
  36338. * Instantiate the action
  36339. * @param triggerOptions defines the trigger options
  36340. * @param sound defines the sound to play
  36341. * @param condition defines the trigger related conditions
  36342. */
  36343. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36344. /** @hidden */
  36345. _prepare(): void;
  36346. /**
  36347. * Execute the action and play the sound.
  36348. */
  36349. execute(): void;
  36350. /**
  36351. * Serializes the actions and its related information.
  36352. * @param parent defines the object to serialize in
  36353. * @returns the serialized object
  36354. */
  36355. serialize(parent: any): any;
  36356. }
  36357. /**
  36358. * This defines an action helpful to stop a defined sound on a triggered action.
  36359. */
  36360. export class StopSoundAction extends Action {
  36361. private _sound;
  36362. /**
  36363. * Instantiate the action
  36364. * @param triggerOptions defines the trigger options
  36365. * @param sound defines the sound to stop
  36366. * @param condition defines the trigger related conditions
  36367. */
  36368. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36369. /** @hidden */
  36370. _prepare(): void;
  36371. /**
  36372. * Execute the action and stop the sound.
  36373. */
  36374. execute(): void;
  36375. /**
  36376. * Serializes the actions and its related information.
  36377. * @param parent defines the object to serialize in
  36378. * @returns the serialized object
  36379. */
  36380. serialize(parent: any): any;
  36381. }
  36382. }
  36383. declare module "babylonjs/Actions/interpolateValueAction" {
  36384. import { Action } from "babylonjs/Actions/action";
  36385. import { Condition } from "babylonjs/Actions/condition";
  36386. import { Observable } from "babylonjs/Misc/observable";
  36387. /**
  36388. * This defines an action responsible to change the value of a property
  36389. * by interpolating between its current value and the newly set one once triggered.
  36390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36391. */
  36392. export class InterpolateValueAction extends Action {
  36393. /**
  36394. * Defines the path of the property where the value should be interpolated
  36395. */
  36396. propertyPath: string;
  36397. /**
  36398. * Defines the target value at the end of the interpolation.
  36399. */
  36400. value: any;
  36401. /**
  36402. * Defines the time it will take for the property to interpolate to the value.
  36403. */
  36404. duration: number;
  36405. /**
  36406. * Defines if the other scene animations should be stopped when the action has been triggered
  36407. */
  36408. stopOtherAnimations?: boolean;
  36409. /**
  36410. * Defines a callback raised once the interpolation animation has been done.
  36411. */
  36412. onInterpolationDone?: () => void;
  36413. /**
  36414. * Observable triggered once the interpolation animation has been done.
  36415. */
  36416. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36417. private _target;
  36418. private _effectiveTarget;
  36419. private _property;
  36420. /**
  36421. * Instantiate the action
  36422. * @param triggerOptions defines the trigger options
  36423. * @param target defines the object containing the value to interpolate
  36424. * @param propertyPath defines the path to the property in the target object
  36425. * @param value defines the target value at the end of the interpolation
  36426. * @param duration deines the time it will take for the property to interpolate to the value.
  36427. * @param condition defines the trigger related conditions
  36428. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36429. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36430. */
  36431. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36432. /** @hidden */
  36433. _prepare(): void;
  36434. /**
  36435. * Execute the action starts the value interpolation.
  36436. */
  36437. execute(): void;
  36438. /**
  36439. * Serializes the actions and its related information.
  36440. * @param parent defines the object to serialize in
  36441. * @returns the serialized object
  36442. */
  36443. serialize(parent: any): any;
  36444. }
  36445. }
  36446. declare module "babylonjs/Actions/index" {
  36447. export * from "babylonjs/Actions/abstractActionManager";
  36448. export * from "babylonjs/Actions/action";
  36449. export * from "babylonjs/Actions/actionEvent";
  36450. export * from "babylonjs/Actions/actionManager";
  36451. export * from "babylonjs/Actions/condition";
  36452. export * from "babylonjs/Actions/directActions";
  36453. export * from "babylonjs/Actions/directAudioActions";
  36454. export * from "babylonjs/Actions/interpolateValueAction";
  36455. }
  36456. declare module "babylonjs/Animations/index" {
  36457. export * from "babylonjs/Animations/animatable";
  36458. export * from "babylonjs/Animations/animation";
  36459. export * from "babylonjs/Animations/animationGroup";
  36460. export * from "babylonjs/Animations/animationPropertiesOverride";
  36461. export * from "babylonjs/Animations/easing";
  36462. export * from "babylonjs/Animations/runtimeAnimation";
  36463. export * from "babylonjs/Animations/animationEvent";
  36464. export * from "babylonjs/Animations/animationGroup";
  36465. export * from "babylonjs/Animations/animationKey";
  36466. export * from "babylonjs/Animations/animationRange";
  36467. export * from "babylonjs/Animations/animatable.interface";
  36468. }
  36469. declare module "babylonjs/Audio/soundTrack" {
  36470. import { Sound } from "babylonjs/Audio/sound";
  36471. import { Analyser } from "babylonjs/Audio/analyser";
  36472. import { Scene } from "babylonjs/scene";
  36473. /**
  36474. * Options allowed during the creation of a sound track.
  36475. */
  36476. export interface ISoundTrackOptions {
  36477. /**
  36478. * The volume the sound track should take during creation
  36479. */
  36480. volume?: number;
  36481. /**
  36482. * Define if the sound track is the main sound track of the scene
  36483. */
  36484. mainTrack?: boolean;
  36485. }
  36486. /**
  36487. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36488. * It will be also used in a future release to apply effects on a specific track.
  36489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36490. */
  36491. export class SoundTrack {
  36492. /**
  36493. * The unique identifier of the sound track in the scene.
  36494. */
  36495. id: number;
  36496. /**
  36497. * The list of sounds included in the sound track.
  36498. */
  36499. soundCollection: Array<Sound>;
  36500. private _outputAudioNode;
  36501. private _scene;
  36502. private _isMainTrack;
  36503. private _connectedAnalyser;
  36504. private _options;
  36505. private _isInitialized;
  36506. /**
  36507. * Creates a new sound track.
  36508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36509. * @param scene Define the scene the sound track belongs to
  36510. * @param options
  36511. */
  36512. constructor(scene: Scene, options?: ISoundTrackOptions);
  36513. private _initializeSoundTrackAudioGraph;
  36514. /**
  36515. * Release the sound track and its associated resources
  36516. */
  36517. dispose(): void;
  36518. /**
  36519. * Adds a sound to this sound track
  36520. * @param sound define the cound to add
  36521. * @ignoreNaming
  36522. */
  36523. AddSound(sound: Sound): void;
  36524. /**
  36525. * Removes a sound to this sound track
  36526. * @param sound define the cound to remove
  36527. * @ignoreNaming
  36528. */
  36529. RemoveSound(sound: Sound): void;
  36530. /**
  36531. * Set a global volume for the full sound track.
  36532. * @param newVolume Define the new volume of the sound track
  36533. */
  36534. setVolume(newVolume: number): void;
  36535. /**
  36536. * Switch the panning model to HRTF:
  36537. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36539. */
  36540. switchPanningModelToHRTF(): void;
  36541. /**
  36542. * Switch the panning model to Equal Power:
  36543. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36545. */
  36546. switchPanningModelToEqualPower(): void;
  36547. /**
  36548. * Connect the sound track to an audio analyser allowing some amazing
  36549. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36551. * @param analyser The analyser to connect to the engine
  36552. */
  36553. connectToAnalyser(analyser: Analyser): void;
  36554. }
  36555. }
  36556. declare module "babylonjs/Audio/audioSceneComponent" {
  36557. import { Sound } from "babylonjs/Audio/sound";
  36558. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36559. import { Nullable } from "babylonjs/types";
  36560. import { Vector3 } from "babylonjs/Maths/math.vector";
  36561. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36562. import { Scene } from "babylonjs/scene";
  36563. import { AbstractScene } from "babylonjs/abstractScene";
  36564. import "babylonjs/Audio/audioEngine";
  36565. module "babylonjs/abstractScene" {
  36566. interface AbstractScene {
  36567. /**
  36568. * The list of sounds used in the scene.
  36569. */
  36570. sounds: Nullable<Array<Sound>>;
  36571. }
  36572. }
  36573. module "babylonjs/scene" {
  36574. interface Scene {
  36575. /**
  36576. * @hidden
  36577. * Backing field
  36578. */
  36579. _mainSoundTrack: SoundTrack;
  36580. /**
  36581. * The main sound track played by the scene.
  36582. * It cotains your primary collection of sounds.
  36583. */
  36584. mainSoundTrack: SoundTrack;
  36585. /**
  36586. * The list of sound tracks added to the scene
  36587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36588. */
  36589. soundTracks: Nullable<Array<SoundTrack>>;
  36590. /**
  36591. * Gets a sound using a given name
  36592. * @param name defines the name to search for
  36593. * @return the found sound or null if not found at all.
  36594. */
  36595. getSoundByName(name: string): Nullable<Sound>;
  36596. /**
  36597. * Gets or sets if audio support is enabled
  36598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36599. */
  36600. audioEnabled: boolean;
  36601. /**
  36602. * Gets or sets if audio will be output to headphones
  36603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36604. */
  36605. headphone: boolean;
  36606. /**
  36607. * Gets or sets custom audio listener position provider
  36608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36609. */
  36610. audioListenerPositionProvider: Nullable<() => Vector3>;
  36611. }
  36612. }
  36613. /**
  36614. * Defines the sound scene component responsible to manage any sounds
  36615. * in a given scene.
  36616. */
  36617. export class AudioSceneComponent implements ISceneSerializableComponent {
  36618. /**
  36619. * The component name helpfull to identify the component in the list of scene components.
  36620. */
  36621. readonly name: string;
  36622. /**
  36623. * The scene the component belongs to.
  36624. */
  36625. scene: Scene;
  36626. private _audioEnabled;
  36627. /**
  36628. * Gets whether audio is enabled or not.
  36629. * Please use related enable/disable method to switch state.
  36630. */
  36631. readonly audioEnabled: boolean;
  36632. private _headphone;
  36633. /**
  36634. * Gets whether audio is outputing to headphone or not.
  36635. * Please use the according Switch methods to change output.
  36636. */
  36637. readonly headphone: boolean;
  36638. private _audioListenerPositionProvider;
  36639. /**
  36640. * Gets the current audio listener position provider
  36641. */
  36642. /**
  36643. * Sets a custom listener position for all sounds in the scene
  36644. * By default, this is the position of the first active camera
  36645. */
  36646. audioListenerPositionProvider: Nullable<() => Vector3>;
  36647. /**
  36648. * Creates a new instance of the component for the given scene
  36649. * @param scene Defines the scene to register the component in
  36650. */
  36651. constructor(scene: Scene);
  36652. /**
  36653. * Registers the component in a given scene
  36654. */
  36655. register(): void;
  36656. /**
  36657. * Rebuilds the elements related to this component in case of
  36658. * context lost for instance.
  36659. */
  36660. rebuild(): void;
  36661. /**
  36662. * Serializes the component data to the specified json object
  36663. * @param serializationObject The object to serialize to
  36664. */
  36665. serialize(serializationObject: any): void;
  36666. /**
  36667. * Adds all the elements from the container to the scene
  36668. * @param container the container holding the elements
  36669. */
  36670. addFromContainer(container: AbstractScene): void;
  36671. /**
  36672. * Removes all the elements in the container from the scene
  36673. * @param container contains the elements to remove
  36674. * @param dispose if the removed element should be disposed (default: false)
  36675. */
  36676. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36677. /**
  36678. * Disposes the component and the associated ressources.
  36679. */
  36680. dispose(): void;
  36681. /**
  36682. * Disables audio in the associated scene.
  36683. */
  36684. disableAudio(): void;
  36685. /**
  36686. * Enables audio in the associated scene.
  36687. */
  36688. enableAudio(): void;
  36689. /**
  36690. * Switch audio to headphone output.
  36691. */
  36692. switchAudioModeForHeadphones(): void;
  36693. /**
  36694. * Switch audio to normal speakers.
  36695. */
  36696. switchAudioModeForNormalSpeakers(): void;
  36697. private _afterRender;
  36698. }
  36699. }
  36700. declare module "babylonjs/Audio/weightedsound" {
  36701. import { Sound } from "babylonjs/Audio/sound";
  36702. /**
  36703. * Wraps one or more Sound objects and selects one with random weight for playback.
  36704. */
  36705. export class WeightedSound {
  36706. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36707. loop: boolean;
  36708. private _coneInnerAngle;
  36709. private _coneOuterAngle;
  36710. private _volume;
  36711. /** A Sound is currently playing. */
  36712. isPlaying: boolean;
  36713. /** A Sound is currently paused. */
  36714. isPaused: boolean;
  36715. private _sounds;
  36716. private _weights;
  36717. private _currentIndex?;
  36718. /**
  36719. * Creates a new WeightedSound from the list of sounds given.
  36720. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36721. * @param sounds Array of Sounds that will be selected from.
  36722. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36723. */
  36724. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36725. /**
  36726. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36727. */
  36728. /**
  36729. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36730. */
  36731. directionalConeInnerAngle: number;
  36732. /**
  36733. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36734. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36735. */
  36736. /**
  36737. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36738. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36739. */
  36740. directionalConeOuterAngle: number;
  36741. /**
  36742. * Playback volume.
  36743. */
  36744. /**
  36745. * Playback volume.
  36746. */
  36747. volume: number;
  36748. private _onended;
  36749. /**
  36750. * Suspend playback
  36751. */
  36752. pause(): void;
  36753. /**
  36754. * Stop playback
  36755. */
  36756. stop(): void;
  36757. /**
  36758. * Start playback.
  36759. * @param startOffset Position the clip head at a specific time in seconds.
  36760. */
  36761. play(startOffset?: number): void;
  36762. }
  36763. }
  36764. declare module "babylonjs/Audio/index" {
  36765. export * from "babylonjs/Audio/analyser";
  36766. export * from "babylonjs/Audio/audioEngine";
  36767. export * from "babylonjs/Audio/audioSceneComponent";
  36768. export * from "babylonjs/Audio/sound";
  36769. export * from "babylonjs/Audio/soundTrack";
  36770. export * from "babylonjs/Audio/weightedsound";
  36771. }
  36772. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36773. import { Behavior } from "babylonjs/Behaviors/behavior";
  36774. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36775. import { BackEase } from "babylonjs/Animations/easing";
  36776. /**
  36777. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36778. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36779. */
  36780. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36781. /**
  36782. * Gets the name of the behavior.
  36783. */
  36784. readonly name: string;
  36785. /**
  36786. * The easing function used by animations
  36787. */
  36788. static EasingFunction: BackEase;
  36789. /**
  36790. * The easing mode used by animations
  36791. */
  36792. static EasingMode: number;
  36793. /**
  36794. * The duration of the animation, in milliseconds
  36795. */
  36796. transitionDuration: number;
  36797. /**
  36798. * Length of the distance animated by the transition when lower radius is reached
  36799. */
  36800. lowerRadiusTransitionRange: number;
  36801. /**
  36802. * Length of the distance animated by the transition when upper radius is reached
  36803. */
  36804. upperRadiusTransitionRange: number;
  36805. private _autoTransitionRange;
  36806. /**
  36807. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36808. */
  36809. /**
  36810. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36811. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36812. */
  36813. autoTransitionRange: boolean;
  36814. private _attachedCamera;
  36815. private _onAfterCheckInputsObserver;
  36816. private _onMeshTargetChangedObserver;
  36817. /**
  36818. * Initializes the behavior.
  36819. */
  36820. init(): void;
  36821. /**
  36822. * Attaches the behavior to its arc rotate camera.
  36823. * @param camera Defines the camera to attach the behavior to
  36824. */
  36825. attach(camera: ArcRotateCamera): void;
  36826. /**
  36827. * Detaches the behavior from its current arc rotate camera.
  36828. */
  36829. detach(): void;
  36830. private _radiusIsAnimating;
  36831. private _radiusBounceTransition;
  36832. private _animatables;
  36833. private _cachedWheelPrecision;
  36834. /**
  36835. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36836. * @param radiusLimit The limit to check against.
  36837. * @return Bool to indicate if at limit.
  36838. */
  36839. private _isRadiusAtLimit;
  36840. /**
  36841. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36842. * @param radiusDelta The delta by which to animate to. Can be negative.
  36843. */
  36844. private _applyBoundRadiusAnimation;
  36845. /**
  36846. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36847. */
  36848. protected _clearAnimationLocks(): void;
  36849. /**
  36850. * Stops and removes all animations that have been applied to the camera
  36851. */
  36852. stopAllAnimations(): void;
  36853. }
  36854. }
  36855. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36856. import { Behavior } from "babylonjs/Behaviors/behavior";
  36857. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36858. import { ExponentialEase } from "babylonjs/Animations/easing";
  36859. import { Nullable } from "babylonjs/types";
  36860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36861. import { Vector3 } from "babylonjs/Maths/math.vector";
  36862. /**
  36863. * 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.
  36864. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36865. */
  36866. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36867. /**
  36868. * Gets the name of the behavior.
  36869. */
  36870. readonly name: string;
  36871. private _mode;
  36872. private _radiusScale;
  36873. private _positionScale;
  36874. private _defaultElevation;
  36875. private _elevationReturnTime;
  36876. private _elevationReturnWaitTime;
  36877. private _zoomStopsAnimation;
  36878. private _framingTime;
  36879. /**
  36880. * The easing function used by animations
  36881. */
  36882. static EasingFunction: ExponentialEase;
  36883. /**
  36884. * The easing mode used by animations
  36885. */
  36886. static EasingMode: number;
  36887. /**
  36888. * Sets the current mode used by the behavior
  36889. */
  36890. /**
  36891. * Gets current mode used by the behavior.
  36892. */
  36893. mode: number;
  36894. /**
  36895. * Sets the scale applied to the radius (1 by default)
  36896. */
  36897. /**
  36898. * Gets the scale applied to the radius
  36899. */
  36900. radiusScale: number;
  36901. /**
  36902. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36903. */
  36904. /**
  36905. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36906. */
  36907. positionScale: number;
  36908. /**
  36909. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36910. * behaviour is triggered, in radians.
  36911. */
  36912. /**
  36913. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36914. * behaviour is triggered, in radians.
  36915. */
  36916. defaultElevation: number;
  36917. /**
  36918. * Sets the time (in milliseconds) taken to return to the default beta position.
  36919. * Negative value indicates camera should not return to default.
  36920. */
  36921. /**
  36922. * Gets the time (in milliseconds) taken to return to the default beta position.
  36923. * Negative value indicates camera should not return to default.
  36924. */
  36925. elevationReturnTime: number;
  36926. /**
  36927. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36928. */
  36929. /**
  36930. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36931. */
  36932. elevationReturnWaitTime: number;
  36933. /**
  36934. * Sets the flag that indicates if user zooming should stop animation.
  36935. */
  36936. /**
  36937. * Gets the flag that indicates if user zooming should stop animation.
  36938. */
  36939. zoomStopsAnimation: boolean;
  36940. /**
  36941. * Sets the transition time when framing the mesh, in milliseconds
  36942. */
  36943. /**
  36944. * Gets the transition time when framing the mesh, in milliseconds
  36945. */
  36946. framingTime: number;
  36947. /**
  36948. * Define if the behavior should automatically change the configured
  36949. * camera limits and sensibilities.
  36950. */
  36951. autoCorrectCameraLimitsAndSensibility: boolean;
  36952. private _onPrePointerObservableObserver;
  36953. private _onAfterCheckInputsObserver;
  36954. private _onMeshTargetChangedObserver;
  36955. private _attachedCamera;
  36956. private _isPointerDown;
  36957. private _lastInteractionTime;
  36958. /**
  36959. * Initializes the behavior.
  36960. */
  36961. init(): void;
  36962. /**
  36963. * Attaches the behavior to its arc rotate camera.
  36964. * @param camera Defines the camera to attach the behavior to
  36965. */
  36966. attach(camera: ArcRotateCamera): void;
  36967. /**
  36968. * Detaches the behavior from its current arc rotate camera.
  36969. */
  36970. detach(): void;
  36971. private _animatables;
  36972. private _betaIsAnimating;
  36973. private _betaTransition;
  36974. private _radiusTransition;
  36975. private _vectorTransition;
  36976. /**
  36977. * Targets the given mesh and updates zoom level accordingly.
  36978. * @param mesh The mesh to target.
  36979. * @param radius Optional. If a cached radius position already exists, overrides default.
  36980. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36981. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36982. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36983. */
  36984. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36985. /**
  36986. * Targets the given mesh with its children and updates zoom level accordingly.
  36987. * @param mesh The mesh to target.
  36988. * @param radius Optional. If a cached radius position already exists, overrides default.
  36989. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36990. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36991. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36992. */
  36993. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36994. /**
  36995. * Targets the given meshes with their children and updates zoom level accordingly.
  36996. * @param meshes The mesh to target.
  36997. * @param radius Optional. If a cached radius position already exists, overrides default.
  36998. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36999. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37000. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37001. */
  37002. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37003. /**
  37004. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37005. * @param minimumWorld Determines the smaller position of the bounding box extend
  37006. * @param maximumWorld Determines the bigger position of the bounding box extend
  37007. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37008. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37009. */
  37010. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37011. /**
  37012. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37013. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37014. * frustum width.
  37015. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37016. * to fully enclose the mesh in the viewing frustum.
  37017. */
  37018. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37019. /**
  37020. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37021. * is automatically returned to its default position (expected to be above ground plane).
  37022. */
  37023. private _maintainCameraAboveGround;
  37024. /**
  37025. * Returns the frustum slope based on the canvas ratio and camera FOV
  37026. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37027. */
  37028. private _getFrustumSlope;
  37029. /**
  37030. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37031. */
  37032. private _clearAnimationLocks;
  37033. /**
  37034. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37035. */
  37036. private _applyUserInteraction;
  37037. /**
  37038. * Stops and removes all animations that have been applied to the camera
  37039. */
  37040. stopAllAnimations(): void;
  37041. /**
  37042. * Gets a value indicating if the user is moving the camera
  37043. */
  37044. readonly isUserIsMoving: boolean;
  37045. /**
  37046. * The camera can move all the way towards the mesh.
  37047. */
  37048. static IgnoreBoundsSizeMode: number;
  37049. /**
  37050. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37051. */
  37052. static FitFrustumSidesMode: number;
  37053. }
  37054. }
  37055. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37056. import { Nullable } from "babylonjs/types";
  37057. import { Camera } from "babylonjs/Cameras/camera";
  37058. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37059. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37060. /**
  37061. * Base class for Camera Pointer Inputs.
  37062. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37063. * for example usage.
  37064. */
  37065. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37066. /**
  37067. * Defines the camera the input is attached to.
  37068. */
  37069. abstract camera: Camera;
  37070. /**
  37071. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37072. */
  37073. protected _altKey: boolean;
  37074. protected _ctrlKey: boolean;
  37075. protected _metaKey: boolean;
  37076. protected _shiftKey: boolean;
  37077. /**
  37078. * Which mouse buttons were pressed at time of last mouse event.
  37079. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37080. */
  37081. protected _buttonsPressed: number;
  37082. /**
  37083. * Defines the buttons associated with the input to handle camera move.
  37084. */
  37085. buttons: number[];
  37086. /**
  37087. * Attach the input controls to a specific dom element to get the input from.
  37088. * @param element Defines the element the controls should be listened from
  37089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37090. */
  37091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37092. /**
  37093. * Detach the current controls from the specified dom element.
  37094. * @param element Defines the element to stop listening the inputs from
  37095. */
  37096. detachControl(element: Nullable<HTMLElement>): void;
  37097. /**
  37098. * Gets the class name of the current input.
  37099. * @returns the class name
  37100. */
  37101. getClassName(): string;
  37102. /**
  37103. * Get the friendly name associated with the input class.
  37104. * @returns the input friendly name
  37105. */
  37106. getSimpleName(): string;
  37107. /**
  37108. * Called on pointer POINTERDOUBLETAP event.
  37109. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37110. */
  37111. protected onDoubleTap(type: string): void;
  37112. /**
  37113. * Called on pointer POINTERMOVE event if only a single touch is active.
  37114. * Override this method to provide functionality.
  37115. */
  37116. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37117. /**
  37118. * Called on pointer POINTERMOVE event if multiple touches are active.
  37119. * Override this method to provide functionality.
  37120. */
  37121. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37122. /**
  37123. * Called on JS contextmenu event.
  37124. * Override this method to provide functionality.
  37125. */
  37126. protected onContextMenu(evt: PointerEvent): void;
  37127. /**
  37128. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37129. * press.
  37130. * Override this method to provide functionality.
  37131. */
  37132. protected onButtonDown(evt: PointerEvent): void;
  37133. /**
  37134. * Called each time a new POINTERUP event occurs. Ie, for each button
  37135. * release.
  37136. * Override this method to provide functionality.
  37137. */
  37138. protected onButtonUp(evt: PointerEvent): void;
  37139. /**
  37140. * Called when window becomes inactive.
  37141. * Override this method to provide functionality.
  37142. */
  37143. protected onLostFocus(): void;
  37144. private _pointerInput;
  37145. private _observer;
  37146. private _onLostFocus;
  37147. private pointA;
  37148. private pointB;
  37149. }
  37150. }
  37151. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37152. import { Nullable } from "babylonjs/types";
  37153. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37154. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37155. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37156. /**
  37157. * Manage the pointers inputs to control an arc rotate camera.
  37158. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37159. */
  37160. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37161. /**
  37162. * Defines the camera the input is attached to.
  37163. */
  37164. camera: ArcRotateCamera;
  37165. /**
  37166. * Gets the class name of the current input.
  37167. * @returns the class name
  37168. */
  37169. getClassName(): string;
  37170. /**
  37171. * Defines the buttons associated with the input to handle camera move.
  37172. */
  37173. buttons: number[];
  37174. /**
  37175. * Defines the pointer angular sensibility along the X axis or how fast is
  37176. * the camera rotating.
  37177. */
  37178. angularSensibilityX: number;
  37179. /**
  37180. * Defines the pointer angular sensibility along the Y axis or how fast is
  37181. * the camera rotating.
  37182. */
  37183. angularSensibilityY: number;
  37184. /**
  37185. * Defines the pointer pinch precision or how fast is the camera zooming.
  37186. */
  37187. pinchPrecision: number;
  37188. /**
  37189. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37190. * from 0.
  37191. * It defines the percentage of current camera.radius to use as delta when
  37192. * pinch zoom is used.
  37193. */
  37194. pinchDeltaPercentage: number;
  37195. /**
  37196. * Defines the pointer panning sensibility or how fast is the camera moving.
  37197. */
  37198. panningSensibility: number;
  37199. /**
  37200. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37201. */
  37202. multiTouchPanning: boolean;
  37203. /**
  37204. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37205. * zoom (pinch) through multitouch.
  37206. */
  37207. multiTouchPanAndZoom: boolean;
  37208. /**
  37209. * Revers pinch action direction.
  37210. */
  37211. pinchInwards: boolean;
  37212. private _isPanClick;
  37213. private _twoFingerActivityCount;
  37214. private _isPinching;
  37215. /**
  37216. * Called on pointer POINTERMOVE event if only a single touch is active.
  37217. */
  37218. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37219. /**
  37220. * Called on pointer POINTERDOUBLETAP event.
  37221. */
  37222. protected onDoubleTap(type: string): void;
  37223. /**
  37224. * Called on pointer POINTERMOVE event if multiple touches are active.
  37225. */
  37226. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37227. /**
  37228. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37229. * press.
  37230. */
  37231. protected onButtonDown(evt: PointerEvent): void;
  37232. /**
  37233. * Called each time a new POINTERUP event occurs. Ie, for each button
  37234. * release.
  37235. */
  37236. protected onButtonUp(evt: PointerEvent): void;
  37237. /**
  37238. * Called when window becomes inactive.
  37239. */
  37240. protected onLostFocus(): void;
  37241. }
  37242. }
  37243. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37244. import { Nullable } from "babylonjs/types";
  37245. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37246. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37247. /**
  37248. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37250. */
  37251. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37252. /**
  37253. * Defines the camera the input is attached to.
  37254. */
  37255. camera: ArcRotateCamera;
  37256. /**
  37257. * Defines the list of key codes associated with the up action (increase alpha)
  37258. */
  37259. keysUp: number[];
  37260. /**
  37261. * Defines the list of key codes associated with the down action (decrease alpha)
  37262. */
  37263. keysDown: number[];
  37264. /**
  37265. * Defines the list of key codes associated with the left action (increase beta)
  37266. */
  37267. keysLeft: number[];
  37268. /**
  37269. * Defines the list of key codes associated with the right action (decrease beta)
  37270. */
  37271. keysRight: number[];
  37272. /**
  37273. * Defines the list of key codes associated with the reset action.
  37274. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37275. */
  37276. keysReset: number[];
  37277. /**
  37278. * Defines the panning sensibility of the inputs.
  37279. * (How fast is the camera paning)
  37280. */
  37281. panningSensibility: number;
  37282. /**
  37283. * Defines the zooming sensibility of the inputs.
  37284. * (How fast is the camera zooming)
  37285. */
  37286. zoomingSensibility: number;
  37287. /**
  37288. * Defines wether maintaining the alt key down switch the movement mode from
  37289. * orientation to zoom.
  37290. */
  37291. useAltToZoom: boolean;
  37292. /**
  37293. * Rotation speed of the camera
  37294. */
  37295. angularSpeed: number;
  37296. private _keys;
  37297. private _ctrlPressed;
  37298. private _altPressed;
  37299. private _onCanvasBlurObserver;
  37300. private _onKeyboardObserver;
  37301. private _engine;
  37302. private _scene;
  37303. /**
  37304. * Attach the input controls to a specific dom element to get the input from.
  37305. * @param element Defines the element the controls should be listened from
  37306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37307. */
  37308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37309. /**
  37310. * Detach the current controls from the specified dom element.
  37311. * @param element Defines the element to stop listening the inputs from
  37312. */
  37313. detachControl(element: Nullable<HTMLElement>): void;
  37314. /**
  37315. * Update the current camera state depending on the inputs that have been used this frame.
  37316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37317. */
  37318. checkInputs(): void;
  37319. /**
  37320. * Gets the class name of the current intput.
  37321. * @returns the class name
  37322. */
  37323. getClassName(): string;
  37324. /**
  37325. * Get the friendly name associated with the input class.
  37326. * @returns the input friendly name
  37327. */
  37328. getSimpleName(): string;
  37329. }
  37330. }
  37331. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37332. import { Nullable } from "babylonjs/types";
  37333. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37334. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37335. /**
  37336. * Manage the mouse wheel inputs to control an arc rotate camera.
  37337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37338. */
  37339. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37340. /**
  37341. * Defines the camera the input is attached to.
  37342. */
  37343. camera: ArcRotateCamera;
  37344. /**
  37345. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37346. */
  37347. wheelPrecision: number;
  37348. /**
  37349. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37350. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37351. */
  37352. wheelDeltaPercentage: number;
  37353. private _wheel;
  37354. private _observer;
  37355. private computeDeltaFromMouseWheelLegacyEvent;
  37356. /**
  37357. * Attach the input controls to a specific dom element to get the input from.
  37358. * @param element Defines the element the controls should be listened from
  37359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37360. */
  37361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37362. /**
  37363. * Detach the current controls from the specified dom element.
  37364. * @param element Defines the element to stop listening the inputs from
  37365. */
  37366. detachControl(element: Nullable<HTMLElement>): void;
  37367. /**
  37368. * Gets the class name of the current intput.
  37369. * @returns the class name
  37370. */
  37371. getClassName(): string;
  37372. /**
  37373. * Get the friendly name associated with the input class.
  37374. * @returns the input friendly name
  37375. */
  37376. getSimpleName(): string;
  37377. }
  37378. }
  37379. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37381. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37382. /**
  37383. * Default Inputs manager for the ArcRotateCamera.
  37384. * It groups all the default supported inputs for ease of use.
  37385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37386. */
  37387. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37388. /**
  37389. * Instantiates a new ArcRotateCameraInputsManager.
  37390. * @param camera Defines the camera the inputs belong to
  37391. */
  37392. constructor(camera: ArcRotateCamera);
  37393. /**
  37394. * Add mouse wheel input support to the input manager.
  37395. * @returns the current input manager
  37396. */
  37397. addMouseWheel(): ArcRotateCameraInputsManager;
  37398. /**
  37399. * Add pointers input support to the input manager.
  37400. * @returns the current input manager
  37401. */
  37402. addPointers(): ArcRotateCameraInputsManager;
  37403. /**
  37404. * Add keyboard input support to the input manager.
  37405. * @returns the current input manager
  37406. */
  37407. addKeyboard(): ArcRotateCameraInputsManager;
  37408. }
  37409. }
  37410. declare module "babylonjs/Cameras/arcRotateCamera" {
  37411. import { Observable } from "babylonjs/Misc/observable";
  37412. import { Nullable } from "babylonjs/types";
  37413. import { Scene } from "babylonjs/scene";
  37414. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37416. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37417. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37418. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37419. import { Camera } from "babylonjs/Cameras/camera";
  37420. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37421. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37422. import { Collider } from "babylonjs/Collisions/collider";
  37423. /**
  37424. * This represents an orbital type of camera.
  37425. *
  37426. * 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.
  37427. * 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.
  37428. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37429. */
  37430. export class ArcRotateCamera extends TargetCamera {
  37431. /**
  37432. * Defines the rotation angle of the camera along the longitudinal axis.
  37433. */
  37434. alpha: number;
  37435. /**
  37436. * Defines the rotation angle of the camera along the latitudinal axis.
  37437. */
  37438. beta: number;
  37439. /**
  37440. * Defines the radius of the camera from it s target point.
  37441. */
  37442. radius: number;
  37443. protected _target: Vector3;
  37444. protected _targetHost: Nullable<AbstractMesh>;
  37445. /**
  37446. * Defines the target point of the camera.
  37447. * The camera looks towards it form the radius distance.
  37448. */
  37449. target: Vector3;
  37450. /**
  37451. * Define the current local position of the camera in the scene
  37452. */
  37453. position: Vector3;
  37454. protected _upVector: Vector3;
  37455. protected _upToYMatrix: Matrix;
  37456. protected _YToUpMatrix: Matrix;
  37457. /**
  37458. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37459. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37460. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37461. */
  37462. upVector: Vector3;
  37463. /**
  37464. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37465. */
  37466. setMatUp(): void;
  37467. /**
  37468. * Current inertia value on the longitudinal axis.
  37469. * The bigger this number the longer it will take for the camera to stop.
  37470. */
  37471. inertialAlphaOffset: number;
  37472. /**
  37473. * Current inertia value on the latitudinal axis.
  37474. * The bigger this number the longer it will take for the camera to stop.
  37475. */
  37476. inertialBetaOffset: number;
  37477. /**
  37478. * Current inertia value on the radius axis.
  37479. * The bigger this number the longer it will take for the camera to stop.
  37480. */
  37481. inertialRadiusOffset: number;
  37482. /**
  37483. * Minimum allowed angle on the longitudinal axis.
  37484. * This can help limiting how the Camera is able to move in the scene.
  37485. */
  37486. lowerAlphaLimit: Nullable<number>;
  37487. /**
  37488. * Maximum allowed angle on the longitudinal axis.
  37489. * This can help limiting how the Camera is able to move in the scene.
  37490. */
  37491. upperAlphaLimit: Nullable<number>;
  37492. /**
  37493. * Minimum allowed angle on the latitudinal axis.
  37494. * This can help limiting how the Camera is able to move in the scene.
  37495. */
  37496. lowerBetaLimit: number;
  37497. /**
  37498. * Maximum allowed angle on the latitudinal axis.
  37499. * This can help limiting how the Camera is able to move in the scene.
  37500. */
  37501. upperBetaLimit: number;
  37502. /**
  37503. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37504. * This can help limiting how the Camera is able to move in the scene.
  37505. */
  37506. lowerRadiusLimit: Nullable<number>;
  37507. /**
  37508. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37509. * This can help limiting how the Camera is able to move in the scene.
  37510. */
  37511. upperRadiusLimit: Nullable<number>;
  37512. /**
  37513. * Defines the current inertia value used during panning of the camera along the X axis.
  37514. */
  37515. inertialPanningX: number;
  37516. /**
  37517. * Defines the current inertia value used during panning of the camera along the Y axis.
  37518. */
  37519. inertialPanningY: number;
  37520. /**
  37521. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37522. * Basically if your fingers moves away from more than this distance you will be considered
  37523. * in pinch mode.
  37524. */
  37525. pinchToPanMaxDistance: number;
  37526. /**
  37527. * Defines the maximum distance the camera can pan.
  37528. * This could help keeping the cammera always in your scene.
  37529. */
  37530. panningDistanceLimit: Nullable<number>;
  37531. /**
  37532. * Defines the target of the camera before paning.
  37533. */
  37534. panningOriginTarget: Vector3;
  37535. /**
  37536. * Defines the value of the inertia used during panning.
  37537. * 0 would mean stop inertia and one would mean no decelleration at all.
  37538. */
  37539. panningInertia: number;
  37540. /**
  37541. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37542. */
  37543. angularSensibilityX: number;
  37544. /**
  37545. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37546. */
  37547. angularSensibilityY: number;
  37548. /**
  37549. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37550. */
  37551. pinchPrecision: number;
  37552. /**
  37553. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37554. * It will be used instead of pinchDeltaPrecision if different from 0.
  37555. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37556. */
  37557. pinchDeltaPercentage: number;
  37558. /**
  37559. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37560. */
  37561. panningSensibility: number;
  37562. /**
  37563. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37564. */
  37565. keysUp: number[];
  37566. /**
  37567. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37568. */
  37569. keysDown: number[];
  37570. /**
  37571. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37572. */
  37573. keysLeft: number[];
  37574. /**
  37575. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37576. */
  37577. keysRight: number[];
  37578. /**
  37579. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37580. */
  37581. wheelPrecision: number;
  37582. /**
  37583. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37584. * It will be used instead of pinchDeltaPrecision if different from 0.
  37585. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37586. */
  37587. wheelDeltaPercentage: number;
  37588. /**
  37589. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37590. */
  37591. zoomOnFactor: number;
  37592. /**
  37593. * Defines a screen offset for the camera position.
  37594. */
  37595. targetScreenOffset: Vector2;
  37596. /**
  37597. * Allows the camera to be completely reversed.
  37598. * If false the camera can not arrive upside down.
  37599. */
  37600. allowUpsideDown: boolean;
  37601. /**
  37602. * Define if double tap/click is used to restore the previously saved state of the camera.
  37603. */
  37604. useInputToRestoreState: boolean;
  37605. /** @hidden */
  37606. _viewMatrix: Matrix;
  37607. /** @hidden */
  37608. _useCtrlForPanning: boolean;
  37609. /** @hidden */
  37610. _panningMouseButton: number;
  37611. /**
  37612. * Defines the input associated to the camera.
  37613. */
  37614. inputs: ArcRotateCameraInputsManager;
  37615. /** @hidden */
  37616. _reset: () => void;
  37617. /**
  37618. * Defines the allowed panning axis.
  37619. */
  37620. panningAxis: Vector3;
  37621. protected _localDirection: Vector3;
  37622. protected _transformedDirection: Vector3;
  37623. private _bouncingBehavior;
  37624. /**
  37625. * Gets the bouncing behavior of the camera if it has been enabled.
  37626. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37627. */
  37628. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37629. /**
  37630. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37631. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37632. */
  37633. useBouncingBehavior: boolean;
  37634. private _framingBehavior;
  37635. /**
  37636. * Gets the framing behavior of the camera if it has been enabled.
  37637. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37638. */
  37639. readonly framingBehavior: Nullable<FramingBehavior>;
  37640. /**
  37641. * Defines if the framing behavior of the camera is enabled on the camera.
  37642. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37643. */
  37644. useFramingBehavior: boolean;
  37645. private _autoRotationBehavior;
  37646. /**
  37647. * Gets the auto rotation behavior of the camera if it has been enabled.
  37648. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37649. */
  37650. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37651. /**
  37652. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37653. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37654. */
  37655. useAutoRotationBehavior: boolean;
  37656. /**
  37657. * Observable triggered when the mesh target has been changed on the camera.
  37658. */
  37659. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37660. /**
  37661. * Event raised when the camera is colliding with a mesh.
  37662. */
  37663. onCollide: (collidedMesh: AbstractMesh) => void;
  37664. /**
  37665. * Defines whether the camera should check collision with the objects oh the scene.
  37666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37667. */
  37668. checkCollisions: boolean;
  37669. /**
  37670. * Defines the collision radius of the camera.
  37671. * This simulates a sphere around the camera.
  37672. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37673. */
  37674. collisionRadius: Vector3;
  37675. protected _collider: Collider;
  37676. protected _previousPosition: Vector3;
  37677. protected _collisionVelocity: Vector3;
  37678. protected _newPosition: Vector3;
  37679. protected _previousAlpha: number;
  37680. protected _previousBeta: number;
  37681. protected _previousRadius: number;
  37682. protected _collisionTriggered: boolean;
  37683. protected _targetBoundingCenter: Nullable<Vector3>;
  37684. private _computationVector;
  37685. /**
  37686. * Instantiates a new ArcRotateCamera in a given scene
  37687. * @param name Defines the name of the camera
  37688. * @param alpha Defines the camera rotation along the logitudinal axis
  37689. * @param beta Defines the camera rotation along the latitudinal axis
  37690. * @param radius Defines the camera distance from its target
  37691. * @param target Defines the camera target
  37692. * @param scene Defines the scene the camera belongs to
  37693. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37694. */
  37695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37696. /** @hidden */
  37697. _initCache(): void;
  37698. /** @hidden */
  37699. _updateCache(ignoreParentClass?: boolean): void;
  37700. protected _getTargetPosition(): Vector3;
  37701. private _storedAlpha;
  37702. private _storedBeta;
  37703. private _storedRadius;
  37704. private _storedTarget;
  37705. private _storedTargetScreenOffset;
  37706. /**
  37707. * Stores the current state of the camera (alpha, beta, radius and target)
  37708. * @returns the camera itself
  37709. */
  37710. storeState(): Camera;
  37711. /**
  37712. * @hidden
  37713. * Restored camera state. You must call storeState() first
  37714. */
  37715. _restoreStateValues(): boolean;
  37716. /** @hidden */
  37717. _isSynchronizedViewMatrix(): boolean;
  37718. /**
  37719. * Attached controls to the current camera.
  37720. * @param element Defines the element the controls should be listened from
  37721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37722. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37723. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37724. */
  37725. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37726. /**
  37727. * Detach the current controls from the camera.
  37728. * The camera will stop reacting to inputs.
  37729. * @param element Defines the element to stop listening the inputs from
  37730. */
  37731. detachControl(element: HTMLElement): void;
  37732. /** @hidden */
  37733. _checkInputs(): void;
  37734. protected _checkLimits(): void;
  37735. /**
  37736. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37737. */
  37738. rebuildAnglesAndRadius(): void;
  37739. /**
  37740. * Use a position to define the current camera related information like aplha, beta and radius
  37741. * @param position Defines the position to set the camera at
  37742. */
  37743. setPosition(position: Vector3): void;
  37744. /**
  37745. * Defines the target the camera should look at.
  37746. * This will automatically adapt alpha beta and radius to fit within the new target.
  37747. * @param target Defines the new target as a Vector or a mesh
  37748. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37749. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37750. */
  37751. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37752. /** @hidden */
  37753. _getViewMatrix(): Matrix;
  37754. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37755. /**
  37756. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37757. * @param meshes Defines the mesh to zoom on
  37758. * @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)
  37759. */
  37760. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37761. /**
  37762. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37763. * The target will be changed but the radius
  37764. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37765. * @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)
  37766. */
  37767. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37768. min: Vector3;
  37769. max: Vector3;
  37770. distance: number;
  37771. }, doNotUpdateMaxZ?: boolean): void;
  37772. /**
  37773. * @override
  37774. * Override Camera.createRigCamera
  37775. */
  37776. createRigCamera(name: string, cameraIndex: number): Camera;
  37777. /**
  37778. * @hidden
  37779. * @override
  37780. * Override Camera._updateRigCameras
  37781. */
  37782. _updateRigCameras(): void;
  37783. /**
  37784. * Destroy the camera and release the current resources hold by it.
  37785. */
  37786. dispose(): void;
  37787. /**
  37788. * Gets the current object class name.
  37789. * @return the class name
  37790. */
  37791. getClassName(): string;
  37792. }
  37793. }
  37794. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37795. import { Behavior } from "babylonjs/Behaviors/behavior";
  37796. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37797. /**
  37798. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37800. */
  37801. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37802. /**
  37803. * Gets the name of the behavior.
  37804. */
  37805. readonly name: string;
  37806. private _zoomStopsAnimation;
  37807. private _idleRotationSpeed;
  37808. private _idleRotationWaitTime;
  37809. private _idleRotationSpinupTime;
  37810. /**
  37811. * Sets the flag that indicates if user zooming should stop animation.
  37812. */
  37813. /**
  37814. * Gets the flag that indicates if user zooming should stop animation.
  37815. */
  37816. zoomStopsAnimation: boolean;
  37817. /**
  37818. * Sets the default speed at which the camera rotates around the model.
  37819. */
  37820. /**
  37821. * Gets the default speed at which the camera rotates around the model.
  37822. */
  37823. idleRotationSpeed: number;
  37824. /**
  37825. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37826. */
  37827. /**
  37828. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37829. */
  37830. idleRotationWaitTime: number;
  37831. /**
  37832. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37833. */
  37834. /**
  37835. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37836. */
  37837. idleRotationSpinupTime: number;
  37838. /**
  37839. * Gets a value indicating if the camera is currently rotating because of this behavior
  37840. */
  37841. readonly rotationInProgress: boolean;
  37842. private _onPrePointerObservableObserver;
  37843. private _onAfterCheckInputsObserver;
  37844. private _attachedCamera;
  37845. private _isPointerDown;
  37846. private _lastFrameTime;
  37847. private _lastInteractionTime;
  37848. private _cameraRotationSpeed;
  37849. /**
  37850. * Initializes the behavior.
  37851. */
  37852. init(): void;
  37853. /**
  37854. * Attaches the behavior to its arc rotate camera.
  37855. * @param camera Defines the camera to attach the behavior to
  37856. */
  37857. attach(camera: ArcRotateCamera): void;
  37858. /**
  37859. * Detaches the behavior from its current arc rotate camera.
  37860. */
  37861. detach(): void;
  37862. /**
  37863. * Returns true if user is scrolling.
  37864. * @return true if user is scrolling.
  37865. */
  37866. private _userIsZooming;
  37867. private _lastFrameRadius;
  37868. private _shouldAnimationStopForInteraction;
  37869. /**
  37870. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37871. */
  37872. private _applyUserInteraction;
  37873. private _userIsMoving;
  37874. }
  37875. }
  37876. declare module "babylonjs/Behaviors/Cameras/index" {
  37877. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37878. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37879. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37880. }
  37881. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37882. import { Mesh } from "babylonjs/Meshes/mesh";
  37883. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37884. import { Behavior } from "babylonjs/Behaviors/behavior";
  37885. /**
  37886. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37887. */
  37888. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37889. private ui;
  37890. /**
  37891. * The name of the behavior
  37892. */
  37893. name: string;
  37894. /**
  37895. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37896. */
  37897. distanceAwayFromFace: number;
  37898. /**
  37899. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37900. */
  37901. distanceAwayFromBottomOfFace: number;
  37902. private _faceVectors;
  37903. private _target;
  37904. private _scene;
  37905. private _onRenderObserver;
  37906. private _tmpMatrix;
  37907. private _tmpVector;
  37908. /**
  37909. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37910. * @param ui The transform node that should be attched to the mesh
  37911. */
  37912. constructor(ui: TransformNode);
  37913. /**
  37914. * Initializes the behavior
  37915. */
  37916. init(): void;
  37917. private _closestFace;
  37918. private _zeroVector;
  37919. private _lookAtTmpMatrix;
  37920. private _lookAtToRef;
  37921. /**
  37922. * Attaches the AttachToBoxBehavior to the passed in mesh
  37923. * @param target The mesh that the specified node will be attached to
  37924. */
  37925. attach(target: Mesh): void;
  37926. /**
  37927. * Detaches the behavior from the mesh
  37928. */
  37929. detach(): void;
  37930. }
  37931. }
  37932. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37933. import { Behavior } from "babylonjs/Behaviors/behavior";
  37934. import { Mesh } from "babylonjs/Meshes/mesh";
  37935. /**
  37936. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37937. */
  37938. export class FadeInOutBehavior implements Behavior<Mesh> {
  37939. /**
  37940. * Time in milliseconds to delay before fading in (Default: 0)
  37941. */
  37942. delay: number;
  37943. /**
  37944. * Time in milliseconds for the mesh to fade in (Default: 300)
  37945. */
  37946. fadeInTime: number;
  37947. private _millisecondsPerFrame;
  37948. private _hovered;
  37949. private _hoverValue;
  37950. private _ownerNode;
  37951. /**
  37952. * Instatiates the FadeInOutBehavior
  37953. */
  37954. constructor();
  37955. /**
  37956. * The name of the behavior
  37957. */
  37958. readonly name: string;
  37959. /**
  37960. * Initializes the behavior
  37961. */
  37962. init(): void;
  37963. /**
  37964. * Attaches the fade behavior on the passed in mesh
  37965. * @param ownerNode The mesh that will be faded in/out once attached
  37966. */
  37967. attach(ownerNode: Mesh): void;
  37968. /**
  37969. * Detaches the behavior from the mesh
  37970. */
  37971. detach(): void;
  37972. /**
  37973. * Triggers the mesh to begin fading in or out
  37974. * @param value if the object should fade in or out (true to fade in)
  37975. */
  37976. fadeIn(value: boolean): void;
  37977. private _update;
  37978. private _setAllVisibility;
  37979. }
  37980. }
  37981. declare module "babylonjs/Misc/pivotTools" {
  37982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37983. /**
  37984. * Class containing a set of static utilities functions for managing Pivots
  37985. * @hidden
  37986. */
  37987. export class PivotTools {
  37988. private static _PivotCached;
  37989. private static _OldPivotPoint;
  37990. private static _PivotTranslation;
  37991. private static _PivotTmpVector;
  37992. /** @hidden */
  37993. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37994. /** @hidden */
  37995. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37996. }
  37997. }
  37998. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37999. import { Scene } from "babylonjs/scene";
  38000. import { Vector4 } from "babylonjs/Maths/math.vector";
  38001. import { Mesh } from "babylonjs/Meshes/mesh";
  38002. import { Nullable } from "babylonjs/types";
  38003. import { Plane } from "babylonjs/Maths/math.plane";
  38004. /**
  38005. * Class containing static functions to help procedurally build meshes
  38006. */
  38007. export class PlaneBuilder {
  38008. /**
  38009. * Creates a plane mesh
  38010. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38011. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38012. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38016. * @param name defines the name of the mesh
  38017. * @param options defines the options used to create the mesh
  38018. * @param scene defines the hosting scene
  38019. * @returns the plane mesh
  38020. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38021. */
  38022. static CreatePlane(name: string, options: {
  38023. size?: number;
  38024. width?: number;
  38025. height?: number;
  38026. sideOrientation?: number;
  38027. frontUVs?: Vector4;
  38028. backUVs?: Vector4;
  38029. updatable?: boolean;
  38030. sourcePlane?: Plane;
  38031. }, scene?: Nullable<Scene>): Mesh;
  38032. }
  38033. }
  38034. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38035. import { Behavior } from "babylonjs/Behaviors/behavior";
  38036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38037. import { Observable } from "babylonjs/Misc/observable";
  38038. import { Vector3 } from "babylonjs/Maths/math.vector";
  38039. import { Ray } from "babylonjs/Culling/ray";
  38040. import "babylonjs/Meshes/Builders/planeBuilder";
  38041. /**
  38042. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38043. */
  38044. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38045. private static _AnyMouseID;
  38046. /**
  38047. * Abstract mesh the behavior is set on
  38048. */
  38049. attachedNode: AbstractMesh;
  38050. private _dragPlane;
  38051. private _scene;
  38052. private _pointerObserver;
  38053. private _beforeRenderObserver;
  38054. private static _planeScene;
  38055. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38056. /**
  38057. * 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)
  38058. */
  38059. maxDragAngle: number;
  38060. /**
  38061. * @hidden
  38062. */
  38063. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38064. /**
  38065. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38066. */
  38067. currentDraggingPointerID: number;
  38068. /**
  38069. * The last position where the pointer hit the drag plane in world space
  38070. */
  38071. lastDragPosition: Vector3;
  38072. /**
  38073. * If the behavior is currently in a dragging state
  38074. */
  38075. dragging: boolean;
  38076. /**
  38077. * 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)
  38078. */
  38079. dragDeltaRatio: number;
  38080. /**
  38081. * If the drag plane orientation should be updated during the dragging (Default: true)
  38082. */
  38083. updateDragPlane: boolean;
  38084. private _debugMode;
  38085. private _moving;
  38086. /**
  38087. * Fires each time the attached mesh is dragged with the pointer
  38088. * * delta between last drag position and current drag position in world space
  38089. * * dragDistance along the drag axis
  38090. * * dragPlaneNormal normal of the current drag plane used during the drag
  38091. * * dragPlanePoint in world space where the drag intersects the drag plane
  38092. */
  38093. onDragObservable: Observable<{
  38094. delta: Vector3;
  38095. dragPlanePoint: Vector3;
  38096. dragPlaneNormal: Vector3;
  38097. dragDistance: number;
  38098. pointerId: number;
  38099. }>;
  38100. /**
  38101. * Fires each time a drag begins (eg. mouse down on mesh)
  38102. */
  38103. onDragStartObservable: Observable<{
  38104. dragPlanePoint: Vector3;
  38105. pointerId: number;
  38106. }>;
  38107. /**
  38108. * Fires each time a drag ends (eg. mouse release after drag)
  38109. */
  38110. onDragEndObservable: Observable<{
  38111. dragPlanePoint: Vector3;
  38112. pointerId: number;
  38113. }>;
  38114. /**
  38115. * If the attached mesh should be moved when dragged
  38116. */
  38117. moveAttached: boolean;
  38118. /**
  38119. * If the drag behavior will react to drag events (Default: true)
  38120. */
  38121. enabled: boolean;
  38122. /**
  38123. * If pointer events should start and release the drag (Default: true)
  38124. */
  38125. startAndReleaseDragOnPointerEvents: boolean;
  38126. /**
  38127. * If camera controls should be detached during the drag
  38128. */
  38129. detachCameraControls: boolean;
  38130. /**
  38131. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38132. */
  38133. useObjectOrienationForDragging: boolean;
  38134. private _options;
  38135. /**
  38136. * Creates a pointer drag behavior that can be attached to a mesh
  38137. * @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)
  38138. */
  38139. constructor(options?: {
  38140. dragAxis?: Vector3;
  38141. dragPlaneNormal?: Vector3;
  38142. });
  38143. /**
  38144. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38145. */
  38146. validateDrag: (targetPosition: Vector3) => boolean;
  38147. /**
  38148. * The name of the behavior
  38149. */
  38150. readonly name: string;
  38151. /**
  38152. * Initializes the behavior
  38153. */
  38154. init(): void;
  38155. private _tmpVector;
  38156. private _alternatePickedPoint;
  38157. private _worldDragAxis;
  38158. private _targetPosition;
  38159. private _attachedElement;
  38160. /**
  38161. * Attaches the drag behavior the passed in mesh
  38162. * @param ownerNode The mesh that will be dragged around once attached
  38163. * @param predicate Predicate to use for pick filtering
  38164. */
  38165. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38166. /**
  38167. * Force relase the drag action by code.
  38168. */
  38169. releaseDrag(): void;
  38170. private _startDragRay;
  38171. private _lastPointerRay;
  38172. /**
  38173. * Simulates the start of a pointer drag event on the behavior
  38174. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38175. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38176. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38177. */
  38178. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38179. private _startDrag;
  38180. private _dragDelta;
  38181. private _moveDrag;
  38182. private _pickWithRayOnDragPlane;
  38183. private _pointA;
  38184. private _pointB;
  38185. private _pointC;
  38186. private _lineA;
  38187. private _lineB;
  38188. private _localAxis;
  38189. private _lookAt;
  38190. private _updateDragPlanePosition;
  38191. /**
  38192. * Detaches the behavior from the mesh
  38193. */
  38194. detach(): void;
  38195. }
  38196. }
  38197. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38198. import { Mesh } from "babylonjs/Meshes/mesh";
  38199. import { Behavior } from "babylonjs/Behaviors/behavior";
  38200. /**
  38201. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38202. */
  38203. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38204. private _dragBehaviorA;
  38205. private _dragBehaviorB;
  38206. private _startDistance;
  38207. private _initialScale;
  38208. private _targetScale;
  38209. private _ownerNode;
  38210. private _sceneRenderObserver;
  38211. /**
  38212. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38213. */
  38214. constructor();
  38215. /**
  38216. * The name of the behavior
  38217. */
  38218. readonly name: string;
  38219. /**
  38220. * Initializes the behavior
  38221. */
  38222. init(): void;
  38223. private _getCurrentDistance;
  38224. /**
  38225. * Attaches the scale behavior the passed in mesh
  38226. * @param ownerNode The mesh that will be scaled around once attached
  38227. */
  38228. attach(ownerNode: Mesh): void;
  38229. /**
  38230. * Detaches the behavior from the mesh
  38231. */
  38232. detach(): void;
  38233. }
  38234. }
  38235. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38236. import { Behavior } from "babylonjs/Behaviors/behavior";
  38237. import { Mesh } from "babylonjs/Meshes/mesh";
  38238. import { Observable } from "babylonjs/Misc/observable";
  38239. /**
  38240. * 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
  38241. */
  38242. export class SixDofDragBehavior implements Behavior<Mesh> {
  38243. private static _virtualScene;
  38244. private _ownerNode;
  38245. private _sceneRenderObserver;
  38246. private _scene;
  38247. private _targetPosition;
  38248. private _virtualOriginMesh;
  38249. private _virtualDragMesh;
  38250. private _pointerObserver;
  38251. private _moving;
  38252. private _startingOrientation;
  38253. /**
  38254. * 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)
  38255. */
  38256. private zDragFactor;
  38257. /**
  38258. * If the object should rotate to face the drag origin
  38259. */
  38260. rotateDraggedObject: boolean;
  38261. /**
  38262. * If the behavior is currently in a dragging state
  38263. */
  38264. dragging: boolean;
  38265. /**
  38266. * 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)
  38267. */
  38268. dragDeltaRatio: number;
  38269. /**
  38270. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38271. */
  38272. currentDraggingPointerID: number;
  38273. /**
  38274. * If camera controls should be detached during the drag
  38275. */
  38276. detachCameraControls: boolean;
  38277. /**
  38278. * Fires each time a drag starts
  38279. */
  38280. onDragStartObservable: Observable<{}>;
  38281. /**
  38282. * Fires each time a drag ends (eg. mouse release after drag)
  38283. */
  38284. onDragEndObservable: Observable<{}>;
  38285. /**
  38286. * 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
  38287. */
  38288. constructor();
  38289. /**
  38290. * The name of the behavior
  38291. */
  38292. readonly name: string;
  38293. /**
  38294. * Initializes the behavior
  38295. */
  38296. init(): void;
  38297. /**
  38298. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38299. */
  38300. private readonly _pointerCamera;
  38301. /**
  38302. * Attaches the scale behavior the passed in mesh
  38303. * @param ownerNode The mesh that will be scaled around once attached
  38304. */
  38305. attach(ownerNode: Mesh): void;
  38306. /**
  38307. * Detaches the behavior from the mesh
  38308. */
  38309. detach(): void;
  38310. }
  38311. }
  38312. declare module "babylonjs/Behaviors/Meshes/index" {
  38313. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38314. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38315. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38316. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38317. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38318. }
  38319. declare module "babylonjs/Behaviors/index" {
  38320. export * from "babylonjs/Behaviors/behavior";
  38321. export * from "babylonjs/Behaviors/Cameras/index";
  38322. export * from "babylonjs/Behaviors/Meshes/index";
  38323. }
  38324. declare module "babylonjs/Bones/boneIKController" {
  38325. import { Bone } from "babylonjs/Bones/bone";
  38326. import { Vector3 } from "babylonjs/Maths/math.vector";
  38327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38328. import { Nullable } from "babylonjs/types";
  38329. /**
  38330. * Class used to apply inverse kinematics to bones
  38331. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38332. */
  38333. export class BoneIKController {
  38334. private static _tmpVecs;
  38335. private static _tmpQuat;
  38336. private static _tmpMats;
  38337. /**
  38338. * Gets or sets the target mesh
  38339. */
  38340. targetMesh: AbstractMesh;
  38341. /** Gets or sets the mesh used as pole */
  38342. poleTargetMesh: AbstractMesh;
  38343. /**
  38344. * Gets or sets the bone used as pole
  38345. */
  38346. poleTargetBone: Nullable<Bone>;
  38347. /**
  38348. * Gets or sets the target position
  38349. */
  38350. targetPosition: Vector3;
  38351. /**
  38352. * Gets or sets the pole target position
  38353. */
  38354. poleTargetPosition: Vector3;
  38355. /**
  38356. * Gets or sets the pole target local offset
  38357. */
  38358. poleTargetLocalOffset: Vector3;
  38359. /**
  38360. * Gets or sets the pole angle
  38361. */
  38362. poleAngle: number;
  38363. /**
  38364. * Gets or sets the mesh associated with the controller
  38365. */
  38366. mesh: AbstractMesh;
  38367. /**
  38368. * 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)
  38369. */
  38370. slerpAmount: number;
  38371. private _bone1Quat;
  38372. private _bone1Mat;
  38373. private _bone2Ang;
  38374. private _bone1;
  38375. private _bone2;
  38376. private _bone1Length;
  38377. private _bone2Length;
  38378. private _maxAngle;
  38379. private _maxReach;
  38380. private _rightHandedSystem;
  38381. private _bendAxis;
  38382. private _slerping;
  38383. private _adjustRoll;
  38384. /**
  38385. * Gets or sets maximum allowed angle
  38386. */
  38387. maxAngle: number;
  38388. /**
  38389. * Creates a new BoneIKController
  38390. * @param mesh defines the mesh to control
  38391. * @param bone defines the bone to control
  38392. * @param options defines options to set up the controller
  38393. */
  38394. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38395. targetMesh?: AbstractMesh;
  38396. poleTargetMesh?: AbstractMesh;
  38397. poleTargetBone?: Bone;
  38398. poleTargetLocalOffset?: Vector3;
  38399. poleAngle?: number;
  38400. bendAxis?: Vector3;
  38401. maxAngle?: number;
  38402. slerpAmount?: number;
  38403. });
  38404. private _setMaxAngle;
  38405. /**
  38406. * Force the controller to update the bones
  38407. */
  38408. update(): void;
  38409. }
  38410. }
  38411. declare module "babylonjs/Bones/boneLookController" {
  38412. import { Vector3 } from "babylonjs/Maths/math.vector";
  38413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38414. import { Bone } from "babylonjs/Bones/bone";
  38415. import { Space } from "babylonjs/Maths/math.axis";
  38416. /**
  38417. * Class used to make a bone look toward a point in space
  38418. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38419. */
  38420. export class BoneLookController {
  38421. private static _tmpVecs;
  38422. private static _tmpQuat;
  38423. private static _tmpMats;
  38424. /**
  38425. * The target Vector3 that the bone will look at
  38426. */
  38427. target: Vector3;
  38428. /**
  38429. * The mesh that the bone is attached to
  38430. */
  38431. mesh: AbstractMesh;
  38432. /**
  38433. * The bone that will be looking to the target
  38434. */
  38435. bone: Bone;
  38436. /**
  38437. * The up axis of the coordinate system that is used when the bone is rotated
  38438. */
  38439. upAxis: Vector3;
  38440. /**
  38441. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38442. */
  38443. upAxisSpace: Space;
  38444. /**
  38445. * Used to make an adjustment to the yaw of the bone
  38446. */
  38447. adjustYaw: number;
  38448. /**
  38449. * Used to make an adjustment to the pitch of the bone
  38450. */
  38451. adjustPitch: number;
  38452. /**
  38453. * Used to make an adjustment to the roll of the bone
  38454. */
  38455. adjustRoll: number;
  38456. /**
  38457. * 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)
  38458. */
  38459. slerpAmount: number;
  38460. private _minYaw;
  38461. private _maxYaw;
  38462. private _minPitch;
  38463. private _maxPitch;
  38464. private _minYawSin;
  38465. private _minYawCos;
  38466. private _maxYawSin;
  38467. private _maxYawCos;
  38468. private _midYawConstraint;
  38469. private _minPitchTan;
  38470. private _maxPitchTan;
  38471. private _boneQuat;
  38472. private _slerping;
  38473. private _transformYawPitch;
  38474. private _transformYawPitchInv;
  38475. private _firstFrameSkipped;
  38476. private _yawRange;
  38477. private _fowardAxis;
  38478. /**
  38479. * Gets or sets the minimum yaw angle that the bone can look to
  38480. */
  38481. minYaw: number;
  38482. /**
  38483. * Gets or sets the maximum yaw angle that the bone can look to
  38484. */
  38485. maxYaw: number;
  38486. /**
  38487. * Gets or sets the minimum pitch angle that the bone can look to
  38488. */
  38489. minPitch: number;
  38490. /**
  38491. * Gets or sets the maximum pitch angle that the bone can look to
  38492. */
  38493. maxPitch: number;
  38494. /**
  38495. * Create a BoneLookController
  38496. * @param mesh the mesh that the bone belongs to
  38497. * @param bone the bone that will be looking to the target
  38498. * @param target the target Vector3 to look at
  38499. * @param options optional settings:
  38500. * * maxYaw: the maximum angle the bone will yaw to
  38501. * * minYaw: the minimum angle the bone will yaw to
  38502. * * maxPitch: the maximum angle the bone will pitch to
  38503. * * minPitch: the minimum angle the bone will yaw to
  38504. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38505. * * upAxis: the up axis of the coordinate system
  38506. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38507. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38508. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38509. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38510. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38511. * * adjustRoll: used to make an adjustment to the roll of the bone
  38512. **/
  38513. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38514. maxYaw?: number;
  38515. minYaw?: number;
  38516. maxPitch?: number;
  38517. minPitch?: number;
  38518. slerpAmount?: number;
  38519. upAxis?: Vector3;
  38520. upAxisSpace?: Space;
  38521. yawAxis?: Vector3;
  38522. pitchAxis?: Vector3;
  38523. adjustYaw?: number;
  38524. adjustPitch?: number;
  38525. adjustRoll?: number;
  38526. });
  38527. /**
  38528. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38529. */
  38530. update(): void;
  38531. private _getAngleDiff;
  38532. private _getAngleBetween;
  38533. private _isAngleBetween;
  38534. }
  38535. }
  38536. declare module "babylonjs/Bones/index" {
  38537. export * from "babylonjs/Bones/bone";
  38538. export * from "babylonjs/Bones/boneIKController";
  38539. export * from "babylonjs/Bones/boneLookController";
  38540. export * from "babylonjs/Bones/skeleton";
  38541. }
  38542. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38543. import { Nullable } from "babylonjs/types";
  38544. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38545. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38546. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38547. /**
  38548. * Manage the gamepad inputs to control an arc rotate camera.
  38549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38550. */
  38551. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38552. /**
  38553. * Defines the camera the input is attached to.
  38554. */
  38555. camera: ArcRotateCamera;
  38556. /**
  38557. * Defines the gamepad the input is gathering event from.
  38558. */
  38559. gamepad: Nullable<Gamepad>;
  38560. /**
  38561. * Defines the gamepad rotation sensiblity.
  38562. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38563. */
  38564. gamepadRotationSensibility: number;
  38565. /**
  38566. * Defines the gamepad move sensiblity.
  38567. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38568. */
  38569. gamepadMoveSensibility: number;
  38570. private _onGamepadConnectedObserver;
  38571. private _onGamepadDisconnectedObserver;
  38572. /**
  38573. * Attach the input controls to a specific dom element to get the input from.
  38574. * @param element Defines the element the controls should be listened from
  38575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38576. */
  38577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38578. /**
  38579. * Detach the current controls from the specified dom element.
  38580. * @param element Defines the element to stop listening the inputs from
  38581. */
  38582. detachControl(element: Nullable<HTMLElement>): void;
  38583. /**
  38584. * Update the current camera state depending on the inputs that have been used this frame.
  38585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38586. */
  38587. checkInputs(): void;
  38588. /**
  38589. * Gets the class name of the current intput.
  38590. * @returns the class name
  38591. */
  38592. getClassName(): string;
  38593. /**
  38594. * Get the friendly name associated with the input class.
  38595. * @returns the input friendly name
  38596. */
  38597. getSimpleName(): string;
  38598. }
  38599. }
  38600. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38601. import { Nullable } from "babylonjs/types";
  38602. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38603. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38604. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38605. interface ArcRotateCameraInputsManager {
  38606. /**
  38607. * Add orientation input support to the input manager.
  38608. * @returns the current input manager
  38609. */
  38610. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38611. }
  38612. }
  38613. /**
  38614. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38616. */
  38617. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38618. /**
  38619. * Defines the camera the input is attached to.
  38620. */
  38621. camera: ArcRotateCamera;
  38622. /**
  38623. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38624. */
  38625. alphaCorrection: number;
  38626. /**
  38627. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38628. */
  38629. gammaCorrection: number;
  38630. private _alpha;
  38631. private _gamma;
  38632. private _dirty;
  38633. private _deviceOrientationHandler;
  38634. /**
  38635. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38636. */
  38637. constructor();
  38638. /**
  38639. * Attach the input controls to a specific dom element to get the input from.
  38640. * @param element Defines the element the controls should be listened from
  38641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38642. */
  38643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38644. /** @hidden */
  38645. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38646. /**
  38647. * Update the current camera state depending on the inputs that have been used this frame.
  38648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38649. */
  38650. checkInputs(): void;
  38651. /**
  38652. * Detach the current controls from the specified dom element.
  38653. * @param element Defines the element to stop listening the inputs from
  38654. */
  38655. detachControl(element: Nullable<HTMLElement>): void;
  38656. /**
  38657. * Gets the class name of the current intput.
  38658. * @returns the class name
  38659. */
  38660. getClassName(): string;
  38661. /**
  38662. * Get the friendly name associated with the input class.
  38663. * @returns the input friendly name
  38664. */
  38665. getSimpleName(): string;
  38666. }
  38667. }
  38668. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38669. import { Nullable } from "babylonjs/types";
  38670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38671. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38672. /**
  38673. * Listen to mouse events to control the camera.
  38674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38675. */
  38676. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38677. /**
  38678. * Defines the camera the input is attached to.
  38679. */
  38680. camera: FlyCamera;
  38681. /**
  38682. * Defines if touch is enabled. (Default is true.)
  38683. */
  38684. touchEnabled: boolean;
  38685. /**
  38686. * Defines the buttons associated with the input to handle camera rotation.
  38687. */
  38688. buttons: number[];
  38689. /**
  38690. * Assign buttons for Yaw control.
  38691. */
  38692. buttonsYaw: number[];
  38693. /**
  38694. * Assign buttons for Pitch control.
  38695. */
  38696. buttonsPitch: number[];
  38697. /**
  38698. * Assign buttons for Roll control.
  38699. */
  38700. buttonsRoll: number[];
  38701. /**
  38702. * Detect if any button is being pressed while mouse is moved.
  38703. * -1 = Mouse locked.
  38704. * 0 = Left button.
  38705. * 1 = Middle Button.
  38706. * 2 = Right Button.
  38707. */
  38708. activeButton: number;
  38709. /**
  38710. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38711. * Higher values reduce its sensitivity.
  38712. */
  38713. angularSensibility: number;
  38714. private _mousemoveCallback;
  38715. private _observer;
  38716. private _rollObserver;
  38717. private previousPosition;
  38718. private noPreventDefault;
  38719. private element;
  38720. /**
  38721. * Listen to mouse events to control the camera.
  38722. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38724. */
  38725. constructor(touchEnabled?: boolean);
  38726. /**
  38727. * Attach the mouse control to the HTML DOM element.
  38728. * @param element Defines the element that listens to the input events.
  38729. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38730. */
  38731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38732. /**
  38733. * Detach the current controls from the specified dom element.
  38734. * @param element Defines the element to stop listening the inputs from
  38735. */
  38736. detachControl(element: Nullable<HTMLElement>): void;
  38737. /**
  38738. * Gets the class name of the current input.
  38739. * @returns the class name.
  38740. */
  38741. getClassName(): string;
  38742. /**
  38743. * Get the friendly name associated with the input class.
  38744. * @returns the input's friendly name.
  38745. */
  38746. getSimpleName(): string;
  38747. private _pointerInput;
  38748. private _onMouseMove;
  38749. /**
  38750. * Rotate camera by mouse offset.
  38751. */
  38752. private rotateCamera;
  38753. }
  38754. }
  38755. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38756. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38757. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38758. /**
  38759. * Default Inputs manager for the FlyCamera.
  38760. * It groups all the default supported inputs for ease of use.
  38761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38762. */
  38763. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38764. /**
  38765. * Instantiates a new FlyCameraInputsManager.
  38766. * @param camera Defines the camera the inputs belong to.
  38767. */
  38768. constructor(camera: FlyCamera);
  38769. /**
  38770. * Add keyboard input support to the input manager.
  38771. * @returns the new FlyCameraKeyboardMoveInput().
  38772. */
  38773. addKeyboard(): FlyCameraInputsManager;
  38774. /**
  38775. * Add mouse input support to the input manager.
  38776. * @param touchEnabled Enable touch screen support.
  38777. * @returns the new FlyCameraMouseInput().
  38778. */
  38779. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38780. }
  38781. }
  38782. declare module "babylonjs/Cameras/flyCamera" {
  38783. import { Scene } from "babylonjs/scene";
  38784. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38786. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38787. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38788. /**
  38789. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38790. * such as in a 3D Space Shooter or a Flight Simulator.
  38791. */
  38792. export class FlyCamera extends TargetCamera {
  38793. /**
  38794. * Define the collision ellipsoid of the camera.
  38795. * This is helpful for simulating a camera body, like a player's body.
  38796. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38797. */
  38798. ellipsoid: Vector3;
  38799. /**
  38800. * Define an offset for the position of the ellipsoid around the camera.
  38801. * This can be helpful if the camera is attached away from the player's body center,
  38802. * such as at its head.
  38803. */
  38804. ellipsoidOffset: Vector3;
  38805. /**
  38806. * Enable or disable collisions of the camera with the rest of the scene objects.
  38807. */
  38808. checkCollisions: boolean;
  38809. /**
  38810. * Enable or disable gravity on the camera.
  38811. */
  38812. applyGravity: boolean;
  38813. /**
  38814. * Define the current direction the camera is moving to.
  38815. */
  38816. cameraDirection: Vector3;
  38817. /**
  38818. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38819. * This overrides and empties cameraRotation.
  38820. */
  38821. rotationQuaternion: Quaternion;
  38822. /**
  38823. * Track Roll to maintain the wanted Rolling when looking around.
  38824. */
  38825. _trackRoll: number;
  38826. /**
  38827. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38828. */
  38829. rollCorrect: number;
  38830. /**
  38831. * Mimic a banked turn, Rolling the camera when Yawing.
  38832. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38833. */
  38834. bankedTurn: boolean;
  38835. /**
  38836. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38837. */
  38838. bankedTurnLimit: number;
  38839. /**
  38840. * Value of 0 disables the banked Roll.
  38841. * Value of 1 is equal to the Yaw angle in radians.
  38842. */
  38843. bankedTurnMultiplier: number;
  38844. /**
  38845. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38846. */
  38847. inputs: FlyCameraInputsManager;
  38848. /**
  38849. * Gets the input sensibility for mouse input.
  38850. * Higher values reduce sensitivity.
  38851. */
  38852. /**
  38853. * Sets the input sensibility for a mouse input.
  38854. * Higher values reduce sensitivity.
  38855. */
  38856. angularSensibility: number;
  38857. /**
  38858. * Get the keys for camera movement forward.
  38859. */
  38860. /**
  38861. * Set the keys for camera movement forward.
  38862. */
  38863. keysForward: number[];
  38864. /**
  38865. * Get the keys for camera movement backward.
  38866. */
  38867. keysBackward: number[];
  38868. /**
  38869. * Get the keys for camera movement up.
  38870. */
  38871. /**
  38872. * Set the keys for camera movement up.
  38873. */
  38874. keysUp: number[];
  38875. /**
  38876. * Get the keys for camera movement down.
  38877. */
  38878. /**
  38879. * Set the keys for camera movement down.
  38880. */
  38881. keysDown: number[];
  38882. /**
  38883. * Get the keys for camera movement left.
  38884. */
  38885. /**
  38886. * Set the keys for camera movement left.
  38887. */
  38888. keysLeft: number[];
  38889. /**
  38890. * Set the keys for camera movement right.
  38891. */
  38892. /**
  38893. * Set the keys for camera movement right.
  38894. */
  38895. keysRight: number[];
  38896. /**
  38897. * Event raised when the camera collides with a mesh in the scene.
  38898. */
  38899. onCollide: (collidedMesh: AbstractMesh) => void;
  38900. private _collider;
  38901. private _needMoveForGravity;
  38902. private _oldPosition;
  38903. private _diffPosition;
  38904. private _newPosition;
  38905. /** @hidden */
  38906. _localDirection: Vector3;
  38907. /** @hidden */
  38908. _transformedDirection: Vector3;
  38909. /**
  38910. * Instantiates a FlyCamera.
  38911. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38912. * such as in a 3D Space Shooter or a Flight Simulator.
  38913. * @param name Define the name of the camera in the scene.
  38914. * @param position Define the starting position of the camera in the scene.
  38915. * @param scene Define the scene the camera belongs to.
  38916. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38917. */
  38918. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38919. /**
  38920. * Attach a control to the HTML DOM element.
  38921. * @param element Defines the element that listens to the input events.
  38922. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38923. */
  38924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38925. /**
  38926. * Detach a control from the HTML DOM element.
  38927. * The camera will stop reacting to that input.
  38928. * @param element Defines the element that listens to the input events.
  38929. */
  38930. detachControl(element: HTMLElement): void;
  38931. private _collisionMask;
  38932. /**
  38933. * Get the mask that the camera ignores in collision events.
  38934. */
  38935. /**
  38936. * Set the mask that the camera ignores in collision events.
  38937. */
  38938. collisionMask: number;
  38939. /** @hidden */
  38940. _collideWithWorld(displacement: Vector3): void;
  38941. /** @hidden */
  38942. private _onCollisionPositionChange;
  38943. /** @hidden */
  38944. _checkInputs(): void;
  38945. /** @hidden */
  38946. _decideIfNeedsToMove(): boolean;
  38947. /** @hidden */
  38948. _updatePosition(): void;
  38949. /**
  38950. * Restore the Roll to its target value at the rate specified.
  38951. * @param rate - Higher means slower restoring.
  38952. * @hidden
  38953. */
  38954. restoreRoll(rate: number): void;
  38955. /**
  38956. * Destroy the camera and release the current resources held by it.
  38957. */
  38958. dispose(): void;
  38959. /**
  38960. * Get the current object class name.
  38961. * @returns the class name.
  38962. */
  38963. getClassName(): string;
  38964. }
  38965. }
  38966. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38967. import { Nullable } from "babylonjs/types";
  38968. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38969. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38970. /**
  38971. * Listen to keyboard events to control the camera.
  38972. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38973. */
  38974. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38975. /**
  38976. * Defines the camera the input is attached to.
  38977. */
  38978. camera: FlyCamera;
  38979. /**
  38980. * The list of keyboard keys used to control the forward move of the camera.
  38981. */
  38982. keysForward: number[];
  38983. /**
  38984. * The list of keyboard keys used to control the backward move of the camera.
  38985. */
  38986. keysBackward: number[];
  38987. /**
  38988. * The list of keyboard keys used to control the forward move of the camera.
  38989. */
  38990. keysUp: number[];
  38991. /**
  38992. * The list of keyboard keys used to control the backward move of the camera.
  38993. */
  38994. keysDown: number[];
  38995. /**
  38996. * The list of keyboard keys used to control the right strafe move of the camera.
  38997. */
  38998. keysRight: number[];
  38999. /**
  39000. * The list of keyboard keys used to control the left strafe move of the camera.
  39001. */
  39002. keysLeft: number[];
  39003. private _keys;
  39004. private _onCanvasBlurObserver;
  39005. private _onKeyboardObserver;
  39006. private _engine;
  39007. private _scene;
  39008. /**
  39009. * Attach the input controls to a specific dom element to get the input from.
  39010. * @param element Defines the element the controls should be listened from
  39011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39012. */
  39013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39014. /**
  39015. * Detach the current controls from the specified dom element.
  39016. * @param element Defines the element to stop listening the inputs from
  39017. */
  39018. detachControl(element: Nullable<HTMLElement>): void;
  39019. /**
  39020. * Gets the class name of the current intput.
  39021. * @returns the class name
  39022. */
  39023. getClassName(): string;
  39024. /** @hidden */
  39025. _onLostFocus(e: FocusEvent): void;
  39026. /**
  39027. * Get the friendly name associated with the input class.
  39028. * @returns the input friendly name
  39029. */
  39030. getSimpleName(): string;
  39031. /**
  39032. * Update the current camera state depending on the inputs that have been used this frame.
  39033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39034. */
  39035. checkInputs(): void;
  39036. }
  39037. }
  39038. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39039. import { Nullable } from "babylonjs/types";
  39040. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39041. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39042. /**
  39043. * Manage the mouse wheel inputs to control a follow camera.
  39044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39045. */
  39046. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39047. /**
  39048. * Defines the camera the input is attached to.
  39049. */
  39050. camera: FollowCamera;
  39051. /**
  39052. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39053. */
  39054. axisControlRadius: boolean;
  39055. /**
  39056. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39057. */
  39058. axisControlHeight: boolean;
  39059. /**
  39060. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39061. */
  39062. axisControlRotation: boolean;
  39063. /**
  39064. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39065. * relation to mouseWheel events.
  39066. */
  39067. wheelPrecision: number;
  39068. /**
  39069. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39070. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39071. */
  39072. wheelDeltaPercentage: number;
  39073. private _wheel;
  39074. private _observer;
  39075. /**
  39076. * Attach the input controls to a specific dom element to get the input from.
  39077. * @param element Defines the element the controls should be listened from
  39078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39079. */
  39080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39081. /**
  39082. * Detach the current controls from the specified dom element.
  39083. * @param element Defines the element to stop listening the inputs from
  39084. */
  39085. detachControl(element: Nullable<HTMLElement>): void;
  39086. /**
  39087. * Gets the class name of the current intput.
  39088. * @returns the class name
  39089. */
  39090. getClassName(): string;
  39091. /**
  39092. * Get the friendly name associated with the input class.
  39093. * @returns the input friendly name
  39094. */
  39095. getSimpleName(): string;
  39096. }
  39097. }
  39098. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39099. import { Nullable } from "babylonjs/types";
  39100. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39101. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39102. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39103. /**
  39104. * Manage the pointers inputs to control an follow camera.
  39105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39106. */
  39107. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39108. /**
  39109. * Defines the camera the input is attached to.
  39110. */
  39111. camera: FollowCamera;
  39112. /**
  39113. * Gets the class name of the current input.
  39114. * @returns the class name
  39115. */
  39116. getClassName(): string;
  39117. /**
  39118. * Defines the pointer angular sensibility along the X axis or how fast is
  39119. * the camera rotating.
  39120. * A negative number will reverse the axis direction.
  39121. */
  39122. angularSensibilityX: number;
  39123. /**
  39124. * Defines the pointer angular sensibility along the Y axis or how fast is
  39125. * the camera rotating.
  39126. * A negative number will reverse the axis direction.
  39127. */
  39128. angularSensibilityY: number;
  39129. /**
  39130. * Defines the pointer pinch precision or how fast is the camera zooming.
  39131. * A negative number will reverse the axis direction.
  39132. */
  39133. pinchPrecision: number;
  39134. /**
  39135. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39136. * from 0.
  39137. * It defines the percentage of current camera.radius to use as delta when
  39138. * pinch zoom is used.
  39139. */
  39140. pinchDeltaPercentage: number;
  39141. /**
  39142. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39143. */
  39144. axisXControlRadius: boolean;
  39145. /**
  39146. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39147. */
  39148. axisXControlHeight: boolean;
  39149. /**
  39150. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39151. */
  39152. axisXControlRotation: boolean;
  39153. /**
  39154. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39155. */
  39156. axisYControlRadius: boolean;
  39157. /**
  39158. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39159. */
  39160. axisYControlHeight: boolean;
  39161. /**
  39162. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39163. */
  39164. axisYControlRotation: boolean;
  39165. /**
  39166. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39167. */
  39168. axisPinchControlRadius: boolean;
  39169. /**
  39170. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39171. */
  39172. axisPinchControlHeight: boolean;
  39173. /**
  39174. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39175. */
  39176. axisPinchControlRotation: boolean;
  39177. /**
  39178. * Log error messages if basic misconfiguration has occurred.
  39179. */
  39180. warningEnable: boolean;
  39181. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39182. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39183. private _warningCounter;
  39184. private _warning;
  39185. }
  39186. }
  39187. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39188. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39189. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39190. /**
  39191. * Default Inputs manager for the FollowCamera.
  39192. * It groups all the default supported inputs for ease of use.
  39193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39194. */
  39195. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39196. /**
  39197. * Instantiates a new FollowCameraInputsManager.
  39198. * @param camera Defines the camera the inputs belong to
  39199. */
  39200. constructor(camera: FollowCamera);
  39201. /**
  39202. * Add keyboard input support to the input manager.
  39203. * @returns the current input manager
  39204. */
  39205. addKeyboard(): FollowCameraInputsManager;
  39206. /**
  39207. * Add mouse wheel input support to the input manager.
  39208. * @returns the current input manager
  39209. */
  39210. addMouseWheel(): FollowCameraInputsManager;
  39211. /**
  39212. * Add pointers input support to the input manager.
  39213. * @returns the current input manager
  39214. */
  39215. addPointers(): FollowCameraInputsManager;
  39216. /**
  39217. * Add orientation input support to the input manager.
  39218. * @returns the current input manager
  39219. */
  39220. addVRDeviceOrientation(): FollowCameraInputsManager;
  39221. }
  39222. }
  39223. declare module "babylonjs/Cameras/followCamera" {
  39224. import { Nullable } from "babylonjs/types";
  39225. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39226. import { Scene } from "babylonjs/scene";
  39227. import { Vector3 } from "babylonjs/Maths/math.vector";
  39228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39229. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39230. /**
  39231. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39232. * an arc rotate version arcFollowCamera are available.
  39233. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39234. */
  39235. export class FollowCamera extends TargetCamera {
  39236. /**
  39237. * Distance the follow camera should follow an object at
  39238. */
  39239. radius: number;
  39240. /**
  39241. * Minimum allowed distance of the camera to the axis of rotation
  39242. * (The camera can not get closer).
  39243. * This can help limiting how the Camera is able to move in the scene.
  39244. */
  39245. lowerRadiusLimit: Nullable<number>;
  39246. /**
  39247. * Maximum allowed distance of the camera to the axis of rotation
  39248. * (The camera can not get further).
  39249. * This can help limiting how the Camera is able to move in the scene.
  39250. */
  39251. upperRadiusLimit: Nullable<number>;
  39252. /**
  39253. * Define a rotation offset between the camera and the object it follows
  39254. */
  39255. rotationOffset: number;
  39256. /**
  39257. * Minimum allowed angle to camera position relative to target object.
  39258. * This can help limiting how the Camera is able to move in the scene.
  39259. */
  39260. lowerRotationOffsetLimit: Nullable<number>;
  39261. /**
  39262. * Maximum allowed angle to camera position relative to target object.
  39263. * This can help limiting how the Camera is able to move in the scene.
  39264. */
  39265. upperRotationOffsetLimit: Nullable<number>;
  39266. /**
  39267. * Define a height offset between the camera and the object it follows.
  39268. * It can help following an object from the top (like a car chaing a plane)
  39269. */
  39270. heightOffset: number;
  39271. /**
  39272. * Minimum allowed height of camera position relative to target object.
  39273. * This can help limiting how the Camera is able to move in the scene.
  39274. */
  39275. lowerHeightOffsetLimit: Nullable<number>;
  39276. /**
  39277. * Maximum allowed height of camera position relative to target object.
  39278. * This can help limiting how the Camera is able to move in the scene.
  39279. */
  39280. upperHeightOffsetLimit: Nullable<number>;
  39281. /**
  39282. * Define how fast the camera can accelerate to follow it s target.
  39283. */
  39284. cameraAcceleration: number;
  39285. /**
  39286. * Define the speed limit of the camera following an object.
  39287. */
  39288. maxCameraSpeed: number;
  39289. /**
  39290. * Define the target of the camera.
  39291. */
  39292. lockedTarget: Nullable<AbstractMesh>;
  39293. /**
  39294. * Defines the input associated with the camera.
  39295. */
  39296. inputs: FollowCameraInputsManager;
  39297. /**
  39298. * Instantiates the follow camera.
  39299. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39300. * @param name Define the name of the camera in the scene
  39301. * @param position Define the position of the camera
  39302. * @param scene Define the scene the camera belong to
  39303. * @param lockedTarget Define the target of the camera
  39304. */
  39305. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39306. private _follow;
  39307. /**
  39308. * Attached controls to the current camera.
  39309. * @param element Defines the element the controls should be listened from
  39310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39311. */
  39312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39313. /**
  39314. * Detach the current controls from the camera.
  39315. * The camera will stop reacting to inputs.
  39316. * @param element Defines the element to stop listening the inputs from
  39317. */
  39318. detachControl(element: HTMLElement): void;
  39319. /** @hidden */
  39320. _checkInputs(): void;
  39321. private _checkLimits;
  39322. /**
  39323. * Gets the camera class name.
  39324. * @returns the class name
  39325. */
  39326. getClassName(): string;
  39327. }
  39328. /**
  39329. * Arc Rotate version of the follow camera.
  39330. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39331. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39332. */
  39333. export class ArcFollowCamera extends TargetCamera {
  39334. /** The longitudinal angle of the camera */
  39335. alpha: number;
  39336. /** The latitudinal angle of the camera */
  39337. beta: number;
  39338. /** The radius of the camera from its target */
  39339. radius: number;
  39340. /** Define the camera target (the messh it should follow) */
  39341. target: Nullable<AbstractMesh>;
  39342. private _cartesianCoordinates;
  39343. /**
  39344. * Instantiates a new ArcFollowCamera
  39345. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39346. * @param name Define the name of the camera
  39347. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39348. * @param beta Define the rotation angle of the camera around the elevation axis
  39349. * @param radius Define the radius of the camera from its target point
  39350. * @param target Define the target of the camera
  39351. * @param scene Define the scene the camera belongs to
  39352. */
  39353. constructor(name: string,
  39354. /** The longitudinal angle of the camera */
  39355. alpha: number,
  39356. /** The latitudinal angle of the camera */
  39357. beta: number,
  39358. /** The radius of the camera from its target */
  39359. radius: number,
  39360. /** Define the camera target (the messh it should follow) */
  39361. target: Nullable<AbstractMesh>, scene: Scene);
  39362. private _follow;
  39363. /** @hidden */
  39364. _checkInputs(): void;
  39365. /**
  39366. * Returns the class name of the object.
  39367. * It is mostly used internally for serialization purposes.
  39368. */
  39369. getClassName(): string;
  39370. }
  39371. }
  39372. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39374. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39375. import { Nullable } from "babylonjs/types";
  39376. /**
  39377. * Manage the keyboard inputs to control the movement of a follow camera.
  39378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39379. */
  39380. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39381. /**
  39382. * Defines the camera the input is attached to.
  39383. */
  39384. camera: FollowCamera;
  39385. /**
  39386. * Defines the list of key codes associated with the up action (increase heightOffset)
  39387. */
  39388. keysHeightOffsetIncr: number[];
  39389. /**
  39390. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39391. */
  39392. keysHeightOffsetDecr: number[];
  39393. /**
  39394. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39395. */
  39396. keysHeightOffsetModifierAlt: boolean;
  39397. /**
  39398. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39399. */
  39400. keysHeightOffsetModifierCtrl: boolean;
  39401. /**
  39402. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39403. */
  39404. keysHeightOffsetModifierShift: boolean;
  39405. /**
  39406. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39407. */
  39408. keysRotationOffsetIncr: number[];
  39409. /**
  39410. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39411. */
  39412. keysRotationOffsetDecr: number[];
  39413. /**
  39414. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39415. */
  39416. keysRotationOffsetModifierAlt: boolean;
  39417. /**
  39418. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39419. */
  39420. keysRotationOffsetModifierCtrl: boolean;
  39421. /**
  39422. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39423. */
  39424. keysRotationOffsetModifierShift: boolean;
  39425. /**
  39426. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39427. */
  39428. keysRadiusIncr: number[];
  39429. /**
  39430. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39431. */
  39432. keysRadiusDecr: number[];
  39433. /**
  39434. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39435. */
  39436. keysRadiusModifierAlt: boolean;
  39437. /**
  39438. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39439. */
  39440. keysRadiusModifierCtrl: boolean;
  39441. /**
  39442. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39443. */
  39444. keysRadiusModifierShift: boolean;
  39445. /**
  39446. * Defines the rate of change of heightOffset.
  39447. */
  39448. heightSensibility: number;
  39449. /**
  39450. * Defines the rate of change of rotationOffset.
  39451. */
  39452. rotationSensibility: number;
  39453. /**
  39454. * Defines the rate of change of radius.
  39455. */
  39456. radiusSensibility: number;
  39457. private _keys;
  39458. private _ctrlPressed;
  39459. private _altPressed;
  39460. private _shiftPressed;
  39461. private _onCanvasBlurObserver;
  39462. private _onKeyboardObserver;
  39463. private _engine;
  39464. private _scene;
  39465. /**
  39466. * Attach the input controls to a specific dom element to get the input from.
  39467. * @param element Defines the element the controls should be listened from
  39468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39469. */
  39470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39471. /**
  39472. * Detach the current controls from the specified dom element.
  39473. * @param element Defines the element to stop listening the inputs from
  39474. */
  39475. detachControl(element: Nullable<HTMLElement>): void;
  39476. /**
  39477. * Update the current camera state depending on the inputs that have been used this frame.
  39478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39479. */
  39480. checkInputs(): void;
  39481. /**
  39482. * Gets the class name of the current input.
  39483. * @returns the class name
  39484. */
  39485. getClassName(): string;
  39486. /**
  39487. * Get the friendly name associated with the input class.
  39488. * @returns the input friendly name
  39489. */
  39490. getSimpleName(): string;
  39491. /**
  39492. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39493. * allow modification of the heightOffset value.
  39494. */
  39495. private _modifierHeightOffset;
  39496. /**
  39497. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39498. * allow modification of the rotationOffset value.
  39499. */
  39500. private _modifierRotationOffset;
  39501. /**
  39502. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39503. * allow modification of the radius value.
  39504. */
  39505. private _modifierRadius;
  39506. }
  39507. }
  39508. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39509. import { Nullable } from "babylonjs/types";
  39510. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39511. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39512. import { Observable } from "babylonjs/Misc/observable";
  39513. module "babylonjs/Cameras/freeCameraInputsManager" {
  39514. interface FreeCameraInputsManager {
  39515. /**
  39516. * @hidden
  39517. */
  39518. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39519. /**
  39520. * Add orientation input support to the input manager.
  39521. * @returns the current input manager
  39522. */
  39523. addDeviceOrientation(): FreeCameraInputsManager;
  39524. }
  39525. }
  39526. /**
  39527. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39528. * Screen rotation is taken into account.
  39529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39530. */
  39531. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39532. private _camera;
  39533. private _screenOrientationAngle;
  39534. private _constantTranform;
  39535. private _screenQuaternion;
  39536. private _alpha;
  39537. private _beta;
  39538. private _gamma;
  39539. /**
  39540. * Can be used to detect if a device orientation sensor is availible on a device
  39541. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39542. * @returns a promise that will resolve on orientation change
  39543. */
  39544. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39545. /**
  39546. * @hidden
  39547. */
  39548. _onDeviceOrientationChangedObservable: Observable<void>;
  39549. /**
  39550. * Instantiates a new input
  39551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39552. */
  39553. constructor();
  39554. /**
  39555. * Define the camera controlled by the input.
  39556. */
  39557. camera: FreeCamera;
  39558. /**
  39559. * Attach the input controls to a specific dom element to get the input from.
  39560. * @param element Defines the element the controls should be listened from
  39561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39562. */
  39563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39564. private _orientationChanged;
  39565. private _deviceOrientation;
  39566. /**
  39567. * Detach the current controls from the specified dom element.
  39568. * @param element Defines the element to stop listening the inputs from
  39569. */
  39570. detachControl(element: Nullable<HTMLElement>): void;
  39571. /**
  39572. * Update the current camera state depending on the inputs that have been used this frame.
  39573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39574. */
  39575. checkInputs(): void;
  39576. /**
  39577. * Gets the class name of the current intput.
  39578. * @returns the class name
  39579. */
  39580. getClassName(): string;
  39581. /**
  39582. * Get the friendly name associated with the input class.
  39583. * @returns the input friendly name
  39584. */
  39585. getSimpleName(): string;
  39586. }
  39587. }
  39588. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39589. import { Nullable } from "babylonjs/types";
  39590. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39591. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39592. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39593. /**
  39594. * Manage the gamepad inputs to control a free camera.
  39595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39596. */
  39597. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39598. /**
  39599. * Define the camera the input is attached to.
  39600. */
  39601. camera: FreeCamera;
  39602. /**
  39603. * Define the Gamepad controlling the input
  39604. */
  39605. gamepad: Nullable<Gamepad>;
  39606. /**
  39607. * Defines the gamepad rotation sensiblity.
  39608. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39609. */
  39610. gamepadAngularSensibility: number;
  39611. /**
  39612. * Defines the gamepad move sensiblity.
  39613. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39614. */
  39615. gamepadMoveSensibility: number;
  39616. private _onGamepadConnectedObserver;
  39617. private _onGamepadDisconnectedObserver;
  39618. private _cameraTransform;
  39619. private _deltaTransform;
  39620. private _vector3;
  39621. private _vector2;
  39622. /**
  39623. * Attach the input controls to a specific dom element to get the input from.
  39624. * @param element Defines the element the controls should be listened from
  39625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39626. */
  39627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39628. /**
  39629. * Detach the current controls from the specified dom element.
  39630. * @param element Defines the element to stop listening the inputs from
  39631. */
  39632. detachControl(element: Nullable<HTMLElement>): void;
  39633. /**
  39634. * Update the current camera state depending on the inputs that have been used this frame.
  39635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39636. */
  39637. checkInputs(): void;
  39638. /**
  39639. * Gets the class name of the current intput.
  39640. * @returns the class name
  39641. */
  39642. getClassName(): string;
  39643. /**
  39644. * Get the friendly name associated with the input class.
  39645. * @returns the input friendly name
  39646. */
  39647. getSimpleName(): string;
  39648. }
  39649. }
  39650. declare module "babylonjs/Misc/virtualJoystick" {
  39651. import { Nullable } from "babylonjs/types";
  39652. import { Vector3 } from "babylonjs/Maths/math.vector";
  39653. /**
  39654. * Defines the potential axis of a Joystick
  39655. */
  39656. export enum JoystickAxis {
  39657. /** X axis */
  39658. X = 0,
  39659. /** Y axis */
  39660. Y = 1,
  39661. /** Z axis */
  39662. Z = 2
  39663. }
  39664. /**
  39665. * Class used to define virtual joystick (used in touch mode)
  39666. */
  39667. export class VirtualJoystick {
  39668. /**
  39669. * Gets or sets a boolean indicating that left and right values must be inverted
  39670. */
  39671. reverseLeftRight: boolean;
  39672. /**
  39673. * Gets or sets a boolean indicating that up and down values must be inverted
  39674. */
  39675. reverseUpDown: boolean;
  39676. /**
  39677. * Gets the offset value for the position (ie. the change of the position value)
  39678. */
  39679. deltaPosition: Vector3;
  39680. /**
  39681. * Gets a boolean indicating if the virtual joystick was pressed
  39682. */
  39683. pressed: boolean;
  39684. /**
  39685. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39686. */
  39687. static Canvas: Nullable<HTMLCanvasElement>;
  39688. private static _globalJoystickIndex;
  39689. private static vjCanvasContext;
  39690. private static vjCanvasWidth;
  39691. private static vjCanvasHeight;
  39692. private static halfWidth;
  39693. private _action;
  39694. private _axisTargetedByLeftAndRight;
  39695. private _axisTargetedByUpAndDown;
  39696. private _joystickSensibility;
  39697. private _inversedSensibility;
  39698. private _joystickPointerID;
  39699. private _joystickColor;
  39700. private _joystickPointerPos;
  39701. private _joystickPreviousPointerPos;
  39702. private _joystickPointerStartPos;
  39703. private _deltaJoystickVector;
  39704. private _leftJoystick;
  39705. private _touches;
  39706. private _onPointerDownHandlerRef;
  39707. private _onPointerMoveHandlerRef;
  39708. private _onPointerUpHandlerRef;
  39709. private _onResize;
  39710. /**
  39711. * Creates a new virtual joystick
  39712. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39713. */
  39714. constructor(leftJoystick?: boolean);
  39715. /**
  39716. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39717. * @param newJoystickSensibility defines the new sensibility
  39718. */
  39719. setJoystickSensibility(newJoystickSensibility: number): void;
  39720. private _onPointerDown;
  39721. private _onPointerMove;
  39722. private _onPointerUp;
  39723. /**
  39724. * Change the color of the virtual joystick
  39725. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39726. */
  39727. setJoystickColor(newColor: string): void;
  39728. /**
  39729. * Defines a callback to call when the joystick is touched
  39730. * @param action defines the callback
  39731. */
  39732. setActionOnTouch(action: () => any): void;
  39733. /**
  39734. * Defines which axis you'd like to control for left & right
  39735. * @param axis defines the axis to use
  39736. */
  39737. setAxisForLeftRight(axis: JoystickAxis): void;
  39738. /**
  39739. * Defines which axis you'd like to control for up & down
  39740. * @param axis defines the axis to use
  39741. */
  39742. setAxisForUpDown(axis: JoystickAxis): void;
  39743. private _drawVirtualJoystick;
  39744. /**
  39745. * Release internal HTML canvas
  39746. */
  39747. releaseCanvas(): void;
  39748. }
  39749. }
  39750. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39751. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39752. import { Nullable } from "babylonjs/types";
  39753. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39755. module "babylonjs/Cameras/freeCameraInputsManager" {
  39756. interface FreeCameraInputsManager {
  39757. /**
  39758. * Add virtual joystick input support to the input manager.
  39759. * @returns the current input manager
  39760. */
  39761. addVirtualJoystick(): FreeCameraInputsManager;
  39762. }
  39763. }
  39764. /**
  39765. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39766. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39767. */
  39768. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39769. /**
  39770. * Defines the camera the input is attached to.
  39771. */
  39772. camera: FreeCamera;
  39773. private _leftjoystick;
  39774. private _rightjoystick;
  39775. /**
  39776. * Gets the left stick of the virtual joystick.
  39777. * @returns The virtual Joystick
  39778. */
  39779. getLeftJoystick(): VirtualJoystick;
  39780. /**
  39781. * Gets the right stick of the virtual joystick.
  39782. * @returns The virtual Joystick
  39783. */
  39784. getRightJoystick(): VirtualJoystick;
  39785. /**
  39786. * Update the current camera state depending on the inputs that have been used this frame.
  39787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39788. */
  39789. checkInputs(): void;
  39790. /**
  39791. * Attach the input controls to a specific dom element to get the input from.
  39792. * @param element Defines the element the controls should be listened from
  39793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39794. */
  39795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39796. /**
  39797. * Detach the current controls from the specified dom element.
  39798. * @param element Defines the element to stop listening the inputs from
  39799. */
  39800. detachControl(element: Nullable<HTMLElement>): void;
  39801. /**
  39802. * Gets the class name of the current intput.
  39803. * @returns the class name
  39804. */
  39805. getClassName(): string;
  39806. /**
  39807. * Get the friendly name associated with the input class.
  39808. * @returns the input friendly name
  39809. */
  39810. getSimpleName(): string;
  39811. }
  39812. }
  39813. declare module "babylonjs/Cameras/Inputs/index" {
  39814. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39815. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39816. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39817. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39818. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39819. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39820. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39821. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39822. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39823. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39824. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39825. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39826. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39827. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39828. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39829. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39830. }
  39831. declare module "babylonjs/Cameras/touchCamera" {
  39832. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39833. import { Scene } from "babylonjs/scene";
  39834. import { Vector3 } from "babylonjs/Maths/math.vector";
  39835. /**
  39836. * This represents a FPS type of camera controlled by touch.
  39837. * This is like a universal camera minus the Gamepad controls.
  39838. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39839. */
  39840. export class TouchCamera extends FreeCamera {
  39841. /**
  39842. * Defines the touch sensibility for rotation.
  39843. * The higher the faster.
  39844. */
  39845. touchAngularSensibility: number;
  39846. /**
  39847. * Defines the touch sensibility for move.
  39848. * The higher the faster.
  39849. */
  39850. touchMoveSensibility: number;
  39851. /**
  39852. * Instantiates a new touch camera.
  39853. * This represents a FPS type of camera controlled by touch.
  39854. * This is like a universal camera minus the Gamepad controls.
  39855. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39856. * @param name Define the name of the camera in the scene
  39857. * @param position Define the start position of the camera in the scene
  39858. * @param scene Define the scene the camera belongs to
  39859. */
  39860. constructor(name: string, position: Vector3, scene: Scene);
  39861. /**
  39862. * Gets the current object class name.
  39863. * @return the class name
  39864. */
  39865. getClassName(): string;
  39866. /** @hidden */
  39867. _setupInputs(): void;
  39868. }
  39869. }
  39870. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39871. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39872. import { Scene } from "babylonjs/scene";
  39873. import { Vector3 } from "babylonjs/Maths/math.vector";
  39874. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39875. import { Axis } from "babylonjs/Maths/math.axis";
  39876. /**
  39877. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39878. * being tilted forward or back and left or right.
  39879. */
  39880. export class DeviceOrientationCamera extends FreeCamera {
  39881. private _initialQuaternion;
  39882. private _quaternionCache;
  39883. private _tmpDragQuaternion;
  39884. private _disablePointerInputWhenUsingDeviceOrientation;
  39885. /**
  39886. * Creates a new device orientation camera
  39887. * @param name The name of the camera
  39888. * @param position The start position camera
  39889. * @param scene The scene the camera belongs to
  39890. */
  39891. constructor(name: string, position: Vector3, scene: Scene);
  39892. /**
  39893. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39894. */
  39895. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39896. private _dragFactor;
  39897. /**
  39898. * Enabled turning on the y axis when the orientation sensor is active
  39899. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39900. */
  39901. enableHorizontalDragging(dragFactor?: number): void;
  39902. /**
  39903. * Gets the current instance class name ("DeviceOrientationCamera").
  39904. * This helps avoiding instanceof at run time.
  39905. * @returns the class name
  39906. */
  39907. getClassName(): string;
  39908. /**
  39909. * @hidden
  39910. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39911. */
  39912. _checkInputs(): void;
  39913. /**
  39914. * Reset the camera to its default orientation on the specified axis only.
  39915. * @param axis The axis to reset
  39916. */
  39917. resetToCurrentRotation(axis?: Axis): void;
  39918. }
  39919. }
  39920. declare module "babylonjs/Gamepads/xboxGamepad" {
  39921. import { Observable } from "babylonjs/Misc/observable";
  39922. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39923. /**
  39924. * Defines supported buttons for XBox360 compatible gamepads
  39925. */
  39926. export enum Xbox360Button {
  39927. /** A */
  39928. A = 0,
  39929. /** B */
  39930. B = 1,
  39931. /** X */
  39932. X = 2,
  39933. /** Y */
  39934. Y = 3,
  39935. /** Start */
  39936. Start = 4,
  39937. /** Back */
  39938. Back = 5,
  39939. /** Left button */
  39940. LB = 6,
  39941. /** Right button */
  39942. RB = 7,
  39943. /** Left stick */
  39944. LeftStick = 8,
  39945. /** Right stick */
  39946. RightStick = 9
  39947. }
  39948. /** Defines values for XBox360 DPad */
  39949. export enum Xbox360Dpad {
  39950. /** Up */
  39951. Up = 0,
  39952. /** Down */
  39953. Down = 1,
  39954. /** Left */
  39955. Left = 2,
  39956. /** Right */
  39957. Right = 3
  39958. }
  39959. /**
  39960. * Defines a XBox360 gamepad
  39961. */
  39962. export class Xbox360Pad extends Gamepad {
  39963. private _leftTrigger;
  39964. private _rightTrigger;
  39965. private _onlefttriggerchanged;
  39966. private _onrighttriggerchanged;
  39967. private _onbuttondown;
  39968. private _onbuttonup;
  39969. private _ondpaddown;
  39970. private _ondpadup;
  39971. /** Observable raised when a button is pressed */
  39972. onButtonDownObservable: Observable<Xbox360Button>;
  39973. /** Observable raised when a button is released */
  39974. onButtonUpObservable: Observable<Xbox360Button>;
  39975. /** Observable raised when a pad is pressed */
  39976. onPadDownObservable: Observable<Xbox360Dpad>;
  39977. /** Observable raised when a pad is released */
  39978. onPadUpObservable: Observable<Xbox360Dpad>;
  39979. private _buttonA;
  39980. private _buttonB;
  39981. private _buttonX;
  39982. private _buttonY;
  39983. private _buttonBack;
  39984. private _buttonStart;
  39985. private _buttonLB;
  39986. private _buttonRB;
  39987. private _buttonLeftStick;
  39988. private _buttonRightStick;
  39989. private _dPadUp;
  39990. private _dPadDown;
  39991. private _dPadLeft;
  39992. private _dPadRight;
  39993. private _isXboxOnePad;
  39994. /**
  39995. * Creates a new XBox360 gamepad object
  39996. * @param id defines the id of this gamepad
  39997. * @param index defines its index
  39998. * @param gamepad defines the internal HTML gamepad object
  39999. * @param xboxOne defines if it is a XBox One gamepad
  40000. */
  40001. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40002. /**
  40003. * Defines the callback to call when left trigger is pressed
  40004. * @param callback defines the callback to use
  40005. */
  40006. onlefttriggerchanged(callback: (value: number) => void): void;
  40007. /**
  40008. * Defines the callback to call when right trigger is pressed
  40009. * @param callback defines the callback to use
  40010. */
  40011. onrighttriggerchanged(callback: (value: number) => void): void;
  40012. /**
  40013. * Gets the left trigger value
  40014. */
  40015. /**
  40016. * Sets the left trigger value
  40017. */
  40018. leftTrigger: number;
  40019. /**
  40020. * Gets the right trigger value
  40021. */
  40022. /**
  40023. * Sets the right trigger value
  40024. */
  40025. rightTrigger: number;
  40026. /**
  40027. * Defines the callback to call when a button is pressed
  40028. * @param callback defines the callback to use
  40029. */
  40030. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40031. /**
  40032. * Defines the callback to call when a button is released
  40033. * @param callback defines the callback to use
  40034. */
  40035. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40036. /**
  40037. * Defines the callback to call when a pad is pressed
  40038. * @param callback defines the callback to use
  40039. */
  40040. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40041. /**
  40042. * Defines the callback to call when a pad is released
  40043. * @param callback defines the callback to use
  40044. */
  40045. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40046. private _setButtonValue;
  40047. private _setDPadValue;
  40048. /**
  40049. * Gets the value of the `A` button
  40050. */
  40051. /**
  40052. * Sets the value of the `A` button
  40053. */
  40054. buttonA: number;
  40055. /**
  40056. * Gets the value of the `B` button
  40057. */
  40058. /**
  40059. * Sets the value of the `B` button
  40060. */
  40061. buttonB: number;
  40062. /**
  40063. * Gets the value of the `X` button
  40064. */
  40065. /**
  40066. * Sets the value of the `X` button
  40067. */
  40068. buttonX: number;
  40069. /**
  40070. * Gets the value of the `Y` button
  40071. */
  40072. /**
  40073. * Sets the value of the `Y` button
  40074. */
  40075. buttonY: number;
  40076. /**
  40077. * Gets the value of the `Start` button
  40078. */
  40079. /**
  40080. * Sets the value of the `Start` button
  40081. */
  40082. buttonStart: number;
  40083. /**
  40084. * Gets the value of the `Back` button
  40085. */
  40086. /**
  40087. * Sets the value of the `Back` button
  40088. */
  40089. buttonBack: number;
  40090. /**
  40091. * Gets the value of the `Left` button
  40092. */
  40093. /**
  40094. * Sets the value of the `Left` button
  40095. */
  40096. buttonLB: number;
  40097. /**
  40098. * Gets the value of the `Right` button
  40099. */
  40100. /**
  40101. * Sets the value of the `Right` button
  40102. */
  40103. buttonRB: number;
  40104. /**
  40105. * Gets the value of the Left joystick
  40106. */
  40107. /**
  40108. * Sets the value of the Left joystick
  40109. */
  40110. buttonLeftStick: number;
  40111. /**
  40112. * Gets the value of the Right joystick
  40113. */
  40114. /**
  40115. * Sets the value of the Right joystick
  40116. */
  40117. buttonRightStick: number;
  40118. /**
  40119. * Gets the value of D-pad up
  40120. */
  40121. /**
  40122. * Sets the value of D-pad up
  40123. */
  40124. dPadUp: number;
  40125. /**
  40126. * Gets the value of D-pad down
  40127. */
  40128. /**
  40129. * Sets the value of D-pad down
  40130. */
  40131. dPadDown: number;
  40132. /**
  40133. * Gets the value of D-pad left
  40134. */
  40135. /**
  40136. * Sets the value of D-pad left
  40137. */
  40138. dPadLeft: number;
  40139. /**
  40140. * Gets the value of D-pad right
  40141. */
  40142. /**
  40143. * Sets the value of D-pad right
  40144. */
  40145. dPadRight: number;
  40146. /**
  40147. * Force the gamepad to synchronize with device values
  40148. */
  40149. update(): void;
  40150. /**
  40151. * Disposes the gamepad
  40152. */
  40153. dispose(): void;
  40154. }
  40155. }
  40156. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40157. import { Observable } from "babylonjs/Misc/observable";
  40158. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40159. /**
  40160. * Defines supported buttons for DualShock compatible gamepads
  40161. */
  40162. export enum DualShockButton {
  40163. /** Cross */
  40164. Cross = 0,
  40165. /** Circle */
  40166. Circle = 1,
  40167. /** Square */
  40168. Square = 2,
  40169. /** Triangle */
  40170. Triangle = 3,
  40171. /** Options */
  40172. Options = 4,
  40173. /** Share */
  40174. Share = 5,
  40175. /** L1 */
  40176. L1 = 6,
  40177. /** R1 */
  40178. R1 = 7,
  40179. /** Left stick */
  40180. LeftStick = 8,
  40181. /** Right stick */
  40182. RightStick = 9
  40183. }
  40184. /** Defines values for DualShock DPad */
  40185. export enum DualShockDpad {
  40186. /** Up */
  40187. Up = 0,
  40188. /** Down */
  40189. Down = 1,
  40190. /** Left */
  40191. Left = 2,
  40192. /** Right */
  40193. Right = 3
  40194. }
  40195. /**
  40196. * Defines a DualShock gamepad
  40197. */
  40198. export class DualShockPad extends Gamepad {
  40199. private _leftTrigger;
  40200. private _rightTrigger;
  40201. private _onlefttriggerchanged;
  40202. private _onrighttriggerchanged;
  40203. private _onbuttondown;
  40204. private _onbuttonup;
  40205. private _ondpaddown;
  40206. private _ondpadup;
  40207. /** Observable raised when a button is pressed */
  40208. onButtonDownObservable: Observable<DualShockButton>;
  40209. /** Observable raised when a button is released */
  40210. onButtonUpObservable: Observable<DualShockButton>;
  40211. /** Observable raised when a pad is pressed */
  40212. onPadDownObservable: Observable<DualShockDpad>;
  40213. /** Observable raised when a pad is released */
  40214. onPadUpObservable: Observable<DualShockDpad>;
  40215. private _buttonCross;
  40216. private _buttonCircle;
  40217. private _buttonSquare;
  40218. private _buttonTriangle;
  40219. private _buttonShare;
  40220. private _buttonOptions;
  40221. private _buttonL1;
  40222. private _buttonR1;
  40223. private _buttonLeftStick;
  40224. private _buttonRightStick;
  40225. private _dPadUp;
  40226. private _dPadDown;
  40227. private _dPadLeft;
  40228. private _dPadRight;
  40229. /**
  40230. * Creates a new DualShock gamepad object
  40231. * @param id defines the id of this gamepad
  40232. * @param index defines its index
  40233. * @param gamepad defines the internal HTML gamepad object
  40234. */
  40235. constructor(id: string, index: number, gamepad: any);
  40236. /**
  40237. * Defines the callback to call when left trigger is pressed
  40238. * @param callback defines the callback to use
  40239. */
  40240. onlefttriggerchanged(callback: (value: number) => void): void;
  40241. /**
  40242. * Defines the callback to call when right trigger is pressed
  40243. * @param callback defines the callback to use
  40244. */
  40245. onrighttriggerchanged(callback: (value: number) => void): void;
  40246. /**
  40247. * Gets the left trigger value
  40248. */
  40249. /**
  40250. * Sets the left trigger value
  40251. */
  40252. leftTrigger: number;
  40253. /**
  40254. * Gets the right trigger value
  40255. */
  40256. /**
  40257. * Sets the right trigger value
  40258. */
  40259. rightTrigger: number;
  40260. /**
  40261. * Defines the callback to call when a button is pressed
  40262. * @param callback defines the callback to use
  40263. */
  40264. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40265. /**
  40266. * Defines the callback to call when a button is released
  40267. * @param callback defines the callback to use
  40268. */
  40269. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40270. /**
  40271. * Defines the callback to call when a pad is pressed
  40272. * @param callback defines the callback to use
  40273. */
  40274. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40275. /**
  40276. * Defines the callback to call when a pad is released
  40277. * @param callback defines the callback to use
  40278. */
  40279. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40280. private _setButtonValue;
  40281. private _setDPadValue;
  40282. /**
  40283. * Gets the value of the `Cross` button
  40284. */
  40285. /**
  40286. * Sets the value of the `Cross` button
  40287. */
  40288. buttonCross: number;
  40289. /**
  40290. * Gets the value of the `Circle` button
  40291. */
  40292. /**
  40293. * Sets the value of the `Circle` button
  40294. */
  40295. buttonCircle: number;
  40296. /**
  40297. * Gets the value of the `Square` button
  40298. */
  40299. /**
  40300. * Sets the value of the `Square` button
  40301. */
  40302. buttonSquare: number;
  40303. /**
  40304. * Gets the value of the `Triangle` button
  40305. */
  40306. /**
  40307. * Sets the value of the `Triangle` button
  40308. */
  40309. buttonTriangle: number;
  40310. /**
  40311. * Gets the value of the `Options` button
  40312. */
  40313. /**
  40314. * Sets the value of the `Options` button
  40315. */
  40316. buttonOptions: number;
  40317. /**
  40318. * Gets the value of the `Share` button
  40319. */
  40320. /**
  40321. * Sets the value of the `Share` button
  40322. */
  40323. buttonShare: number;
  40324. /**
  40325. * Gets the value of the `L1` button
  40326. */
  40327. /**
  40328. * Sets the value of the `L1` button
  40329. */
  40330. buttonL1: number;
  40331. /**
  40332. * Gets the value of the `R1` button
  40333. */
  40334. /**
  40335. * Sets the value of the `R1` button
  40336. */
  40337. buttonR1: number;
  40338. /**
  40339. * Gets the value of the Left joystick
  40340. */
  40341. /**
  40342. * Sets the value of the Left joystick
  40343. */
  40344. buttonLeftStick: number;
  40345. /**
  40346. * Gets the value of the Right joystick
  40347. */
  40348. /**
  40349. * Sets the value of the Right joystick
  40350. */
  40351. buttonRightStick: number;
  40352. /**
  40353. * Gets the value of D-pad up
  40354. */
  40355. /**
  40356. * Sets the value of D-pad up
  40357. */
  40358. dPadUp: number;
  40359. /**
  40360. * Gets the value of D-pad down
  40361. */
  40362. /**
  40363. * Sets the value of D-pad down
  40364. */
  40365. dPadDown: number;
  40366. /**
  40367. * Gets the value of D-pad left
  40368. */
  40369. /**
  40370. * Sets the value of D-pad left
  40371. */
  40372. dPadLeft: number;
  40373. /**
  40374. * Gets the value of D-pad right
  40375. */
  40376. /**
  40377. * Sets the value of D-pad right
  40378. */
  40379. dPadRight: number;
  40380. /**
  40381. * Force the gamepad to synchronize with device values
  40382. */
  40383. update(): void;
  40384. /**
  40385. * Disposes the gamepad
  40386. */
  40387. dispose(): void;
  40388. }
  40389. }
  40390. declare module "babylonjs/Gamepads/gamepadManager" {
  40391. import { Observable } from "babylonjs/Misc/observable";
  40392. import { Nullable } from "babylonjs/types";
  40393. import { Scene } from "babylonjs/scene";
  40394. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40395. /**
  40396. * Manager for handling gamepads
  40397. */
  40398. export class GamepadManager {
  40399. private _scene?;
  40400. private _babylonGamepads;
  40401. private _oneGamepadConnected;
  40402. /** @hidden */
  40403. _isMonitoring: boolean;
  40404. private _gamepadEventSupported;
  40405. private _gamepadSupport;
  40406. /**
  40407. * observable to be triggered when the gamepad controller has been connected
  40408. */
  40409. onGamepadConnectedObservable: Observable<Gamepad>;
  40410. /**
  40411. * observable to be triggered when the gamepad controller has been disconnected
  40412. */
  40413. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40414. private _onGamepadConnectedEvent;
  40415. private _onGamepadDisconnectedEvent;
  40416. /**
  40417. * Initializes the gamepad manager
  40418. * @param _scene BabylonJS scene
  40419. */
  40420. constructor(_scene?: Scene | undefined);
  40421. /**
  40422. * The gamepads in the game pad manager
  40423. */
  40424. readonly gamepads: Gamepad[];
  40425. /**
  40426. * Get the gamepad controllers based on type
  40427. * @param type The type of gamepad controller
  40428. * @returns Nullable gamepad
  40429. */
  40430. getGamepadByType(type?: number): Nullable<Gamepad>;
  40431. /**
  40432. * Disposes the gamepad manager
  40433. */
  40434. dispose(): void;
  40435. private _addNewGamepad;
  40436. private _startMonitoringGamepads;
  40437. private _stopMonitoringGamepads;
  40438. /** @hidden */
  40439. _checkGamepadsStatus(): void;
  40440. private _updateGamepadObjects;
  40441. }
  40442. }
  40443. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40444. import { Nullable } from "babylonjs/types";
  40445. import { Scene } from "babylonjs/scene";
  40446. import { ISceneComponent } from "babylonjs/sceneComponent";
  40447. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40448. module "babylonjs/scene" {
  40449. interface Scene {
  40450. /** @hidden */
  40451. _gamepadManager: Nullable<GamepadManager>;
  40452. /**
  40453. * Gets the gamepad manager associated with the scene
  40454. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40455. */
  40456. gamepadManager: GamepadManager;
  40457. }
  40458. }
  40459. module "babylonjs/Cameras/freeCameraInputsManager" {
  40460. /**
  40461. * Interface representing a free camera inputs manager
  40462. */
  40463. interface FreeCameraInputsManager {
  40464. /**
  40465. * Adds gamepad input support to the FreeCameraInputsManager.
  40466. * @returns the FreeCameraInputsManager
  40467. */
  40468. addGamepad(): FreeCameraInputsManager;
  40469. }
  40470. }
  40471. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40472. /**
  40473. * Interface representing an arc rotate camera inputs manager
  40474. */
  40475. interface ArcRotateCameraInputsManager {
  40476. /**
  40477. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40478. * @returns the camera inputs manager
  40479. */
  40480. addGamepad(): ArcRotateCameraInputsManager;
  40481. }
  40482. }
  40483. /**
  40484. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40485. */
  40486. export class GamepadSystemSceneComponent implements ISceneComponent {
  40487. /**
  40488. * The component name helpfull to identify the component in the list of scene components.
  40489. */
  40490. readonly name: string;
  40491. /**
  40492. * The scene the component belongs to.
  40493. */
  40494. scene: Scene;
  40495. /**
  40496. * Creates a new instance of the component for the given scene
  40497. * @param scene Defines the scene to register the component in
  40498. */
  40499. constructor(scene: Scene);
  40500. /**
  40501. * Registers the component in a given scene
  40502. */
  40503. register(): void;
  40504. /**
  40505. * Rebuilds the elements related to this component in case of
  40506. * context lost for instance.
  40507. */
  40508. rebuild(): void;
  40509. /**
  40510. * Disposes the component and the associated ressources
  40511. */
  40512. dispose(): void;
  40513. private _beforeCameraUpdate;
  40514. }
  40515. }
  40516. declare module "babylonjs/Cameras/universalCamera" {
  40517. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40518. import { Scene } from "babylonjs/scene";
  40519. import { Vector3 } from "babylonjs/Maths/math.vector";
  40520. import "babylonjs/Gamepads/gamepadSceneComponent";
  40521. /**
  40522. * 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,
  40523. * which still works and will still be found in many Playgrounds.
  40524. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40525. */
  40526. export class UniversalCamera extends TouchCamera {
  40527. /**
  40528. * Defines the gamepad rotation sensiblity.
  40529. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40530. */
  40531. gamepadAngularSensibility: number;
  40532. /**
  40533. * Defines the gamepad move sensiblity.
  40534. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40535. */
  40536. gamepadMoveSensibility: number;
  40537. /**
  40538. * 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,
  40539. * which still works and will still be found in many Playgrounds.
  40540. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40541. * @param name Define the name of the camera in the scene
  40542. * @param position Define the start position of the camera in the scene
  40543. * @param scene Define the scene the camera belongs to
  40544. */
  40545. constructor(name: string, position: Vector3, scene: Scene);
  40546. /**
  40547. * Gets the current object class name.
  40548. * @return the class name
  40549. */
  40550. getClassName(): string;
  40551. }
  40552. }
  40553. declare module "babylonjs/Cameras/gamepadCamera" {
  40554. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40555. import { Scene } from "babylonjs/scene";
  40556. import { Vector3 } from "babylonjs/Maths/math.vector";
  40557. /**
  40558. * This represents a FPS type of camera. This is only here for back compat purpose.
  40559. * Please use the UniversalCamera instead as both are identical.
  40560. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40561. */
  40562. export class GamepadCamera extends UniversalCamera {
  40563. /**
  40564. * Instantiates a new Gamepad Camera
  40565. * This represents a FPS type of camera. This is only here for back compat purpose.
  40566. * Please use the UniversalCamera instead as both are identical.
  40567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40568. * @param name Define the name of the camera in the scene
  40569. * @param position Define the start position of the camera in the scene
  40570. * @param scene Define the scene the camera belongs to
  40571. */
  40572. constructor(name: string, position: Vector3, scene: Scene);
  40573. /**
  40574. * Gets the current object class name.
  40575. * @return the class name
  40576. */
  40577. getClassName(): string;
  40578. }
  40579. }
  40580. declare module "babylonjs/Shaders/pass.fragment" {
  40581. /** @hidden */
  40582. export var passPixelShader: {
  40583. name: string;
  40584. shader: string;
  40585. };
  40586. }
  40587. declare module "babylonjs/Shaders/passCube.fragment" {
  40588. /** @hidden */
  40589. export var passCubePixelShader: {
  40590. name: string;
  40591. shader: string;
  40592. };
  40593. }
  40594. declare module "babylonjs/PostProcesses/passPostProcess" {
  40595. import { Nullable } from "babylonjs/types";
  40596. import { Camera } from "babylonjs/Cameras/camera";
  40597. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40598. import { Engine } from "babylonjs/Engines/engine";
  40599. import "babylonjs/Shaders/pass.fragment";
  40600. import "babylonjs/Shaders/passCube.fragment";
  40601. /**
  40602. * PassPostProcess which produces an output the same as it's input
  40603. */
  40604. export class PassPostProcess extends PostProcess {
  40605. /**
  40606. * Creates the PassPostProcess
  40607. * @param name The name of the effect.
  40608. * @param options The required width/height ratio to downsize to before computing the render pass.
  40609. * @param camera The camera to apply the render pass to.
  40610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40611. * @param engine The engine which the post process will be applied. (default: current engine)
  40612. * @param reusable If the post process can be reused on the same frame. (default: false)
  40613. * @param textureType The type of texture to be used when performing the post processing.
  40614. * @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)
  40615. */
  40616. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40617. }
  40618. /**
  40619. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40620. */
  40621. export class PassCubePostProcess extends PostProcess {
  40622. private _face;
  40623. /**
  40624. * Gets or sets the cube face to display.
  40625. * * 0 is +X
  40626. * * 1 is -X
  40627. * * 2 is +Y
  40628. * * 3 is -Y
  40629. * * 4 is +Z
  40630. * * 5 is -Z
  40631. */
  40632. face: number;
  40633. /**
  40634. * Creates the PassCubePostProcess
  40635. * @param name The name of the effect.
  40636. * @param options The required width/height ratio to downsize to before computing the render pass.
  40637. * @param camera The camera to apply the render pass to.
  40638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40639. * @param engine The engine which the post process will be applied. (default: current engine)
  40640. * @param reusable If the post process can be reused on the same frame. (default: false)
  40641. * @param textureType The type of texture to be used when performing the post processing.
  40642. * @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)
  40643. */
  40644. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40645. }
  40646. }
  40647. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40648. /** @hidden */
  40649. export var anaglyphPixelShader: {
  40650. name: string;
  40651. shader: string;
  40652. };
  40653. }
  40654. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40655. import { Engine } from "babylonjs/Engines/engine";
  40656. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40657. import { Camera } from "babylonjs/Cameras/camera";
  40658. import "babylonjs/Shaders/anaglyph.fragment";
  40659. /**
  40660. * Postprocess used to generate anaglyphic rendering
  40661. */
  40662. export class AnaglyphPostProcess extends PostProcess {
  40663. private _passedProcess;
  40664. /**
  40665. * Creates a new AnaglyphPostProcess
  40666. * @param name defines postprocess name
  40667. * @param options defines creation options or target ratio scale
  40668. * @param rigCameras defines cameras using this postprocess
  40669. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40670. * @param engine defines hosting engine
  40671. * @param reusable defines if the postprocess will be reused multiple times per frame
  40672. */
  40673. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40674. }
  40675. }
  40676. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40677. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40678. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40679. import { Scene } from "babylonjs/scene";
  40680. import { Vector3 } from "babylonjs/Maths/math.vector";
  40681. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40682. /**
  40683. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40684. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40685. */
  40686. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40687. /**
  40688. * Creates a new AnaglyphArcRotateCamera
  40689. * @param name defines camera name
  40690. * @param alpha defines alpha angle (in radians)
  40691. * @param beta defines beta angle (in radians)
  40692. * @param radius defines radius
  40693. * @param target defines camera target
  40694. * @param interaxialDistance defines distance between each color axis
  40695. * @param scene defines the hosting scene
  40696. */
  40697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40698. /**
  40699. * Gets camera class name
  40700. * @returns AnaglyphArcRotateCamera
  40701. */
  40702. getClassName(): string;
  40703. }
  40704. }
  40705. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40706. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40707. import { Scene } from "babylonjs/scene";
  40708. import { Vector3 } from "babylonjs/Maths/math.vector";
  40709. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40710. /**
  40711. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40712. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40713. */
  40714. export class AnaglyphFreeCamera extends FreeCamera {
  40715. /**
  40716. * Creates a new AnaglyphFreeCamera
  40717. * @param name defines camera name
  40718. * @param position defines initial position
  40719. * @param interaxialDistance defines distance between each color axis
  40720. * @param scene defines the hosting scene
  40721. */
  40722. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40723. /**
  40724. * Gets camera class name
  40725. * @returns AnaglyphFreeCamera
  40726. */
  40727. getClassName(): string;
  40728. }
  40729. }
  40730. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40731. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40732. import { Scene } from "babylonjs/scene";
  40733. import { Vector3 } from "babylonjs/Maths/math.vector";
  40734. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40735. /**
  40736. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40737. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40738. */
  40739. export class AnaglyphGamepadCamera extends GamepadCamera {
  40740. /**
  40741. * Creates a new AnaglyphGamepadCamera
  40742. * @param name defines camera name
  40743. * @param position defines initial position
  40744. * @param interaxialDistance defines distance between each color axis
  40745. * @param scene defines the hosting scene
  40746. */
  40747. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40748. /**
  40749. * Gets camera class name
  40750. * @returns AnaglyphGamepadCamera
  40751. */
  40752. getClassName(): string;
  40753. }
  40754. }
  40755. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40756. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40757. import { Scene } from "babylonjs/scene";
  40758. import { Vector3 } from "babylonjs/Maths/math.vector";
  40759. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40760. /**
  40761. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40762. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40763. */
  40764. export class AnaglyphUniversalCamera extends UniversalCamera {
  40765. /**
  40766. * Creates a new AnaglyphUniversalCamera
  40767. * @param name defines camera name
  40768. * @param position defines initial position
  40769. * @param interaxialDistance defines distance between each color axis
  40770. * @param scene defines the hosting scene
  40771. */
  40772. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40773. /**
  40774. * Gets camera class name
  40775. * @returns AnaglyphUniversalCamera
  40776. */
  40777. getClassName(): string;
  40778. }
  40779. }
  40780. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40781. /** @hidden */
  40782. export var stereoscopicInterlacePixelShader: {
  40783. name: string;
  40784. shader: string;
  40785. };
  40786. }
  40787. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40788. import { Camera } from "babylonjs/Cameras/camera";
  40789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40790. import { Engine } from "babylonjs/Engines/engine";
  40791. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40792. /**
  40793. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40794. */
  40795. export class StereoscopicInterlacePostProcess extends PostProcess {
  40796. private _stepSize;
  40797. private _passedProcess;
  40798. /**
  40799. * Initializes a StereoscopicInterlacePostProcess
  40800. * @param name The name of the effect.
  40801. * @param rigCameras The rig cameras to be appled to the post process
  40802. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40804. * @param engine The engine which the post process will be applied. (default: current engine)
  40805. * @param reusable If the post process can be reused on the same frame. (default: false)
  40806. */
  40807. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40808. }
  40809. }
  40810. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40811. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40812. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40813. import { Scene } from "babylonjs/scene";
  40814. import { Vector3 } from "babylonjs/Maths/math.vector";
  40815. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40816. /**
  40817. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40818. * @see http://doc.babylonjs.com/features/cameras
  40819. */
  40820. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40821. /**
  40822. * Creates a new StereoscopicArcRotateCamera
  40823. * @param name defines camera name
  40824. * @param alpha defines alpha angle (in radians)
  40825. * @param beta defines beta angle (in radians)
  40826. * @param radius defines radius
  40827. * @param target defines camera target
  40828. * @param interaxialDistance defines distance between each color axis
  40829. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40830. * @param scene defines the hosting scene
  40831. */
  40832. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40833. /**
  40834. * Gets camera class name
  40835. * @returns StereoscopicArcRotateCamera
  40836. */
  40837. getClassName(): string;
  40838. }
  40839. }
  40840. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40841. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40842. import { Scene } from "babylonjs/scene";
  40843. import { Vector3 } from "babylonjs/Maths/math.vector";
  40844. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40845. /**
  40846. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40847. * @see http://doc.babylonjs.com/features/cameras
  40848. */
  40849. export class StereoscopicFreeCamera extends FreeCamera {
  40850. /**
  40851. * Creates a new StereoscopicFreeCamera
  40852. * @param name defines camera name
  40853. * @param position defines initial position
  40854. * @param interaxialDistance defines distance between each color axis
  40855. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40856. * @param scene defines the hosting scene
  40857. */
  40858. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40859. /**
  40860. * Gets camera class name
  40861. * @returns StereoscopicFreeCamera
  40862. */
  40863. getClassName(): string;
  40864. }
  40865. }
  40866. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40867. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40868. import { Scene } from "babylonjs/scene";
  40869. import { Vector3 } from "babylonjs/Maths/math.vector";
  40870. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40871. /**
  40872. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40873. * @see http://doc.babylonjs.com/features/cameras
  40874. */
  40875. export class StereoscopicGamepadCamera extends GamepadCamera {
  40876. /**
  40877. * Creates a new StereoscopicGamepadCamera
  40878. * @param name defines camera name
  40879. * @param position defines initial position
  40880. * @param interaxialDistance defines distance between each color axis
  40881. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40882. * @param scene defines the hosting scene
  40883. */
  40884. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40885. /**
  40886. * Gets camera class name
  40887. * @returns StereoscopicGamepadCamera
  40888. */
  40889. getClassName(): string;
  40890. }
  40891. }
  40892. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40893. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40894. import { Scene } from "babylonjs/scene";
  40895. import { Vector3 } from "babylonjs/Maths/math.vector";
  40896. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40897. /**
  40898. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40899. * @see http://doc.babylonjs.com/features/cameras
  40900. */
  40901. export class StereoscopicUniversalCamera extends UniversalCamera {
  40902. /**
  40903. * Creates a new StereoscopicUniversalCamera
  40904. * @param name defines camera name
  40905. * @param position defines initial position
  40906. * @param interaxialDistance defines distance between each color axis
  40907. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40908. * @param scene defines the hosting scene
  40909. */
  40910. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40911. /**
  40912. * Gets camera class name
  40913. * @returns StereoscopicUniversalCamera
  40914. */
  40915. getClassName(): string;
  40916. }
  40917. }
  40918. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40919. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40920. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40921. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40922. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40923. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40924. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40925. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40926. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40927. }
  40928. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40929. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40930. import { Scene } from "babylonjs/scene";
  40931. import { Vector3 } from "babylonjs/Maths/math.vector";
  40932. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40933. /**
  40934. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40935. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40936. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40937. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40938. */
  40939. export class VirtualJoysticksCamera extends FreeCamera {
  40940. /**
  40941. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40942. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40943. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40944. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40945. * @param name Define the name of the camera in the scene
  40946. * @param position Define the start position of the camera in the scene
  40947. * @param scene Define the scene the camera belongs to
  40948. */
  40949. constructor(name: string, position: Vector3, scene: Scene);
  40950. /**
  40951. * Gets the current object class name.
  40952. * @return the class name
  40953. */
  40954. getClassName(): string;
  40955. }
  40956. }
  40957. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40958. import { Matrix } from "babylonjs/Maths/math.vector";
  40959. /**
  40960. * This represents all the required metrics to create a VR camera.
  40961. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40962. */
  40963. export class VRCameraMetrics {
  40964. /**
  40965. * Define the horizontal resolution off the screen.
  40966. */
  40967. hResolution: number;
  40968. /**
  40969. * Define the vertical resolution off the screen.
  40970. */
  40971. vResolution: number;
  40972. /**
  40973. * Define the horizontal screen size.
  40974. */
  40975. hScreenSize: number;
  40976. /**
  40977. * Define the vertical screen size.
  40978. */
  40979. vScreenSize: number;
  40980. /**
  40981. * Define the vertical screen center position.
  40982. */
  40983. vScreenCenter: number;
  40984. /**
  40985. * Define the distance of the eyes to the screen.
  40986. */
  40987. eyeToScreenDistance: number;
  40988. /**
  40989. * Define the distance between both lenses
  40990. */
  40991. lensSeparationDistance: number;
  40992. /**
  40993. * Define the distance between both viewer's eyes.
  40994. */
  40995. interpupillaryDistance: number;
  40996. /**
  40997. * Define the distortion factor of the VR postprocess.
  40998. * Please, touch with care.
  40999. */
  41000. distortionK: number[];
  41001. /**
  41002. * Define the chromatic aberration correction factors for the VR post process.
  41003. */
  41004. chromaAbCorrection: number[];
  41005. /**
  41006. * Define the scale factor of the post process.
  41007. * The smaller the better but the slower.
  41008. */
  41009. postProcessScaleFactor: number;
  41010. /**
  41011. * Define an offset for the lens center.
  41012. */
  41013. lensCenterOffset: number;
  41014. /**
  41015. * Define if the current vr camera should compensate the distortion of the lense or not.
  41016. */
  41017. compensateDistortion: boolean;
  41018. /**
  41019. * Defines if multiview should be enabled when rendering (Default: false)
  41020. */
  41021. multiviewEnabled: boolean;
  41022. /**
  41023. * Gets the rendering aspect ratio based on the provided resolutions.
  41024. */
  41025. readonly aspectRatio: number;
  41026. /**
  41027. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41028. */
  41029. readonly aspectRatioFov: number;
  41030. /**
  41031. * @hidden
  41032. */
  41033. readonly leftHMatrix: Matrix;
  41034. /**
  41035. * @hidden
  41036. */
  41037. readonly rightHMatrix: Matrix;
  41038. /**
  41039. * @hidden
  41040. */
  41041. readonly leftPreViewMatrix: Matrix;
  41042. /**
  41043. * @hidden
  41044. */
  41045. readonly rightPreViewMatrix: Matrix;
  41046. /**
  41047. * Get the default VRMetrics based on the most generic setup.
  41048. * @returns the default vr metrics
  41049. */
  41050. static GetDefault(): VRCameraMetrics;
  41051. }
  41052. }
  41053. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41054. /** @hidden */
  41055. export var vrDistortionCorrectionPixelShader: {
  41056. name: string;
  41057. shader: string;
  41058. };
  41059. }
  41060. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41061. import { Camera } from "babylonjs/Cameras/camera";
  41062. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41063. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41064. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41065. /**
  41066. * VRDistortionCorrectionPostProcess used for mobile VR
  41067. */
  41068. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41069. private _isRightEye;
  41070. private _distortionFactors;
  41071. private _postProcessScaleFactor;
  41072. private _lensCenterOffset;
  41073. private _scaleIn;
  41074. private _scaleFactor;
  41075. private _lensCenter;
  41076. /**
  41077. * Initializes the VRDistortionCorrectionPostProcess
  41078. * @param name The name of the effect.
  41079. * @param camera The camera to apply the render pass to.
  41080. * @param isRightEye If this is for the right eye distortion
  41081. * @param vrMetrics All the required metrics for the VR camera
  41082. */
  41083. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41084. }
  41085. }
  41086. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41087. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41088. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41089. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41090. import { Scene } from "babylonjs/scene";
  41091. import { Vector3 } from "babylonjs/Maths/math.vector";
  41092. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41093. import "babylonjs/Cameras/RigModes/vrRigMode";
  41094. /**
  41095. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41097. */
  41098. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41099. /**
  41100. * Creates a new VRDeviceOrientationArcRotateCamera
  41101. * @param name defines camera name
  41102. * @param alpha defines the camera rotation along the logitudinal axis
  41103. * @param beta defines the camera rotation along the latitudinal axis
  41104. * @param radius defines the camera distance from its target
  41105. * @param target defines the camera target
  41106. * @param scene defines the scene the camera belongs to
  41107. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41108. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41109. */
  41110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41111. /**
  41112. * Gets camera class name
  41113. * @returns VRDeviceOrientationArcRotateCamera
  41114. */
  41115. getClassName(): string;
  41116. }
  41117. }
  41118. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41119. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41120. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41121. import { Scene } from "babylonjs/scene";
  41122. import { Vector3 } from "babylonjs/Maths/math.vector";
  41123. import "babylonjs/Cameras/RigModes/vrRigMode";
  41124. /**
  41125. * Camera used to simulate VR rendering (based on FreeCamera)
  41126. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41127. */
  41128. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41129. /**
  41130. * Creates a new VRDeviceOrientationFreeCamera
  41131. * @param name defines camera name
  41132. * @param position defines the start position of the camera
  41133. * @param scene defines the scene the camera belongs to
  41134. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41135. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41136. */
  41137. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41138. /**
  41139. * Gets camera class name
  41140. * @returns VRDeviceOrientationFreeCamera
  41141. */
  41142. getClassName(): string;
  41143. }
  41144. }
  41145. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41146. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41147. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41148. import { Scene } from "babylonjs/scene";
  41149. import { Vector3 } from "babylonjs/Maths/math.vector";
  41150. import "babylonjs/Gamepads/gamepadSceneComponent";
  41151. /**
  41152. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41153. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41154. */
  41155. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41156. /**
  41157. * Creates a new VRDeviceOrientationGamepadCamera
  41158. * @param name defines camera name
  41159. * @param position defines the start position of the camera
  41160. * @param scene defines the scene the camera belongs to
  41161. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41162. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41163. */
  41164. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41165. /**
  41166. * Gets camera class name
  41167. * @returns VRDeviceOrientationGamepadCamera
  41168. */
  41169. getClassName(): string;
  41170. }
  41171. }
  41172. declare module "babylonjs/Materials/pushMaterial" {
  41173. import { Nullable } from "babylonjs/types";
  41174. import { Scene } from "babylonjs/scene";
  41175. import { Matrix } from "babylonjs/Maths/math.vector";
  41176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41177. import { Mesh } from "babylonjs/Meshes/mesh";
  41178. import { Material } from "babylonjs/Materials/material";
  41179. import { Effect } from "babylonjs/Materials/effect";
  41180. /**
  41181. * Base class of materials working in push mode in babylon JS
  41182. * @hidden
  41183. */
  41184. export class PushMaterial extends Material {
  41185. protected _activeEffect: Effect;
  41186. protected _normalMatrix: Matrix;
  41187. /**
  41188. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41189. * This means that the material can keep using a previous shader while a new one is being compiled.
  41190. * This is mostly used when shader parallel compilation is supported (true by default)
  41191. */
  41192. allowShaderHotSwapping: boolean;
  41193. constructor(name: string, scene: Scene);
  41194. getEffect(): Effect;
  41195. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41196. /**
  41197. * Binds the given world matrix to the active effect
  41198. *
  41199. * @param world the matrix to bind
  41200. */
  41201. bindOnlyWorldMatrix(world: Matrix): void;
  41202. /**
  41203. * Binds the given normal matrix to the active effect
  41204. *
  41205. * @param normalMatrix the matrix to bind
  41206. */
  41207. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41208. bind(world: Matrix, mesh?: Mesh): void;
  41209. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41210. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41211. }
  41212. }
  41213. declare module "babylonjs/Materials/materialFlags" {
  41214. /**
  41215. * This groups all the flags used to control the materials channel.
  41216. */
  41217. export class MaterialFlags {
  41218. private static _DiffuseTextureEnabled;
  41219. /**
  41220. * Are diffuse textures enabled in the application.
  41221. */
  41222. static DiffuseTextureEnabled: boolean;
  41223. private static _AmbientTextureEnabled;
  41224. /**
  41225. * Are ambient textures enabled in the application.
  41226. */
  41227. static AmbientTextureEnabled: boolean;
  41228. private static _OpacityTextureEnabled;
  41229. /**
  41230. * Are opacity textures enabled in the application.
  41231. */
  41232. static OpacityTextureEnabled: boolean;
  41233. private static _ReflectionTextureEnabled;
  41234. /**
  41235. * Are reflection textures enabled in the application.
  41236. */
  41237. static ReflectionTextureEnabled: boolean;
  41238. private static _EmissiveTextureEnabled;
  41239. /**
  41240. * Are emissive textures enabled in the application.
  41241. */
  41242. static EmissiveTextureEnabled: boolean;
  41243. private static _SpecularTextureEnabled;
  41244. /**
  41245. * Are specular textures enabled in the application.
  41246. */
  41247. static SpecularTextureEnabled: boolean;
  41248. private static _BumpTextureEnabled;
  41249. /**
  41250. * Are bump textures enabled in the application.
  41251. */
  41252. static BumpTextureEnabled: boolean;
  41253. private static _LightmapTextureEnabled;
  41254. /**
  41255. * Are lightmap textures enabled in the application.
  41256. */
  41257. static LightmapTextureEnabled: boolean;
  41258. private static _RefractionTextureEnabled;
  41259. /**
  41260. * Are refraction textures enabled in the application.
  41261. */
  41262. static RefractionTextureEnabled: boolean;
  41263. private static _ColorGradingTextureEnabled;
  41264. /**
  41265. * Are color grading textures enabled in the application.
  41266. */
  41267. static ColorGradingTextureEnabled: boolean;
  41268. private static _FresnelEnabled;
  41269. /**
  41270. * Are fresnels enabled in the application.
  41271. */
  41272. static FresnelEnabled: boolean;
  41273. private static _ClearCoatTextureEnabled;
  41274. /**
  41275. * Are clear coat textures enabled in the application.
  41276. */
  41277. static ClearCoatTextureEnabled: boolean;
  41278. private static _ClearCoatBumpTextureEnabled;
  41279. /**
  41280. * Are clear coat bump textures enabled in the application.
  41281. */
  41282. static ClearCoatBumpTextureEnabled: boolean;
  41283. private static _ClearCoatTintTextureEnabled;
  41284. /**
  41285. * Are clear coat tint textures enabled in the application.
  41286. */
  41287. static ClearCoatTintTextureEnabled: boolean;
  41288. private static _SheenTextureEnabled;
  41289. /**
  41290. * Are sheen textures enabled in the application.
  41291. */
  41292. static SheenTextureEnabled: boolean;
  41293. private static _AnisotropicTextureEnabled;
  41294. /**
  41295. * Are anisotropic textures enabled in the application.
  41296. */
  41297. static AnisotropicTextureEnabled: boolean;
  41298. private static _ThicknessTextureEnabled;
  41299. /**
  41300. * Are thickness textures enabled in the application.
  41301. */
  41302. static ThicknessTextureEnabled: boolean;
  41303. }
  41304. }
  41305. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41306. /** @hidden */
  41307. export var defaultFragmentDeclaration: {
  41308. name: string;
  41309. shader: string;
  41310. };
  41311. }
  41312. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41313. /** @hidden */
  41314. export var defaultUboDeclaration: {
  41315. name: string;
  41316. shader: string;
  41317. };
  41318. }
  41319. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41320. /** @hidden */
  41321. export var lightFragmentDeclaration: {
  41322. name: string;
  41323. shader: string;
  41324. };
  41325. }
  41326. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41327. /** @hidden */
  41328. export var lightUboDeclaration: {
  41329. name: string;
  41330. shader: string;
  41331. };
  41332. }
  41333. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41334. /** @hidden */
  41335. export var lightsFragmentFunctions: {
  41336. name: string;
  41337. shader: string;
  41338. };
  41339. }
  41340. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41341. /** @hidden */
  41342. export var shadowsFragmentFunctions: {
  41343. name: string;
  41344. shader: string;
  41345. };
  41346. }
  41347. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41348. /** @hidden */
  41349. export var fresnelFunction: {
  41350. name: string;
  41351. shader: string;
  41352. };
  41353. }
  41354. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41355. /** @hidden */
  41356. export var reflectionFunction: {
  41357. name: string;
  41358. shader: string;
  41359. };
  41360. }
  41361. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41362. /** @hidden */
  41363. export var bumpFragmentFunctions: {
  41364. name: string;
  41365. shader: string;
  41366. };
  41367. }
  41368. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41369. /** @hidden */
  41370. export var logDepthDeclaration: {
  41371. name: string;
  41372. shader: string;
  41373. };
  41374. }
  41375. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41376. /** @hidden */
  41377. export var bumpFragment: {
  41378. name: string;
  41379. shader: string;
  41380. };
  41381. }
  41382. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41383. /** @hidden */
  41384. export var depthPrePass: {
  41385. name: string;
  41386. shader: string;
  41387. };
  41388. }
  41389. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41390. /** @hidden */
  41391. export var lightFragment: {
  41392. name: string;
  41393. shader: string;
  41394. };
  41395. }
  41396. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41397. /** @hidden */
  41398. export var logDepthFragment: {
  41399. name: string;
  41400. shader: string;
  41401. };
  41402. }
  41403. declare module "babylonjs/Shaders/default.fragment" {
  41404. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41405. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41406. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41409. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41410. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41411. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41412. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41413. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41414. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41415. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41416. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41417. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41418. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41419. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41420. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41421. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41422. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41423. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41424. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41425. /** @hidden */
  41426. export var defaultPixelShader: {
  41427. name: string;
  41428. shader: string;
  41429. };
  41430. }
  41431. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41432. /** @hidden */
  41433. export var defaultVertexDeclaration: {
  41434. name: string;
  41435. shader: string;
  41436. };
  41437. }
  41438. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41439. /** @hidden */
  41440. export var bumpVertexDeclaration: {
  41441. name: string;
  41442. shader: string;
  41443. };
  41444. }
  41445. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41446. /** @hidden */
  41447. export var bumpVertex: {
  41448. name: string;
  41449. shader: string;
  41450. };
  41451. }
  41452. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41453. /** @hidden */
  41454. export var fogVertex: {
  41455. name: string;
  41456. shader: string;
  41457. };
  41458. }
  41459. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41460. /** @hidden */
  41461. export var shadowsVertex: {
  41462. name: string;
  41463. shader: string;
  41464. };
  41465. }
  41466. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41467. /** @hidden */
  41468. export var pointCloudVertex: {
  41469. name: string;
  41470. shader: string;
  41471. };
  41472. }
  41473. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41474. /** @hidden */
  41475. export var logDepthVertex: {
  41476. name: string;
  41477. shader: string;
  41478. };
  41479. }
  41480. declare module "babylonjs/Shaders/default.vertex" {
  41481. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41482. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41483. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41484. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41485. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41486. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41487. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41488. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41489. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41490. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41493. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41494. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41495. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41496. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41497. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41499. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41500. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41501. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41502. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41503. /** @hidden */
  41504. export var defaultVertexShader: {
  41505. name: string;
  41506. shader: string;
  41507. };
  41508. }
  41509. declare module "babylonjs/Materials/standardMaterial" {
  41510. import { SmartArray } from "babylonjs/Misc/smartArray";
  41511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41512. import { Nullable } from "babylonjs/types";
  41513. import { Scene } from "babylonjs/scene";
  41514. import { Matrix } from "babylonjs/Maths/math.vector";
  41515. import { Color3 } from "babylonjs/Maths/math.color";
  41516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41518. import { Mesh } from "babylonjs/Meshes/mesh";
  41519. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41520. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41521. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41522. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41523. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41524. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41526. import "babylonjs/Shaders/default.fragment";
  41527. import "babylonjs/Shaders/default.vertex";
  41528. /** @hidden */
  41529. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41530. MAINUV1: boolean;
  41531. MAINUV2: boolean;
  41532. DIFFUSE: boolean;
  41533. DIFFUSEDIRECTUV: number;
  41534. AMBIENT: boolean;
  41535. AMBIENTDIRECTUV: number;
  41536. OPACITY: boolean;
  41537. OPACITYDIRECTUV: number;
  41538. OPACITYRGB: boolean;
  41539. REFLECTION: boolean;
  41540. EMISSIVE: boolean;
  41541. EMISSIVEDIRECTUV: number;
  41542. SPECULAR: boolean;
  41543. SPECULARDIRECTUV: number;
  41544. BUMP: boolean;
  41545. BUMPDIRECTUV: number;
  41546. PARALLAX: boolean;
  41547. PARALLAXOCCLUSION: boolean;
  41548. SPECULAROVERALPHA: boolean;
  41549. CLIPPLANE: boolean;
  41550. CLIPPLANE2: boolean;
  41551. CLIPPLANE3: boolean;
  41552. CLIPPLANE4: boolean;
  41553. ALPHATEST: boolean;
  41554. DEPTHPREPASS: boolean;
  41555. ALPHAFROMDIFFUSE: boolean;
  41556. POINTSIZE: boolean;
  41557. FOG: boolean;
  41558. SPECULARTERM: boolean;
  41559. DIFFUSEFRESNEL: boolean;
  41560. OPACITYFRESNEL: boolean;
  41561. REFLECTIONFRESNEL: boolean;
  41562. REFRACTIONFRESNEL: boolean;
  41563. EMISSIVEFRESNEL: boolean;
  41564. FRESNEL: boolean;
  41565. NORMAL: boolean;
  41566. UV1: boolean;
  41567. UV2: boolean;
  41568. VERTEXCOLOR: boolean;
  41569. VERTEXALPHA: boolean;
  41570. NUM_BONE_INFLUENCERS: number;
  41571. BonesPerMesh: number;
  41572. BONETEXTURE: boolean;
  41573. INSTANCES: boolean;
  41574. GLOSSINESS: boolean;
  41575. ROUGHNESS: boolean;
  41576. EMISSIVEASILLUMINATION: boolean;
  41577. LINKEMISSIVEWITHDIFFUSE: boolean;
  41578. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41579. LIGHTMAP: boolean;
  41580. LIGHTMAPDIRECTUV: number;
  41581. OBJECTSPACE_NORMALMAP: boolean;
  41582. USELIGHTMAPASSHADOWMAP: boolean;
  41583. REFLECTIONMAP_3D: boolean;
  41584. REFLECTIONMAP_SPHERICAL: boolean;
  41585. REFLECTIONMAP_PLANAR: boolean;
  41586. REFLECTIONMAP_CUBIC: boolean;
  41587. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41588. REFLECTIONMAP_PROJECTION: boolean;
  41589. REFLECTIONMAP_SKYBOX: boolean;
  41590. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41591. REFLECTIONMAP_EXPLICIT: boolean;
  41592. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41593. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41594. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41595. INVERTCUBICMAP: boolean;
  41596. LOGARITHMICDEPTH: boolean;
  41597. REFRACTION: boolean;
  41598. REFRACTIONMAP_3D: boolean;
  41599. REFLECTIONOVERALPHA: boolean;
  41600. TWOSIDEDLIGHTING: boolean;
  41601. SHADOWFLOAT: boolean;
  41602. MORPHTARGETS: boolean;
  41603. MORPHTARGETS_NORMAL: boolean;
  41604. MORPHTARGETS_TANGENT: boolean;
  41605. MORPHTARGETS_UV: boolean;
  41606. NUM_MORPH_INFLUENCERS: number;
  41607. NONUNIFORMSCALING: boolean;
  41608. PREMULTIPLYALPHA: boolean;
  41609. IMAGEPROCESSING: boolean;
  41610. VIGNETTE: boolean;
  41611. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41612. VIGNETTEBLENDMODEOPAQUE: boolean;
  41613. TONEMAPPING: boolean;
  41614. TONEMAPPING_ACES: boolean;
  41615. CONTRAST: boolean;
  41616. COLORCURVES: boolean;
  41617. COLORGRADING: boolean;
  41618. COLORGRADING3D: boolean;
  41619. SAMPLER3DGREENDEPTH: boolean;
  41620. SAMPLER3DBGRMAP: boolean;
  41621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41622. MULTIVIEW: boolean;
  41623. /**
  41624. * If the reflection texture on this material is in linear color space
  41625. * @hidden
  41626. */
  41627. IS_REFLECTION_LINEAR: boolean;
  41628. /**
  41629. * If the refraction texture on this material is in linear color space
  41630. * @hidden
  41631. */
  41632. IS_REFRACTION_LINEAR: boolean;
  41633. EXPOSURE: boolean;
  41634. constructor();
  41635. setReflectionMode(modeToEnable: string): void;
  41636. }
  41637. /**
  41638. * This is the default material used in Babylon. It is the best trade off between quality
  41639. * and performances.
  41640. * @see http://doc.babylonjs.com/babylon101/materials
  41641. */
  41642. export class StandardMaterial extends PushMaterial {
  41643. private _diffuseTexture;
  41644. /**
  41645. * The basic texture of the material as viewed under a light.
  41646. */
  41647. diffuseTexture: Nullable<BaseTexture>;
  41648. private _ambientTexture;
  41649. /**
  41650. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41651. */
  41652. ambientTexture: Nullable<BaseTexture>;
  41653. private _opacityTexture;
  41654. /**
  41655. * Define the transparency of the material from a texture.
  41656. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41657. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41658. */
  41659. opacityTexture: Nullable<BaseTexture>;
  41660. private _reflectionTexture;
  41661. /**
  41662. * Define the texture used to display the reflection.
  41663. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41664. */
  41665. reflectionTexture: Nullable<BaseTexture>;
  41666. private _emissiveTexture;
  41667. /**
  41668. * Define texture of the material as if self lit.
  41669. * This will be mixed in the final result even in the absence of light.
  41670. */
  41671. emissiveTexture: Nullable<BaseTexture>;
  41672. private _specularTexture;
  41673. /**
  41674. * Define how the color and intensity of the highlight given by the light in the material.
  41675. */
  41676. specularTexture: Nullable<BaseTexture>;
  41677. private _bumpTexture;
  41678. /**
  41679. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41680. * 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.
  41681. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41682. */
  41683. bumpTexture: Nullable<BaseTexture>;
  41684. private _lightmapTexture;
  41685. /**
  41686. * Complex lighting can be computationally expensive to compute at runtime.
  41687. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41688. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41689. */
  41690. lightmapTexture: Nullable<BaseTexture>;
  41691. private _refractionTexture;
  41692. /**
  41693. * Define the texture used to display the refraction.
  41694. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41695. */
  41696. refractionTexture: Nullable<BaseTexture>;
  41697. /**
  41698. * The color of the material lit by the environmental background lighting.
  41699. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41700. */
  41701. ambientColor: Color3;
  41702. /**
  41703. * The basic color of the material as viewed under a light.
  41704. */
  41705. diffuseColor: Color3;
  41706. /**
  41707. * Define how the color and intensity of the highlight given by the light in the material.
  41708. */
  41709. specularColor: Color3;
  41710. /**
  41711. * Define the color of the material as if self lit.
  41712. * This will be mixed in the final result even in the absence of light.
  41713. */
  41714. emissiveColor: Color3;
  41715. /**
  41716. * Defines how sharp are the highlights in the material.
  41717. * The bigger the value the sharper giving a more glossy feeling to the result.
  41718. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41719. */
  41720. specularPower: number;
  41721. private _useAlphaFromDiffuseTexture;
  41722. /**
  41723. * Does the transparency come from the diffuse texture alpha channel.
  41724. */
  41725. useAlphaFromDiffuseTexture: boolean;
  41726. private _useEmissiveAsIllumination;
  41727. /**
  41728. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41729. */
  41730. useEmissiveAsIllumination: boolean;
  41731. private _linkEmissiveWithDiffuse;
  41732. /**
  41733. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41734. * the emissive level when the final color is close to one.
  41735. */
  41736. linkEmissiveWithDiffuse: boolean;
  41737. private _useSpecularOverAlpha;
  41738. /**
  41739. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41740. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41741. */
  41742. useSpecularOverAlpha: boolean;
  41743. private _useReflectionOverAlpha;
  41744. /**
  41745. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41746. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41747. */
  41748. useReflectionOverAlpha: boolean;
  41749. private _disableLighting;
  41750. /**
  41751. * Does lights from the scene impacts this material.
  41752. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41753. */
  41754. disableLighting: boolean;
  41755. private _useObjectSpaceNormalMap;
  41756. /**
  41757. * Allows using an object space normal map (instead of tangent space).
  41758. */
  41759. useObjectSpaceNormalMap: boolean;
  41760. private _useParallax;
  41761. /**
  41762. * Is parallax enabled or not.
  41763. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41764. */
  41765. useParallax: boolean;
  41766. private _useParallaxOcclusion;
  41767. /**
  41768. * Is parallax occlusion enabled or not.
  41769. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41770. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41771. */
  41772. useParallaxOcclusion: boolean;
  41773. /**
  41774. * 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.
  41775. */
  41776. parallaxScaleBias: number;
  41777. private _roughness;
  41778. /**
  41779. * Helps to define how blurry the reflections should appears in the material.
  41780. */
  41781. roughness: number;
  41782. /**
  41783. * In case of refraction, define the value of the index of refraction.
  41784. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41785. */
  41786. indexOfRefraction: number;
  41787. /**
  41788. * Invert the refraction texture alongside the y axis.
  41789. * It can be useful with procedural textures or probe for instance.
  41790. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41791. */
  41792. invertRefractionY: boolean;
  41793. /**
  41794. * Defines the alpha limits in alpha test mode.
  41795. */
  41796. alphaCutOff: number;
  41797. private _useLightmapAsShadowmap;
  41798. /**
  41799. * In case of light mapping, define whether the map contains light or shadow informations.
  41800. */
  41801. useLightmapAsShadowmap: boolean;
  41802. private _diffuseFresnelParameters;
  41803. /**
  41804. * Define the diffuse fresnel parameters of the material.
  41805. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41806. */
  41807. diffuseFresnelParameters: FresnelParameters;
  41808. private _opacityFresnelParameters;
  41809. /**
  41810. * Define the opacity fresnel parameters of the material.
  41811. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41812. */
  41813. opacityFresnelParameters: FresnelParameters;
  41814. private _reflectionFresnelParameters;
  41815. /**
  41816. * Define the reflection fresnel parameters of the material.
  41817. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41818. */
  41819. reflectionFresnelParameters: FresnelParameters;
  41820. private _refractionFresnelParameters;
  41821. /**
  41822. * Define the refraction fresnel parameters of the material.
  41823. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41824. */
  41825. refractionFresnelParameters: FresnelParameters;
  41826. private _emissiveFresnelParameters;
  41827. /**
  41828. * Define the emissive fresnel parameters of the material.
  41829. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41830. */
  41831. emissiveFresnelParameters: FresnelParameters;
  41832. private _useReflectionFresnelFromSpecular;
  41833. /**
  41834. * If true automatically deducts the fresnels values from the material specularity.
  41835. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41836. */
  41837. useReflectionFresnelFromSpecular: boolean;
  41838. private _useGlossinessFromSpecularMapAlpha;
  41839. /**
  41840. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41841. */
  41842. useGlossinessFromSpecularMapAlpha: boolean;
  41843. private _maxSimultaneousLights;
  41844. /**
  41845. * Defines the maximum number of lights that can be used in the material
  41846. */
  41847. maxSimultaneousLights: number;
  41848. private _invertNormalMapX;
  41849. /**
  41850. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41851. */
  41852. invertNormalMapX: boolean;
  41853. private _invertNormalMapY;
  41854. /**
  41855. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41856. */
  41857. invertNormalMapY: boolean;
  41858. private _twoSidedLighting;
  41859. /**
  41860. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41861. */
  41862. twoSidedLighting: boolean;
  41863. /**
  41864. * Default configuration related to image processing available in the standard Material.
  41865. */
  41866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41867. /**
  41868. * Gets the image processing configuration used either in this material.
  41869. */
  41870. /**
  41871. * Sets the Default image processing configuration used either in the this material.
  41872. *
  41873. * If sets to null, the scene one is in use.
  41874. */
  41875. imageProcessingConfiguration: ImageProcessingConfiguration;
  41876. /**
  41877. * Keep track of the image processing observer to allow dispose and replace.
  41878. */
  41879. private _imageProcessingObserver;
  41880. /**
  41881. * Attaches a new image processing configuration to the Standard Material.
  41882. * @param configuration
  41883. */
  41884. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41885. /**
  41886. * Gets wether the color curves effect is enabled.
  41887. */
  41888. /**
  41889. * Sets wether the color curves effect is enabled.
  41890. */
  41891. cameraColorCurvesEnabled: boolean;
  41892. /**
  41893. * Gets wether the color grading effect is enabled.
  41894. */
  41895. /**
  41896. * Gets wether the color grading effect is enabled.
  41897. */
  41898. cameraColorGradingEnabled: boolean;
  41899. /**
  41900. * Gets wether tonemapping is enabled or not.
  41901. */
  41902. /**
  41903. * Sets wether tonemapping is enabled or not
  41904. */
  41905. cameraToneMappingEnabled: boolean;
  41906. /**
  41907. * The camera exposure used on this material.
  41908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41909. * This corresponds to a photographic exposure.
  41910. */
  41911. /**
  41912. * The camera exposure used on this material.
  41913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41914. * This corresponds to a photographic exposure.
  41915. */
  41916. cameraExposure: number;
  41917. /**
  41918. * Gets The camera contrast used on this material.
  41919. */
  41920. /**
  41921. * Sets The camera contrast used on this material.
  41922. */
  41923. cameraContrast: number;
  41924. /**
  41925. * Gets the Color Grading 2D Lookup Texture.
  41926. */
  41927. /**
  41928. * Sets the Color Grading 2D Lookup Texture.
  41929. */
  41930. cameraColorGradingTexture: Nullable<BaseTexture>;
  41931. /**
  41932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41934. * 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;
  41935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41936. */
  41937. /**
  41938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41940. * 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;
  41941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41942. */
  41943. cameraColorCurves: Nullable<ColorCurves>;
  41944. /**
  41945. * Custom callback helping to override the default shader used in the material.
  41946. */
  41947. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41948. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41949. protected _worldViewProjectionMatrix: Matrix;
  41950. protected _globalAmbientColor: Color3;
  41951. protected _useLogarithmicDepth: boolean;
  41952. protected _rebuildInParallel: boolean;
  41953. /**
  41954. * Instantiates a new standard material.
  41955. * This is the default material used in Babylon. It is the best trade off between quality
  41956. * and performances.
  41957. * @see http://doc.babylonjs.com/babylon101/materials
  41958. * @param name Define the name of the material in the scene
  41959. * @param scene Define the scene the material belong to
  41960. */
  41961. constructor(name: string, scene: Scene);
  41962. /**
  41963. * Gets a boolean indicating that current material needs to register RTT
  41964. */
  41965. readonly hasRenderTargetTextures: boolean;
  41966. /**
  41967. * Gets the current class name of the material e.g. "StandardMaterial"
  41968. * Mainly use in serialization.
  41969. * @returns the class name
  41970. */
  41971. getClassName(): string;
  41972. /**
  41973. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41974. * You can try switching to logarithmic depth.
  41975. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41976. */
  41977. useLogarithmicDepth: boolean;
  41978. /**
  41979. * Specifies if the material will require alpha blending
  41980. * @returns a boolean specifying if alpha blending is needed
  41981. */
  41982. needAlphaBlending(): boolean;
  41983. /**
  41984. * Specifies if this material should be rendered in alpha test mode
  41985. * @returns a boolean specifying if an alpha test is needed.
  41986. */
  41987. needAlphaTesting(): boolean;
  41988. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41989. /**
  41990. * Get the texture used for alpha test purpose.
  41991. * @returns the diffuse texture in case of the standard material.
  41992. */
  41993. getAlphaTestTexture(): Nullable<BaseTexture>;
  41994. /**
  41995. * Get if the submesh is ready to be used and all its information available.
  41996. * Child classes can use it to update shaders
  41997. * @param mesh defines the mesh to check
  41998. * @param subMesh defines which submesh to check
  41999. * @param useInstances specifies that instances should be used
  42000. * @returns a boolean indicating that the submesh is ready or not
  42001. */
  42002. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42003. /**
  42004. * Builds the material UBO layouts.
  42005. * Used internally during the effect preparation.
  42006. */
  42007. buildUniformLayout(): void;
  42008. /**
  42009. * Unbinds the material from the mesh
  42010. */
  42011. unbind(): void;
  42012. /**
  42013. * Binds the submesh to this material by preparing the effect and shader to draw
  42014. * @param world defines the world transformation matrix
  42015. * @param mesh defines the mesh containing the submesh
  42016. * @param subMesh defines the submesh to bind the material to
  42017. */
  42018. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42019. /**
  42020. * Get the list of animatables in the material.
  42021. * @returns the list of animatables object used in the material
  42022. */
  42023. getAnimatables(): IAnimatable[];
  42024. /**
  42025. * Gets the active textures from the material
  42026. * @returns an array of textures
  42027. */
  42028. getActiveTextures(): BaseTexture[];
  42029. /**
  42030. * Specifies if the material uses a texture
  42031. * @param texture defines the texture to check against the material
  42032. * @returns a boolean specifying if the material uses the texture
  42033. */
  42034. hasTexture(texture: BaseTexture): boolean;
  42035. /**
  42036. * Disposes the material
  42037. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42038. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42039. */
  42040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42041. /**
  42042. * Makes a duplicate of the material, and gives it a new name
  42043. * @param name defines the new name for the duplicated material
  42044. * @returns the cloned material
  42045. */
  42046. clone(name: string): StandardMaterial;
  42047. /**
  42048. * Serializes this material in a JSON representation
  42049. * @returns the serialized material object
  42050. */
  42051. serialize(): any;
  42052. /**
  42053. * Creates a standard material from parsed material data
  42054. * @param source defines the JSON representation of the material
  42055. * @param scene defines the hosting scene
  42056. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42057. * @returns a new standard material
  42058. */
  42059. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42060. /**
  42061. * Are diffuse textures enabled in the application.
  42062. */
  42063. static DiffuseTextureEnabled: boolean;
  42064. /**
  42065. * Are ambient textures enabled in the application.
  42066. */
  42067. static AmbientTextureEnabled: boolean;
  42068. /**
  42069. * Are opacity textures enabled in the application.
  42070. */
  42071. static OpacityTextureEnabled: boolean;
  42072. /**
  42073. * Are reflection textures enabled in the application.
  42074. */
  42075. static ReflectionTextureEnabled: boolean;
  42076. /**
  42077. * Are emissive textures enabled in the application.
  42078. */
  42079. static EmissiveTextureEnabled: boolean;
  42080. /**
  42081. * Are specular textures enabled in the application.
  42082. */
  42083. static SpecularTextureEnabled: boolean;
  42084. /**
  42085. * Are bump textures enabled in the application.
  42086. */
  42087. static BumpTextureEnabled: boolean;
  42088. /**
  42089. * Are lightmap textures enabled in the application.
  42090. */
  42091. static LightmapTextureEnabled: boolean;
  42092. /**
  42093. * Are refraction textures enabled in the application.
  42094. */
  42095. static RefractionTextureEnabled: boolean;
  42096. /**
  42097. * Are color grading textures enabled in the application.
  42098. */
  42099. static ColorGradingTextureEnabled: boolean;
  42100. /**
  42101. * Are fresnels enabled in the application.
  42102. */
  42103. static FresnelEnabled: boolean;
  42104. }
  42105. }
  42106. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42107. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42109. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42110. /** @hidden */
  42111. export var imageProcessingPixelShader: {
  42112. name: string;
  42113. shader: string;
  42114. };
  42115. }
  42116. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42117. import { Nullable } from "babylonjs/types";
  42118. import { Color4 } from "babylonjs/Maths/math.color";
  42119. import { Camera } from "babylonjs/Cameras/camera";
  42120. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42121. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42122. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42123. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42124. import { Engine } from "babylonjs/Engines/engine";
  42125. import "babylonjs/Shaders/imageProcessing.fragment";
  42126. import "babylonjs/Shaders/postprocess.vertex";
  42127. /**
  42128. * ImageProcessingPostProcess
  42129. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42130. */
  42131. export class ImageProcessingPostProcess extends PostProcess {
  42132. /**
  42133. * Default configuration related to image processing available in the PBR Material.
  42134. */
  42135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42136. /**
  42137. * Gets the image processing configuration used either in this material.
  42138. */
  42139. /**
  42140. * Sets the Default image processing configuration used either in the this material.
  42141. *
  42142. * If sets to null, the scene one is in use.
  42143. */
  42144. imageProcessingConfiguration: ImageProcessingConfiguration;
  42145. /**
  42146. * Keep track of the image processing observer to allow dispose and replace.
  42147. */
  42148. private _imageProcessingObserver;
  42149. /**
  42150. * Attaches a new image processing configuration to the PBR Material.
  42151. * @param configuration
  42152. */
  42153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42154. /**
  42155. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42156. */
  42157. /**
  42158. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42159. */
  42160. colorCurves: Nullable<ColorCurves>;
  42161. /**
  42162. * Gets wether the color curves effect is enabled.
  42163. */
  42164. /**
  42165. * Sets wether the color curves effect is enabled.
  42166. */
  42167. colorCurvesEnabled: boolean;
  42168. /**
  42169. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42170. */
  42171. /**
  42172. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42173. */
  42174. colorGradingTexture: Nullable<BaseTexture>;
  42175. /**
  42176. * Gets wether the color grading effect is enabled.
  42177. */
  42178. /**
  42179. * Gets wether the color grading effect is enabled.
  42180. */
  42181. colorGradingEnabled: boolean;
  42182. /**
  42183. * Gets exposure used in the effect.
  42184. */
  42185. /**
  42186. * Sets exposure used in the effect.
  42187. */
  42188. exposure: number;
  42189. /**
  42190. * Gets wether tonemapping is enabled or not.
  42191. */
  42192. /**
  42193. * Sets wether tonemapping is enabled or not
  42194. */
  42195. toneMappingEnabled: boolean;
  42196. /**
  42197. * Gets the type of tone mapping effect.
  42198. */
  42199. /**
  42200. * Sets the type of tone mapping effect.
  42201. */
  42202. toneMappingType: number;
  42203. /**
  42204. * Gets contrast used in the effect.
  42205. */
  42206. /**
  42207. * Sets contrast used in the effect.
  42208. */
  42209. contrast: number;
  42210. /**
  42211. * Gets Vignette stretch size.
  42212. */
  42213. /**
  42214. * Sets Vignette stretch size.
  42215. */
  42216. vignetteStretch: number;
  42217. /**
  42218. * Gets Vignette centre X Offset.
  42219. */
  42220. /**
  42221. * Sets Vignette centre X Offset.
  42222. */
  42223. vignetteCentreX: number;
  42224. /**
  42225. * Gets Vignette centre Y Offset.
  42226. */
  42227. /**
  42228. * Sets Vignette centre Y Offset.
  42229. */
  42230. vignetteCentreY: number;
  42231. /**
  42232. * Gets Vignette weight or intensity of the vignette effect.
  42233. */
  42234. /**
  42235. * Sets Vignette weight or intensity of the vignette effect.
  42236. */
  42237. vignetteWeight: number;
  42238. /**
  42239. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42240. * if vignetteEnabled is set to true.
  42241. */
  42242. /**
  42243. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42244. * if vignetteEnabled is set to true.
  42245. */
  42246. vignetteColor: Color4;
  42247. /**
  42248. * Gets Camera field of view used by the Vignette effect.
  42249. */
  42250. /**
  42251. * Sets Camera field of view used by the Vignette effect.
  42252. */
  42253. vignetteCameraFov: number;
  42254. /**
  42255. * Gets the vignette blend mode allowing different kind of effect.
  42256. */
  42257. /**
  42258. * Sets the vignette blend mode allowing different kind of effect.
  42259. */
  42260. vignetteBlendMode: number;
  42261. /**
  42262. * Gets wether the vignette effect is enabled.
  42263. */
  42264. /**
  42265. * Sets wether the vignette effect is enabled.
  42266. */
  42267. vignetteEnabled: boolean;
  42268. private _fromLinearSpace;
  42269. /**
  42270. * Gets wether the input of the processing is in Gamma or Linear Space.
  42271. */
  42272. /**
  42273. * Sets wether the input of the processing is in Gamma or Linear Space.
  42274. */
  42275. fromLinearSpace: boolean;
  42276. /**
  42277. * Defines cache preventing GC.
  42278. */
  42279. private _defines;
  42280. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42281. /**
  42282. * "ImageProcessingPostProcess"
  42283. * @returns "ImageProcessingPostProcess"
  42284. */
  42285. getClassName(): string;
  42286. protected _updateParameters(): void;
  42287. dispose(camera?: Camera): void;
  42288. }
  42289. }
  42290. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42291. import { Scene } from "babylonjs/scene";
  42292. import { Color3 } from "babylonjs/Maths/math.color";
  42293. import { Mesh } from "babylonjs/Meshes/mesh";
  42294. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42295. import { Nullable } from "babylonjs/types";
  42296. /**
  42297. * Class containing static functions to help procedurally build meshes
  42298. */
  42299. export class GroundBuilder {
  42300. /**
  42301. * Creates a ground mesh
  42302. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42303. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42305. * @param name defines the name of the mesh
  42306. * @param options defines the options used to create the mesh
  42307. * @param scene defines the hosting scene
  42308. * @returns the ground mesh
  42309. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42310. */
  42311. static CreateGround(name: string, options: {
  42312. width?: number;
  42313. height?: number;
  42314. subdivisions?: number;
  42315. subdivisionsX?: number;
  42316. subdivisionsY?: number;
  42317. updatable?: boolean;
  42318. }, scene: any): Mesh;
  42319. /**
  42320. * Creates a tiled ground mesh
  42321. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42322. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42323. * * 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
  42324. * * 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
  42325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42326. * @param name defines the name of the mesh
  42327. * @param options defines the options used to create the mesh
  42328. * @param scene defines the hosting scene
  42329. * @returns the tiled ground mesh
  42330. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42331. */
  42332. static CreateTiledGround(name: string, options: {
  42333. xmin: number;
  42334. zmin: number;
  42335. xmax: number;
  42336. zmax: number;
  42337. subdivisions?: {
  42338. w: number;
  42339. h: number;
  42340. };
  42341. precision?: {
  42342. w: number;
  42343. h: number;
  42344. };
  42345. updatable?: boolean;
  42346. }, scene?: Nullable<Scene>): Mesh;
  42347. /**
  42348. * Creates a ground mesh from a height map
  42349. * * The parameter `url` sets the URL of the height map image resource.
  42350. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42351. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42352. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42353. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42354. * * 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.
  42355. * * 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).
  42356. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42358. * @param name defines the name of the mesh
  42359. * @param url defines the url to the height map
  42360. * @param options defines the options used to create the mesh
  42361. * @param scene defines the hosting scene
  42362. * @returns the ground mesh
  42363. * @see https://doc.babylonjs.com/babylon101/height_map
  42364. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42365. */
  42366. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42367. width?: number;
  42368. height?: number;
  42369. subdivisions?: number;
  42370. minHeight?: number;
  42371. maxHeight?: number;
  42372. colorFilter?: Color3;
  42373. alphaFilter?: number;
  42374. updatable?: boolean;
  42375. onReady?: (mesh: GroundMesh) => void;
  42376. }, scene?: Nullable<Scene>): GroundMesh;
  42377. }
  42378. }
  42379. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42380. import { Vector4 } from "babylonjs/Maths/math.vector";
  42381. import { Mesh } from "babylonjs/Meshes/mesh";
  42382. /**
  42383. * Class containing static functions to help procedurally build meshes
  42384. */
  42385. export class TorusBuilder {
  42386. /**
  42387. * Creates a torus mesh
  42388. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42389. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42390. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42394. * @param name defines the name of the mesh
  42395. * @param options defines the options used to create the mesh
  42396. * @param scene defines the hosting scene
  42397. * @returns the torus mesh
  42398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42399. */
  42400. static CreateTorus(name: string, options: {
  42401. diameter?: number;
  42402. thickness?: number;
  42403. tessellation?: number;
  42404. updatable?: boolean;
  42405. sideOrientation?: number;
  42406. frontUVs?: Vector4;
  42407. backUVs?: Vector4;
  42408. }, scene: any): Mesh;
  42409. }
  42410. }
  42411. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42412. import { Vector4 } from "babylonjs/Maths/math.vector";
  42413. import { Color4 } from "babylonjs/Maths/math.color";
  42414. import { Mesh } from "babylonjs/Meshes/mesh";
  42415. /**
  42416. * Class containing static functions to help procedurally build meshes
  42417. */
  42418. export class CylinderBuilder {
  42419. /**
  42420. * Creates a cylinder or a cone mesh
  42421. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42422. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42423. * * 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.
  42424. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42425. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42426. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42427. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42428. * * 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).
  42429. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42430. * * 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).
  42431. * * 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
  42432. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42433. * * 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
  42434. * * 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.
  42435. * * If `enclose` is false, a ring surface is one element.
  42436. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42437. * * 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
  42438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42441. * @param name defines the name of the mesh
  42442. * @param options defines the options used to create the mesh
  42443. * @param scene defines the hosting scene
  42444. * @returns the cylinder mesh
  42445. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42446. */
  42447. static CreateCylinder(name: string, options: {
  42448. height?: number;
  42449. diameterTop?: number;
  42450. diameterBottom?: number;
  42451. diameter?: number;
  42452. tessellation?: number;
  42453. subdivisions?: number;
  42454. arc?: number;
  42455. faceColors?: Color4[];
  42456. faceUV?: Vector4[];
  42457. updatable?: boolean;
  42458. hasRings?: boolean;
  42459. enclose?: boolean;
  42460. cap?: number;
  42461. sideOrientation?: number;
  42462. frontUVs?: Vector4;
  42463. backUVs?: Vector4;
  42464. }, scene: any): Mesh;
  42465. }
  42466. }
  42467. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42468. import { Observable } from "babylonjs/Misc/observable";
  42469. import { Nullable } from "babylonjs/types";
  42470. import { Camera } from "babylonjs/Cameras/camera";
  42471. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42472. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42473. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42474. import { Scene } from "babylonjs/scene";
  42475. import { Vector3 } from "babylonjs/Maths/math.vector";
  42476. import { Color3 } from "babylonjs/Maths/math.color";
  42477. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42479. import { Mesh } from "babylonjs/Meshes/mesh";
  42480. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42481. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42482. import "babylonjs/Meshes/Builders/groundBuilder";
  42483. import "babylonjs/Meshes/Builders/torusBuilder";
  42484. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42485. import "babylonjs/Gamepads/gamepadSceneComponent";
  42486. import "babylonjs/Animations/animatable";
  42487. /**
  42488. * Options to modify the vr teleportation behavior.
  42489. */
  42490. export interface VRTeleportationOptions {
  42491. /**
  42492. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42493. */
  42494. floorMeshName?: string;
  42495. /**
  42496. * A list of meshes to be used as the teleportation floor. (default: empty)
  42497. */
  42498. floorMeshes?: Mesh[];
  42499. }
  42500. /**
  42501. * Options to modify the vr experience helper's behavior.
  42502. */
  42503. export interface VRExperienceHelperOptions extends WebVROptions {
  42504. /**
  42505. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42506. */
  42507. createDeviceOrientationCamera?: boolean;
  42508. /**
  42509. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42510. */
  42511. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42512. /**
  42513. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42514. */
  42515. laserToggle?: boolean;
  42516. /**
  42517. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42518. */
  42519. floorMeshes?: Mesh[];
  42520. /**
  42521. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42522. */
  42523. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42524. }
  42525. /**
  42526. * Event containing information after VR has been entered
  42527. */
  42528. export class OnAfterEnteringVRObservableEvent {
  42529. /**
  42530. * If entering vr was successful
  42531. */
  42532. success: boolean;
  42533. }
  42534. /**
  42535. * Helps to quickly add VR support to an existing scene.
  42536. * See http://doc.babylonjs.com/how_to/webvr_helper
  42537. */
  42538. export class VRExperienceHelper {
  42539. /** Options to modify the vr experience helper's behavior. */
  42540. webVROptions: VRExperienceHelperOptions;
  42541. private _scene;
  42542. private _position;
  42543. private _btnVR;
  42544. private _btnVRDisplayed;
  42545. private _webVRsupported;
  42546. private _webVRready;
  42547. private _webVRrequesting;
  42548. private _webVRpresenting;
  42549. private _hasEnteredVR;
  42550. private _fullscreenVRpresenting;
  42551. private _canvas;
  42552. private _webVRCamera;
  42553. private _vrDeviceOrientationCamera;
  42554. private _deviceOrientationCamera;
  42555. private _existingCamera;
  42556. private _onKeyDown;
  42557. private _onVrDisplayPresentChange;
  42558. private _onVRDisplayChanged;
  42559. private _onVRRequestPresentStart;
  42560. private _onVRRequestPresentComplete;
  42561. /**
  42562. * 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)
  42563. */
  42564. enableGazeEvenWhenNoPointerLock: boolean;
  42565. /**
  42566. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42567. */
  42568. exitVROnDoubleTap: boolean;
  42569. /**
  42570. * Observable raised right before entering VR.
  42571. */
  42572. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42573. /**
  42574. * Observable raised when entering VR has completed.
  42575. */
  42576. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42577. /**
  42578. * Observable raised when exiting VR.
  42579. */
  42580. onExitingVRObservable: Observable<VRExperienceHelper>;
  42581. /**
  42582. * Observable raised when controller mesh is loaded.
  42583. */
  42584. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42585. /** Return this.onEnteringVRObservable
  42586. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42587. */
  42588. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42589. /** Return this.onExitingVRObservable
  42590. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42591. */
  42592. readonly onExitingVR: Observable<VRExperienceHelper>;
  42593. /** Return this.onControllerMeshLoadedObservable
  42594. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42595. */
  42596. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42597. private _rayLength;
  42598. private _useCustomVRButton;
  42599. private _teleportationRequested;
  42600. private _teleportActive;
  42601. private _floorMeshName;
  42602. private _floorMeshesCollection;
  42603. private _rotationAllowed;
  42604. private _teleportBackwardsVector;
  42605. private _teleportationTarget;
  42606. private _isDefaultTeleportationTarget;
  42607. private _postProcessMove;
  42608. private _teleportationFillColor;
  42609. private _teleportationBorderColor;
  42610. private _rotationAngle;
  42611. private _haloCenter;
  42612. private _cameraGazer;
  42613. private _padSensibilityUp;
  42614. private _padSensibilityDown;
  42615. private _leftController;
  42616. private _rightController;
  42617. /**
  42618. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42619. */
  42620. onNewMeshSelected: Observable<AbstractMesh>;
  42621. /**
  42622. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42623. * This observable will provide the mesh and the controller used to select the mesh
  42624. */
  42625. onMeshSelectedWithController: Observable<{
  42626. mesh: AbstractMesh;
  42627. controller: WebVRController;
  42628. }>;
  42629. /**
  42630. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42631. */
  42632. onNewMeshPicked: Observable<PickingInfo>;
  42633. private _circleEase;
  42634. /**
  42635. * Observable raised before camera teleportation
  42636. */
  42637. onBeforeCameraTeleport: Observable<Vector3>;
  42638. /**
  42639. * Observable raised after camera teleportation
  42640. */
  42641. onAfterCameraTeleport: Observable<Vector3>;
  42642. /**
  42643. * Observable raised when current selected mesh gets unselected
  42644. */
  42645. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42646. private _raySelectionPredicate;
  42647. /**
  42648. * To be optionaly changed by user to define custom ray selection
  42649. */
  42650. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42651. /**
  42652. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42653. */
  42654. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42655. /**
  42656. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42657. */
  42658. teleportationEnabled: boolean;
  42659. private _defaultHeight;
  42660. private _teleportationInitialized;
  42661. private _interactionsEnabled;
  42662. private _interactionsRequested;
  42663. private _displayGaze;
  42664. private _displayLaserPointer;
  42665. /**
  42666. * The mesh used to display where the user is going to teleport.
  42667. */
  42668. /**
  42669. * Sets the mesh to be used to display where the user is going to teleport.
  42670. */
  42671. teleportationTarget: Mesh;
  42672. /**
  42673. * 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
  42674. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42675. * See http://doc.babylonjs.com/resources/baking_transformations
  42676. */
  42677. gazeTrackerMesh: Mesh;
  42678. /**
  42679. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42680. */
  42681. updateGazeTrackerScale: boolean;
  42682. /**
  42683. * If the gaze trackers color should be updated when selecting meshes
  42684. */
  42685. updateGazeTrackerColor: boolean;
  42686. /**
  42687. * If the controller laser color should be updated when selecting meshes
  42688. */
  42689. updateControllerLaserColor: boolean;
  42690. /**
  42691. * The gaze tracking mesh corresponding to the left controller
  42692. */
  42693. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42694. /**
  42695. * The gaze tracking mesh corresponding to the right controller
  42696. */
  42697. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42698. /**
  42699. * If the ray of the gaze should be displayed.
  42700. */
  42701. /**
  42702. * Sets if the ray of the gaze should be displayed.
  42703. */
  42704. displayGaze: boolean;
  42705. /**
  42706. * If the ray of the LaserPointer should be displayed.
  42707. */
  42708. /**
  42709. * Sets if the ray of the LaserPointer should be displayed.
  42710. */
  42711. displayLaserPointer: boolean;
  42712. /**
  42713. * The deviceOrientationCamera used as the camera when not in VR.
  42714. */
  42715. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42716. /**
  42717. * Based on the current WebVR support, returns the current VR camera used.
  42718. */
  42719. readonly currentVRCamera: Nullable<Camera>;
  42720. /**
  42721. * The webVRCamera which is used when in VR.
  42722. */
  42723. readonly webVRCamera: WebVRFreeCamera;
  42724. /**
  42725. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42726. */
  42727. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42728. /**
  42729. * The html button that is used to trigger entering into VR.
  42730. */
  42731. readonly vrButton: Nullable<HTMLButtonElement>;
  42732. private readonly _teleportationRequestInitiated;
  42733. /**
  42734. * Defines wether or not Pointer lock should be requested when switching to
  42735. * full screen.
  42736. */
  42737. requestPointerLockOnFullScreen: boolean;
  42738. /**
  42739. * Instantiates a VRExperienceHelper.
  42740. * Helps to quickly add VR support to an existing scene.
  42741. * @param scene The scene the VRExperienceHelper belongs to.
  42742. * @param webVROptions Options to modify the vr experience helper's behavior.
  42743. */
  42744. constructor(scene: Scene,
  42745. /** Options to modify the vr experience helper's behavior. */
  42746. webVROptions?: VRExperienceHelperOptions);
  42747. private _onDefaultMeshLoaded;
  42748. private _onResize;
  42749. private _onFullscreenChange;
  42750. /**
  42751. * Gets a value indicating if we are currently in VR mode.
  42752. */
  42753. readonly isInVRMode: boolean;
  42754. private onVrDisplayPresentChange;
  42755. private onVRDisplayChanged;
  42756. private moveButtonToBottomRight;
  42757. private displayVRButton;
  42758. private updateButtonVisibility;
  42759. private _cachedAngularSensibility;
  42760. /**
  42761. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42762. * Otherwise, will use the fullscreen API.
  42763. */
  42764. enterVR(): void;
  42765. /**
  42766. * Attempt to exit VR, or fullscreen.
  42767. */
  42768. exitVR(): void;
  42769. /**
  42770. * The position of the vr experience helper.
  42771. */
  42772. /**
  42773. * Sets the position of the vr experience helper.
  42774. */
  42775. position: Vector3;
  42776. /**
  42777. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42778. */
  42779. enableInteractions(): void;
  42780. private readonly _noControllerIsActive;
  42781. private beforeRender;
  42782. private _isTeleportationFloor;
  42783. /**
  42784. * Adds a floor mesh to be used for teleportation.
  42785. * @param floorMesh the mesh to be used for teleportation.
  42786. */
  42787. addFloorMesh(floorMesh: Mesh): void;
  42788. /**
  42789. * Removes a floor mesh from being used for teleportation.
  42790. * @param floorMesh the mesh to be removed.
  42791. */
  42792. removeFloorMesh(floorMesh: Mesh): void;
  42793. /**
  42794. * Enables interactions and teleportation using the VR controllers and gaze.
  42795. * @param vrTeleportationOptions options to modify teleportation behavior.
  42796. */
  42797. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42798. private _onNewGamepadConnected;
  42799. private _tryEnableInteractionOnController;
  42800. private _onNewGamepadDisconnected;
  42801. private _enableInteractionOnController;
  42802. private _checkTeleportWithRay;
  42803. private _checkRotate;
  42804. private _checkTeleportBackwards;
  42805. private _enableTeleportationOnController;
  42806. private _createTeleportationCircles;
  42807. private _displayTeleportationTarget;
  42808. private _hideTeleportationTarget;
  42809. private _rotateCamera;
  42810. private _moveTeleportationSelectorTo;
  42811. private _workingVector;
  42812. private _workingQuaternion;
  42813. private _workingMatrix;
  42814. /**
  42815. * Teleports the users feet to the desired location
  42816. * @param location The location where the user's feet should be placed
  42817. */
  42818. teleportCamera(location: Vector3): void;
  42819. private _convertNormalToDirectionOfRay;
  42820. private _castRayAndSelectObject;
  42821. private _notifySelectedMeshUnselected;
  42822. /**
  42823. * Sets the color of the laser ray from the vr controllers.
  42824. * @param color new color for the ray.
  42825. */
  42826. changeLaserColor(color: Color3): void;
  42827. /**
  42828. * Sets the color of the ray from the vr headsets gaze.
  42829. * @param color new color for the ray.
  42830. */
  42831. changeGazeColor(color: Color3): void;
  42832. /**
  42833. * Exits VR and disposes of the vr experience helper
  42834. */
  42835. dispose(): void;
  42836. /**
  42837. * Gets the name of the VRExperienceHelper class
  42838. * @returns "VRExperienceHelper"
  42839. */
  42840. getClassName(): string;
  42841. }
  42842. }
  42843. declare module "babylonjs/Cameras/VR/index" {
  42844. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42845. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42846. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42847. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42848. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42849. export * from "babylonjs/Cameras/VR/webVRCamera";
  42850. }
  42851. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42852. import { Observable } from "babylonjs/Misc/observable";
  42853. import { Nullable } from "babylonjs/types";
  42854. import { IDisposable, Scene } from "babylonjs/scene";
  42855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42856. /**
  42857. * Manages an XRSession to work with Babylon's engine
  42858. * @see https://doc.babylonjs.com/how_to/webxr
  42859. */
  42860. export class WebXRSessionManager implements IDisposable {
  42861. private scene;
  42862. /**
  42863. * Fires every time a new xrFrame arrives which can be used to update the camera
  42864. */
  42865. onXRFrameObservable: Observable<any>;
  42866. /**
  42867. * Fires when the xr session is ended either by the device or manually done
  42868. */
  42869. onXRSessionEnded: Observable<any>;
  42870. /**
  42871. * Underlying xr session
  42872. */
  42873. session: XRSession;
  42874. /**
  42875. * Type of reference space used when creating the session
  42876. */
  42877. referenceSpace: XRReferenceSpace;
  42878. /** @hidden */
  42879. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42880. /**
  42881. * Current XR frame
  42882. */
  42883. currentFrame: Nullable<XRFrame>;
  42884. private _xrNavigator;
  42885. private baseLayer;
  42886. /**
  42887. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42888. * @param scene The scene which the session should be created for
  42889. */
  42890. constructor(scene: Scene);
  42891. /**
  42892. * Initializes the manager
  42893. * After initialization enterXR can be called to start an XR session
  42894. * @returns Promise which resolves after it is initialized
  42895. */
  42896. initializeAsync(): Promise<void>;
  42897. /**
  42898. * Initializes an xr session
  42899. * @param xrSessionMode mode to initialize
  42900. * @returns a promise which will resolve once the session has been initialized
  42901. */
  42902. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42903. /**
  42904. * Sets the reference space on the xr session
  42905. * @param referenceSpace space to set
  42906. * @returns a promise that will resolve once the reference space has been set
  42907. */
  42908. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42909. /**
  42910. * Updates the render state of the session
  42911. * @param state state to set
  42912. * @returns a promise that resolves once the render state has been updated
  42913. */
  42914. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42915. /**
  42916. * Starts rendering to the xr layer
  42917. * @returns a promise that will resolve once rendering has started
  42918. */
  42919. startRenderingToXRAsync(): Promise<void>;
  42920. /**
  42921. * Stops the xrSession and restores the renderloop
  42922. * @returns Promise which resolves after it exits XR
  42923. */
  42924. exitXRAsync(): Promise<unknown>;
  42925. /**
  42926. * Checks if a session would be supported for the creation options specified
  42927. * @param sessionMode session mode to check if supported eg. immersive-vr
  42928. * @returns true if supported
  42929. */
  42930. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42931. /**
  42932. * @hidden
  42933. * Converts the render layer of xrSession to a render target
  42934. * @param session session to create render target for
  42935. * @param scene scene the new render target should be created for
  42936. */
  42937. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42938. /**
  42939. * Disposes of the session manager
  42940. */
  42941. dispose(): void;
  42942. }
  42943. }
  42944. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42945. import { Scene } from "babylonjs/scene";
  42946. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42947. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42948. /**
  42949. * WebXR Camera which holds the views for the xrSession
  42950. * @see https://doc.babylonjs.com/how_to/webxr
  42951. */
  42952. export class WebXRCamera extends FreeCamera {
  42953. private static _TmpMatrix;
  42954. /**
  42955. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42956. * @param name the name of the camera
  42957. * @param scene the scene to add the camera to
  42958. */
  42959. constructor(name: string, scene: Scene);
  42960. private _updateNumberOfRigCameras;
  42961. /** @hidden */
  42962. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42963. /**
  42964. * Updates the cameras position from the current pose information of the XR session
  42965. * @param xrSessionManager the session containing pose information
  42966. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42967. */
  42968. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42969. }
  42970. }
  42971. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42972. import { Nullable } from "babylonjs/types";
  42973. import { IDisposable } from "babylonjs/scene";
  42974. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42975. /**
  42976. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42977. */
  42978. export class WebXRManagedOutputCanvas implements IDisposable {
  42979. private helper;
  42980. private _canvas;
  42981. /**
  42982. * xrpresent context of the canvas which can be used to display/mirror xr content
  42983. */
  42984. canvasContext: WebGLRenderingContext;
  42985. /**
  42986. * xr layer for the canvas
  42987. */
  42988. xrLayer: Nullable<XRWebGLLayer>;
  42989. /**
  42990. * Initializes the xr layer for the session
  42991. * @param xrSession xr session
  42992. * @returns a promise that will resolve once the XR Layer has been created
  42993. */
  42994. initializeXRLayerAsync(xrSession: any): any;
  42995. /**
  42996. * Initializes the canvas to be added/removed upon entering/exiting xr
  42997. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42998. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42999. */
  43000. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43001. /**
  43002. * Disposes of the object
  43003. */
  43004. dispose(): void;
  43005. private _setManagedOutputCanvas;
  43006. private _addCanvas;
  43007. private _removeCanvas;
  43008. }
  43009. }
  43010. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43011. import { Observable } from "babylonjs/Misc/observable";
  43012. import { IDisposable, Scene } from "babylonjs/scene";
  43013. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43015. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43016. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43017. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43018. /**
  43019. * States of the webXR experience
  43020. */
  43021. export enum WebXRState {
  43022. /**
  43023. * Transitioning to being in XR mode
  43024. */
  43025. ENTERING_XR = 0,
  43026. /**
  43027. * Transitioning to non XR mode
  43028. */
  43029. EXITING_XR = 1,
  43030. /**
  43031. * In XR mode and presenting
  43032. */
  43033. IN_XR = 2,
  43034. /**
  43035. * Not entered XR mode
  43036. */
  43037. NOT_IN_XR = 3
  43038. }
  43039. /**
  43040. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43041. * @see https://doc.babylonjs.com/how_to/webxr
  43042. */
  43043. export class WebXRExperienceHelper implements IDisposable {
  43044. private scene;
  43045. /**
  43046. * 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
  43047. */
  43048. container: AbstractMesh;
  43049. /**
  43050. * Camera used to render xr content
  43051. */
  43052. camera: WebXRCamera;
  43053. /**
  43054. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43055. */
  43056. state: WebXRState;
  43057. private _setState;
  43058. private static _TmpVector;
  43059. /**
  43060. * Fires when the state of the experience helper has changed
  43061. */
  43062. onStateChangedObservable: Observable<WebXRState>;
  43063. /** Session manager used to keep track of xr session */
  43064. sessionManager: WebXRSessionManager;
  43065. private _nonVRCamera;
  43066. private _originalSceneAutoClear;
  43067. private _supported;
  43068. /**
  43069. * Creates the experience helper
  43070. * @param scene the scene to attach the experience helper to
  43071. * @returns a promise for the experience helper
  43072. */
  43073. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43074. /**
  43075. * Creates a WebXRExperienceHelper
  43076. * @param scene The scene the helper should be created in
  43077. */
  43078. private constructor();
  43079. /**
  43080. * Exits XR mode and returns the scene to its original state
  43081. * @returns promise that resolves after xr mode has exited
  43082. */
  43083. exitXRAsync(): Promise<unknown>;
  43084. /**
  43085. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43086. * @param sessionCreationOptions options for the XR session
  43087. * @param referenceSpaceType frame of reference of the XR session
  43088. * @param outputCanvas the output canvas that will be used to enter XR mode
  43089. * @returns promise that resolves after xr mode has entered
  43090. */
  43091. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43092. /**
  43093. * Updates the global position of the camera by moving the camera's container
  43094. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43095. * @param position The desired global position of the camera
  43096. */
  43097. setPositionOfCameraUsingContainer(position: Vector3): void;
  43098. /**
  43099. * Rotates the xr camera by rotating the camera's container around the camera's position
  43100. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43101. * @param rotation the desired quaternion rotation to apply to the camera
  43102. */
  43103. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43104. /**
  43105. * Disposes of the experience helper
  43106. */
  43107. dispose(): void;
  43108. }
  43109. }
  43110. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43111. import { Nullable } from "babylonjs/types";
  43112. import { Observable } from "babylonjs/Misc/observable";
  43113. import { IDisposable, Scene } from "babylonjs/scene";
  43114. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43115. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43116. /**
  43117. * Button which can be used to enter a different mode of XR
  43118. */
  43119. export class WebXREnterExitUIButton {
  43120. /** button element */
  43121. element: HTMLElement;
  43122. /** XR initialization options for the button */
  43123. sessionMode: XRSessionMode;
  43124. /** Reference space type */
  43125. referenceSpaceType: XRReferenceSpaceType;
  43126. /**
  43127. * Creates a WebXREnterExitUIButton
  43128. * @param element button element
  43129. * @param sessionMode XR initialization session mode
  43130. * @param referenceSpaceType the type of reference space to be used
  43131. */
  43132. constructor(
  43133. /** button element */
  43134. element: HTMLElement,
  43135. /** XR initialization options for the button */
  43136. sessionMode: XRSessionMode,
  43137. /** Reference space type */
  43138. referenceSpaceType: XRReferenceSpaceType);
  43139. /**
  43140. * Overwritable function which can be used to update the button's visuals when the state changes
  43141. * @param activeButton the current active button in the UI
  43142. */
  43143. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43144. }
  43145. /**
  43146. * Options to create the webXR UI
  43147. */
  43148. export class WebXREnterExitUIOptions {
  43149. /**
  43150. * Context to enter xr with
  43151. */
  43152. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43153. /**
  43154. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43155. */
  43156. customButtons?: Array<WebXREnterExitUIButton>;
  43157. }
  43158. /**
  43159. * UI to allow the user to enter/exit XR mode
  43160. */
  43161. export class WebXREnterExitUI implements IDisposable {
  43162. private scene;
  43163. private _overlay;
  43164. private _buttons;
  43165. private _activeButton;
  43166. /**
  43167. * Fired every time the active button is changed.
  43168. *
  43169. * When xr is entered via a button that launches xr that button will be the callback parameter
  43170. *
  43171. * When exiting xr the callback parameter will be null)
  43172. */
  43173. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43174. /**
  43175. * Creates UI to allow the user to enter/exit XR mode
  43176. * @param scene the scene to add the ui to
  43177. * @param helper the xr experience helper to enter/exit xr with
  43178. * @param options options to configure the UI
  43179. * @returns the created ui
  43180. */
  43181. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43182. private constructor();
  43183. private _updateButtons;
  43184. /**
  43185. * Disposes of the object
  43186. */
  43187. dispose(): void;
  43188. }
  43189. }
  43190. declare module "babylonjs/Cameras/XR/webXRController" {
  43191. import { Nullable } from "babylonjs/types";
  43192. import { Observable } from "babylonjs/Misc/observable";
  43193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43194. import { Ray } from "babylonjs/Culling/ray";
  43195. import { Scene } from "babylonjs/scene";
  43196. /**
  43197. * Represents an XR input
  43198. */
  43199. export class WebXRController {
  43200. private scene;
  43201. /** The underlying input source for the controller */
  43202. inputSource: XRInputSource;
  43203. private parentContainer;
  43204. /**
  43205. * 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
  43206. */
  43207. grip?: AbstractMesh;
  43208. /**
  43209. * Pointer which can be used to select objects or attach a visible laser to
  43210. */
  43211. pointer: AbstractMesh;
  43212. /**
  43213. * Event that fires when the controller is removed/disposed
  43214. */
  43215. onDisposeObservable: Observable<{}>;
  43216. private _tmpMatrix;
  43217. private _tmpQuaternion;
  43218. private _tmpVector;
  43219. /**
  43220. * Creates the controller
  43221. * @see https://doc.babylonjs.com/how_to/webxr
  43222. * @param scene the scene which the controller should be associated to
  43223. * @param inputSource the underlying input source for the controller
  43224. * @param parentContainer parent that the controller meshes should be children of
  43225. */
  43226. constructor(scene: Scene,
  43227. /** The underlying input source for the controller */
  43228. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43229. /**
  43230. * Updates the controller pose based on the given XRFrame
  43231. * @param xrFrame xr frame to update the pose with
  43232. * @param referenceSpace reference space to use
  43233. */
  43234. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43235. /**
  43236. * Gets a world space ray coming from the controller
  43237. * @param result the resulting ray
  43238. */
  43239. getWorldPointerRayToRef(result: Ray): void;
  43240. /**
  43241. * Disposes of the object
  43242. */
  43243. dispose(): void;
  43244. }
  43245. }
  43246. declare module "babylonjs/Cameras/XR/webXRInput" {
  43247. import { Observable } from "babylonjs/Misc/observable";
  43248. import { IDisposable } from "babylonjs/scene";
  43249. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43250. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43251. /**
  43252. * XR input used to track XR inputs such as controllers/rays
  43253. */
  43254. export class WebXRInput implements IDisposable {
  43255. /**
  43256. * Base experience the input listens to
  43257. */
  43258. baseExperience: WebXRExperienceHelper;
  43259. /**
  43260. * XR controllers being tracked
  43261. */
  43262. controllers: Array<WebXRController>;
  43263. private _frameObserver;
  43264. private _stateObserver;
  43265. /**
  43266. * Event when a controller has been connected/added
  43267. */
  43268. onControllerAddedObservable: Observable<WebXRController>;
  43269. /**
  43270. * Event when a controller has been removed/disconnected
  43271. */
  43272. onControllerRemovedObservable: Observable<WebXRController>;
  43273. /**
  43274. * Initializes the WebXRInput
  43275. * @param baseExperience experience helper which the input should be created for
  43276. */
  43277. constructor(
  43278. /**
  43279. * Base experience the input listens to
  43280. */
  43281. baseExperience: WebXRExperienceHelper);
  43282. private _onInputSourcesChange;
  43283. private _addAndRemoveControllers;
  43284. /**
  43285. * Disposes of the object
  43286. */
  43287. dispose(): void;
  43288. }
  43289. }
  43290. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43292. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43293. /**
  43294. * Enables teleportation
  43295. */
  43296. export class WebXRControllerTeleportation {
  43297. private _teleportationFillColor;
  43298. private _teleportationBorderColor;
  43299. private _tmpRay;
  43300. private _tmpVector;
  43301. /**
  43302. * Creates a WebXRControllerTeleportation
  43303. * @param input input manager to add teleportation to
  43304. * @param floorMeshes floormeshes which can be teleported to
  43305. */
  43306. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43307. }
  43308. }
  43309. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43310. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43311. /**
  43312. * Handles pointer input automatically for the pointer of XR controllers
  43313. */
  43314. export class WebXRControllerPointerSelection {
  43315. private static _idCounter;
  43316. private _tmpRay;
  43317. /**
  43318. * Creates a WebXRControllerPointerSelection
  43319. * @param input input manager to setup pointer selection
  43320. */
  43321. constructor(input: WebXRInput);
  43322. private _convertNormalToDirectionOfRay;
  43323. private _updatePointerDistance;
  43324. }
  43325. }
  43326. declare module "babylonjs/Loading/sceneLoader" {
  43327. import { Observable } from "babylonjs/Misc/observable";
  43328. import { Nullable } from "babylonjs/types";
  43329. import { Scene } from "babylonjs/scene";
  43330. import { Engine } from "babylonjs/Engines/engine";
  43331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43332. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43333. import { AssetContainer } from "babylonjs/assetContainer";
  43334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43335. import { Skeleton } from "babylonjs/Bones/skeleton";
  43336. /**
  43337. * Class used to represent data loading progression
  43338. */
  43339. export class SceneLoaderProgressEvent {
  43340. /** defines if data length to load can be evaluated */
  43341. readonly lengthComputable: boolean;
  43342. /** defines the loaded data length */
  43343. readonly loaded: number;
  43344. /** defines the data length to load */
  43345. readonly total: number;
  43346. /**
  43347. * Create a new progress event
  43348. * @param lengthComputable defines if data length to load can be evaluated
  43349. * @param loaded defines the loaded data length
  43350. * @param total defines the data length to load
  43351. */
  43352. constructor(
  43353. /** defines if data length to load can be evaluated */
  43354. lengthComputable: boolean,
  43355. /** defines the loaded data length */
  43356. loaded: number,
  43357. /** defines the data length to load */
  43358. total: number);
  43359. /**
  43360. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43361. * @param event defines the source event
  43362. * @returns a new SceneLoaderProgressEvent
  43363. */
  43364. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43365. }
  43366. /**
  43367. * Interface used by SceneLoader plugins to define supported file extensions
  43368. */
  43369. export interface ISceneLoaderPluginExtensions {
  43370. /**
  43371. * Defines the list of supported extensions
  43372. */
  43373. [extension: string]: {
  43374. isBinary: boolean;
  43375. };
  43376. }
  43377. /**
  43378. * Interface used by SceneLoader plugin factory
  43379. */
  43380. export interface ISceneLoaderPluginFactory {
  43381. /**
  43382. * Defines the name of the factory
  43383. */
  43384. name: string;
  43385. /**
  43386. * Function called to create a new plugin
  43387. * @return the new plugin
  43388. */
  43389. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43390. /**
  43391. * Boolean indicating if the plugin can direct load specific data
  43392. */
  43393. canDirectLoad?: (data: string) => boolean;
  43394. }
  43395. /**
  43396. * Interface used to define a SceneLoader plugin
  43397. */
  43398. export interface ISceneLoaderPlugin {
  43399. /**
  43400. * The friendly name of this plugin.
  43401. */
  43402. name: string;
  43403. /**
  43404. * The file extensions supported by this plugin.
  43405. */
  43406. extensions: string | ISceneLoaderPluginExtensions;
  43407. /**
  43408. * Import meshes into a scene.
  43409. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43410. * @param scene The scene to import into
  43411. * @param data The data to import
  43412. * @param rootUrl The root url for scene and resources
  43413. * @param meshes The meshes array to import into
  43414. * @param particleSystems The particle systems array to import into
  43415. * @param skeletons The skeletons array to import into
  43416. * @param onError The callback when import fails
  43417. * @returns True if successful or false otherwise
  43418. */
  43419. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43420. /**
  43421. * Load into a scene.
  43422. * @param scene The scene to load into
  43423. * @param data The data to import
  43424. * @param rootUrl The root url for scene and resources
  43425. * @param onError The callback when import fails
  43426. * @returns true if successful or false otherwise
  43427. */
  43428. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43429. /**
  43430. * The callback that returns true if the data can be directly loaded.
  43431. */
  43432. canDirectLoad?: (data: string) => boolean;
  43433. /**
  43434. * The callback that allows custom handling of the root url based on the response url.
  43435. */
  43436. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43437. /**
  43438. * Load into an asset container.
  43439. * @param scene The scene to load into
  43440. * @param data The data to import
  43441. * @param rootUrl The root url for scene and resources
  43442. * @param onError The callback when import fails
  43443. * @returns The loaded asset container
  43444. */
  43445. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43446. }
  43447. /**
  43448. * Interface used to define an async SceneLoader plugin
  43449. */
  43450. export interface ISceneLoaderPluginAsync {
  43451. /**
  43452. * The friendly name of this plugin.
  43453. */
  43454. name: string;
  43455. /**
  43456. * The file extensions supported by this plugin.
  43457. */
  43458. extensions: string | ISceneLoaderPluginExtensions;
  43459. /**
  43460. * Import meshes into a scene.
  43461. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43462. * @param scene The scene to import into
  43463. * @param data The data to import
  43464. * @param rootUrl The root url for scene and resources
  43465. * @param onProgress The callback when the load progresses
  43466. * @param fileName Defines the name of the file to load
  43467. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43468. */
  43469. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43470. meshes: AbstractMesh[];
  43471. particleSystems: IParticleSystem[];
  43472. skeletons: Skeleton[];
  43473. animationGroups: AnimationGroup[];
  43474. }>;
  43475. /**
  43476. * Load into a scene.
  43477. * @param scene The scene to load into
  43478. * @param data The data to import
  43479. * @param rootUrl The root url for scene and resources
  43480. * @param onProgress The callback when the load progresses
  43481. * @param fileName Defines the name of the file to load
  43482. * @returns Nothing
  43483. */
  43484. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43485. /**
  43486. * The callback that returns true if the data can be directly loaded.
  43487. */
  43488. canDirectLoad?: (data: string) => boolean;
  43489. /**
  43490. * The callback that allows custom handling of the root url based on the response url.
  43491. */
  43492. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43493. /**
  43494. * Load into an asset container.
  43495. * @param scene The scene to load into
  43496. * @param data The data to import
  43497. * @param rootUrl The root url for scene and resources
  43498. * @param onProgress The callback when the load progresses
  43499. * @param fileName Defines the name of the file to load
  43500. * @returns The loaded asset container
  43501. */
  43502. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43503. }
  43504. /**
  43505. * Class used to load scene from various file formats using registered plugins
  43506. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43507. */
  43508. export class SceneLoader {
  43509. /**
  43510. * No logging while loading
  43511. */
  43512. static readonly NO_LOGGING: number;
  43513. /**
  43514. * Minimal logging while loading
  43515. */
  43516. static readonly MINIMAL_LOGGING: number;
  43517. /**
  43518. * Summary logging while loading
  43519. */
  43520. static readonly SUMMARY_LOGGING: number;
  43521. /**
  43522. * Detailled logging while loading
  43523. */
  43524. static readonly DETAILED_LOGGING: number;
  43525. /**
  43526. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43527. */
  43528. static ForceFullSceneLoadingForIncremental: boolean;
  43529. /**
  43530. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43531. */
  43532. static ShowLoadingScreen: boolean;
  43533. /**
  43534. * Defines the current logging level (while loading the scene)
  43535. * @ignorenaming
  43536. */
  43537. static loggingLevel: number;
  43538. /**
  43539. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43540. */
  43541. static CleanBoneMatrixWeights: boolean;
  43542. /**
  43543. * Event raised when a plugin is used to load a scene
  43544. */
  43545. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43546. private static _registeredPlugins;
  43547. private static _getDefaultPlugin;
  43548. private static _getPluginForExtension;
  43549. private static _getPluginForDirectLoad;
  43550. private static _getPluginForFilename;
  43551. private static _getDirectLoad;
  43552. private static _loadData;
  43553. private static _getFileInfo;
  43554. /**
  43555. * Gets a plugin that can load the given extension
  43556. * @param extension defines the extension to load
  43557. * @returns a plugin or null if none works
  43558. */
  43559. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43560. /**
  43561. * Gets a boolean indicating that the given extension can be loaded
  43562. * @param extension defines the extension to load
  43563. * @returns true if the extension is supported
  43564. */
  43565. static IsPluginForExtensionAvailable(extension: string): boolean;
  43566. /**
  43567. * Adds a new plugin to the list of registered plugins
  43568. * @param plugin defines the plugin to add
  43569. */
  43570. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43571. /**
  43572. * Import meshes into a scene
  43573. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43574. * @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)
  43575. * @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)
  43576. * @param scene the instance of BABYLON.Scene to append to
  43577. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43578. * @param onProgress a callback with a progress event for each file being loaded
  43579. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43580. * @param pluginExtension the extension used to determine the plugin
  43581. * @returns The loaded plugin
  43582. */
  43583. 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>;
  43584. /**
  43585. * Import meshes into a scene
  43586. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43587. * @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)
  43588. * @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)
  43589. * @param scene the instance of BABYLON.Scene to append to
  43590. * @param onProgress a callback with a progress event for each file being loaded
  43591. * @param pluginExtension the extension used to determine the plugin
  43592. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43593. */
  43594. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43595. meshes: AbstractMesh[];
  43596. particleSystems: IParticleSystem[];
  43597. skeletons: Skeleton[];
  43598. animationGroups: AnimationGroup[];
  43599. }>;
  43600. /**
  43601. * Load a scene
  43602. * @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)
  43603. * @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)
  43604. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43605. * @param onSuccess a callback with the scene when import succeeds
  43606. * @param onProgress a callback with a progress event for each file being loaded
  43607. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43608. * @param pluginExtension the extension used to determine the plugin
  43609. * @returns The loaded plugin
  43610. */
  43611. 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>;
  43612. /**
  43613. * Load a scene
  43614. * @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)
  43615. * @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)
  43616. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43617. * @param onProgress a callback with a progress event for each file being loaded
  43618. * @param pluginExtension the extension used to determine the plugin
  43619. * @returns The loaded scene
  43620. */
  43621. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43622. /**
  43623. * Append a scene
  43624. * @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)
  43625. * @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)
  43626. * @param scene is the instance of BABYLON.Scene to append to
  43627. * @param onSuccess a callback with the scene when import succeeds
  43628. * @param onProgress a callback with a progress event for each file being loaded
  43629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43630. * @param pluginExtension the extension used to determine the plugin
  43631. * @returns The loaded plugin
  43632. */
  43633. 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>;
  43634. /**
  43635. * Append a scene
  43636. * @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)
  43637. * @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)
  43638. * @param scene is the instance of BABYLON.Scene to append to
  43639. * @param onProgress a callback with a progress event for each file being loaded
  43640. * @param pluginExtension the extension used to determine the plugin
  43641. * @returns The given scene
  43642. */
  43643. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43644. /**
  43645. * Load a scene into an asset container
  43646. * @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)
  43647. * @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)
  43648. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43649. * @param onSuccess a callback with the scene when import succeeds
  43650. * @param onProgress a callback with a progress event for each file being loaded
  43651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43652. * @param pluginExtension the extension used to determine the plugin
  43653. * @returns The loaded plugin
  43654. */
  43655. 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>;
  43656. /**
  43657. * Load a scene into an asset container
  43658. * @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)
  43659. * @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)
  43660. * @param scene is the instance of Scene to append to
  43661. * @param onProgress a callback with a progress event for each file being loaded
  43662. * @param pluginExtension the extension used to determine the plugin
  43663. * @returns The loaded asset container
  43664. */
  43665. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43666. }
  43667. }
  43668. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43669. import { Scene } from "babylonjs/scene";
  43670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43671. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43672. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43673. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43674. /**
  43675. * Generic Controller
  43676. */
  43677. export class GenericController extends WebVRController {
  43678. /**
  43679. * Base Url for the controller model.
  43680. */
  43681. static readonly MODEL_BASE_URL: string;
  43682. /**
  43683. * File name for the controller model.
  43684. */
  43685. static readonly MODEL_FILENAME: string;
  43686. /**
  43687. * Creates a new GenericController from a gamepad
  43688. * @param vrGamepad the gamepad that the controller should be created from
  43689. */
  43690. constructor(vrGamepad: any);
  43691. /**
  43692. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43693. * @param scene scene in which to add meshes
  43694. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43695. */
  43696. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43697. /**
  43698. * Called once for each button that changed state since the last frame
  43699. * @param buttonIdx Which button index changed
  43700. * @param state New state of the button
  43701. * @param changes Which properties on the state changed since last frame
  43702. */
  43703. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43704. }
  43705. }
  43706. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43707. import { Observable } from "babylonjs/Misc/observable";
  43708. import { Scene } from "babylonjs/scene";
  43709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43710. import { Ray } from "babylonjs/Culling/ray";
  43711. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43712. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43713. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43714. /**
  43715. * Defines the WindowsMotionController object that the state of the windows motion controller
  43716. */
  43717. export class WindowsMotionController extends WebVRController {
  43718. /**
  43719. * The base url used to load the left and right controller models
  43720. */
  43721. static MODEL_BASE_URL: string;
  43722. /**
  43723. * The name of the left controller model file
  43724. */
  43725. static MODEL_LEFT_FILENAME: string;
  43726. /**
  43727. * The name of the right controller model file
  43728. */
  43729. static MODEL_RIGHT_FILENAME: string;
  43730. /**
  43731. * The controller name prefix for this controller type
  43732. */
  43733. static readonly GAMEPAD_ID_PREFIX: string;
  43734. /**
  43735. * The controller id pattern for this controller type
  43736. */
  43737. private static readonly GAMEPAD_ID_PATTERN;
  43738. private _loadedMeshInfo;
  43739. private readonly _mapping;
  43740. /**
  43741. * Fired when the trackpad on this controller is clicked
  43742. */
  43743. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43744. /**
  43745. * Fired when the trackpad on this controller is modified
  43746. */
  43747. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43748. /**
  43749. * The current x and y values of this controller's trackpad
  43750. */
  43751. trackpad: StickValues;
  43752. /**
  43753. * Creates a new WindowsMotionController from a gamepad
  43754. * @param vrGamepad the gamepad that the controller should be created from
  43755. */
  43756. constructor(vrGamepad: any);
  43757. /**
  43758. * Fired when the trigger on this controller is modified
  43759. */
  43760. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43761. /**
  43762. * Fired when the menu button on this controller is modified
  43763. */
  43764. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43765. /**
  43766. * Fired when the grip button on this controller is modified
  43767. */
  43768. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43769. /**
  43770. * Fired when the thumbstick button on this controller is modified
  43771. */
  43772. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43773. /**
  43774. * Fired when the touchpad button on this controller is modified
  43775. */
  43776. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43777. /**
  43778. * Fired when the touchpad values on this controller are modified
  43779. */
  43780. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43781. private _updateTrackpad;
  43782. /**
  43783. * Called once per frame by the engine.
  43784. */
  43785. update(): void;
  43786. /**
  43787. * Called once for each button that changed state since the last frame
  43788. * @param buttonIdx Which button index changed
  43789. * @param state New state of the button
  43790. * @param changes Which properties on the state changed since last frame
  43791. */
  43792. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43793. /**
  43794. * Moves the buttons on the controller mesh based on their current state
  43795. * @param buttonName the name of the button to move
  43796. * @param buttonValue the value of the button which determines the buttons new position
  43797. */
  43798. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43799. /**
  43800. * Moves the axis on the controller mesh based on its current state
  43801. * @param axis the index of the axis
  43802. * @param axisValue the value of the axis which determines the meshes new position
  43803. * @hidden
  43804. */
  43805. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43806. /**
  43807. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43808. * @param scene scene in which to add meshes
  43809. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43810. */
  43811. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43812. /**
  43813. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43814. * can be transformed by button presses and axes values, based on this._mapping.
  43815. *
  43816. * @param scene scene in which the meshes exist
  43817. * @param meshes list of meshes that make up the controller model to process
  43818. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43819. */
  43820. private processModel;
  43821. private createMeshInfo;
  43822. /**
  43823. * Gets the ray of the controller in the direction the controller is pointing
  43824. * @param length the length the resulting ray should be
  43825. * @returns a ray in the direction the controller is pointing
  43826. */
  43827. getForwardRay(length?: number): Ray;
  43828. /**
  43829. * Disposes of the controller
  43830. */
  43831. dispose(): void;
  43832. }
  43833. }
  43834. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43835. import { Observable } from "babylonjs/Misc/observable";
  43836. import { Scene } from "babylonjs/scene";
  43837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43838. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43839. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43840. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43841. /**
  43842. * Oculus Touch Controller
  43843. */
  43844. export class OculusTouchController extends WebVRController {
  43845. /**
  43846. * Base Url for the controller model.
  43847. */
  43848. static MODEL_BASE_URL: string;
  43849. /**
  43850. * File name for the left controller model.
  43851. */
  43852. static MODEL_LEFT_FILENAME: string;
  43853. /**
  43854. * File name for the right controller model.
  43855. */
  43856. static MODEL_RIGHT_FILENAME: string;
  43857. /**
  43858. * Base Url for the Quest controller model.
  43859. */
  43860. static QUEST_MODEL_BASE_URL: string;
  43861. /**
  43862. * @hidden
  43863. * If the controllers are running on a device that needs the updated Quest controller models
  43864. */
  43865. static _IsQuest: boolean;
  43866. /**
  43867. * Fired when the secondary trigger on this controller is modified
  43868. */
  43869. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43870. /**
  43871. * Fired when the thumb rest on this controller is modified
  43872. */
  43873. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43874. /**
  43875. * Creates a new OculusTouchController from a gamepad
  43876. * @param vrGamepad the gamepad that the controller should be created from
  43877. */
  43878. constructor(vrGamepad: any);
  43879. /**
  43880. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43881. * @param scene scene in which to add meshes
  43882. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43883. */
  43884. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43885. /**
  43886. * Fired when the A button on this controller is modified
  43887. */
  43888. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the B button on this controller is modified
  43891. */
  43892. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Fired when the X button on this controller is modified
  43895. */
  43896. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Fired when the Y button on this controller is modified
  43899. */
  43900. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Called once for each button that changed state since the last frame
  43903. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43904. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43905. * 2) secondary trigger (same)
  43906. * 3) A (right) X (left), touch, pressed = value
  43907. * 4) B / Y
  43908. * 5) thumb rest
  43909. * @param buttonIdx Which button index changed
  43910. * @param state New state of the button
  43911. * @param changes Which properties on the state changed since last frame
  43912. */
  43913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43914. }
  43915. }
  43916. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43917. import { Scene } from "babylonjs/scene";
  43918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43920. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43921. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43922. import { Observable } from "babylonjs/Misc/observable";
  43923. /**
  43924. * Vive Controller
  43925. */
  43926. export class ViveController extends WebVRController {
  43927. /**
  43928. * Base Url for the controller model.
  43929. */
  43930. static MODEL_BASE_URL: string;
  43931. /**
  43932. * File name for the controller model.
  43933. */
  43934. static MODEL_FILENAME: string;
  43935. /**
  43936. * Creates a new ViveController from a gamepad
  43937. * @param vrGamepad the gamepad that the controller should be created from
  43938. */
  43939. constructor(vrGamepad: any);
  43940. /**
  43941. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43942. * @param scene scene in which to add meshes
  43943. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43944. */
  43945. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43946. /**
  43947. * Fired when the left button on this controller is modified
  43948. */
  43949. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43950. /**
  43951. * Fired when the right button on this controller is modified
  43952. */
  43953. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43954. /**
  43955. * Fired when the menu button on this controller is modified
  43956. */
  43957. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43958. /**
  43959. * Called once for each button that changed state since the last frame
  43960. * Vive mapping:
  43961. * 0: touchpad
  43962. * 1: trigger
  43963. * 2: left AND right buttons
  43964. * 3: menu button
  43965. * @param buttonIdx Which button index changed
  43966. * @param state New state of the button
  43967. * @param changes Which properties on the state changed since last frame
  43968. */
  43969. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43970. }
  43971. }
  43972. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43973. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43974. /**
  43975. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43976. */
  43977. export class WebXRControllerModelLoader {
  43978. /**
  43979. * Creates the WebXRControllerModelLoader
  43980. * @param input xr input that creates the controllers
  43981. */
  43982. constructor(input: WebXRInput);
  43983. }
  43984. }
  43985. declare module "babylonjs/Cameras/XR/index" {
  43986. export * from "babylonjs/Cameras/XR/webXRCamera";
  43987. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43988. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43989. export * from "babylonjs/Cameras/XR/webXRInput";
  43990. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43991. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43992. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43993. export * from "babylonjs/Cameras/XR/webXRController";
  43994. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43995. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43996. }
  43997. declare module "babylonjs/Cameras/RigModes/index" {
  43998. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43999. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44000. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44001. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44002. }
  44003. declare module "babylonjs/Cameras/index" {
  44004. export * from "babylonjs/Cameras/Inputs/index";
  44005. export * from "babylonjs/Cameras/cameraInputsManager";
  44006. export * from "babylonjs/Cameras/camera";
  44007. export * from "babylonjs/Cameras/targetCamera";
  44008. export * from "babylonjs/Cameras/freeCamera";
  44009. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44010. export * from "babylonjs/Cameras/touchCamera";
  44011. export * from "babylonjs/Cameras/arcRotateCamera";
  44012. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44013. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44014. export * from "babylonjs/Cameras/flyCamera";
  44015. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44016. export * from "babylonjs/Cameras/followCamera";
  44017. export * from "babylonjs/Cameras/followCameraInputsManager";
  44018. export * from "babylonjs/Cameras/gamepadCamera";
  44019. export * from "babylonjs/Cameras/Stereoscopic/index";
  44020. export * from "babylonjs/Cameras/universalCamera";
  44021. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44022. export * from "babylonjs/Cameras/VR/index";
  44023. export * from "babylonjs/Cameras/XR/index";
  44024. export * from "babylonjs/Cameras/RigModes/index";
  44025. }
  44026. declare module "babylonjs/Collisions/index" {
  44027. export * from "babylonjs/Collisions/collider";
  44028. export * from "babylonjs/Collisions/collisionCoordinator";
  44029. export * from "babylonjs/Collisions/pickingInfo";
  44030. export * from "babylonjs/Collisions/intersectionInfo";
  44031. export * from "babylonjs/Collisions/meshCollisionData";
  44032. }
  44033. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44034. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44035. import { Vector3 } from "babylonjs/Maths/math.vector";
  44036. import { Ray } from "babylonjs/Culling/ray";
  44037. import { Plane } from "babylonjs/Maths/math.plane";
  44038. /**
  44039. * Contains an array of blocks representing the octree
  44040. */
  44041. export interface IOctreeContainer<T> {
  44042. /**
  44043. * Blocks within the octree
  44044. */
  44045. blocks: Array<OctreeBlock<T>>;
  44046. }
  44047. /**
  44048. * Class used to store a cell in an octree
  44049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44050. */
  44051. export class OctreeBlock<T> {
  44052. /**
  44053. * Gets the content of the current block
  44054. */
  44055. entries: T[];
  44056. /**
  44057. * Gets the list of block children
  44058. */
  44059. blocks: Array<OctreeBlock<T>>;
  44060. private _depth;
  44061. private _maxDepth;
  44062. private _capacity;
  44063. private _minPoint;
  44064. private _maxPoint;
  44065. private _boundingVectors;
  44066. private _creationFunc;
  44067. /**
  44068. * Creates a new block
  44069. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44070. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44071. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44072. * @param depth defines the current depth of this block in the octree
  44073. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44074. * @param creationFunc defines a callback to call when an element is added to the block
  44075. */
  44076. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44077. /**
  44078. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44079. */
  44080. readonly capacity: number;
  44081. /**
  44082. * Gets the minimum vector (in world space) of the block's bounding box
  44083. */
  44084. readonly minPoint: Vector3;
  44085. /**
  44086. * Gets the maximum vector (in world space) of the block's bounding box
  44087. */
  44088. readonly maxPoint: Vector3;
  44089. /**
  44090. * Add a new element to this block
  44091. * @param entry defines the element to add
  44092. */
  44093. addEntry(entry: T): void;
  44094. /**
  44095. * Remove an element from this block
  44096. * @param entry defines the element to remove
  44097. */
  44098. removeEntry(entry: T): void;
  44099. /**
  44100. * Add an array of elements to this block
  44101. * @param entries defines the array of elements to add
  44102. */
  44103. addEntries(entries: T[]): void;
  44104. /**
  44105. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44106. * @param frustumPlanes defines the frustum planes to test
  44107. * @param selection defines the array to store current content if selection is positive
  44108. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44109. */
  44110. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44111. /**
  44112. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44113. * @param sphereCenter defines the bounding sphere center
  44114. * @param sphereRadius defines the bounding sphere radius
  44115. * @param selection defines the array to store current content if selection is positive
  44116. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44117. */
  44118. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44119. /**
  44120. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44121. * @param ray defines the ray to test with
  44122. * @param selection defines the array to store current content if selection is positive
  44123. */
  44124. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44125. /**
  44126. * Subdivide the content into child blocks (this block will then be empty)
  44127. */
  44128. createInnerBlocks(): void;
  44129. /**
  44130. * @hidden
  44131. */
  44132. 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;
  44133. }
  44134. }
  44135. declare module "babylonjs/Culling/Octrees/octree" {
  44136. import { SmartArray } from "babylonjs/Misc/smartArray";
  44137. import { Vector3 } from "babylonjs/Maths/math.vector";
  44138. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44140. import { Ray } from "babylonjs/Culling/ray";
  44141. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44142. import { Plane } from "babylonjs/Maths/math.plane";
  44143. /**
  44144. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44146. */
  44147. export class Octree<T> {
  44148. /** 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.) */
  44149. maxDepth: number;
  44150. /**
  44151. * Blocks within the octree containing objects
  44152. */
  44153. blocks: Array<OctreeBlock<T>>;
  44154. /**
  44155. * Content stored in the octree
  44156. */
  44157. dynamicContent: T[];
  44158. private _maxBlockCapacity;
  44159. private _selectionContent;
  44160. private _creationFunc;
  44161. /**
  44162. * Creates a octree
  44163. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44164. * @param creationFunc function to be used to instatiate the octree
  44165. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44166. * @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.)
  44167. */
  44168. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44169. /** 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.) */
  44170. maxDepth?: number);
  44171. /**
  44172. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44173. * @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);
  44174. * @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);
  44175. * @param entries meshes to be added to the octree blocks
  44176. */
  44177. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44178. /**
  44179. * Adds a mesh to the octree
  44180. * @param entry Mesh to add to the octree
  44181. */
  44182. addMesh(entry: T): void;
  44183. /**
  44184. * Remove an element from the octree
  44185. * @param entry defines the element to remove
  44186. */
  44187. removeMesh(entry: T): void;
  44188. /**
  44189. * Selects an array of meshes within the frustum
  44190. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44191. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44192. * @returns array of meshes within the frustum
  44193. */
  44194. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44195. /**
  44196. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44197. * @param sphereCenter defines the bounding sphere center
  44198. * @param sphereRadius defines the bounding sphere radius
  44199. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44200. * @returns an array of objects that intersect the sphere
  44201. */
  44202. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44203. /**
  44204. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44205. * @param ray defines the ray to test with
  44206. * @returns array of intersected objects
  44207. */
  44208. intersectsRay(ray: Ray): SmartArray<T>;
  44209. /**
  44210. * Adds a mesh into the octree block if it intersects the block
  44211. */
  44212. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44213. /**
  44214. * Adds a submesh into the octree block if it intersects the block
  44215. */
  44216. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44217. }
  44218. }
  44219. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44220. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44221. import { Scene } from "babylonjs/scene";
  44222. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44224. import { Ray } from "babylonjs/Culling/ray";
  44225. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44226. import { Collider } from "babylonjs/Collisions/collider";
  44227. module "babylonjs/scene" {
  44228. interface Scene {
  44229. /**
  44230. * @hidden
  44231. * Backing Filed
  44232. */
  44233. _selectionOctree: Octree<AbstractMesh>;
  44234. /**
  44235. * Gets the octree used to boost mesh selection (picking)
  44236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44237. */
  44238. selectionOctree: Octree<AbstractMesh>;
  44239. /**
  44240. * Creates or updates the octree used to boost selection (picking)
  44241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44242. * @param maxCapacity defines the maximum capacity per leaf
  44243. * @param maxDepth defines the maximum depth of the octree
  44244. * @returns an octree of AbstractMesh
  44245. */
  44246. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44247. }
  44248. }
  44249. module "babylonjs/Meshes/abstractMesh" {
  44250. interface AbstractMesh {
  44251. /**
  44252. * @hidden
  44253. * Backing Field
  44254. */
  44255. _submeshesOctree: Octree<SubMesh>;
  44256. /**
  44257. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44258. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44259. * @param maxCapacity defines the maximum size of each block (64 by default)
  44260. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44261. * @returns the new octree
  44262. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44263. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44264. */
  44265. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44266. }
  44267. }
  44268. /**
  44269. * Defines the octree scene component responsible to manage any octrees
  44270. * in a given scene.
  44271. */
  44272. export class OctreeSceneComponent {
  44273. /**
  44274. * The component name help to identify the component in the list of scene components.
  44275. */
  44276. readonly name: string;
  44277. /**
  44278. * The scene the component belongs to.
  44279. */
  44280. scene: Scene;
  44281. /**
  44282. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44283. */
  44284. readonly checksIsEnabled: boolean;
  44285. /**
  44286. * Creates a new instance of the component for the given scene
  44287. * @param scene Defines the scene to register the component in
  44288. */
  44289. constructor(scene: Scene);
  44290. /**
  44291. * Registers the component in a given scene
  44292. */
  44293. register(): void;
  44294. /**
  44295. * Return the list of active meshes
  44296. * @returns the list of active meshes
  44297. */
  44298. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44299. /**
  44300. * Return the list of active sub meshes
  44301. * @param mesh The mesh to get the candidates sub meshes from
  44302. * @returns the list of active sub meshes
  44303. */
  44304. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44305. private _tempRay;
  44306. /**
  44307. * Return the list of sub meshes intersecting with a given local ray
  44308. * @param mesh defines the mesh to find the submesh for
  44309. * @param localRay defines the ray in local space
  44310. * @returns the list of intersecting sub meshes
  44311. */
  44312. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44313. /**
  44314. * Return the list of sub meshes colliding with a collider
  44315. * @param mesh defines the mesh to find the submesh for
  44316. * @param collider defines the collider to evaluate the collision against
  44317. * @returns the list of colliding sub meshes
  44318. */
  44319. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44320. /**
  44321. * Rebuilds the elements related to this component in case of
  44322. * context lost for instance.
  44323. */
  44324. rebuild(): void;
  44325. /**
  44326. * Disposes the component and the associated ressources.
  44327. */
  44328. dispose(): void;
  44329. }
  44330. }
  44331. declare module "babylonjs/Culling/Octrees/index" {
  44332. export * from "babylonjs/Culling/Octrees/octree";
  44333. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44334. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44335. }
  44336. declare module "babylonjs/Culling/index" {
  44337. export * from "babylonjs/Culling/boundingBox";
  44338. export * from "babylonjs/Culling/boundingInfo";
  44339. export * from "babylonjs/Culling/boundingSphere";
  44340. export * from "babylonjs/Culling/Octrees/index";
  44341. export * from "babylonjs/Culling/ray";
  44342. }
  44343. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44344. import { IDisposable, Scene } from "babylonjs/scene";
  44345. import { Nullable } from "babylonjs/types";
  44346. import { Observable } from "babylonjs/Misc/observable";
  44347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44348. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44349. import { Camera } from "babylonjs/Cameras/camera";
  44350. /**
  44351. * Renders a layer on top of an existing scene
  44352. */
  44353. export class UtilityLayerRenderer implements IDisposable {
  44354. /** the original scene that will be rendered on top of */
  44355. originalScene: Scene;
  44356. private _pointerCaptures;
  44357. private _lastPointerEvents;
  44358. private static _DefaultUtilityLayer;
  44359. private static _DefaultKeepDepthUtilityLayer;
  44360. private _sharedGizmoLight;
  44361. private _renderCamera;
  44362. /**
  44363. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44364. * @returns the camera that is used when rendering the utility layer
  44365. */
  44366. getRenderCamera(): Nullable<Camera>;
  44367. /**
  44368. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44369. * @param cam the camera that should be used when rendering the utility layer
  44370. */
  44371. setRenderCamera(cam: Nullable<Camera>): void;
  44372. /**
  44373. * @hidden
  44374. * Light which used by gizmos to get light shading
  44375. */
  44376. _getSharedGizmoLight(): HemisphericLight;
  44377. /**
  44378. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44379. */
  44380. pickUtilitySceneFirst: boolean;
  44381. /**
  44382. * 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)
  44383. */
  44384. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44385. /**
  44386. * 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)
  44387. */
  44388. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44389. /**
  44390. * The scene that is rendered on top of the original scene
  44391. */
  44392. utilityLayerScene: Scene;
  44393. /**
  44394. * If the utility layer should automatically be rendered on top of existing scene
  44395. */
  44396. shouldRender: boolean;
  44397. /**
  44398. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44399. */
  44400. onlyCheckPointerDownEvents: boolean;
  44401. /**
  44402. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44403. */
  44404. processAllEvents: boolean;
  44405. /**
  44406. * Observable raised when the pointer move from the utility layer scene to the main scene
  44407. */
  44408. onPointerOutObservable: Observable<number>;
  44409. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44410. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44411. private _afterRenderObserver;
  44412. private _sceneDisposeObserver;
  44413. private _originalPointerObserver;
  44414. /**
  44415. * Instantiates a UtilityLayerRenderer
  44416. * @param originalScene the original scene that will be rendered on top of
  44417. * @param handleEvents boolean indicating if the utility layer should handle events
  44418. */
  44419. constructor(
  44420. /** the original scene that will be rendered on top of */
  44421. originalScene: Scene, handleEvents?: boolean);
  44422. private _notifyObservers;
  44423. /**
  44424. * Renders the utility layers scene on top of the original scene
  44425. */
  44426. render(): void;
  44427. /**
  44428. * Disposes of the renderer
  44429. */
  44430. dispose(): void;
  44431. private _updateCamera;
  44432. }
  44433. }
  44434. declare module "babylonjs/Gizmos/gizmo" {
  44435. import { Nullable } from "babylonjs/types";
  44436. import { IDisposable } from "babylonjs/scene";
  44437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44438. import { Mesh } from "babylonjs/Meshes/mesh";
  44439. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44440. /**
  44441. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44442. */
  44443. export class Gizmo implements IDisposable {
  44444. /** The utility layer the gizmo will be added to */
  44445. gizmoLayer: UtilityLayerRenderer;
  44446. /**
  44447. * The root mesh of the gizmo
  44448. */
  44449. _rootMesh: Mesh;
  44450. private _attachedMesh;
  44451. /**
  44452. * Ratio for the scale of the gizmo (Default: 1)
  44453. */
  44454. scaleRatio: number;
  44455. /**
  44456. * If a custom mesh has been set (Default: false)
  44457. */
  44458. protected _customMeshSet: boolean;
  44459. /**
  44460. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44461. * * When set, interactions will be enabled
  44462. */
  44463. attachedMesh: Nullable<AbstractMesh>;
  44464. /**
  44465. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44466. * @param mesh The mesh to replace the default mesh of the gizmo
  44467. */
  44468. setCustomMesh(mesh: Mesh): void;
  44469. /**
  44470. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44471. */
  44472. updateGizmoRotationToMatchAttachedMesh: boolean;
  44473. /**
  44474. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44475. */
  44476. updateGizmoPositionToMatchAttachedMesh: boolean;
  44477. /**
  44478. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44479. */
  44480. updateScale: boolean;
  44481. protected _interactionsEnabled: boolean;
  44482. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44483. private _beforeRenderObserver;
  44484. private _tempVector;
  44485. /**
  44486. * Creates a gizmo
  44487. * @param gizmoLayer The utility layer the gizmo will be added to
  44488. */
  44489. constructor(
  44490. /** The utility layer the gizmo will be added to */
  44491. gizmoLayer?: UtilityLayerRenderer);
  44492. /**
  44493. * Updates the gizmo to match the attached mesh's position/rotation
  44494. */
  44495. protected _update(): void;
  44496. /**
  44497. * Disposes of the gizmo
  44498. */
  44499. dispose(): void;
  44500. }
  44501. }
  44502. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44503. import { Observable } from "babylonjs/Misc/observable";
  44504. import { Nullable } from "babylonjs/types";
  44505. import { Vector3 } from "babylonjs/Maths/math.vector";
  44506. import { Color3 } from "babylonjs/Maths/math.color";
  44507. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44509. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44510. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44512. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44513. import { Scene } from "babylonjs/scene";
  44514. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44515. /**
  44516. * Single plane drag gizmo
  44517. */
  44518. export class PlaneDragGizmo extends Gizmo {
  44519. /**
  44520. * Drag behavior responsible for the gizmos dragging interactions
  44521. */
  44522. dragBehavior: PointerDragBehavior;
  44523. private _pointerObserver;
  44524. /**
  44525. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44526. */
  44527. snapDistance: number;
  44528. /**
  44529. * Event that fires each time the gizmo snaps to a new location.
  44530. * * snapDistance is the the change in distance
  44531. */
  44532. onSnapObservable: Observable<{
  44533. snapDistance: number;
  44534. }>;
  44535. private _plane;
  44536. private _coloredMaterial;
  44537. private _hoverMaterial;
  44538. private _isEnabled;
  44539. private _parent;
  44540. /** @hidden */
  44541. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44542. /** @hidden */
  44543. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44544. /**
  44545. * Creates a PlaneDragGizmo
  44546. * @param gizmoLayer The utility layer the gizmo will be added to
  44547. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44548. * @param color The color of the gizmo
  44549. */
  44550. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44551. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44552. /**
  44553. * If the gizmo is enabled
  44554. */
  44555. isEnabled: boolean;
  44556. /**
  44557. * Disposes of the gizmo
  44558. */
  44559. dispose(): void;
  44560. }
  44561. }
  44562. declare module "babylonjs/Gizmos/positionGizmo" {
  44563. import { Observable } from "babylonjs/Misc/observable";
  44564. import { Nullable } from "babylonjs/types";
  44565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44566. import { Mesh } from "babylonjs/Meshes/mesh";
  44567. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44568. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44569. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44570. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44571. /**
  44572. * Gizmo that enables dragging a mesh along 3 axis
  44573. */
  44574. export class PositionGizmo extends Gizmo {
  44575. /**
  44576. * Internal gizmo used for interactions on the x axis
  44577. */
  44578. xGizmo: AxisDragGizmo;
  44579. /**
  44580. * Internal gizmo used for interactions on the y axis
  44581. */
  44582. yGizmo: AxisDragGizmo;
  44583. /**
  44584. * Internal gizmo used for interactions on the z axis
  44585. */
  44586. zGizmo: AxisDragGizmo;
  44587. /**
  44588. * Internal gizmo used for interactions on the yz plane
  44589. */
  44590. xPlaneGizmo: PlaneDragGizmo;
  44591. /**
  44592. * Internal gizmo used for interactions on the xz plane
  44593. */
  44594. yPlaneGizmo: PlaneDragGizmo;
  44595. /**
  44596. * Internal gizmo used for interactions on the xy plane
  44597. */
  44598. zPlaneGizmo: PlaneDragGizmo;
  44599. /**
  44600. * private variables
  44601. */
  44602. private _meshAttached;
  44603. private _updateGizmoRotationToMatchAttachedMesh;
  44604. private _snapDistance;
  44605. private _scaleRatio;
  44606. /** Fires an event when any of it's sub gizmos are dragged */
  44607. onDragStartObservable: Observable<unknown>;
  44608. /** Fires an event when any of it's sub gizmos are released from dragging */
  44609. onDragEndObservable: Observable<unknown>;
  44610. /**
  44611. * If set to true, planar drag is enabled
  44612. */
  44613. private _planarGizmoEnabled;
  44614. attachedMesh: Nullable<AbstractMesh>;
  44615. /**
  44616. * Creates a PositionGizmo
  44617. * @param gizmoLayer The utility layer the gizmo will be added to
  44618. */
  44619. constructor(gizmoLayer?: UtilityLayerRenderer);
  44620. /**
  44621. * If the planar drag gizmo is enabled
  44622. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44623. */
  44624. planarGizmoEnabled: boolean;
  44625. updateGizmoRotationToMatchAttachedMesh: boolean;
  44626. /**
  44627. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44628. */
  44629. snapDistance: number;
  44630. /**
  44631. * Ratio for the scale of the gizmo (Default: 1)
  44632. */
  44633. scaleRatio: number;
  44634. /**
  44635. * Disposes of the gizmo
  44636. */
  44637. dispose(): void;
  44638. /**
  44639. * CustomMeshes are not supported by this gizmo
  44640. * @param mesh The mesh to replace the default mesh of the gizmo
  44641. */
  44642. setCustomMesh(mesh: Mesh): void;
  44643. }
  44644. }
  44645. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44646. import { Observable } from "babylonjs/Misc/observable";
  44647. import { Nullable } from "babylonjs/types";
  44648. import { Vector3 } from "babylonjs/Maths/math.vector";
  44649. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44651. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44652. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44653. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44654. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44655. import { Scene } from "babylonjs/scene";
  44656. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44657. import { Color3 } from "babylonjs/Maths/math.color";
  44658. /**
  44659. * Single axis drag gizmo
  44660. */
  44661. export class AxisDragGizmo extends Gizmo {
  44662. /**
  44663. * Drag behavior responsible for the gizmos dragging interactions
  44664. */
  44665. dragBehavior: PointerDragBehavior;
  44666. private _pointerObserver;
  44667. /**
  44668. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44669. */
  44670. snapDistance: number;
  44671. /**
  44672. * Event that fires each time the gizmo snaps to a new location.
  44673. * * snapDistance is the the change in distance
  44674. */
  44675. onSnapObservable: Observable<{
  44676. snapDistance: number;
  44677. }>;
  44678. private _isEnabled;
  44679. private _parent;
  44680. private _arrow;
  44681. private _coloredMaterial;
  44682. private _hoverMaterial;
  44683. /** @hidden */
  44684. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44685. /** @hidden */
  44686. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44687. /**
  44688. * Creates an AxisDragGizmo
  44689. * @param gizmoLayer The utility layer the gizmo will be added to
  44690. * @param dragAxis The axis which the gizmo will be able to drag on
  44691. * @param color The color of the gizmo
  44692. */
  44693. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44694. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44695. /**
  44696. * If the gizmo is enabled
  44697. */
  44698. isEnabled: boolean;
  44699. /**
  44700. * Disposes of the gizmo
  44701. */
  44702. dispose(): void;
  44703. }
  44704. }
  44705. declare module "babylonjs/Debug/axesViewer" {
  44706. import { Vector3 } from "babylonjs/Maths/math.vector";
  44707. import { Nullable } from "babylonjs/types";
  44708. import { Scene } from "babylonjs/scene";
  44709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44710. /**
  44711. * The Axes viewer will show 3 axes in a specific point in space
  44712. */
  44713. export class AxesViewer {
  44714. private _xAxis;
  44715. private _yAxis;
  44716. private _zAxis;
  44717. private _scaleLinesFactor;
  44718. private _instanced;
  44719. /**
  44720. * Gets the hosting scene
  44721. */
  44722. scene: Scene;
  44723. /**
  44724. * Gets or sets a number used to scale line length
  44725. */
  44726. scaleLines: number;
  44727. /** Gets the node hierarchy used to render x-axis */
  44728. readonly xAxis: TransformNode;
  44729. /** Gets the node hierarchy used to render y-axis */
  44730. readonly yAxis: TransformNode;
  44731. /** Gets the node hierarchy used to render z-axis */
  44732. readonly zAxis: TransformNode;
  44733. /**
  44734. * Creates a new AxesViewer
  44735. * @param scene defines the hosting scene
  44736. * @param scaleLines defines a number used to scale line length (1 by default)
  44737. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44738. * @param xAxis defines the node hierarchy used to render the x-axis
  44739. * @param yAxis defines the node hierarchy used to render the y-axis
  44740. * @param zAxis defines the node hierarchy used to render the z-axis
  44741. */
  44742. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44743. /**
  44744. * Force the viewer to update
  44745. * @param position defines the position of the viewer
  44746. * @param xaxis defines the x axis of the viewer
  44747. * @param yaxis defines the y axis of the viewer
  44748. * @param zaxis defines the z axis of the viewer
  44749. */
  44750. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44751. /**
  44752. * Creates an instance of this axes viewer.
  44753. * @returns a new axes viewer with instanced meshes
  44754. */
  44755. createInstance(): AxesViewer;
  44756. /** Releases resources */
  44757. dispose(): void;
  44758. private static _SetRenderingGroupId;
  44759. }
  44760. }
  44761. declare module "babylonjs/Debug/boneAxesViewer" {
  44762. import { Nullable } from "babylonjs/types";
  44763. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44764. import { Vector3 } from "babylonjs/Maths/math.vector";
  44765. import { Mesh } from "babylonjs/Meshes/mesh";
  44766. import { Bone } from "babylonjs/Bones/bone";
  44767. import { Scene } from "babylonjs/scene";
  44768. /**
  44769. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44770. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44771. */
  44772. export class BoneAxesViewer extends AxesViewer {
  44773. /**
  44774. * Gets or sets the target mesh where to display the axes viewer
  44775. */
  44776. mesh: Nullable<Mesh>;
  44777. /**
  44778. * Gets or sets the target bone where to display the axes viewer
  44779. */
  44780. bone: Nullable<Bone>;
  44781. /** Gets current position */
  44782. pos: Vector3;
  44783. /** Gets direction of X axis */
  44784. xaxis: Vector3;
  44785. /** Gets direction of Y axis */
  44786. yaxis: Vector3;
  44787. /** Gets direction of Z axis */
  44788. zaxis: Vector3;
  44789. /**
  44790. * Creates a new BoneAxesViewer
  44791. * @param scene defines the hosting scene
  44792. * @param bone defines the target bone
  44793. * @param mesh defines the target mesh
  44794. * @param scaleLines defines a scaling factor for line length (1 by default)
  44795. */
  44796. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44797. /**
  44798. * Force the viewer to update
  44799. */
  44800. update(): void;
  44801. /** Releases resources */
  44802. dispose(): void;
  44803. }
  44804. }
  44805. declare module "babylonjs/Debug/debugLayer" {
  44806. import { Scene } from "babylonjs/scene";
  44807. /**
  44808. * Interface used to define scene explorer extensibility option
  44809. */
  44810. export interface IExplorerExtensibilityOption {
  44811. /**
  44812. * Define the option label
  44813. */
  44814. label: string;
  44815. /**
  44816. * Defines the action to execute on click
  44817. */
  44818. action: (entity: any) => void;
  44819. }
  44820. /**
  44821. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44822. */
  44823. export interface IExplorerExtensibilityGroup {
  44824. /**
  44825. * Defines a predicate to test if a given type mut be extended
  44826. */
  44827. predicate: (entity: any) => boolean;
  44828. /**
  44829. * Gets the list of options added to a type
  44830. */
  44831. entries: IExplorerExtensibilityOption[];
  44832. }
  44833. /**
  44834. * Interface used to define the options to use to create the Inspector
  44835. */
  44836. export interface IInspectorOptions {
  44837. /**
  44838. * Display in overlay mode (default: false)
  44839. */
  44840. overlay?: boolean;
  44841. /**
  44842. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44843. */
  44844. globalRoot?: HTMLElement;
  44845. /**
  44846. * Display the Scene explorer
  44847. */
  44848. showExplorer?: boolean;
  44849. /**
  44850. * Display the property inspector
  44851. */
  44852. showInspector?: boolean;
  44853. /**
  44854. * Display in embed mode (both panes on the right)
  44855. */
  44856. embedMode?: boolean;
  44857. /**
  44858. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44859. */
  44860. handleResize?: boolean;
  44861. /**
  44862. * Allow the panes to popup (default: true)
  44863. */
  44864. enablePopup?: boolean;
  44865. /**
  44866. * Allow the panes to be closed by users (default: true)
  44867. */
  44868. enableClose?: boolean;
  44869. /**
  44870. * Optional list of extensibility entries
  44871. */
  44872. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44873. /**
  44874. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44875. */
  44876. inspectorURL?: string;
  44877. }
  44878. module "babylonjs/scene" {
  44879. interface Scene {
  44880. /**
  44881. * @hidden
  44882. * Backing field
  44883. */
  44884. _debugLayer: DebugLayer;
  44885. /**
  44886. * Gets the debug layer (aka Inspector) associated with the scene
  44887. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44888. */
  44889. debugLayer: DebugLayer;
  44890. }
  44891. }
  44892. /**
  44893. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44894. * what is happening in your scene
  44895. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44896. */
  44897. export class DebugLayer {
  44898. /**
  44899. * Define the url to get the inspector script from.
  44900. * By default it uses the babylonjs CDN.
  44901. * @ignoreNaming
  44902. */
  44903. static InspectorURL: string;
  44904. private _scene;
  44905. private BJSINSPECTOR;
  44906. private _onPropertyChangedObservable?;
  44907. /**
  44908. * Observable triggered when a property is changed through the inspector.
  44909. */
  44910. readonly onPropertyChangedObservable: any;
  44911. /**
  44912. * Instantiates a new debug layer.
  44913. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44914. * what is happening in your scene
  44915. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44916. * @param scene Defines the scene to inspect
  44917. */
  44918. constructor(scene: Scene);
  44919. /** Creates the inspector window. */
  44920. private _createInspector;
  44921. /**
  44922. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44923. * @param entity defines the entity to select
  44924. * @param lineContainerTitle defines the specific block to highlight
  44925. */
  44926. select(entity: any, lineContainerTitle?: string): void;
  44927. /** Get the inspector from bundle or global */
  44928. private _getGlobalInspector;
  44929. /**
  44930. * Get if the inspector is visible or not.
  44931. * @returns true if visible otherwise, false
  44932. */
  44933. isVisible(): boolean;
  44934. /**
  44935. * Hide the inspector and close its window.
  44936. */
  44937. hide(): void;
  44938. /**
  44939. * Launch the debugLayer.
  44940. * @param config Define the configuration of the inspector
  44941. * @return a promise fulfilled when the debug layer is visible
  44942. */
  44943. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44944. }
  44945. }
  44946. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44947. import { Nullable } from "babylonjs/types";
  44948. import { Scene } from "babylonjs/scene";
  44949. import { Vector4 } from "babylonjs/Maths/math.vector";
  44950. import { Color4 } from "babylonjs/Maths/math.color";
  44951. import { Mesh } from "babylonjs/Meshes/mesh";
  44952. /**
  44953. * Class containing static functions to help procedurally build meshes
  44954. */
  44955. export class BoxBuilder {
  44956. /**
  44957. * Creates a box mesh
  44958. * * The parameter `size` sets the size (float) of each box side (default 1)
  44959. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44960. * * 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)
  44961. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44966. * @param name defines the name of the mesh
  44967. * @param options defines the options used to create the mesh
  44968. * @param scene defines the hosting scene
  44969. * @returns the box mesh
  44970. */
  44971. static CreateBox(name: string, options: {
  44972. size?: number;
  44973. width?: number;
  44974. height?: number;
  44975. depth?: number;
  44976. faceUV?: Vector4[];
  44977. faceColors?: Color4[];
  44978. sideOrientation?: number;
  44979. frontUVs?: Vector4;
  44980. backUVs?: Vector4;
  44981. wrap?: boolean;
  44982. topBaseAt?: number;
  44983. bottomBaseAt?: number;
  44984. updatable?: boolean;
  44985. }, scene?: Nullable<Scene>): Mesh;
  44986. }
  44987. }
  44988. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44989. import { Vector4 } from "babylonjs/Maths/math.vector";
  44990. import { Mesh } from "babylonjs/Meshes/mesh";
  44991. import { Scene } from "babylonjs/scene";
  44992. import { Nullable } from "babylonjs/types";
  44993. /**
  44994. * Class containing static functions to help procedurally build meshes
  44995. */
  44996. export class SphereBuilder {
  44997. /**
  44998. * Creates a sphere mesh
  44999. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45000. * * 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`)
  45001. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45002. * * 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
  45003. * * 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)
  45004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45007. * @param name defines the name of the mesh
  45008. * @param options defines the options used to create the mesh
  45009. * @param scene defines the hosting scene
  45010. * @returns the sphere mesh
  45011. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45012. */
  45013. static CreateSphere(name: string, options: {
  45014. segments?: number;
  45015. diameter?: number;
  45016. diameterX?: number;
  45017. diameterY?: number;
  45018. diameterZ?: number;
  45019. arc?: number;
  45020. slice?: number;
  45021. sideOrientation?: number;
  45022. frontUVs?: Vector4;
  45023. backUVs?: Vector4;
  45024. updatable?: boolean;
  45025. }, scene?: Nullable<Scene>): Mesh;
  45026. }
  45027. }
  45028. declare module "babylonjs/Debug/physicsViewer" {
  45029. import { Nullable } from "babylonjs/types";
  45030. import { Scene } from "babylonjs/scene";
  45031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45032. import { Mesh } from "babylonjs/Meshes/mesh";
  45033. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45034. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45035. /**
  45036. * Used to show the physics impostor around the specific mesh
  45037. */
  45038. export class PhysicsViewer {
  45039. /** @hidden */
  45040. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45041. /** @hidden */
  45042. protected _meshes: Array<Nullable<AbstractMesh>>;
  45043. /** @hidden */
  45044. protected _scene: Nullable<Scene>;
  45045. /** @hidden */
  45046. protected _numMeshes: number;
  45047. /** @hidden */
  45048. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45049. private _renderFunction;
  45050. private _utilityLayer;
  45051. private _debugBoxMesh;
  45052. private _debugSphereMesh;
  45053. private _debugCylinderMesh;
  45054. private _debugMaterial;
  45055. private _debugMeshMeshes;
  45056. /**
  45057. * Creates a new PhysicsViewer
  45058. * @param scene defines the hosting scene
  45059. */
  45060. constructor(scene: Scene);
  45061. /** @hidden */
  45062. protected _updateDebugMeshes(): void;
  45063. /**
  45064. * Renders a specified physic impostor
  45065. * @param impostor defines the impostor to render
  45066. * @param targetMesh defines the mesh represented by the impostor
  45067. * @returns the new debug mesh used to render the impostor
  45068. */
  45069. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45070. /**
  45071. * Hides a specified physic impostor
  45072. * @param impostor defines the impostor to hide
  45073. */
  45074. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45075. private _getDebugMaterial;
  45076. private _getDebugBoxMesh;
  45077. private _getDebugSphereMesh;
  45078. private _getDebugCylinderMesh;
  45079. private _getDebugMeshMesh;
  45080. private _getDebugMesh;
  45081. /** Releases all resources */
  45082. dispose(): void;
  45083. }
  45084. }
  45085. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45086. import { Vector3 } from "babylonjs/Maths/math.vector";
  45087. import { Color4 } from "babylonjs/Maths/math.color";
  45088. import { Nullable } from "babylonjs/types";
  45089. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45090. import { Scene } from "babylonjs/scene";
  45091. /**
  45092. * Class containing static functions to help procedurally build meshes
  45093. */
  45094. export class LinesBuilder {
  45095. /**
  45096. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45097. * * 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
  45098. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45099. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45100. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45101. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45102. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45103. * * 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
  45104. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45107. * @param name defines the name of the new line system
  45108. * @param options defines the options used to create the line system
  45109. * @param scene defines the hosting scene
  45110. * @returns a new line system mesh
  45111. */
  45112. static CreateLineSystem(name: string, options: {
  45113. lines: Vector3[][];
  45114. updatable?: boolean;
  45115. instance?: Nullable<LinesMesh>;
  45116. colors?: Nullable<Color4[][]>;
  45117. useVertexAlpha?: boolean;
  45118. }, scene: Nullable<Scene>): LinesMesh;
  45119. /**
  45120. * Creates a line mesh
  45121. * 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
  45122. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45123. * * The parameter `points` is an array successive Vector3
  45124. * * 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
  45125. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45126. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45127. * * When updating an instance, remember that only point positions can change, not the number of points
  45128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45130. * @param name defines the name of the new line system
  45131. * @param options defines the options used to create the line system
  45132. * @param scene defines the hosting scene
  45133. * @returns a new line mesh
  45134. */
  45135. static CreateLines(name: string, options: {
  45136. points: Vector3[];
  45137. updatable?: boolean;
  45138. instance?: Nullable<LinesMesh>;
  45139. colors?: Color4[];
  45140. useVertexAlpha?: boolean;
  45141. }, scene?: Nullable<Scene>): LinesMesh;
  45142. /**
  45143. * Creates a dashed line mesh
  45144. * * 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
  45145. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45146. * * The parameter `points` is an array successive Vector3
  45147. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45148. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45149. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45150. * * 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
  45151. * * When updating an instance, remember that only point positions can change, not the number of points
  45152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45153. * @param name defines the name of the mesh
  45154. * @param options defines the options used to create the mesh
  45155. * @param scene defines the hosting scene
  45156. * @returns the dashed line mesh
  45157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45158. */
  45159. static CreateDashedLines(name: string, options: {
  45160. points: Vector3[];
  45161. dashSize?: number;
  45162. gapSize?: number;
  45163. dashNb?: number;
  45164. updatable?: boolean;
  45165. instance?: LinesMesh;
  45166. }, scene?: Nullable<Scene>): LinesMesh;
  45167. }
  45168. }
  45169. declare module "babylonjs/Debug/rayHelper" {
  45170. import { Nullable } from "babylonjs/types";
  45171. import { Ray } from "babylonjs/Culling/ray";
  45172. import { Vector3 } from "babylonjs/Maths/math.vector";
  45173. import { Color3 } from "babylonjs/Maths/math.color";
  45174. import { Scene } from "babylonjs/scene";
  45175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45176. import "babylonjs/Meshes/Builders/linesBuilder";
  45177. /**
  45178. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45179. * in order to better appreciate the issue one might have.
  45180. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45181. */
  45182. export class RayHelper {
  45183. /**
  45184. * Defines the ray we are currently tryin to visualize.
  45185. */
  45186. ray: Nullable<Ray>;
  45187. private _renderPoints;
  45188. private _renderLine;
  45189. private _renderFunction;
  45190. private _scene;
  45191. private _updateToMeshFunction;
  45192. private _attachedToMesh;
  45193. private _meshSpaceDirection;
  45194. private _meshSpaceOrigin;
  45195. /**
  45196. * Helper function to create a colored helper in a scene in one line.
  45197. * @param ray Defines the ray we are currently tryin to visualize
  45198. * @param scene Defines the scene the ray is used in
  45199. * @param color Defines the color we want to see the ray in
  45200. * @returns The newly created ray helper.
  45201. */
  45202. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45203. /**
  45204. * Instantiate a new ray helper.
  45205. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45206. * in order to better appreciate the issue one might have.
  45207. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45208. * @param ray Defines the ray we are currently tryin to visualize
  45209. */
  45210. constructor(ray: Ray);
  45211. /**
  45212. * Shows the ray we are willing to debug.
  45213. * @param scene Defines the scene the ray needs to be rendered in
  45214. * @param color Defines the color the ray needs to be rendered in
  45215. */
  45216. show(scene: Scene, color?: Color3): void;
  45217. /**
  45218. * Hides the ray we are debugging.
  45219. */
  45220. hide(): void;
  45221. private _render;
  45222. /**
  45223. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45224. * @param mesh Defines the mesh we want the helper attached to
  45225. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45226. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45227. * @param length Defines the length of the ray
  45228. */
  45229. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45230. /**
  45231. * Detach the ray helper from the mesh it has previously been attached to.
  45232. */
  45233. detachFromMesh(): void;
  45234. private _updateToMesh;
  45235. /**
  45236. * Dispose the helper and release its associated resources.
  45237. */
  45238. dispose(): void;
  45239. }
  45240. }
  45241. declare module "babylonjs/Debug/skeletonViewer" {
  45242. import { Color3 } from "babylonjs/Maths/math.color";
  45243. import { Scene } from "babylonjs/scene";
  45244. import { Nullable } from "babylonjs/types";
  45245. import { Skeleton } from "babylonjs/Bones/skeleton";
  45246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45247. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45248. /**
  45249. * Class used to render a debug view of a given skeleton
  45250. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45251. */
  45252. export class SkeletonViewer {
  45253. /** defines the skeleton to render */
  45254. skeleton: Skeleton;
  45255. /** defines the mesh attached to the skeleton */
  45256. mesh: AbstractMesh;
  45257. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45258. autoUpdateBonesMatrices: boolean;
  45259. /** defines the rendering group id to use with the viewer */
  45260. renderingGroupId: number;
  45261. /** Gets or sets the color used to render the skeleton */
  45262. color: Color3;
  45263. private _scene;
  45264. private _debugLines;
  45265. private _debugMesh;
  45266. private _isEnabled;
  45267. private _renderFunction;
  45268. private _utilityLayer;
  45269. /**
  45270. * Returns the mesh used to render the bones
  45271. */
  45272. readonly debugMesh: Nullable<LinesMesh>;
  45273. /**
  45274. * Creates a new SkeletonViewer
  45275. * @param skeleton defines the skeleton to render
  45276. * @param mesh defines the mesh attached to the skeleton
  45277. * @param scene defines the hosting scene
  45278. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45279. * @param renderingGroupId defines the rendering group id to use with the viewer
  45280. */
  45281. constructor(
  45282. /** defines the skeleton to render */
  45283. skeleton: Skeleton,
  45284. /** defines the mesh attached to the skeleton */
  45285. mesh: AbstractMesh, scene: Scene,
  45286. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45287. autoUpdateBonesMatrices?: boolean,
  45288. /** defines the rendering group id to use with the viewer */
  45289. renderingGroupId?: number);
  45290. /** Gets or sets a boolean indicating if the viewer is enabled */
  45291. isEnabled: boolean;
  45292. private _getBonePosition;
  45293. private _getLinesForBonesWithLength;
  45294. private _getLinesForBonesNoLength;
  45295. /** Update the viewer to sync with current skeleton state */
  45296. update(): void;
  45297. /** Release associated resources */
  45298. dispose(): void;
  45299. }
  45300. }
  45301. declare module "babylonjs/Debug/index" {
  45302. export * from "babylonjs/Debug/axesViewer";
  45303. export * from "babylonjs/Debug/boneAxesViewer";
  45304. export * from "babylonjs/Debug/debugLayer";
  45305. export * from "babylonjs/Debug/physicsViewer";
  45306. export * from "babylonjs/Debug/rayHelper";
  45307. export * from "babylonjs/Debug/skeletonViewer";
  45308. }
  45309. declare module "babylonjs/Engines/nullEngine" {
  45310. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45311. import { Scene } from "babylonjs/scene";
  45312. import { Engine } from "babylonjs/Engines/engine";
  45313. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45314. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45316. import { Effect } from "babylonjs/Materials/effect";
  45317. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45318. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45319. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45320. /**
  45321. * Options to create the null engine
  45322. */
  45323. export class NullEngineOptions {
  45324. /**
  45325. * Render width (Default: 512)
  45326. */
  45327. renderWidth: number;
  45328. /**
  45329. * Render height (Default: 256)
  45330. */
  45331. renderHeight: number;
  45332. /**
  45333. * Texture size (Default: 512)
  45334. */
  45335. textureSize: number;
  45336. /**
  45337. * If delta time between frames should be constant
  45338. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45339. */
  45340. deterministicLockstep: boolean;
  45341. /**
  45342. * Maximum about of steps between frames (Default: 4)
  45343. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45344. */
  45345. lockstepMaxSteps: number;
  45346. }
  45347. /**
  45348. * The null engine class provides support for headless version of babylon.js.
  45349. * This can be used in server side scenario or for testing purposes
  45350. */
  45351. export class NullEngine extends Engine {
  45352. private _options;
  45353. /**
  45354. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45355. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45356. * @returns true if engine is in deterministic lock step mode
  45357. */
  45358. isDeterministicLockStep(): boolean;
  45359. /**
  45360. * Gets the max steps when engine is running in deterministic lock step
  45361. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45362. * @returns the max steps
  45363. */
  45364. getLockstepMaxSteps(): number;
  45365. /**
  45366. * Gets the current hardware scaling level.
  45367. * By default the hardware scaling level is computed from the window device ratio.
  45368. * 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.
  45369. * @returns a number indicating the current hardware scaling level
  45370. */
  45371. getHardwareScalingLevel(): number;
  45372. constructor(options?: NullEngineOptions);
  45373. /**
  45374. * Creates a vertex buffer
  45375. * @param vertices the data for the vertex buffer
  45376. * @returns the new WebGL static buffer
  45377. */
  45378. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45379. /**
  45380. * Creates a new index buffer
  45381. * @param indices defines the content of the index buffer
  45382. * @param updatable defines if the index buffer must be updatable
  45383. * @returns a new webGL buffer
  45384. */
  45385. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45386. /**
  45387. * Clear the current render buffer or the current render target (if any is set up)
  45388. * @param color defines the color to use
  45389. * @param backBuffer defines if the back buffer must be cleared
  45390. * @param depth defines if the depth buffer must be cleared
  45391. * @param stencil defines if the stencil buffer must be cleared
  45392. */
  45393. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45394. /**
  45395. * Gets the current render width
  45396. * @param useScreen defines if screen size must be used (or the current render target if any)
  45397. * @returns a number defining the current render width
  45398. */
  45399. getRenderWidth(useScreen?: boolean): number;
  45400. /**
  45401. * Gets the current render height
  45402. * @param useScreen defines if screen size must be used (or the current render target if any)
  45403. * @returns a number defining the current render height
  45404. */
  45405. getRenderHeight(useScreen?: boolean): number;
  45406. /**
  45407. * Set the WebGL's viewport
  45408. * @param viewport defines the viewport element to be used
  45409. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45410. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45411. */
  45412. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45413. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45414. /**
  45415. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45416. * @param pipelineContext defines the pipeline context to use
  45417. * @param uniformsNames defines the list of uniform names
  45418. * @returns an array of webGL uniform locations
  45419. */
  45420. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45421. /**
  45422. * Gets the lsit of active attributes for a given webGL program
  45423. * @param pipelineContext defines the pipeline context to use
  45424. * @param attributesNames defines the list of attribute names to get
  45425. * @returns an array of indices indicating the offset of each attribute
  45426. */
  45427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45428. /**
  45429. * Binds an effect to the webGL context
  45430. * @param effect defines the effect to bind
  45431. */
  45432. bindSamplers(effect: Effect): void;
  45433. /**
  45434. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45435. * @param effect defines the effect to activate
  45436. */
  45437. enableEffect(effect: Effect): void;
  45438. /**
  45439. * Set various states to the webGL context
  45440. * @param culling defines backface culling state
  45441. * @param zOffset defines the value to apply to zOffset (0 by default)
  45442. * @param force defines if states must be applied even if cache is up to date
  45443. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45444. */
  45445. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45446. /**
  45447. * Set the value of an uniform to an array of int32
  45448. * @param uniform defines the webGL uniform location where to store the value
  45449. * @param array defines the array of int32 to store
  45450. */
  45451. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45452. /**
  45453. * Set the value of an uniform to an array of int32 (stored as vec2)
  45454. * @param uniform defines the webGL uniform location where to store the value
  45455. * @param array defines the array of int32 to store
  45456. */
  45457. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45458. /**
  45459. * Set the value of an uniform to an array of int32 (stored as vec3)
  45460. * @param uniform defines the webGL uniform location where to store the value
  45461. * @param array defines the array of int32 to store
  45462. */
  45463. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45464. /**
  45465. * Set the value of an uniform to an array of int32 (stored as vec4)
  45466. * @param uniform defines the webGL uniform location where to store the value
  45467. * @param array defines the array of int32 to store
  45468. */
  45469. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45470. /**
  45471. * Set the value of an uniform to an array of float32
  45472. * @param uniform defines the webGL uniform location where to store the value
  45473. * @param array defines the array of float32 to store
  45474. */
  45475. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45476. /**
  45477. * Set the value of an uniform to an array of float32 (stored as vec2)
  45478. * @param uniform defines the webGL uniform location where to store the value
  45479. * @param array defines the array of float32 to store
  45480. */
  45481. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45482. /**
  45483. * Set the value of an uniform to an array of float32 (stored as vec3)
  45484. * @param uniform defines the webGL uniform location where to store the value
  45485. * @param array defines the array of float32 to store
  45486. */
  45487. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45488. /**
  45489. * Set the value of an uniform to an array of float32 (stored as vec4)
  45490. * @param uniform defines the webGL uniform location where to store the value
  45491. * @param array defines the array of float32 to store
  45492. */
  45493. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45494. /**
  45495. * Set the value of an uniform to an array of number
  45496. * @param uniform defines the webGL uniform location where to store the value
  45497. * @param array defines the array of number to store
  45498. */
  45499. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45500. /**
  45501. * Set the value of an uniform to an array of number (stored as vec2)
  45502. * @param uniform defines the webGL uniform location where to store the value
  45503. * @param array defines the array of number to store
  45504. */
  45505. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45506. /**
  45507. * Set the value of an uniform to an array of number (stored as vec3)
  45508. * @param uniform defines the webGL uniform location where to store the value
  45509. * @param array defines the array of number to store
  45510. */
  45511. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45512. /**
  45513. * Set the value of an uniform to an array of number (stored as vec4)
  45514. * @param uniform defines the webGL uniform location where to store the value
  45515. * @param array defines the array of number to store
  45516. */
  45517. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45518. /**
  45519. * Set the value of an uniform to an array of float32 (stored as matrices)
  45520. * @param uniform defines the webGL uniform location where to store the value
  45521. * @param matrices defines the array of float32 to store
  45522. */
  45523. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45524. /**
  45525. * Set the value of an uniform to a matrix (3x3)
  45526. * @param uniform defines the webGL uniform location where to store the value
  45527. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45528. */
  45529. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45530. /**
  45531. * Set the value of an uniform to a matrix (2x2)
  45532. * @param uniform defines the webGL uniform location where to store the value
  45533. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45534. */
  45535. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45536. /**
  45537. * Set the value of an uniform to a number (float)
  45538. * @param uniform defines the webGL uniform location where to store the value
  45539. * @param value defines the float number to store
  45540. */
  45541. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45542. /**
  45543. * Set the value of an uniform to a vec2
  45544. * @param uniform defines the webGL uniform location where to store the value
  45545. * @param x defines the 1st component of the value
  45546. * @param y defines the 2nd component of the value
  45547. */
  45548. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45549. /**
  45550. * Set the value of an uniform to a vec3
  45551. * @param uniform defines the webGL uniform location where to store the value
  45552. * @param x defines the 1st component of the value
  45553. * @param y defines the 2nd component of the value
  45554. * @param z defines the 3rd component of the value
  45555. */
  45556. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45557. /**
  45558. * Set the value of an uniform to a boolean
  45559. * @param uniform defines the webGL uniform location where to store the value
  45560. * @param bool defines the boolean to store
  45561. */
  45562. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45563. /**
  45564. * Set the value of an uniform to a vec4
  45565. * @param uniform defines the webGL uniform location where to store the value
  45566. * @param x defines the 1st component of the value
  45567. * @param y defines the 2nd component of the value
  45568. * @param z defines the 3rd component of the value
  45569. * @param w defines the 4th component of the value
  45570. */
  45571. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45572. /**
  45573. * Sets the current alpha mode
  45574. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45575. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45576. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45577. */
  45578. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45579. /**
  45580. * Bind webGl buffers directly to the webGL context
  45581. * @param vertexBuffers defines the vertex buffer to bind
  45582. * @param indexBuffer defines the index buffer to bind
  45583. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45584. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45585. * @param effect defines the effect associated with the vertex buffer
  45586. */
  45587. bindBuffers(vertexBuffers: {
  45588. [key: string]: VertexBuffer;
  45589. }, indexBuffer: DataBuffer, effect: Effect): void;
  45590. /**
  45591. * Force the entire cache to be cleared
  45592. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45593. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45594. */
  45595. wipeCaches(bruteForce?: boolean): void;
  45596. /**
  45597. * Send a draw order
  45598. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45599. * @param indexStart defines the starting index
  45600. * @param indexCount defines the number of index to draw
  45601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45602. */
  45603. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45604. /**
  45605. * Draw a list of indexed primitives
  45606. * @param fillMode defines the primitive to use
  45607. * @param indexStart defines the starting index
  45608. * @param indexCount defines the number of index to draw
  45609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45610. */
  45611. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45612. /**
  45613. * Draw a list of unindexed primitives
  45614. * @param fillMode defines the primitive to use
  45615. * @param verticesStart defines the index of first vertex to draw
  45616. * @param verticesCount defines the count of vertices to draw
  45617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45618. */
  45619. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45620. /** @hidden */
  45621. _createTexture(): WebGLTexture;
  45622. /** @hidden */
  45623. _releaseTexture(texture: InternalTexture): void;
  45624. /**
  45625. * Usually called from Texture.ts.
  45626. * Passed information to create a WebGLTexture
  45627. * @param urlArg defines a value which contains one of the following:
  45628. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45629. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45630. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45631. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45632. * @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)
  45633. * @param scene needed for loading to the correct scene
  45634. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45635. * @param onLoad optional callback to be called upon successful completion
  45636. * @param onError optional callback to be called upon failure
  45637. * @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
  45638. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45639. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45640. * @param forcedExtension defines the extension to use to pick the right loader
  45641. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45642. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45643. */
  45644. 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;
  45645. /**
  45646. * Creates a new render target texture
  45647. * @param size defines the size of the texture
  45648. * @param options defines the options used to create the texture
  45649. * @returns a new render target texture stored in an InternalTexture
  45650. */
  45651. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45652. /**
  45653. * Update the sampling mode of a given texture
  45654. * @param samplingMode defines the required sampling mode
  45655. * @param texture defines the texture to update
  45656. */
  45657. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45658. /**
  45659. * Binds the frame buffer to the specified texture.
  45660. * @param texture The texture to render to or null for the default canvas
  45661. * @param faceIndex The face of the texture to render to in case of cube texture
  45662. * @param requiredWidth The width of the target to render to
  45663. * @param requiredHeight The height of the target to render to
  45664. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45665. * @param depthStencilTexture The depth stencil texture to use to render
  45666. * @param lodLevel defines le lod level to bind to the frame buffer
  45667. */
  45668. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45669. /**
  45670. * Unbind the current render target texture from the webGL context
  45671. * @param texture defines the render target texture to unbind
  45672. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45673. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45674. */
  45675. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45676. /**
  45677. * Creates a dynamic vertex buffer
  45678. * @param vertices the data for the dynamic vertex buffer
  45679. * @returns the new WebGL dynamic buffer
  45680. */
  45681. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45682. /**
  45683. * Update the content of a dynamic texture
  45684. * @param texture defines the texture to update
  45685. * @param canvas defines the canvas containing the source
  45686. * @param invertY defines if data must be stored with Y axis inverted
  45687. * @param premulAlpha defines if alpha is stored as premultiplied
  45688. * @param format defines the format of the data
  45689. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45690. */
  45691. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45692. /**
  45693. * Gets a boolean indicating if all created effects are ready
  45694. * @returns true if all effects are ready
  45695. */
  45696. areAllEffectsReady(): boolean;
  45697. /**
  45698. * @hidden
  45699. * Get the current error code of the webGL context
  45700. * @returns the error code
  45701. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45702. */
  45703. getError(): number;
  45704. /** @hidden */
  45705. _getUnpackAlignement(): number;
  45706. /** @hidden */
  45707. _unpackFlipY(value: boolean): void;
  45708. /**
  45709. * Update a dynamic index buffer
  45710. * @param indexBuffer defines the target index buffer
  45711. * @param indices defines the data to update
  45712. * @param offset defines the offset in the target index buffer where update should start
  45713. */
  45714. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45715. /**
  45716. * Updates a dynamic vertex buffer.
  45717. * @param vertexBuffer the vertex buffer to update
  45718. * @param vertices the data used to update the vertex buffer
  45719. * @param byteOffset the byte offset of the data (optional)
  45720. * @param byteLength the byte length of the data (optional)
  45721. */
  45722. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45723. /** @hidden */
  45724. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45725. /** @hidden */
  45726. _bindTexture(channel: number, texture: InternalTexture): void;
  45727. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45728. /**
  45729. * 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
  45730. */
  45731. releaseEffects(): void;
  45732. displayLoadingUI(): void;
  45733. hideLoadingUI(): void;
  45734. /** @hidden */
  45735. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45736. /** @hidden */
  45737. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45738. /** @hidden */
  45739. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45740. /** @hidden */
  45741. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45742. }
  45743. }
  45744. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45745. import { Nullable, int } from "babylonjs/types";
  45746. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45747. /** @hidden */
  45748. export class _OcclusionDataStorage {
  45749. /** @hidden */
  45750. occlusionInternalRetryCounter: number;
  45751. /** @hidden */
  45752. isOcclusionQueryInProgress: boolean;
  45753. /** @hidden */
  45754. isOccluded: boolean;
  45755. /** @hidden */
  45756. occlusionRetryCount: number;
  45757. /** @hidden */
  45758. occlusionType: number;
  45759. /** @hidden */
  45760. occlusionQueryAlgorithmType: number;
  45761. }
  45762. module "babylonjs/Engines/engine" {
  45763. interface Engine {
  45764. /**
  45765. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45766. * @return the new query
  45767. */
  45768. createQuery(): WebGLQuery;
  45769. /**
  45770. * Delete and release a webGL query
  45771. * @param query defines the query to delete
  45772. * @return the current engine
  45773. */
  45774. deleteQuery(query: WebGLQuery): Engine;
  45775. /**
  45776. * Check if a given query has resolved and got its value
  45777. * @param query defines the query to check
  45778. * @returns true if the query got its value
  45779. */
  45780. isQueryResultAvailable(query: WebGLQuery): boolean;
  45781. /**
  45782. * Gets the value of a given query
  45783. * @param query defines the query to check
  45784. * @returns the value of the query
  45785. */
  45786. getQueryResult(query: WebGLQuery): number;
  45787. /**
  45788. * Initiates an occlusion query
  45789. * @param algorithmType defines the algorithm to use
  45790. * @param query defines the query to use
  45791. * @returns the current engine
  45792. * @see http://doc.babylonjs.com/features/occlusionquery
  45793. */
  45794. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45795. /**
  45796. * Ends an occlusion query
  45797. * @see http://doc.babylonjs.com/features/occlusionquery
  45798. * @param algorithmType defines the algorithm to use
  45799. * @returns the current engine
  45800. */
  45801. endOcclusionQuery(algorithmType: number): Engine;
  45802. /**
  45803. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45804. * Please note that only one query can be issued at a time
  45805. * @returns a time token used to track the time span
  45806. */
  45807. startTimeQuery(): Nullable<_TimeToken>;
  45808. /**
  45809. * Ends a time query
  45810. * @param token defines the token used to measure the time span
  45811. * @returns the time spent (in ns)
  45812. */
  45813. endTimeQuery(token: _TimeToken): int;
  45814. /** @hidden */
  45815. _currentNonTimestampToken: Nullable<_TimeToken>;
  45816. /** @hidden */
  45817. _createTimeQuery(): WebGLQuery;
  45818. /** @hidden */
  45819. _deleteTimeQuery(query: WebGLQuery): void;
  45820. /** @hidden */
  45821. _getGlAlgorithmType(algorithmType: number): number;
  45822. /** @hidden */
  45823. _getTimeQueryResult(query: WebGLQuery): any;
  45824. /** @hidden */
  45825. _getTimeQueryAvailability(query: WebGLQuery): any;
  45826. }
  45827. }
  45828. module "babylonjs/Meshes/abstractMesh" {
  45829. interface AbstractMesh {
  45830. /**
  45831. * Backing filed
  45832. * @hidden
  45833. */
  45834. __occlusionDataStorage: _OcclusionDataStorage;
  45835. /**
  45836. * Access property
  45837. * @hidden
  45838. */
  45839. _occlusionDataStorage: _OcclusionDataStorage;
  45840. /**
  45841. * 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.
  45842. * The default value is -1 which means don't break the query and wait till the result
  45843. * @see http://doc.babylonjs.com/features/occlusionquery
  45844. */
  45845. occlusionRetryCount: number;
  45846. /**
  45847. * 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:
  45848. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45849. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45850. * * 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.
  45851. * @see http://doc.babylonjs.com/features/occlusionquery
  45852. */
  45853. occlusionType: number;
  45854. /**
  45855. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45856. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45857. * * 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.
  45858. * @see http://doc.babylonjs.com/features/occlusionquery
  45859. */
  45860. occlusionQueryAlgorithmType: number;
  45861. /**
  45862. * 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
  45863. * @see http://doc.babylonjs.com/features/occlusionquery
  45864. */
  45865. isOccluded: boolean;
  45866. /**
  45867. * Flag to check the progress status of the query
  45868. * @see http://doc.babylonjs.com/features/occlusionquery
  45869. */
  45870. isOcclusionQueryInProgress: boolean;
  45871. }
  45872. }
  45873. }
  45874. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45875. import { Nullable } from "babylonjs/types";
  45876. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45877. /** @hidden */
  45878. export var _forceTransformFeedbackToBundle: boolean;
  45879. module "babylonjs/Engines/engine" {
  45880. interface Engine {
  45881. /**
  45882. * Creates a webGL transform feedback object
  45883. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45884. * @returns the webGL transform feedback object
  45885. */
  45886. createTransformFeedback(): WebGLTransformFeedback;
  45887. /**
  45888. * Delete a webGL transform feedback object
  45889. * @param value defines the webGL transform feedback object to delete
  45890. */
  45891. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45892. /**
  45893. * Bind a webGL transform feedback object to the webgl context
  45894. * @param value defines the webGL transform feedback object to bind
  45895. */
  45896. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45897. /**
  45898. * Begins a transform feedback operation
  45899. * @param usePoints defines if points or triangles must be used
  45900. */
  45901. beginTransformFeedback(usePoints: boolean): void;
  45902. /**
  45903. * Ends a transform feedback operation
  45904. */
  45905. endTransformFeedback(): void;
  45906. /**
  45907. * Specify the varyings to use with transform feedback
  45908. * @param program defines the associated webGL program
  45909. * @param value defines the list of strings representing the varying names
  45910. */
  45911. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45912. /**
  45913. * Bind a webGL buffer for a transform feedback operation
  45914. * @param value defines the webGL buffer to bind
  45915. */
  45916. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45917. }
  45918. }
  45919. }
  45920. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45921. import { Scene } from "babylonjs/scene";
  45922. import { Engine } from "babylonjs/Engines/engine";
  45923. import { Texture } from "babylonjs/Materials/Textures/texture";
  45924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45925. import "babylonjs/Engines/Extensions/engine.multiRender";
  45926. /**
  45927. * Creation options of the multi render target texture.
  45928. */
  45929. export interface IMultiRenderTargetOptions {
  45930. /**
  45931. * Define if the texture needs to create mip maps after render.
  45932. */
  45933. generateMipMaps?: boolean;
  45934. /**
  45935. * Define the types of all the draw buffers we want to create
  45936. */
  45937. types?: number[];
  45938. /**
  45939. * Define the sampling modes of all the draw buffers we want to create
  45940. */
  45941. samplingModes?: number[];
  45942. /**
  45943. * Define if a depth buffer is required
  45944. */
  45945. generateDepthBuffer?: boolean;
  45946. /**
  45947. * Define if a stencil buffer is required
  45948. */
  45949. generateStencilBuffer?: boolean;
  45950. /**
  45951. * Define if a depth texture is required instead of a depth buffer
  45952. */
  45953. generateDepthTexture?: boolean;
  45954. /**
  45955. * Define the number of desired draw buffers
  45956. */
  45957. textureCount?: number;
  45958. /**
  45959. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45960. */
  45961. doNotChangeAspectRatio?: boolean;
  45962. /**
  45963. * Define the default type of the buffers we are creating
  45964. */
  45965. defaultType?: number;
  45966. }
  45967. /**
  45968. * A multi render target, like a render target provides the ability to render to a texture.
  45969. * Unlike the render target, it can render to several draw buffers in one draw.
  45970. * This is specially interesting in deferred rendering or for any effects requiring more than
  45971. * just one color from a single pass.
  45972. */
  45973. export class MultiRenderTarget extends RenderTargetTexture {
  45974. private _internalTextures;
  45975. private _textures;
  45976. private _multiRenderTargetOptions;
  45977. /**
  45978. * Get if draw buffers are currently supported by the used hardware and browser.
  45979. */
  45980. readonly isSupported: boolean;
  45981. /**
  45982. * Get the list of textures generated by the multi render target.
  45983. */
  45984. readonly textures: Texture[];
  45985. /**
  45986. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45987. */
  45988. readonly depthTexture: Texture;
  45989. /**
  45990. * Set the wrapping mode on U of all the textures we are rendering to.
  45991. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45992. */
  45993. wrapU: number;
  45994. /**
  45995. * Set the wrapping mode on V of all the textures we are rendering to.
  45996. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45997. */
  45998. wrapV: number;
  45999. /**
  46000. * Instantiate a new multi render target texture.
  46001. * A multi render target, like a render target provides the ability to render to a texture.
  46002. * Unlike the render target, it can render to several draw buffers in one draw.
  46003. * This is specially interesting in deferred rendering or for any effects requiring more than
  46004. * just one color from a single pass.
  46005. * @param name Define the name of the texture
  46006. * @param size Define the size of the buffers to render to
  46007. * @param count Define the number of target we are rendering into
  46008. * @param scene Define the scene the texture belongs to
  46009. * @param options Define the options used to create the multi render target
  46010. */
  46011. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46012. /** @hidden */
  46013. _rebuild(): void;
  46014. private _createInternalTextures;
  46015. private _createTextures;
  46016. /**
  46017. * Define the number of samples used if MSAA is enabled.
  46018. */
  46019. samples: number;
  46020. /**
  46021. * Resize all the textures in the multi render target.
  46022. * Be carrefull as it will recreate all the data in the new texture.
  46023. * @param size Define the new size
  46024. */
  46025. resize(size: any): void;
  46026. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46027. /**
  46028. * Dispose the render targets and their associated resources
  46029. */
  46030. dispose(): void;
  46031. /**
  46032. * Release all the underlying texture used as draw buffers.
  46033. */
  46034. releaseInternalTextures(): void;
  46035. }
  46036. }
  46037. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46038. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46039. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46040. import { Nullable } from "babylonjs/types";
  46041. module "babylonjs/Engines/thinEngine" {
  46042. interface ThinEngine {
  46043. /**
  46044. * Unbind a list of render target textures from the webGL context
  46045. * This is used only when drawBuffer extension or webGL2 are active
  46046. * @param textures defines the render target textures to unbind
  46047. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46048. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46049. */
  46050. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46051. /**
  46052. * Create a multi render target texture
  46053. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46054. * @param size defines the size of the texture
  46055. * @param options defines the creation options
  46056. * @returns the cube texture as an InternalTexture
  46057. */
  46058. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46059. /**
  46060. * Update the sample count for a given multiple render target texture
  46061. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46062. * @param textures defines the textures to update
  46063. * @param samples defines the sample count to set
  46064. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46065. */
  46066. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46067. }
  46068. }
  46069. }
  46070. declare module "babylonjs/Engines/Extensions/index" {
  46071. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46072. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46073. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46074. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46075. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46076. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46077. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46078. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46079. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46080. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46081. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46082. }
  46083. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46085. /** @hidden */
  46086. export var rgbdEncodePixelShader: {
  46087. name: string;
  46088. shader: string;
  46089. };
  46090. }
  46091. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46092. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46093. /** @hidden */
  46094. export var rgbdDecodePixelShader: {
  46095. name: string;
  46096. shader: string;
  46097. };
  46098. }
  46099. declare module "babylonjs/Misc/environmentTextureTools" {
  46100. import { Nullable } from "babylonjs/types";
  46101. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46102. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46103. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46104. import "babylonjs/Engines/Extensions/engine.renderTarget";
  46105. import "babylonjs/Shaders/rgbdEncode.fragment";
  46106. import "babylonjs/Shaders/rgbdDecode.fragment";
  46107. /**
  46108. * Raw texture data and descriptor sufficient for WebGL texture upload
  46109. */
  46110. export interface EnvironmentTextureInfo {
  46111. /**
  46112. * Version of the environment map
  46113. */
  46114. version: number;
  46115. /**
  46116. * Width of image
  46117. */
  46118. width: number;
  46119. /**
  46120. * Irradiance information stored in the file.
  46121. */
  46122. irradiance: any;
  46123. /**
  46124. * Specular information stored in the file.
  46125. */
  46126. specular: any;
  46127. }
  46128. /**
  46129. * Defines One Image in the file. It requires only the position in the file
  46130. * as well as the length.
  46131. */
  46132. interface BufferImageData {
  46133. /**
  46134. * Length of the image data.
  46135. */
  46136. length: number;
  46137. /**
  46138. * Position of the data from the null terminator delimiting the end of the JSON.
  46139. */
  46140. position: number;
  46141. }
  46142. /**
  46143. * Defines the specular data enclosed in the file.
  46144. * This corresponds to the version 1 of the data.
  46145. */
  46146. export interface EnvironmentTextureSpecularInfoV1 {
  46147. /**
  46148. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46149. */
  46150. specularDataPosition?: number;
  46151. /**
  46152. * This contains all the images data needed to reconstruct the cubemap.
  46153. */
  46154. mipmaps: Array<BufferImageData>;
  46155. /**
  46156. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46157. */
  46158. lodGenerationScale: number;
  46159. }
  46160. /**
  46161. * Sets of helpers addressing the serialization and deserialization of environment texture
  46162. * stored in a BabylonJS env file.
  46163. * Those files are usually stored as .env files.
  46164. */
  46165. export class EnvironmentTextureTools {
  46166. /**
  46167. * Magic number identifying the env file.
  46168. */
  46169. private static _MagicBytes;
  46170. /**
  46171. * Gets the environment info from an env file.
  46172. * @param data The array buffer containing the .env bytes.
  46173. * @returns the environment file info (the json header) if successfully parsed.
  46174. */
  46175. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46176. /**
  46177. * Creates an environment texture from a loaded cube texture.
  46178. * @param texture defines the cube texture to convert in env file
  46179. * @return a promise containing the environment data if succesfull.
  46180. */
  46181. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46182. /**
  46183. * Creates a JSON representation of the spherical data.
  46184. * @param texture defines the texture containing the polynomials
  46185. * @return the JSON representation of the spherical info
  46186. */
  46187. private static _CreateEnvTextureIrradiance;
  46188. /**
  46189. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46190. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46191. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46192. * @return the views described by info providing access to the underlying buffer
  46193. */
  46194. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46195. /**
  46196. * Uploads the texture info contained in the env file to the GPU.
  46197. * @param texture defines the internal texture to upload to
  46198. * @param arrayBuffer defines the buffer cotaining the data to load
  46199. * @param info defines the texture info retrieved through the GetEnvInfo method
  46200. * @returns a promise
  46201. */
  46202. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46203. /**
  46204. * Uploads the levels of image data to the GPU.
  46205. * @param texture defines the internal texture to upload to
  46206. * @param imageData defines the array buffer views of image data [mipmap][face]
  46207. * @returns a promise
  46208. */
  46209. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46210. /**
  46211. * Uploads spherical polynomials information to the texture.
  46212. * @param texture defines the texture we are trying to upload the information to
  46213. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46214. */
  46215. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46216. /** @hidden */
  46217. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46218. }
  46219. }
  46220. declare module "babylonjs/Maths/math.vertexFormat" {
  46221. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46222. /**
  46223. * Contains position and normal vectors for a vertex
  46224. */
  46225. export class PositionNormalVertex {
  46226. /** the position of the vertex (defaut: 0,0,0) */
  46227. position: Vector3;
  46228. /** the normal of the vertex (defaut: 0,1,0) */
  46229. normal: Vector3;
  46230. /**
  46231. * Creates a PositionNormalVertex
  46232. * @param position the position of the vertex (defaut: 0,0,0)
  46233. * @param normal the normal of the vertex (defaut: 0,1,0)
  46234. */
  46235. constructor(
  46236. /** the position of the vertex (defaut: 0,0,0) */
  46237. position?: Vector3,
  46238. /** the normal of the vertex (defaut: 0,1,0) */
  46239. normal?: Vector3);
  46240. /**
  46241. * Clones the PositionNormalVertex
  46242. * @returns the cloned PositionNormalVertex
  46243. */
  46244. clone(): PositionNormalVertex;
  46245. }
  46246. /**
  46247. * Contains position, normal and uv vectors for a vertex
  46248. */
  46249. export class PositionNormalTextureVertex {
  46250. /** the position of the vertex (defaut: 0,0,0) */
  46251. position: Vector3;
  46252. /** the normal of the vertex (defaut: 0,1,0) */
  46253. normal: Vector3;
  46254. /** the uv of the vertex (default: 0,0) */
  46255. uv: Vector2;
  46256. /**
  46257. * Creates a PositionNormalTextureVertex
  46258. * @param position the position of the vertex (defaut: 0,0,0)
  46259. * @param normal the normal of the vertex (defaut: 0,1,0)
  46260. * @param uv the uv of the vertex (default: 0,0)
  46261. */
  46262. constructor(
  46263. /** the position of the vertex (defaut: 0,0,0) */
  46264. position?: Vector3,
  46265. /** the normal of the vertex (defaut: 0,1,0) */
  46266. normal?: Vector3,
  46267. /** the uv of the vertex (default: 0,0) */
  46268. uv?: Vector2);
  46269. /**
  46270. * Clones the PositionNormalTextureVertex
  46271. * @returns the cloned PositionNormalTextureVertex
  46272. */
  46273. clone(): PositionNormalTextureVertex;
  46274. }
  46275. }
  46276. declare module "babylonjs/Maths/math" {
  46277. export * from "babylonjs/Maths/math.axis";
  46278. export * from "babylonjs/Maths/math.color";
  46279. export * from "babylonjs/Maths/math.constants";
  46280. export * from "babylonjs/Maths/math.frustum";
  46281. export * from "babylonjs/Maths/math.path";
  46282. export * from "babylonjs/Maths/math.plane";
  46283. export * from "babylonjs/Maths/math.size";
  46284. export * from "babylonjs/Maths/math.vector";
  46285. export * from "babylonjs/Maths/math.vertexFormat";
  46286. export * from "babylonjs/Maths/math.viewport";
  46287. }
  46288. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46289. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46290. /** @hidden */
  46291. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46292. private _genericAttributeLocation;
  46293. private _varyingLocationCount;
  46294. private _varyingLocationMap;
  46295. private _replacements;
  46296. private _textureCount;
  46297. private _uniforms;
  46298. lineProcessor(line: string): string;
  46299. attributeProcessor(attribute: string): string;
  46300. varyingProcessor(varying: string, isFragment: boolean): string;
  46301. uniformProcessor(uniform: string): string;
  46302. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46303. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46304. }
  46305. }
  46306. declare module "babylonjs/Engines/nativeEngine" {
  46307. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46308. import { Engine } from "babylonjs/Engines/engine";
  46309. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46312. import { Effect } from "babylonjs/Materials/effect";
  46313. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46314. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46315. import { Scene } from "babylonjs/scene";
  46316. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46317. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46318. /**
  46319. * Container for accessors for natively-stored mesh data buffers.
  46320. */
  46321. class NativeDataBuffer extends DataBuffer {
  46322. /**
  46323. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46324. */
  46325. nativeIndexBuffer?: any;
  46326. /**
  46327. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46328. */
  46329. nativeVertexBuffer?: any;
  46330. }
  46331. /** @hidden */
  46332. export class NativeEngine extends Engine {
  46333. private readonly _native;
  46334. getHardwareScalingLevel(): number;
  46335. constructor();
  46336. /**
  46337. * Can be used to override the current requestAnimationFrame requester.
  46338. * @hidden
  46339. */
  46340. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46341. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46342. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46343. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46344. recordVertexArrayObject(vertexBuffers: {
  46345. [key: string]: VertexBuffer;
  46346. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46347. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46348. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46349. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46350. /**
  46351. * Draw a list of indexed primitives
  46352. * @param fillMode defines the primitive to use
  46353. * @param indexStart defines the starting index
  46354. * @param indexCount defines the number of index to draw
  46355. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46356. */
  46357. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46358. /**
  46359. * Draw a list of unindexed primitives
  46360. * @param fillMode defines the primitive to use
  46361. * @param verticesStart defines the index of first vertex to draw
  46362. * @param verticesCount defines the count of vertices to draw
  46363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46364. */
  46365. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46366. createPipelineContext(): IPipelineContext;
  46367. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46368. /** @hidden */
  46369. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46370. /** @hidden */
  46371. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46372. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46373. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46374. protected _setProgram(program: WebGLProgram): void;
  46375. _releaseEffect(effect: Effect): void;
  46376. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46377. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46378. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46379. bindSamplers(effect: Effect): void;
  46380. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46381. getRenderWidth(useScreen?: boolean): number;
  46382. getRenderHeight(useScreen?: boolean): number;
  46383. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46384. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46385. /**
  46386. * Set the z offset to apply to current rendering
  46387. * @param value defines the offset to apply
  46388. */
  46389. setZOffset(value: number): void;
  46390. /**
  46391. * Gets the current value of the zOffset
  46392. * @returns the current zOffset state
  46393. */
  46394. getZOffset(): number;
  46395. /**
  46396. * Enable or disable depth buffering
  46397. * @param enable defines the state to set
  46398. */
  46399. setDepthBuffer(enable: boolean): void;
  46400. /**
  46401. * Gets a boolean indicating if depth writing is enabled
  46402. * @returns the current depth writing state
  46403. */
  46404. getDepthWrite(): boolean;
  46405. /**
  46406. * Enable or disable depth writing
  46407. * @param enable defines the state to set
  46408. */
  46409. setDepthWrite(enable: boolean): void;
  46410. /**
  46411. * Enable or disable color writing
  46412. * @param enable defines the state to set
  46413. */
  46414. setColorWrite(enable: boolean): void;
  46415. /**
  46416. * Gets a boolean indicating if color writing is enabled
  46417. * @returns the current color writing state
  46418. */
  46419. getColorWrite(): boolean;
  46420. /**
  46421. * Sets alpha constants used by some alpha blending modes
  46422. * @param r defines the red component
  46423. * @param g defines the green component
  46424. * @param b defines the blue component
  46425. * @param a defines the alpha component
  46426. */
  46427. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46428. /**
  46429. * Sets the current alpha mode
  46430. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46431. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46432. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46433. */
  46434. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46435. /**
  46436. * Gets the current alpha mode
  46437. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46438. * @returns the current alpha mode
  46439. */
  46440. getAlphaMode(): number;
  46441. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46442. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46443. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46444. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46445. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46446. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46447. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46448. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46449. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46450. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46451. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46452. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46453. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46454. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46455. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46456. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46457. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46458. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46459. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46460. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46461. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46462. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46463. wipeCaches(bruteForce?: boolean): void;
  46464. _createTexture(): WebGLTexture;
  46465. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46466. /**
  46467. * Usually called from BABYLON.Texture.ts.
  46468. * Passed information to create a WebGLTexture
  46469. * @param urlArg defines a value which contains one of the following:
  46470. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46471. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46472. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46473. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46474. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46475. * @param scene needed for loading to the correct scene
  46476. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46477. * @param onLoad optional callback to be called upon successful completion
  46478. * @param onError optional callback to be called upon failure
  46479. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46480. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46481. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46482. * @param forcedExtension defines the extension to use to pick the right loader
  46483. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46484. */
  46485. 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;
  46486. /**
  46487. * Creates a cube texture
  46488. * @param rootUrl defines the url where the files to load is located
  46489. * @param scene defines the current scene
  46490. * @param files defines the list of files to load (1 per face)
  46491. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46492. * @param onLoad defines an optional callback raised when the texture is loaded
  46493. * @param onError defines an optional callback raised if there is an issue to load the texture
  46494. * @param format defines the format of the data
  46495. * @param forcedExtension defines the extension to use to pick the right loader
  46496. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46497. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46498. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46499. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46500. * @returns the cube texture as an InternalTexture
  46501. */
  46502. 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;
  46503. private _getSamplingFilter;
  46504. private static _GetNativeTextureFormat;
  46505. createRenderTargetTexture(size: number | {
  46506. width: number;
  46507. height: number;
  46508. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46509. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46510. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46511. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46512. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46513. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46514. /**
  46515. * Updates a dynamic vertex buffer.
  46516. * @param vertexBuffer the vertex buffer to update
  46517. * @param data the data used to update the vertex buffer
  46518. * @param byteOffset the byte offset of the data (optional)
  46519. * @param byteLength the byte length of the data (optional)
  46520. */
  46521. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46522. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46523. private _updateAnisotropicLevel;
  46524. private _getAddressMode;
  46525. /** @hidden */
  46526. _bindTexture(channel: number, texture: InternalTexture): void;
  46527. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46528. releaseEffects(): void;
  46529. /** @hidden */
  46530. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46531. /** @hidden */
  46532. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46533. /** @hidden */
  46534. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46535. /** @hidden */
  46536. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46537. }
  46538. }
  46539. declare module "babylonjs/Engines/index" {
  46540. export * from "babylonjs/Engines/constants";
  46541. export * from "babylonjs/Engines/engineCapabilities";
  46542. export * from "babylonjs/Engines/instancingAttributeInfo";
  46543. export * from "babylonjs/Engines/thinEngine";
  46544. export * from "babylonjs/Engines/engine";
  46545. export * from "babylonjs/Engines/engineStore";
  46546. export * from "babylonjs/Engines/nullEngine";
  46547. export * from "babylonjs/Engines/Extensions/index";
  46548. export * from "babylonjs/Engines/IPipelineContext";
  46549. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46550. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46551. export * from "babylonjs/Engines/nativeEngine";
  46552. }
  46553. declare module "babylonjs/Events/clipboardEvents" {
  46554. /**
  46555. * Gather the list of clipboard event types as constants.
  46556. */
  46557. export class ClipboardEventTypes {
  46558. /**
  46559. * The clipboard event is fired when a copy command is active (pressed).
  46560. */
  46561. static readonly COPY: number;
  46562. /**
  46563. * The clipboard event is fired when a cut command is active (pressed).
  46564. */
  46565. static readonly CUT: number;
  46566. /**
  46567. * The clipboard event is fired when a paste command is active (pressed).
  46568. */
  46569. static readonly PASTE: number;
  46570. }
  46571. /**
  46572. * This class is used to store clipboard related info for the onClipboardObservable event.
  46573. */
  46574. export class ClipboardInfo {
  46575. /**
  46576. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46577. */
  46578. type: number;
  46579. /**
  46580. * Defines the related dom event
  46581. */
  46582. event: ClipboardEvent;
  46583. /**
  46584. *Creates an instance of ClipboardInfo.
  46585. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46586. * @param event Defines the related dom event
  46587. */
  46588. constructor(
  46589. /**
  46590. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46591. */
  46592. type: number,
  46593. /**
  46594. * Defines the related dom event
  46595. */
  46596. event: ClipboardEvent);
  46597. /**
  46598. * Get the clipboard event's type from the keycode.
  46599. * @param keyCode Defines the keyCode for the current keyboard event.
  46600. * @return {number}
  46601. */
  46602. static GetTypeFromCharacter(keyCode: number): number;
  46603. }
  46604. }
  46605. declare module "babylonjs/Events/index" {
  46606. export * from "babylonjs/Events/keyboardEvents";
  46607. export * from "babylonjs/Events/pointerEvents";
  46608. export * from "babylonjs/Events/clipboardEvents";
  46609. }
  46610. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46611. import { Scene } from "babylonjs/scene";
  46612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46613. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46614. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46615. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46616. /**
  46617. * Google Daydream controller
  46618. */
  46619. export class DaydreamController extends WebVRController {
  46620. /**
  46621. * Base Url for the controller model.
  46622. */
  46623. static MODEL_BASE_URL: string;
  46624. /**
  46625. * File name for the controller model.
  46626. */
  46627. static MODEL_FILENAME: string;
  46628. /**
  46629. * Gamepad Id prefix used to identify Daydream Controller.
  46630. */
  46631. static readonly GAMEPAD_ID_PREFIX: string;
  46632. /**
  46633. * Creates a new DaydreamController from a gamepad
  46634. * @param vrGamepad the gamepad that the controller should be created from
  46635. */
  46636. constructor(vrGamepad: any);
  46637. /**
  46638. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46639. * @param scene scene in which to add meshes
  46640. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46641. */
  46642. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46643. /**
  46644. * Called once for each button that changed state since the last frame
  46645. * @param buttonIdx Which button index changed
  46646. * @param state New state of the button
  46647. * @param changes Which properties on the state changed since last frame
  46648. */
  46649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46650. }
  46651. }
  46652. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46653. import { Scene } from "babylonjs/scene";
  46654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46655. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46656. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46657. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46658. /**
  46659. * Gear VR Controller
  46660. */
  46661. export class GearVRController extends WebVRController {
  46662. /**
  46663. * Base Url for the controller model.
  46664. */
  46665. static MODEL_BASE_URL: string;
  46666. /**
  46667. * File name for the controller model.
  46668. */
  46669. static MODEL_FILENAME: string;
  46670. /**
  46671. * Gamepad Id prefix used to identify this controller.
  46672. */
  46673. static readonly GAMEPAD_ID_PREFIX: string;
  46674. private readonly _buttonIndexToObservableNameMap;
  46675. /**
  46676. * Creates a new GearVRController from a gamepad
  46677. * @param vrGamepad the gamepad that the controller should be created from
  46678. */
  46679. constructor(vrGamepad: any);
  46680. /**
  46681. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46682. * @param scene scene in which to add meshes
  46683. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46684. */
  46685. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46686. /**
  46687. * Called once for each button that changed state since the last frame
  46688. * @param buttonIdx Which button index changed
  46689. * @param state New state of the button
  46690. * @param changes Which properties on the state changed since last frame
  46691. */
  46692. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46693. }
  46694. }
  46695. declare module "babylonjs/Gamepads/Controllers/index" {
  46696. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46697. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46698. export * from "babylonjs/Gamepads/Controllers/genericController";
  46699. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46700. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46701. export * from "babylonjs/Gamepads/Controllers/viveController";
  46702. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46703. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46704. }
  46705. declare module "babylonjs/Gamepads/index" {
  46706. export * from "babylonjs/Gamepads/Controllers/index";
  46707. export * from "babylonjs/Gamepads/gamepad";
  46708. export * from "babylonjs/Gamepads/gamepadManager";
  46709. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46710. export * from "babylonjs/Gamepads/xboxGamepad";
  46711. export * from "babylonjs/Gamepads/dualShockGamepad";
  46712. }
  46713. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46714. import { Scene } from "babylonjs/scene";
  46715. import { Vector4 } from "babylonjs/Maths/math.vector";
  46716. import { Color4 } from "babylonjs/Maths/math.color";
  46717. import { Mesh } from "babylonjs/Meshes/mesh";
  46718. import { Nullable } from "babylonjs/types";
  46719. /**
  46720. * Class containing static functions to help procedurally build meshes
  46721. */
  46722. export class PolyhedronBuilder {
  46723. /**
  46724. * Creates a polyhedron mesh
  46725. * * 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
  46726. * * The parameter `size` (positive float, default 1) sets the polygon size
  46727. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46728. * * 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`
  46729. * * 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
  46730. * * 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)`)
  46731. * * 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
  46732. * * 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
  46733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46736. * @param name defines the name of the mesh
  46737. * @param options defines the options used to create the mesh
  46738. * @param scene defines the hosting scene
  46739. * @returns the polyhedron mesh
  46740. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46741. */
  46742. static CreatePolyhedron(name: string, options: {
  46743. type?: number;
  46744. size?: number;
  46745. sizeX?: number;
  46746. sizeY?: number;
  46747. sizeZ?: number;
  46748. custom?: any;
  46749. faceUV?: Vector4[];
  46750. faceColors?: Color4[];
  46751. flat?: boolean;
  46752. updatable?: boolean;
  46753. sideOrientation?: number;
  46754. frontUVs?: Vector4;
  46755. backUVs?: Vector4;
  46756. }, scene?: Nullable<Scene>): Mesh;
  46757. }
  46758. }
  46759. declare module "babylonjs/Gizmos/scaleGizmo" {
  46760. import { Observable } from "babylonjs/Misc/observable";
  46761. import { Nullable } from "babylonjs/types";
  46762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46763. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46764. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46765. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46766. /**
  46767. * Gizmo that enables scaling a mesh along 3 axis
  46768. */
  46769. export class ScaleGizmo extends Gizmo {
  46770. /**
  46771. * Internal gizmo used for interactions on the x axis
  46772. */
  46773. xGizmo: AxisScaleGizmo;
  46774. /**
  46775. * Internal gizmo used for interactions on the y axis
  46776. */
  46777. yGizmo: AxisScaleGizmo;
  46778. /**
  46779. * Internal gizmo used for interactions on the z axis
  46780. */
  46781. zGizmo: AxisScaleGizmo;
  46782. /**
  46783. * Internal gizmo used to scale all axis equally
  46784. */
  46785. uniformScaleGizmo: AxisScaleGizmo;
  46786. private _meshAttached;
  46787. private _updateGizmoRotationToMatchAttachedMesh;
  46788. private _snapDistance;
  46789. private _scaleRatio;
  46790. private _uniformScalingMesh;
  46791. private _octahedron;
  46792. /** Fires an event when any of it's sub gizmos are dragged */
  46793. onDragStartObservable: Observable<unknown>;
  46794. /** Fires an event when any of it's sub gizmos are released from dragging */
  46795. onDragEndObservable: Observable<unknown>;
  46796. attachedMesh: Nullable<AbstractMesh>;
  46797. /**
  46798. * Creates a ScaleGizmo
  46799. * @param gizmoLayer The utility layer the gizmo will be added to
  46800. */
  46801. constructor(gizmoLayer?: UtilityLayerRenderer);
  46802. updateGizmoRotationToMatchAttachedMesh: boolean;
  46803. /**
  46804. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46805. */
  46806. snapDistance: number;
  46807. /**
  46808. * Ratio for the scale of the gizmo (Default: 1)
  46809. */
  46810. scaleRatio: number;
  46811. /**
  46812. * Disposes of the gizmo
  46813. */
  46814. dispose(): void;
  46815. }
  46816. }
  46817. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46818. import { Observable } from "babylonjs/Misc/observable";
  46819. import { Nullable } from "babylonjs/types";
  46820. import { Vector3 } from "babylonjs/Maths/math.vector";
  46821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46822. import { Mesh } from "babylonjs/Meshes/mesh";
  46823. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46824. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46825. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46826. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46827. import { Color3 } from "babylonjs/Maths/math.color";
  46828. /**
  46829. * Single axis scale gizmo
  46830. */
  46831. export class AxisScaleGizmo extends Gizmo {
  46832. /**
  46833. * Drag behavior responsible for the gizmos dragging interactions
  46834. */
  46835. dragBehavior: PointerDragBehavior;
  46836. private _pointerObserver;
  46837. /**
  46838. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46839. */
  46840. snapDistance: number;
  46841. /**
  46842. * Event that fires each time the gizmo snaps to a new location.
  46843. * * snapDistance is the the change in distance
  46844. */
  46845. onSnapObservable: Observable<{
  46846. snapDistance: number;
  46847. }>;
  46848. /**
  46849. * If the scaling operation should be done on all axis (default: false)
  46850. */
  46851. uniformScaling: boolean;
  46852. private _isEnabled;
  46853. private _parent;
  46854. private _arrow;
  46855. private _coloredMaterial;
  46856. private _hoverMaterial;
  46857. /**
  46858. * Creates an AxisScaleGizmo
  46859. * @param gizmoLayer The utility layer the gizmo will be added to
  46860. * @param dragAxis The axis which the gizmo will be able to scale on
  46861. * @param color The color of the gizmo
  46862. */
  46863. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46864. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46865. /**
  46866. * If the gizmo is enabled
  46867. */
  46868. isEnabled: boolean;
  46869. /**
  46870. * Disposes of the gizmo
  46871. */
  46872. dispose(): void;
  46873. /**
  46874. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46875. * @param mesh The mesh to replace the default mesh of the gizmo
  46876. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46877. */
  46878. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46879. }
  46880. }
  46881. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46882. import { Observable } from "babylonjs/Misc/observable";
  46883. import { Nullable } from "babylonjs/types";
  46884. import { Vector3 } from "babylonjs/Maths/math.vector";
  46885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46886. import { Mesh } from "babylonjs/Meshes/mesh";
  46887. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46888. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46889. import { Color3 } from "babylonjs/Maths/math.color";
  46890. import "babylonjs/Meshes/Builders/boxBuilder";
  46891. /**
  46892. * Bounding box gizmo
  46893. */
  46894. export class BoundingBoxGizmo extends Gizmo {
  46895. private _lineBoundingBox;
  46896. private _rotateSpheresParent;
  46897. private _scaleBoxesParent;
  46898. private _boundingDimensions;
  46899. private _renderObserver;
  46900. private _pointerObserver;
  46901. private _scaleDragSpeed;
  46902. private _tmpQuaternion;
  46903. private _tmpVector;
  46904. private _tmpRotationMatrix;
  46905. /**
  46906. * 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)
  46907. */
  46908. ignoreChildren: boolean;
  46909. /**
  46910. * 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)
  46911. */
  46912. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46913. /**
  46914. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46915. */
  46916. rotationSphereSize: number;
  46917. /**
  46918. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46919. */
  46920. scaleBoxSize: number;
  46921. /**
  46922. * 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)
  46923. */
  46924. fixedDragMeshScreenSize: boolean;
  46925. /**
  46926. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46927. */
  46928. fixedDragMeshScreenSizeDistanceFactor: number;
  46929. /**
  46930. * Fired when a rotation sphere or scale box is dragged
  46931. */
  46932. onDragStartObservable: Observable<{}>;
  46933. /**
  46934. * Fired when a scale box is dragged
  46935. */
  46936. onScaleBoxDragObservable: Observable<{}>;
  46937. /**
  46938. * Fired when a scale box drag is ended
  46939. */
  46940. onScaleBoxDragEndObservable: Observable<{}>;
  46941. /**
  46942. * Fired when a rotation sphere is dragged
  46943. */
  46944. onRotationSphereDragObservable: Observable<{}>;
  46945. /**
  46946. * Fired when a rotation sphere drag is ended
  46947. */
  46948. onRotationSphereDragEndObservable: Observable<{}>;
  46949. /**
  46950. * 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)
  46951. */
  46952. scalePivot: Nullable<Vector3>;
  46953. /**
  46954. * Mesh used as a pivot to rotate the attached mesh
  46955. */
  46956. private _anchorMesh;
  46957. private _existingMeshScale;
  46958. private _dragMesh;
  46959. private pointerDragBehavior;
  46960. private coloredMaterial;
  46961. private hoverColoredMaterial;
  46962. /**
  46963. * Sets the color of the bounding box gizmo
  46964. * @param color the color to set
  46965. */
  46966. setColor(color: Color3): void;
  46967. /**
  46968. * Creates an BoundingBoxGizmo
  46969. * @param gizmoLayer The utility layer the gizmo will be added to
  46970. * @param color The color of the gizmo
  46971. */
  46972. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46973. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46974. private _selectNode;
  46975. /**
  46976. * Updates the bounding box information for the Gizmo
  46977. */
  46978. updateBoundingBox(): void;
  46979. private _updateRotationSpheres;
  46980. private _updateScaleBoxes;
  46981. /**
  46982. * Enables rotation on the specified axis and disables rotation on the others
  46983. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46984. */
  46985. setEnabledRotationAxis(axis: string): void;
  46986. /**
  46987. * Enables/disables scaling
  46988. * @param enable if scaling should be enabled
  46989. */
  46990. setEnabledScaling(enable: boolean): void;
  46991. private _updateDummy;
  46992. /**
  46993. * Enables a pointer drag behavior on the bounding box of the gizmo
  46994. */
  46995. enableDragBehavior(): void;
  46996. /**
  46997. * Disposes of the gizmo
  46998. */
  46999. dispose(): void;
  47000. /**
  47001. * 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)
  47002. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47003. * @returns the bounding box mesh with the passed in mesh as a child
  47004. */
  47005. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47006. /**
  47007. * CustomMeshes are not supported by this gizmo
  47008. * @param mesh The mesh to replace the default mesh of the gizmo
  47009. */
  47010. setCustomMesh(mesh: Mesh): void;
  47011. }
  47012. }
  47013. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47014. import { Observable } from "babylonjs/Misc/observable";
  47015. import { Nullable } from "babylonjs/types";
  47016. import { Vector3 } from "babylonjs/Maths/math.vector";
  47017. import { Color3 } from "babylonjs/Maths/math.color";
  47018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47019. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47020. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47021. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47022. import "babylonjs/Meshes/Builders/linesBuilder";
  47023. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47024. /**
  47025. * Single plane rotation gizmo
  47026. */
  47027. export class PlaneRotationGizmo extends Gizmo {
  47028. /**
  47029. * Drag behavior responsible for the gizmos dragging interactions
  47030. */
  47031. dragBehavior: PointerDragBehavior;
  47032. private _pointerObserver;
  47033. /**
  47034. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47035. */
  47036. snapDistance: number;
  47037. /**
  47038. * Event that fires each time the gizmo snaps to a new location.
  47039. * * snapDistance is the the change in distance
  47040. */
  47041. onSnapObservable: Observable<{
  47042. snapDistance: number;
  47043. }>;
  47044. private _isEnabled;
  47045. private _parent;
  47046. /**
  47047. * Creates a PlaneRotationGizmo
  47048. * @param gizmoLayer The utility layer the gizmo will be added to
  47049. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47050. * @param color The color of the gizmo
  47051. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47052. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47053. */
  47054. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47055. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47056. /**
  47057. * If the gizmo is enabled
  47058. */
  47059. isEnabled: boolean;
  47060. /**
  47061. * Disposes of the gizmo
  47062. */
  47063. dispose(): void;
  47064. }
  47065. }
  47066. declare module "babylonjs/Gizmos/rotationGizmo" {
  47067. import { Observable } from "babylonjs/Misc/observable";
  47068. import { Nullable } from "babylonjs/types";
  47069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47070. import { Mesh } from "babylonjs/Meshes/mesh";
  47071. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47072. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47073. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47074. /**
  47075. * Gizmo that enables rotating a mesh along 3 axis
  47076. */
  47077. export class RotationGizmo extends Gizmo {
  47078. /**
  47079. * Internal gizmo used for interactions on the x axis
  47080. */
  47081. xGizmo: PlaneRotationGizmo;
  47082. /**
  47083. * Internal gizmo used for interactions on the y axis
  47084. */
  47085. yGizmo: PlaneRotationGizmo;
  47086. /**
  47087. * Internal gizmo used for interactions on the z axis
  47088. */
  47089. zGizmo: PlaneRotationGizmo;
  47090. /** Fires an event when any of it's sub gizmos are dragged */
  47091. onDragStartObservable: Observable<unknown>;
  47092. /** Fires an event when any of it's sub gizmos are released from dragging */
  47093. onDragEndObservable: Observable<unknown>;
  47094. private _meshAttached;
  47095. attachedMesh: Nullable<AbstractMesh>;
  47096. /**
  47097. * Creates a RotationGizmo
  47098. * @param gizmoLayer The utility layer the gizmo will be added to
  47099. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47100. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47101. */
  47102. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47103. updateGizmoRotationToMatchAttachedMesh: boolean;
  47104. /**
  47105. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47106. */
  47107. snapDistance: number;
  47108. /**
  47109. * Ratio for the scale of the gizmo (Default: 1)
  47110. */
  47111. scaleRatio: number;
  47112. /**
  47113. * Disposes of the gizmo
  47114. */
  47115. dispose(): void;
  47116. /**
  47117. * CustomMeshes are not supported by this gizmo
  47118. * @param mesh The mesh to replace the default mesh of the gizmo
  47119. */
  47120. setCustomMesh(mesh: Mesh): void;
  47121. }
  47122. }
  47123. declare module "babylonjs/Gizmos/gizmoManager" {
  47124. import { Observable } from "babylonjs/Misc/observable";
  47125. import { Nullable } from "babylonjs/types";
  47126. import { Scene, IDisposable } from "babylonjs/scene";
  47127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47128. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47129. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47130. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47131. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47132. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47133. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47134. /**
  47135. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47136. */
  47137. export class GizmoManager implements IDisposable {
  47138. private scene;
  47139. /**
  47140. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47141. */
  47142. gizmos: {
  47143. positionGizmo: Nullable<PositionGizmo>;
  47144. rotationGizmo: Nullable<RotationGizmo>;
  47145. scaleGizmo: Nullable<ScaleGizmo>;
  47146. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47147. };
  47148. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47149. clearGizmoOnEmptyPointerEvent: boolean;
  47150. /** Fires an event when the manager is attached to a mesh */
  47151. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47152. private _gizmosEnabled;
  47153. private _pointerObserver;
  47154. private _attachedMesh;
  47155. private _boundingBoxColor;
  47156. private _defaultUtilityLayer;
  47157. private _defaultKeepDepthUtilityLayer;
  47158. /**
  47159. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47160. */
  47161. boundingBoxDragBehavior: SixDofDragBehavior;
  47162. /**
  47163. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47164. */
  47165. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47166. /**
  47167. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47168. */
  47169. usePointerToAttachGizmos: boolean;
  47170. /**
  47171. * Utility layer that the bounding box gizmo belongs to
  47172. */
  47173. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47174. /**
  47175. * Utility layer that all gizmos besides bounding box belong to
  47176. */
  47177. readonly utilityLayer: UtilityLayerRenderer;
  47178. /**
  47179. * Instatiates a gizmo manager
  47180. * @param scene the scene to overlay the gizmos on top of
  47181. */
  47182. constructor(scene: Scene);
  47183. /**
  47184. * Attaches a set of gizmos to the specified mesh
  47185. * @param mesh The mesh the gizmo's should be attached to
  47186. */
  47187. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47188. /**
  47189. * If the position gizmo is enabled
  47190. */
  47191. positionGizmoEnabled: boolean;
  47192. /**
  47193. * If the rotation gizmo is enabled
  47194. */
  47195. rotationGizmoEnabled: boolean;
  47196. /**
  47197. * If the scale gizmo is enabled
  47198. */
  47199. scaleGizmoEnabled: boolean;
  47200. /**
  47201. * If the boundingBox gizmo is enabled
  47202. */
  47203. boundingBoxGizmoEnabled: boolean;
  47204. /**
  47205. * Disposes of the gizmo manager
  47206. */
  47207. dispose(): void;
  47208. }
  47209. }
  47210. declare module "babylonjs/Lights/directionalLight" {
  47211. import { Camera } from "babylonjs/Cameras/camera";
  47212. import { Scene } from "babylonjs/scene";
  47213. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47215. import { Light } from "babylonjs/Lights/light";
  47216. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47217. import { Effect } from "babylonjs/Materials/effect";
  47218. /**
  47219. * A directional light is defined by a direction (what a surprise!).
  47220. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47221. * 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.
  47222. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47223. */
  47224. export class DirectionalLight extends ShadowLight {
  47225. private _shadowFrustumSize;
  47226. /**
  47227. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47228. */
  47229. /**
  47230. * Specifies a fix frustum size for the shadow generation.
  47231. */
  47232. shadowFrustumSize: number;
  47233. private _shadowOrthoScale;
  47234. /**
  47235. * Gets the shadow projection scale against the optimal computed one.
  47236. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47237. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47238. */
  47239. /**
  47240. * Sets the shadow projection scale against the optimal computed one.
  47241. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47242. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47243. */
  47244. shadowOrthoScale: number;
  47245. /**
  47246. * Automatically compute the projection matrix to best fit (including all the casters)
  47247. * on each frame.
  47248. */
  47249. autoUpdateExtends: boolean;
  47250. private _orthoLeft;
  47251. private _orthoRight;
  47252. private _orthoTop;
  47253. private _orthoBottom;
  47254. /**
  47255. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47256. * The directional light is emitted from everywhere in the given direction.
  47257. * It can cast shadows.
  47258. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47259. * @param name The friendly name of the light
  47260. * @param direction The direction of the light
  47261. * @param scene The scene the light belongs to
  47262. */
  47263. constructor(name: string, direction: Vector3, scene: Scene);
  47264. /**
  47265. * Returns the string "DirectionalLight".
  47266. * @return The class name
  47267. */
  47268. getClassName(): string;
  47269. /**
  47270. * Returns the integer 1.
  47271. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47272. */
  47273. getTypeID(): number;
  47274. /**
  47275. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47276. * Returns the DirectionalLight Shadow projection matrix.
  47277. */
  47278. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47279. /**
  47280. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47281. * Returns the DirectionalLight Shadow projection matrix.
  47282. */
  47283. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47284. /**
  47285. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47286. * Returns the DirectionalLight Shadow projection matrix.
  47287. */
  47288. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47289. protected _buildUniformLayout(): void;
  47290. /**
  47291. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47292. * @param effect The effect to update
  47293. * @param lightIndex The index of the light in the effect to update
  47294. * @returns The directional light
  47295. */
  47296. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47297. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47298. /**
  47299. * Gets the minZ used for shadow according to both the scene and the light.
  47300. *
  47301. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47302. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47303. * @param activeCamera The camera we are returning the min for
  47304. * @returns the depth min z
  47305. */
  47306. getDepthMinZ(activeCamera: Camera): number;
  47307. /**
  47308. * Gets the maxZ used for shadow according to both the scene and the light.
  47309. *
  47310. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47311. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47312. * @param activeCamera The camera we are returning the max for
  47313. * @returns the depth max z
  47314. */
  47315. getDepthMaxZ(activeCamera: Camera): number;
  47316. /**
  47317. * Prepares the list of defines specific to the light type.
  47318. * @param defines the list of defines
  47319. * @param lightIndex defines the index of the light for the effect
  47320. */
  47321. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47322. }
  47323. }
  47324. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47325. import { Mesh } from "babylonjs/Meshes/mesh";
  47326. /**
  47327. * Class containing static functions to help procedurally build meshes
  47328. */
  47329. export class HemisphereBuilder {
  47330. /**
  47331. * Creates a hemisphere mesh
  47332. * @param name defines the name of the mesh
  47333. * @param options defines the options used to create the mesh
  47334. * @param scene defines the hosting scene
  47335. * @returns the hemisphere mesh
  47336. */
  47337. static CreateHemisphere(name: string, options: {
  47338. segments?: number;
  47339. diameter?: number;
  47340. sideOrientation?: number;
  47341. }, scene: any): Mesh;
  47342. }
  47343. }
  47344. declare module "babylonjs/Lights/spotLight" {
  47345. import { Nullable } from "babylonjs/types";
  47346. import { Scene } from "babylonjs/scene";
  47347. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47349. import { Effect } from "babylonjs/Materials/effect";
  47350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47351. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47352. /**
  47353. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47354. * These values define a cone of light starting from the position, emitting toward the direction.
  47355. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47356. * and the exponent defines the speed of the decay of the light with distance (reach).
  47357. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47358. */
  47359. export class SpotLight extends ShadowLight {
  47360. private _angle;
  47361. private _innerAngle;
  47362. private _cosHalfAngle;
  47363. private _lightAngleScale;
  47364. private _lightAngleOffset;
  47365. /**
  47366. * Gets the cone angle of the spot light in Radians.
  47367. */
  47368. /**
  47369. * Sets the cone angle of the spot light in Radians.
  47370. */
  47371. angle: number;
  47372. /**
  47373. * Only used in gltf falloff mode, this defines the angle where
  47374. * the directional falloff will start before cutting at angle which could be seen
  47375. * as outer angle.
  47376. */
  47377. /**
  47378. * Only used in gltf falloff mode, this defines the angle where
  47379. * the directional falloff will start before cutting at angle which could be seen
  47380. * as outer angle.
  47381. */
  47382. innerAngle: number;
  47383. private _shadowAngleScale;
  47384. /**
  47385. * Allows scaling the angle of the light for shadow generation only.
  47386. */
  47387. /**
  47388. * Allows scaling the angle of the light for shadow generation only.
  47389. */
  47390. shadowAngleScale: number;
  47391. /**
  47392. * The light decay speed with the distance from the emission spot.
  47393. */
  47394. exponent: number;
  47395. private _projectionTextureMatrix;
  47396. /**
  47397. * Allows reading the projecton texture
  47398. */
  47399. readonly projectionTextureMatrix: Matrix;
  47400. protected _projectionTextureLightNear: number;
  47401. /**
  47402. * Gets the near clip of the Spotlight for texture projection.
  47403. */
  47404. /**
  47405. * Sets the near clip of the Spotlight for texture projection.
  47406. */
  47407. projectionTextureLightNear: number;
  47408. protected _projectionTextureLightFar: number;
  47409. /**
  47410. * Gets the far clip of the Spotlight for texture projection.
  47411. */
  47412. /**
  47413. * Sets the far clip of the Spotlight for texture projection.
  47414. */
  47415. projectionTextureLightFar: number;
  47416. protected _projectionTextureUpDirection: Vector3;
  47417. /**
  47418. * Gets the Up vector of the Spotlight for texture projection.
  47419. */
  47420. /**
  47421. * Sets the Up vector of the Spotlight for texture projection.
  47422. */
  47423. projectionTextureUpDirection: Vector3;
  47424. private _projectionTexture;
  47425. /**
  47426. * Gets the projection texture of the light.
  47427. */
  47428. /**
  47429. * Sets the projection texture of the light.
  47430. */
  47431. projectionTexture: Nullable<BaseTexture>;
  47432. private _projectionTextureViewLightDirty;
  47433. private _projectionTextureProjectionLightDirty;
  47434. private _projectionTextureDirty;
  47435. private _projectionTextureViewTargetVector;
  47436. private _projectionTextureViewLightMatrix;
  47437. private _projectionTextureProjectionLightMatrix;
  47438. private _projectionTextureScalingMatrix;
  47439. /**
  47440. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47441. * It can cast shadows.
  47442. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47443. * @param name The light friendly name
  47444. * @param position The position of the spot light in the scene
  47445. * @param direction The direction of the light in the scene
  47446. * @param angle The cone angle of the light in Radians
  47447. * @param exponent The light decay speed with the distance from the emission spot
  47448. * @param scene The scene the lights belongs to
  47449. */
  47450. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47451. /**
  47452. * Returns the string "SpotLight".
  47453. * @returns the class name
  47454. */
  47455. getClassName(): string;
  47456. /**
  47457. * Returns the integer 2.
  47458. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47459. */
  47460. getTypeID(): number;
  47461. /**
  47462. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47463. */
  47464. protected _setDirection(value: Vector3): void;
  47465. /**
  47466. * Overrides the position setter to recompute the projection texture view light Matrix.
  47467. */
  47468. protected _setPosition(value: Vector3): void;
  47469. /**
  47470. * 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.
  47471. * Returns the SpotLight.
  47472. */
  47473. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47474. protected _computeProjectionTextureViewLightMatrix(): void;
  47475. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47476. /**
  47477. * Main function for light texture projection matrix computing.
  47478. */
  47479. protected _computeProjectionTextureMatrix(): void;
  47480. protected _buildUniformLayout(): void;
  47481. private _computeAngleValues;
  47482. /**
  47483. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47484. * @param effect The effect to update
  47485. * @param lightIndex The index of the light in the effect to update
  47486. * @returns The spot light
  47487. */
  47488. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47489. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47490. /**
  47491. * Disposes the light and the associated resources.
  47492. */
  47493. dispose(): void;
  47494. /**
  47495. * Prepares the list of defines specific to the light type.
  47496. * @param defines the list of defines
  47497. * @param lightIndex defines the index of the light for the effect
  47498. */
  47499. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47500. }
  47501. }
  47502. declare module "babylonjs/Gizmos/lightGizmo" {
  47503. import { Nullable } from "babylonjs/types";
  47504. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47505. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47506. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47507. import { Light } from "babylonjs/Lights/light";
  47508. /**
  47509. * Gizmo that enables viewing a light
  47510. */
  47511. export class LightGizmo extends Gizmo {
  47512. private _lightMesh;
  47513. private _material;
  47514. private cachedPosition;
  47515. private cachedForward;
  47516. /**
  47517. * Creates a LightGizmo
  47518. * @param gizmoLayer The utility layer the gizmo will be added to
  47519. */
  47520. constructor(gizmoLayer?: UtilityLayerRenderer);
  47521. private _light;
  47522. /**
  47523. * The light that the gizmo is attached to
  47524. */
  47525. light: Nullable<Light>;
  47526. /**
  47527. * Gets the material used to render the light gizmo
  47528. */
  47529. readonly material: StandardMaterial;
  47530. /**
  47531. * @hidden
  47532. * Updates the gizmo to match the attached mesh's position/rotation
  47533. */
  47534. protected _update(): void;
  47535. private static _Scale;
  47536. /**
  47537. * Creates the lines for a light mesh
  47538. */
  47539. private static _createLightLines;
  47540. /**
  47541. * Disposes of the light gizmo
  47542. */
  47543. dispose(): void;
  47544. private static _CreateHemisphericLightMesh;
  47545. private static _CreatePointLightMesh;
  47546. private static _CreateSpotLightMesh;
  47547. private static _CreateDirectionalLightMesh;
  47548. }
  47549. }
  47550. declare module "babylonjs/Gizmos/index" {
  47551. export * from "babylonjs/Gizmos/axisDragGizmo";
  47552. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47553. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47554. export * from "babylonjs/Gizmos/gizmo";
  47555. export * from "babylonjs/Gizmos/gizmoManager";
  47556. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47557. export * from "babylonjs/Gizmos/positionGizmo";
  47558. export * from "babylonjs/Gizmos/rotationGizmo";
  47559. export * from "babylonjs/Gizmos/scaleGizmo";
  47560. export * from "babylonjs/Gizmos/lightGizmo";
  47561. export * from "babylonjs/Gizmos/planeDragGizmo";
  47562. }
  47563. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47564. /** @hidden */
  47565. export var backgroundFragmentDeclaration: {
  47566. name: string;
  47567. shader: string;
  47568. };
  47569. }
  47570. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47571. /** @hidden */
  47572. export var backgroundUboDeclaration: {
  47573. name: string;
  47574. shader: string;
  47575. };
  47576. }
  47577. declare module "babylonjs/Shaders/background.fragment" {
  47578. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47579. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47580. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47581. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47582. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47583. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47584. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47585. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47586. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47587. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47588. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47589. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47590. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47591. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47592. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47593. /** @hidden */
  47594. export var backgroundPixelShader: {
  47595. name: string;
  47596. shader: string;
  47597. };
  47598. }
  47599. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47600. /** @hidden */
  47601. export var backgroundVertexDeclaration: {
  47602. name: string;
  47603. shader: string;
  47604. };
  47605. }
  47606. declare module "babylonjs/Shaders/background.vertex" {
  47607. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47608. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47610. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47611. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47612. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47613. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47614. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47615. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47616. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47617. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47618. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47619. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47620. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47621. /** @hidden */
  47622. export var backgroundVertexShader: {
  47623. name: string;
  47624. shader: string;
  47625. };
  47626. }
  47627. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47628. import { Nullable, int, float } from "babylonjs/types";
  47629. import { Scene } from "babylonjs/scene";
  47630. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47631. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47633. import { Mesh } from "babylonjs/Meshes/mesh";
  47634. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47635. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47636. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47638. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47639. import { Color3 } from "babylonjs/Maths/math.color";
  47640. import "babylonjs/Shaders/background.fragment";
  47641. import "babylonjs/Shaders/background.vertex";
  47642. /**
  47643. * Background material used to create an efficient environement around your scene.
  47644. */
  47645. export class BackgroundMaterial extends PushMaterial {
  47646. /**
  47647. * Standard reflectance value at parallel view angle.
  47648. */
  47649. static StandardReflectance0: number;
  47650. /**
  47651. * Standard reflectance value at grazing angle.
  47652. */
  47653. static StandardReflectance90: number;
  47654. protected _primaryColor: Color3;
  47655. /**
  47656. * Key light Color (multiply against the environement texture)
  47657. */
  47658. primaryColor: Color3;
  47659. protected __perceptualColor: Nullable<Color3>;
  47660. /**
  47661. * Experimental Internal Use Only.
  47662. *
  47663. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47664. * This acts as a helper to set the primary color to a more "human friendly" value.
  47665. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47666. * output color as close as possible from the chosen value.
  47667. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47668. * part of lighting setup.)
  47669. */
  47670. _perceptualColor: Nullable<Color3>;
  47671. protected _primaryColorShadowLevel: float;
  47672. /**
  47673. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47674. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47675. */
  47676. primaryColorShadowLevel: float;
  47677. protected _primaryColorHighlightLevel: float;
  47678. /**
  47679. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47680. * The primary color is used at the level chosen to define what the white area would look.
  47681. */
  47682. primaryColorHighlightLevel: float;
  47683. protected _reflectionTexture: Nullable<BaseTexture>;
  47684. /**
  47685. * Reflection Texture used in the material.
  47686. * Should be author in a specific way for the best result (refer to the documentation).
  47687. */
  47688. reflectionTexture: Nullable<BaseTexture>;
  47689. protected _reflectionBlur: float;
  47690. /**
  47691. * Reflection Texture level of blur.
  47692. *
  47693. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47694. * texture twice.
  47695. */
  47696. reflectionBlur: float;
  47697. protected _diffuseTexture: Nullable<BaseTexture>;
  47698. /**
  47699. * Diffuse Texture used in the material.
  47700. * Should be author in a specific way for the best result (refer to the documentation).
  47701. */
  47702. diffuseTexture: Nullable<BaseTexture>;
  47703. protected _shadowLights: Nullable<IShadowLight[]>;
  47704. /**
  47705. * Specify the list of lights casting shadow on the material.
  47706. * All scene shadow lights will be included if null.
  47707. */
  47708. shadowLights: Nullable<IShadowLight[]>;
  47709. protected _shadowLevel: float;
  47710. /**
  47711. * Helps adjusting the shadow to a softer level if required.
  47712. * 0 means black shadows and 1 means no shadows.
  47713. */
  47714. shadowLevel: float;
  47715. protected _sceneCenter: Vector3;
  47716. /**
  47717. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47718. * It is usually zero but might be interesting to modify according to your setup.
  47719. */
  47720. sceneCenter: Vector3;
  47721. protected _opacityFresnel: boolean;
  47722. /**
  47723. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47724. * This helps ensuring a nice transition when the camera goes under the ground.
  47725. */
  47726. opacityFresnel: boolean;
  47727. protected _reflectionFresnel: boolean;
  47728. /**
  47729. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47730. * This helps adding a mirror texture on the ground.
  47731. */
  47732. reflectionFresnel: boolean;
  47733. protected _reflectionFalloffDistance: number;
  47734. /**
  47735. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47736. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47737. */
  47738. reflectionFalloffDistance: number;
  47739. protected _reflectionAmount: number;
  47740. /**
  47741. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47742. */
  47743. reflectionAmount: number;
  47744. protected _reflectionReflectance0: number;
  47745. /**
  47746. * This specifies the weight of the reflection at grazing angle.
  47747. */
  47748. reflectionReflectance0: number;
  47749. protected _reflectionReflectance90: number;
  47750. /**
  47751. * This specifies the weight of the reflection at a perpendicular point of view.
  47752. */
  47753. reflectionReflectance90: number;
  47754. /**
  47755. * Sets the reflection reflectance fresnel values according to the default standard
  47756. * empirically know to work well :-)
  47757. */
  47758. reflectionStandardFresnelWeight: number;
  47759. protected _useRGBColor: boolean;
  47760. /**
  47761. * Helps to directly use the maps channels instead of their level.
  47762. */
  47763. useRGBColor: boolean;
  47764. protected _enableNoise: boolean;
  47765. /**
  47766. * This helps reducing the banding effect that could occur on the background.
  47767. */
  47768. enableNoise: boolean;
  47769. /**
  47770. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47771. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47772. * Recommended to be keep at 1.0 except for special cases.
  47773. */
  47774. fovMultiplier: number;
  47775. private _fovMultiplier;
  47776. /**
  47777. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47778. */
  47779. useEquirectangularFOV: boolean;
  47780. private _maxSimultaneousLights;
  47781. /**
  47782. * Number of Simultaneous lights allowed on the material.
  47783. */
  47784. maxSimultaneousLights: int;
  47785. /**
  47786. * Default configuration related to image processing available in the Background Material.
  47787. */
  47788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47789. /**
  47790. * Keep track of the image processing observer to allow dispose and replace.
  47791. */
  47792. private _imageProcessingObserver;
  47793. /**
  47794. * Attaches a new image processing configuration to the PBR Material.
  47795. * @param configuration (if null the scene configuration will be use)
  47796. */
  47797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47798. /**
  47799. * Gets the image processing configuration used either in this material.
  47800. */
  47801. /**
  47802. * Sets the Default image processing configuration used either in the this material.
  47803. *
  47804. * If sets to null, the scene one is in use.
  47805. */
  47806. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47807. /**
  47808. * Gets wether the color curves effect is enabled.
  47809. */
  47810. /**
  47811. * Sets wether the color curves effect is enabled.
  47812. */
  47813. cameraColorCurvesEnabled: boolean;
  47814. /**
  47815. * Gets wether the color grading effect is enabled.
  47816. */
  47817. /**
  47818. * Gets wether the color grading effect is enabled.
  47819. */
  47820. cameraColorGradingEnabled: boolean;
  47821. /**
  47822. * Gets wether tonemapping is enabled or not.
  47823. */
  47824. /**
  47825. * Sets wether tonemapping is enabled or not
  47826. */
  47827. cameraToneMappingEnabled: boolean;
  47828. /**
  47829. * The camera exposure used on this material.
  47830. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47831. * This corresponds to a photographic exposure.
  47832. */
  47833. /**
  47834. * The camera exposure used on this material.
  47835. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47836. * This corresponds to a photographic exposure.
  47837. */
  47838. cameraExposure: float;
  47839. /**
  47840. * Gets The camera contrast used on this material.
  47841. */
  47842. /**
  47843. * Sets The camera contrast used on this material.
  47844. */
  47845. cameraContrast: float;
  47846. /**
  47847. * Gets the Color Grading 2D Lookup Texture.
  47848. */
  47849. /**
  47850. * Sets the Color Grading 2D Lookup Texture.
  47851. */
  47852. cameraColorGradingTexture: Nullable<BaseTexture>;
  47853. /**
  47854. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47855. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47856. * 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;
  47857. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47858. */
  47859. /**
  47860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47862. * 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;
  47863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47864. */
  47865. cameraColorCurves: Nullable<ColorCurves>;
  47866. /**
  47867. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47868. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47869. */
  47870. switchToBGR: boolean;
  47871. private _renderTargets;
  47872. private _reflectionControls;
  47873. private _white;
  47874. private _primaryShadowColor;
  47875. private _primaryHighlightColor;
  47876. /**
  47877. * Instantiates a Background Material in the given scene
  47878. * @param name The friendly name of the material
  47879. * @param scene The scene to add the material to
  47880. */
  47881. constructor(name: string, scene: Scene);
  47882. /**
  47883. * Gets a boolean indicating that current material needs to register RTT
  47884. */
  47885. readonly hasRenderTargetTextures: boolean;
  47886. /**
  47887. * The entire material has been created in order to prevent overdraw.
  47888. * @returns false
  47889. */
  47890. needAlphaTesting(): boolean;
  47891. /**
  47892. * The entire material has been created in order to prevent overdraw.
  47893. * @returns true if blending is enable
  47894. */
  47895. needAlphaBlending(): boolean;
  47896. /**
  47897. * Checks wether the material is ready to be rendered for a given mesh.
  47898. * @param mesh The mesh to render
  47899. * @param subMesh The submesh to check against
  47900. * @param useInstances Specify wether or not the material is used with instances
  47901. * @returns true if all the dependencies are ready (Textures, Effects...)
  47902. */
  47903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47904. /**
  47905. * Compute the primary color according to the chosen perceptual color.
  47906. */
  47907. private _computePrimaryColorFromPerceptualColor;
  47908. /**
  47909. * Compute the highlights and shadow colors according to their chosen levels.
  47910. */
  47911. private _computePrimaryColors;
  47912. /**
  47913. * Build the uniform buffer used in the material.
  47914. */
  47915. buildUniformLayout(): void;
  47916. /**
  47917. * Unbind the material.
  47918. */
  47919. unbind(): void;
  47920. /**
  47921. * Bind only the world matrix to the material.
  47922. * @param world The world matrix to bind.
  47923. */
  47924. bindOnlyWorldMatrix(world: Matrix): void;
  47925. /**
  47926. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47927. * @param world The world matrix to bind.
  47928. * @param subMesh The submesh to bind for.
  47929. */
  47930. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47931. /**
  47932. * Checks to see if a texture is used in the material.
  47933. * @param texture - Base texture to use.
  47934. * @returns - Boolean specifying if a texture is used in the material.
  47935. */
  47936. hasTexture(texture: BaseTexture): boolean;
  47937. /**
  47938. * Dispose the material.
  47939. * @param forceDisposeEffect Force disposal of the associated effect.
  47940. * @param forceDisposeTextures Force disposal of the associated textures.
  47941. */
  47942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47943. /**
  47944. * Clones the material.
  47945. * @param name The cloned name.
  47946. * @returns The cloned material.
  47947. */
  47948. clone(name: string): BackgroundMaterial;
  47949. /**
  47950. * Serializes the current material to its JSON representation.
  47951. * @returns The JSON representation.
  47952. */
  47953. serialize(): any;
  47954. /**
  47955. * Gets the class name of the material
  47956. * @returns "BackgroundMaterial"
  47957. */
  47958. getClassName(): string;
  47959. /**
  47960. * Parse a JSON input to create back a background material.
  47961. * @param source The JSON data to parse
  47962. * @param scene The scene to create the parsed material in
  47963. * @param rootUrl The root url of the assets the material depends upon
  47964. * @returns the instantiated BackgroundMaterial.
  47965. */
  47966. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47967. }
  47968. }
  47969. declare module "babylonjs/Helpers/environmentHelper" {
  47970. import { Observable } from "babylonjs/Misc/observable";
  47971. import { Nullable } from "babylonjs/types";
  47972. import { Scene } from "babylonjs/scene";
  47973. import { Vector3 } from "babylonjs/Maths/math.vector";
  47974. import { Color3 } from "babylonjs/Maths/math.color";
  47975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47976. import { Mesh } from "babylonjs/Meshes/mesh";
  47977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47978. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47979. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47980. import "babylonjs/Meshes/Builders/planeBuilder";
  47981. import "babylonjs/Meshes/Builders/boxBuilder";
  47982. /**
  47983. * Represents the different options available during the creation of
  47984. * a Environment helper.
  47985. *
  47986. * This can control the default ground, skybox and image processing setup of your scene.
  47987. */
  47988. export interface IEnvironmentHelperOptions {
  47989. /**
  47990. * Specifies wether or not to create a ground.
  47991. * True by default.
  47992. */
  47993. createGround: boolean;
  47994. /**
  47995. * Specifies the ground size.
  47996. * 15 by default.
  47997. */
  47998. groundSize: number;
  47999. /**
  48000. * The texture used on the ground for the main color.
  48001. * Comes from the BabylonJS CDN by default.
  48002. *
  48003. * Remarks: Can be either a texture or a url.
  48004. */
  48005. groundTexture: string | BaseTexture;
  48006. /**
  48007. * The color mixed in the ground texture by default.
  48008. * BabylonJS clearColor by default.
  48009. */
  48010. groundColor: Color3;
  48011. /**
  48012. * Specifies the ground opacity.
  48013. * 1 by default.
  48014. */
  48015. groundOpacity: number;
  48016. /**
  48017. * Enables the ground to receive shadows.
  48018. * True by default.
  48019. */
  48020. enableGroundShadow: boolean;
  48021. /**
  48022. * Helps preventing the shadow to be fully black on the ground.
  48023. * 0.5 by default.
  48024. */
  48025. groundShadowLevel: number;
  48026. /**
  48027. * Creates a mirror texture attach to the ground.
  48028. * false by default.
  48029. */
  48030. enableGroundMirror: boolean;
  48031. /**
  48032. * Specifies the ground mirror size ratio.
  48033. * 0.3 by default as the default kernel is 64.
  48034. */
  48035. groundMirrorSizeRatio: number;
  48036. /**
  48037. * Specifies the ground mirror blur kernel size.
  48038. * 64 by default.
  48039. */
  48040. groundMirrorBlurKernel: number;
  48041. /**
  48042. * Specifies the ground mirror visibility amount.
  48043. * 1 by default
  48044. */
  48045. groundMirrorAmount: number;
  48046. /**
  48047. * Specifies the ground mirror reflectance weight.
  48048. * This uses the standard weight of the background material to setup the fresnel effect
  48049. * of the mirror.
  48050. * 1 by default.
  48051. */
  48052. groundMirrorFresnelWeight: number;
  48053. /**
  48054. * Specifies the ground mirror Falloff distance.
  48055. * This can helps reducing the size of the reflection.
  48056. * 0 by Default.
  48057. */
  48058. groundMirrorFallOffDistance: number;
  48059. /**
  48060. * Specifies the ground mirror texture type.
  48061. * Unsigned Int by Default.
  48062. */
  48063. groundMirrorTextureType: number;
  48064. /**
  48065. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48066. * the shown objects.
  48067. */
  48068. groundYBias: number;
  48069. /**
  48070. * Specifies wether or not to create a skybox.
  48071. * True by default.
  48072. */
  48073. createSkybox: boolean;
  48074. /**
  48075. * Specifies the skybox size.
  48076. * 20 by default.
  48077. */
  48078. skyboxSize: number;
  48079. /**
  48080. * The texture used on the skybox for the main color.
  48081. * Comes from the BabylonJS CDN by default.
  48082. *
  48083. * Remarks: Can be either a texture or a url.
  48084. */
  48085. skyboxTexture: string | BaseTexture;
  48086. /**
  48087. * The color mixed in the skybox texture by default.
  48088. * BabylonJS clearColor by default.
  48089. */
  48090. skyboxColor: Color3;
  48091. /**
  48092. * The background rotation around the Y axis of the scene.
  48093. * This helps aligning the key lights of your scene with the background.
  48094. * 0 by default.
  48095. */
  48096. backgroundYRotation: number;
  48097. /**
  48098. * Compute automatically the size of the elements to best fit with the scene.
  48099. */
  48100. sizeAuto: boolean;
  48101. /**
  48102. * Default position of the rootMesh if autoSize is not true.
  48103. */
  48104. rootPosition: Vector3;
  48105. /**
  48106. * Sets up the image processing in the scene.
  48107. * true by default.
  48108. */
  48109. setupImageProcessing: boolean;
  48110. /**
  48111. * The texture used as your environment texture in the scene.
  48112. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48113. *
  48114. * Remarks: Can be either a texture or a url.
  48115. */
  48116. environmentTexture: string | BaseTexture;
  48117. /**
  48118. * The value of the exposure to apply to the scene.
  48119. * 0.6 by default if setupImageProcessing is true.
  48120. */
  48121. cameraExposure: number;
  48122. /**
  48123. * The value of the contrast to apply to the scene.
  48124. * 1.6 by default if setupImageProcessing is true.
  48125. */
  48126. cameraContrast: number;
  48127. /**
  48128. * Specifies wether or not tonemapping should be enabled in the scene.
  48129. * true by default if setupImageProcessing is true.
  48130. */
  48131. toneMappingEnabled: boolean;
  48132. }
  48133. /**
  48134. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48135. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48136. * It also helps with the default setup of your imageProcessing configuration.
  48137. */
  48138. export class EnvironmentHelper {
  48139. /**
  48140. * Default ground texture URL.
  48141. */
  48142. private static _groundTextureCDNUrl;
  48143. /**
  48144. * Default skybox texture URL.
  48145. */
  48146. private static _skyboxTextureCDNUrl;
  48147. /**
  48148. * Default environment texture URL.
  48149. */
  48150. private static _environmentTextureCDNUrl;
  48151. /**
  48152. * Creates the default options for the helper.
  48153. */
  48154. private static _getDefaultOptions;
  48155. private _rootMesh;
  48156. /**
  48157. * Gets the root mesh created by the helper.
  48158. */
  48159. readonly rootMesh: Mesh;
  48160. private _skybox;
  48161. /**
  48162. * Gets the skybox created by the helper.
  48163. */
  48164. readonly skybox: Nullable<Mesh>;
  48165. private _skyboxTexture;
  48166. /**
  48167. * Gets the skybox texture created by the helper.
  48168. */
  48169. readonly skyboxTexture: Nullable<BaseTexture>;
  48170. private _skyboxMaterial;
  48171. /**
  48172. * Gets the skybox material created by the helper.
  48173. */
  48174. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48175. private _ground;
  48176. /**
  48177. * Gets the ground mesh created by the helper.
  48178. */
  48179. readonly ground: Nullable<Mesh>;
  48180. private _groundTexture;
  48181. /**
  48182. * Gets the ground texture created by the helper.
  48183. */
  48184. readonly groundTexture: Nullable<BaseTexture>;
  48185. private _groundMirror;
  48186. /**
  48187. * Gets the ground mirror created by the helper.
  48188. */
  48189. readonly groundMirror: Nullable<MirrorTexture>;
  48190. /**
  48191. * Gets the ground mirror render list to helps pushing the meshes
  48192. * you wish in the ground reflection.
  48193. */
  48194. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48195. private _groundMaterial;
  48196. /**
  48197. * Gets the ground material created by the helper.
  48198. */
  48199. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48200. /**
  48201. * Stores the creation options.
  48202. */
  48203. private readonly _scene;
  48204. private _options;
  48205. /**
  48206. * This observable will be notified with any error during the creation of the environment,
  48207. * mainly texture creation errors.
  48208. */
  48209. onErrorObservable: Observable<{
  48210. message?: string;
  48211. exception?: any;
  48212. }>;
  48213. /**
  48214. * constructor
  48215. * @param options Defines the options we want to customize the helper
  48216. * @param scene The scene to add the material to
  48217. */
  48218. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48219. /**
  48220. * Updates the background according to the new options
  48221. * @param options
  48222. */
  48223. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48224. /**
  48225. * Sets the primary color of all the available elements.
  48226. * @param color the main color to affect to the ground and the background
  48227. */
  48228. setMainColor(color: Color3): void;
  48229. /**
  48230. * Setup the image processing according to the specified options.
  48231. */
  48232. private _setupImageProcessing;
  48233. /**
  48234. * Setup the environment texture according to the specified options.
  48235. */
  48236. private _setupEnvironmentTexture;
  48237. /**
  48238. * Setup the background according to the specified options.
  48239. */
  48240. private _setupBackground;
  48241. /**
  48242. * Get the scene sizes according to the setup.
  48243. */
  48244. private _getSceneSize;
  48245. /**
  48246. * Setup the ground according to the specified options.
  48247. */
  48248. private _setupGround;
  48249. /**
  48250. * Setup the ground material according to the specified options.
  48251. */
  48252. private _setupGroundMaterial;
  48253. /**
  48254. * Setup the ground diffuse texture according to the specified options.
  48255. */
  48256. private _setupGroundDiffuseTexture;
  48257. /**
  48258. * Setup the ground mirror texture according to the specified options.
  48259. */
  48260. private _setupGroundMirrorTexture;
  48261. /**
  48262. * Setup the ground to receive the mirror texture.
  48263. */
  48264. private _setupMirrorInGroundMaterial;
  48265. /**
  48266. * Setup the skybox according to the specified options.
  48267. */
  48268. private _setupSkybox;
  48269. /**
  48270. * Setup the skybox material according to the specified options.
  48271. */
  48272. private _setupSkyboxMaterial;
  48273. /**
  48274. * Setup the skybox reflection texture according to the specified options.
  48275. */
  48276. private _setupSkyboxReflectionTexture;
  48277. private _errorHandler;
  48278. /**
  48279. * Dispose all the elements created by the Helper.
  48280. */
  48281. dispose(): void;
  48282. }
  48283. }
  48284. declare module "babylonjs/Helpers/photoDome" {
  48285. import { Observable } from "babylonjs/Misc/observable";
  48286. import { Nullable } from "babylonjs/types";
  48287. import { Scene } from "babylonjs/scene";
  48288. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48289. import { Mesh } from "babylonjs/Meshes/mesh";
  48290. import { Texture } from "babylonjs/Materials/Textures/texture";
  48291. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48292. import "babylonjs/Meshes/Builders/sphereBuilder";
  48293. /**
  48294. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48295. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48296. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48297. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48298. */
  48299. export class PhotoDome extends TransformNode {
  48300. /**
  48301. * Define the image as a Monoscopic panoramic 360 image.
  48302. */
  48303. static readonly MODE_MONOSCOPIC: number;
  48304. /**
  48305. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48306. */
  48307. static readonly MODE_TOPBOTTOM: number;
  48308. /**
  48309. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48310. */
  48311. static readonly MODE_SIDEBYSIDE: number;
  48312. private _useDirectMapping;
  48313. /**
  48314. * The texture being displayed on the sphere
  48315. */
  48316. protected _photoTexture: Texture;
  48317. /**
  48318. * Gets or sets the texture being displayed on the sphere
  48319. */
  48320. photoTexture: Texture;
  48321. /**
  48322. * Observable raised when an error occured while loading the 360 image
  48323. */
  48324. onLoadErrorObservable: Observable<string>;
  48325. /**
  48326. * The skybox material
  48327. */
  48328. protected _material: BackgroundMaterial;
  48329. /**
  48330. * The surface used for the skybox
  48331. */
  48332. protected _mesh: Mesh;
  48333. /**
  48334. * Gets the mesh used for the skybox.
  48335. */
  48336. readonly mesh: Mesh;
  48337. /**
  48338. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48339. * Also see the options.resolution property.
  48340. */
  48341. fovMultiplier: number;
  48342. private _imageMode;
  48343. /**
  48344. * Gets or set the current video mode for the video. It can be:
  48345. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48346. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48347. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48348. */
  48349. imageMode: number;
  48350. /**
  48351. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48352. * @param name Element's name, child elements will append suffixes for their own names.
  48353. * @param urlsOfPhoto defines the url of the photo to display
  48354. * @param options defines an object containing optional or exposed sub element properties
  48355. * @param onError defines a callback called when an error occured while loading the texture
  48356. */
  48357. constructor(name: string, urlOfPhoto: string, options: {
  48358. resolution?: number;
  48359. size?: number;
  48360. useDirectMapping?: boolean;
  48361. faceForward?: boolean;
  48362. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48363. private _onBeforeCameraRenderObserver;
  48364. private _changeImageMode;
  48365. /**
  48366. * Releases resources associated with this node.
  48367. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48368. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48369. */
  48370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48371. }
  48372. }
  48373. declare module "babylonjs/Misc/rgbdTextureTools" {
  48374. import "babylonjs/Shaders/rgbdDecode.fragment";
  48375. import { Texture } from "babylonjs/Materials/Textures/texture";
  48376. /**
  48377. * Class used to host RGBD texture specific utilities
  48378. */
  48379. export class RGBDTextureTools {
  48380. /**
  48381. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48382. * @param texture the texture to expand.
  48383. */
  48384. static ExpandRGBDTexture(texture: Texture): void;
  48385. }
  48386. }
  48387. declare module "babylonjs/Misc/brdfTextureTools" {
  48388. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48389. import { Scene } from "babylonjs/scene";
  48390. /**
  48391. * Class used to host texture specific utilities
  48392. */
  48393. export class BRDFTextureTools {
  48394. /**
  48395. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48396. * @param scene defines the hosting scene
  48397. * @returns the environment BRDF texture
  48398. */
  48399. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48400. private static _environmentBRDFBase64Texture;
  48401. }
  48402. }
  48403. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48404. import { Nullable } from "babylonjs/types";
  48405. import { Color3 } from "babylonjs/Maths/math.color";
  48406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48407. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48408. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48409. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48410. import { Engine } from "babylonjs/Engines/engine";
  48411. import { Scene } from "babylonjs/scene";
  48412. /**
  48413. * @hidden
  48414. */
  48415. export interface IMaterialClearCoatDefines {
  48416. CLEARCOAT: boolean;
  48417. CLEARCOAT_DEFAULTIOR: boolean;
  48418. CLEARCOAT_TEXTURE: boolean;
  48419. CLEARCOAT_TEXTUREDIRECTUV: number;
  48420. CLEARCOAT_BUMP: boolean;
  48421. CLEARCOAT_BUMPDIRECTUV: number;
  48422. CLEARCOAT_TINT: boolean;
  48423. CLEARCOAT_TINT_TEXTURE: boolean;
  48424. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48425. /** @hidden */
  48426. _areTexturesDirty: boolean;
  48427. }
  48428. /**
  48429. * Define the code related to the clear coat parameters of the pbr material.
  48430. */
  48431. export class PBRClearCoatConfiguration {
  48432. /**
  48433. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48434. * The default fits with a polyurethane material.
  48435. */
  48436. private static readonly _DefaultIndexOfRefraction;
  48437. private _isEnabled;
  48438. /**
  48439. * Defines if the clear coat is enabled in the material.
  48440. */
  48441. isEnabled: boolean;
  48442. /**
  48443. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48444. */
  48445. intensity: number;
  48446. /**
  48447. * Defines the clear coat layer roughness.
  48448. */
  48449. roughness: number;
  48450. private _indexOfRefraction;
  48451. /**
  48452. * Defines the index of refraction of the clear coat.
  48453. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48454. * The default fits with a polyurethane material.
  48455. * Changing the default value is more performance intensive.
  48456. */
  48457. indexOfRefraction: number;
  48458. private _texture;
  48459. /**
  48460. * Stores the clear coat values in a texture.
  48461. */
  48462. texture: Nullable<BaseTexture>;
  48463. private _bumpTexture;
  48464. /**
  48465. * Define the clear coat specific bump texture.
  48466. */
  48467. bumpTexture: Nullable<BaseTexture>;
  48468. private _isTintEnabled;
  48469. /**
  48470. * Defines if the clear coat tint is enabled in the material.
  48471. */
  48472. isTintEnabled: boolean;
  48473. /**
  48474. * Defines the clear coat tint of the material.
  48475. * This is only use if tint is enabled
  48476. */
  48477. tintColor: Color3;
  48478. /**
  48479. * Defines the distance at which the tint color should be found in the
  48480. * clear coat media.
  48481. * This is only use if tint is enabled
  48482. */
  48483. tintColorAtDistance: number;
  48484. /**
  48485. * Defines the clear coat layer thickness.
  48486. * This is only use if tint is enabled
  48487. */
  48488. tintThickness: number;
  48489. private _tintTexture;
  48490. /**
  48491. * Stores the clear tint values in a texture.
  48492. * rgb is tint
  48493. * a is a thickness factor
  48494. */
  48495. tintTexture: Nullable<BaseTexture>;
  48496. /** @hidden */
  48497. private _internalMarkAllSubMeshesAsTexturesDirty;
  48498. /** @hidden */
  48499. _markAllSubMeshesAsTexturesDirty(): void;
  48500. /**
  48501. * Instantiate a new istance of clear coat configuration.
  48502. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48503. */
  48504. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48505. /**
  48506. * Gets wehter the submesh is ready to be used or not.
  48507. * @param defines the list of "defines" to update.
  48508. * @param scene defines the scene the material belongs to.
  48509. * @param engine defines the engine the material belongs to.
  48510. * @param disableBumpMap defines wether the material disables bump or not.
  48511. * @returns - boolean indicating that the submesh is ready or not.
  48512. */
  48513. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48514. /**
  48515. * Checks to see if a texture is used in the material.
  48516. * @param defines the list of "defines" to update.
  48517. * @param scene defines the scene to the material belongs to.
  48518. */
  48519. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48520. /**
  48521. * Binds the material data.
  48522. * @param uniformBuffer defines the Uniform buffer to fill in.
  48523. * @param scene defines the scene the material belongs to.
  48524. * @param engine defines the engine the material belongs to.
  48525. * @param disableBumpMap defines wether the material disables bump or not.
  48526. * @param isFrozen defines wether the material is frozen or not.
  48527. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48528. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48529. */
  48530. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48531. /**
  48532. * Checks to see if a texture is used in the material.
  48533. * @param texture - Base texture to use.
  48534. * @returns - Boolean specifying if a texture is used in the material.
  48535. */
  48536. hasTexture(texture: BaseTexture): boolean;
  48537. /**
  48538. * Returns an array of the actively used textures.
  48539. * @param activeTextures Array of BaseTextures
  48540. */
  48541. getActiveTextures(activeTextures: BaseTexture[]): void;
  48542. /**
  48543. * Returns the animatable textures.
  48544. * @param animatables Array of animatable textures.
  48545. */
  48546. getAnimatables(animatables: IAnimatable[]): void;
  48547. /**
  48548. * Disposes the resources of the material.
  48549. * @param forceDisposeTextures - Forces the disposal of all textures.
  48550. */
  48551. dispose(forceDisposeTextures?: boolean): void;
  48552. /**
  48553. * Get the current class name of the texture useful for serialization or dynamic coding.
  48554. * @returns "PBRClearCoatConfiguration"
  48555. */
  48556. getClassName(): string;
  48557. /**
  48558. * Add fallbacks to the effect fallbacks list.
  48559. * @param defines defines the Base texture to use.
  48560. * @param fallbacks defines the current fallback list.
  48561. * @param currentRank defines the current fallback rank.
  48562. * @returns the new fallback rank.
  48563. */
  48564. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48565. /**
  48566. * Add the required uniforms to the current list.
  48567. * @param uniforms defines the current uniform list.
  48568. */
  48569. static AddUniforms(uniforms: string[]): void;
  48570. /**
  48571. * Add the required samplers to the current list.
  48572. * @param samplers defines the current sampler list.
  48573. */
  48574. static AddSamplers(samplers: string[]): void;
  48575. /**
  48576. * Add the required uniforms to the current buffer.
  48577. * @param uniformBuffer defines the current uniform buffer.
  48578. */
  48579. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48580. /**
  48581. * Makes a duplicate of the current configuration into another one.
  48582. * @param clearCoatConfiguration define the config where to copy the info
  48583. */
  48584. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48585. /**
  48586. * Serializes this clear coat configuration.
  48587. * @returns - An object with the serialized config.
  48588. */
  48589. serialize(): any;
  48590. /**
  48591. * Parses a anisotropy Configuration from a serialized object.
  48592. * @param source - Serialized object.
  48593. * @param scene Defines the scene we are parsing for
  48594. * @param rootUrl Defines the rootUrl to load from
  48595. */
  48596. parse(source: any, scene: Scene, rootUrl: string): void;
  48597. }
  48598. }
  48599. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48600. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48602. import { Vector2 } from "babylonjs/Maths/math.vector";
  48603. import { Scene } from "babylonjs/scene";
  48604. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48605. import { Nullable } from "babylonjs/types";
  48606. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48607. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48608. /**
  48609. * @hidden
  48610. */
  48611. export interface IMaterialAnisotropicDefines {
  48612. ANISOTROPIC: boolean;
  48613. ANISOTROPIC_TEXTURE: boolean;
  48614. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48615. MAINUV1: boolean;
  48616. _areTexturesDirty: boolean;
  48617. _needUVs: boolean;
  48618. }
  48619. /**
  48620. * Define the code related to the anisotropic parameters of the pbr material.
  48621. */
  48622. export class PBRAnisotropicConfiguration {
  48623. private _isEnabled;
  48624. /**
  48625. * Defines if the anisotropy is enabled in the material.
  48626. */
  48627. isEnabled: boolean;
  48628. /**
  48629. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48630. */
  48631. intensity: number;
  48632. /**
  48633. * Defines if the effect is along the tangents, bitangents or in between.
  48634. * By default, the effect is "strectching" the highlights along the tangents.
  48635. */
  48636. direction: Vector2;
  48637. private _texture;
  48638. /**
  48639. * Stores the anisotropy values in a texture.
  48640. * rg is direction (like normal from -1 to 1)
  48641. * b is a intensity
  48642. */
  48643. texture: Nullable<BaseTexture>;
  48644. /** @hidden */
  48645. private _internalMarkAllSubMeshesAsTexturesDirty;
  48646. /** @hidden */
  48647. _markAllSubMeshesAsTexturesDirty(): void;
  48648. /**
  48649. * Instantiate a new istance of anisotropy configuration.
  48650. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48651. */
  48652. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48653. /**
  48654. * Specifies that the submesh is ready to be used.
  48655. * @param defines the list of "defines" to update.
  48656. * @param scene defines the scene the material belongs to.
  48657. * @returns - boolean indicating that the submesh is ready or not.
  48658. */
  48659. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48660. /**
  48661. * Checks to see if a texture is used in the material.
  48662. * @param defines the list of "defines" to update.
  48663. * @param mesh the mesh we are preparing the defines for.
  48664. * @param scene defines the scene the material belongs to.
  48665. */
  48666. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48667. /**
  48668. * Binds the material data.
  48669. * @param uniformBuffer defines the Uniform buffer to fill in.
  48670. * @param scene defines the scene the material belongs to.
  48671. * @param isFrozen defines wether the material is frozen or not.
  48672. */
  48673. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48674. /**
  48675. * Checks to see if a texture is used in the material.
  48676. * @param texture - Base texture to use.
  48677. * @returns - Boolean specifying if a texture is used in the material.
  48678. */
  48679. hasTexture(texture: BaseTexture): boolean;
  48680. /**
  48681. * Returns an array of the actively used textures.
  48682. * @param activeTextures Array of BaseTextures
  48683. */
  48684. getActiveTextures(activeTextures: BaseTexture[]): void;
  48685. /**
  48686. * Returns the animatable textures.
  48687. * @param animatables Array of animatable textures.
  48688. */
  48689. getAnimatables(animatables: IAnimatable[]): void;
  48690. /**
  48691. * Disposes the resources of the material.
  48692. * @param forceDisposeTextures - Forces the disposal of all textures.
  48693. */
  48694. dispose(forceDisposeTextures?: boolean): void;
  48695. /**
  48696. * Get the current class name of the texture useful for serialization or dynamic coding.
  48697. * @returns "PBRAnisotropicConfiguration"
  48698. */
  48699. getClassName(): string;
  48700. /**
  48701. * Add fallbacks to the effect fallbacks list.
  48702. * @param defines defines the Base texture to use.
  48703. * @param fallbacks defines the current fallback list.
  48704. * @param currentRank defines the current fallback rank.
  48705. * @returns the new fallback rank.
  48706. */
  48707. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48708. /**
  48709. * Add the required uniforms to the current list.
  48710. * @param uniforms defines the current uniform list.
  48711. */
  48712. static AddUniforms(uniforms: string[]): void;
  48713. /**
  48714. * Add the required uniforms to the current buffer.
  48715. * @param uniformBuffer defines the current uniform buffer.
  48716. */
  48717. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48718. /**
  48719. * Add the required samplers to the current list.
  48720. * @param samplers defines the current sampler list.
  48721. */
  48722. static AddSamplers(samplers: string[]): void;
  48723. /**
  48724. * Makes a duplicate of the current configuration into another one.
  48725. * @param anisotropicConfiguration define the config where to copy the info
  48726. */
  48727. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48728. /**
  48729. * Serializes this anisotropy configuration.
  48730. * @returns - An object with the serialized config.
  48731. */
  48732. serialize(): any;
  48733. /**
  48734. * Parses a anisotropy Configuration from a serialized object.
  48735. * @param source - Serialized object.
  48736. * @param scene Defines the scene we are parsing for
  48737. * @param rootUrl Defines the rootUrl to load from
  48738. */
  48739. parse(source: any, scene: Scene, rootUrl: string): void;
  48740. }
  48741. }
  48742. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48743. import { Scene } from "babylonjs/scene";
  48744. /**
  48745. * @hidden
  48746. */
  48747. export interface IMaterialBRDFDefines {
  48748. BRDF_V_HEIGHT_CORRELATED: boolean;
  48749. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48750. SPHERICAL_HARMONICS: boolean;
  48751. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48752. /** @hidden */
  48753. _areMiscDirty: boolean;
  48754. }
  48755. /**
  48756. * Define the code related to the BRDF parameters of the pbr material.
  48757. */
  48758. export class PBRBRDFConfiguration {
  48759. /**
  48760. * Default value used for the energy conservation.
  48761. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48762. */
  48763. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48764. /**
  48765. * Default value used for the Smith Visibility Height Correlated mode.
  48766. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48767. */
  48768. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48769. /**
  48770. * Default value used for the IBL diffuse part.
  48771. * This can help switching back to the polynomials mode globally which is a tiny bit
  48772. * less GPU intensive at the drawback of a lower quality.
  48773. */
  48774. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48775. /**
  48776. * Default value used for activating energy conservation for the specular workflow.
  48777. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48778. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48779. */
  48780. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48781. private _useEnergyConservation;
  48782. /**
  48783. * Defines if the material uses energy conservation.
  48784. */
  48785. useEnergyConservation: boolean;
  48786. private _useSmithVisibilityHeightCorrelated;
  48787. /**
  48788. * LEGACY Mode set to false
  48789. * Defines if the material uses height smith correlated visibility term.
  48790. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48791. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48792. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48793. * Not relying on height correlated will also disable energy conservation.
  48794. */
  48795. useSmithVisibilityHeightCorrelated: boolean;
  48796. private _useSphericalHarmonics;
  48797. /**
  48798. * LEGACY Mode set to false
  48799. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48800. * diffuse part of the IBL.
  48801. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48802. * to the ground truth.
  48803. */
  48804. useSphericalHarmonics: boolean;
  48805. private _useSpecularGlossinessInputEnergyConservation;
  48806. /**
  48807. * Defines if the material uses energy conservation, when the specular workflow is active.
  48808. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48809. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48810. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48811. */
  48812. useSpecularGlossinessInputEnergyConservation: boolean;
  48813. /** @hidden */
  48814. private _internalMarkAllSubMeshesAsMiscDirty;
  48815. /** @hidden */
  48816. _markAllSubMeshesAsMiscDirty(): void;
  48817. /**
  48818. * Instantiate a new istance of clear coat configuration.
  48819. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48820. */
  48821. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48822. /**
  48823. * Checks to see if a texture is used in the material.
  48824. * @param defines the list of "defines" to update.
  48825. */
  48826. prepareDefines(defines: IMaterialBRDFDefines): void;
  48827. /**
  48828. * Get the current class name of the texture useful for serialization or dynamic coding.
  48829. * @returns "PBRClearCoatConfiguration"
  48830. */
  48831. getClassName(): string;
  48832. /**
  48833. * Makes a duplicate of the current configuration into another one.
  48834. * @param brdfConfiguration define the config where to copy the info
  48835. */
  48836. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48837. /**
  48838. * Serializes this BRDF configuration.
  48839. * @returns - An object with the serialized config.
  48840. */
  48841. serialize(): any;
  48842. /**
  48843. * Parses a anisotropy Configuration from a serialized object.
  48844. * @param source - Serialized object.
  48845. * @param scene Defines the scene we are parsing for
  48846. * @param rootUrl Defines the rootUrl to load from
  48847. */
  48848. parse(source: any, scene: Scene, rootUrl: string): void;
  48849. }
  48850. }
  48851. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48852. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48853. import { Color3 } from "babylonjs/Maths/math.color";
  48854. import { Scene } from "babylonjs/scene";
  48855. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48856. import { Nullable } from "babylonjs/types";
  48857. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48858. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48859. /**
  48860. * @hidden
  48861. */
  48862. export interface IMaterialSheenDefines {
  48863. SHEEN: boolean;
  48864. SHEEN_TEXTURE: boolean;
  48865. SHEEN_TEXTUREDIRECTUV: number;
  48866. SHEEN_LINKWITHALBEDO: boolean;
  48867. /** @hidden */
  48868. _areTexturesDirty: boolean;
  48869. }
  48870. /**
  48871. * Define the code related to the Sheen parameters of the pbr material.
  48872. */
  48873. export class PBRSheenConfiguration {
  48874. private _isEnabled;
  48875. /**
  48876. * Defines if the material uses sheen.
  48877. */
  48878. isEnabled: boolean;
  48879. private _linkSheenWithAlbedo;
  48880. /**
  48881. * Defines if the sheen is linked to the sheen color.
  48882. */
  48883. linkSheenWithAlbedo: boolean;
  48884. /**
  48885. * Defines the sheen intensity.
  48886. */
  48887. intensity: number;
  48888. /**
  48889. * Defines the sheen color.
  48890. */
  48891. color: Color3;
  48892. private _texture;
  48893. /**
  48894. * Stores the sheen tint values in a texture.
  48895. * rgb is tint
  48896. * a is a intensity
  48897. */
  48898. texture: Nullable<BaseTexture>;
  48899. /** @hidden */
  48900. private _internalMarkAllSubMeshesAsTexturesDirty;
  48901. /** @hidden */
  48902. _markAllSubMeshesAsTexturesDirty(): void;
  48903. /**
  48904. * Instantiate a new istance of clear coat configuration.
  48905. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48906. */
  48907. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48908. /**
  48909. * Specifies that the submesh is ready to be used.
  48910. * @param defines the list of "defines" to update.
  48911. * @param scene defines the scene the material belongs to.
  48912. * @returns - boolean indicating that the submesh is ready or not.
  48913. */
  48914. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48915. /**
  48916. * Checks to see if a texture is used in the material.
  48917. * @param defines the list of "defines" to update.
  48918. * @param scene defines the scene the material belongs to.
  48919. */
  48920. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48921. /**
  48922. * Binds the material data.
  48923. * @param uniformBuffer defines the Uniform buffer to fill in.
  48924. * @param scene defines the scene the material belongs to.
  48925. * @param isFrozen defines wether the material is frozen or not.
  48926. */
  48927. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48928. /**
  48929. * Checks to see if a texture is used in the material.
  48930. * @param texture - Base texture to use.
  48931. * @returns - Boolean specifying if a texture is used in the material.
  48932. */
  48933. hasTexture(texture: BaseTexture): boolean;
  48934. /**
  48935. * Returns an array of the actively used textures.
  48936. * @param activeTextures Array of BaseTextures
  48937. */
  48938. getActiveTextures(activeTextures: BaseTexture[]): void;
  48939. /**
  48940. * Returns the animatable textures.
  48941. * @param animatables Array of animatable textures.
  48942. */
  48943. getAnimatables(animatables: IAnimatable[]): void;
  48944. /**
  48945. * Disposes the resources of the material.
  48946. * @param forceDisposeTextures - Forces the disposal of all textures.
  48947. */
  48948. dispose(forceDisposeTextures?: boolean): void;
  48949. /**
  48950. * Get the current class name of the texture useful for serialization or dynamic coding.
  48951. * @returns "PBRSheenConfiguration"
  48952. */
  48953. getClassName(): string;
  48954. /**
  48955. * Add fallbacks to the effect fallbacks list.
  48956. * @param defines defines the Base texture to use.
  48957. * @param fallbacks defines the current fallback list.
  48958. * @param currentRank defines the current fallback rank.
  48959. * @returns the new fallback rank.
  48960. */
  48961. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48962. /**
  48963. * Add the required uniforms to the current list.
  48964. * @param uniforms defines the current uniform list.
  48965. */
  48966. static AddUniforms(uniforms: string[]): void;
  48967. /**
  48968. * Add the required uniforms to the current buffer.
  48969. * @param uniformBuffer defines the current uniform buffer.
  48970. */
  48971. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48972. /**
  48973. * Add the required samplers to the current list.
  48974. * @param samplers defines the current sampler list.
  48975. */
  48976. static AddSamplers(samplers: string[]): void;
  48977. /**
  48978. * Makes a duplicate of the current configuration into another one.
  48979. * @param sheenConfiguration define the config where to copy the info
  48980. */
  48981. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48982. /**
  48983. * Serializes this BRDF configuration.
  48984. * @returns - An object with the serialized config.
  48985. */
  48986. serialize(): any;
  48987. /**
  48988. * Parses a anisotropy Configuration from a serialized object.
  48989. * @param source - Serialized object.
  48990. * @param scene Defines the scene we are parsing for
  48991. * @param rootUrl Defines the rootUrl to load from
  48992. */
  48993. parse(source: any, scene: Scene, rootUrl: string): void;
  48994. }
  48995. }
  48996. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48997. import { Nullable } from "babylonjs/types";
  48998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48999. import { Color3 } from "babylonjs/Maths/math.color";
  49000. import { SmartArray } from "babylonjs/Misc/smartArray";
  49001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49003. import { Effect } from "babylonjs/Materials/effect";
  49004. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49005. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49006. import { Engine } from "babylonjs/Engines/engine";
  49007. import { Scene } from "babylonjs/scene";
  49008. /**
  49009. * @hidden
  49010. */
  49011. export interface IMaterialSubSurfaceDefines {
  49012. SUBSURFACE: boolean;
  49013. SS_REFRACTION: boolean;
  49014. SS_TRANSLUCENCY: boolean;
  49015. SS_SCATERRING: boolean;
  49016. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49017. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49018. SS_REFRACTIONMAP_3D: boolean;
  49019. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49020. SS_LODINREFRACTIONALPHA: boolean;
  49021. SS_GAMMAREFRACTION: boolean;
  49022. SS_RGBDREFRACTION: boolean;
  49023. SS_LINEARSPECULARREFRACTION: boolean;
  49024. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49025. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49026. /** @hidden */
  49027. _areTexturesDirty: boolean;
  49028. }
  49029. /**
  49030. * Define the code related to the sub surface parameters of the pbr material.
  49031. */
  49032. export class PBRSubSurfaceConfiguration {
  49033. private _isRefractionEnabled;
  49034. /**
  49035. * Defines if the refraction is enabled in the material.
  49036. */
  49037. isRefractionEnabled: boolean;
  49038. private _isTranslucencyEnabled;
  49039. /**
  49040. * Defines if the translucency is enabled in the material.
  49041. */
  49042. isTranslucencyEnabled: boolean;
  49043. private _isScatteringEnabled;
  49044. /**
  49045. * Defines the refraction intensity of the material.
  49046. * The refraction when enabled replaces the Diffuse part of the material.
  49047. * The intensity helps transitionning between diffuse and refraction.
  49048. */
  49049. refractionIntensity: number;
  49050. /**
  49051. * Defines the translucency intensity of the material.
  49052. * When translucency has been enabled, this defines how much of the "translucency"
  49053. * is addded to the diffuse part of the material.
  49054. */
  49055. translucencyIntensity: number;
  49056. /**
  49057. * Defines the scattering intensity of the material.
  49058. * When scattering has been enabled, this defines how much of the "scattered light"
  49059. * is addded to the diffuse part of the material.
  49060. */
  49061. scatteringIntensity: number;
  49062. private _thicknessTexture;
  49063. /**
  49064. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49065. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49066. * 0 would mean minimumThickness
  49067. * 1 would mean maximumThickness
  49068. * The other channels might be use as a mask to vary the different effects intensity.
  49069. */
  49070. thicknessTexture: Nullable<BaseTexture>;
  49071. private _refractionTexture;
  49072. /**
  49073. * Defines the texture to use for refraction.
  49074. */
  49075. refractionTexture: Nullable<BaseTexture>;
  49076. private _indexOfRefraction;
  49077. /**
  49078. * Defines the index of refraction used in the material.
  49079. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49080. */
  49081. indexOfRefraction: number;
  49082. private _invertRefractionY;
  49083. /**
  49084. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49085. */
  49086. invertRefractionY: boolean;
  49087. private _linkRefractionWithTransparency;
  49088. /**
  49089. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49090. * Materials half opaque for instance using refraction could benefit from this control.
  49091. */
  49092. linkRefractionWithTransparency: boolean;
  49093. /**
  49094. * Defines the minimum thickness stored in the thickness map.
  49095. * If no thickness map is defined, this value will be used to simulate thickness.
  49096. */
  49097. minimumThickness: number;
  49098. /**
  49099. * Defines the maximum thickness stored in the thickness map.
  49100. */
  49101. maximumThickness: number;
  49102. /**
  49103. * Defines the volume tint of the material.
  49104. * This is used for both translucency and scattering.
  49105. */
  49106. tintColor: Color3;
  49107. /**
  49108. * Defines the distance at which the tint color should be found in the media.
  49109. * This is used for refraction only.
  49110. */
  49111. tintColorAtDistance: number;
  49112. /**
  49113. * Defines how far each channel transmit through the media.
  49114. * It is defined as a color to simplify it selection.
  49115. */
  49116. diffusionDistance: Color3;
  49117. private _useMaskFromThicknessTexture;
  49118. /**
  49119. * Stores the intensity of the different subsurface effects in the thickness texture.
  49120. * * the green channel is the translucency intensity.
  49121. * * the blue channel is the scattering intensity.
  49122. * * the alpha channel is the refraction intensity.
  49123. */
  49124. useMaskFromThicknessTexture: boolean;
  49125. /** @hidden */
  49126. private _internalMarkAllSubMeshesAsTexturesDirty;
  49127. /** @hidden */
  49128. _markAllSubMeshesAsTexturesDirty(): void;
  49129. /**
  49130. * Instantiate a new istance of sub surface configuration.
  49131. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49132. */
  49133. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49134. /**
  49135. * Gets wehter the submesh is ready to be used or not.
  49136. * @param defines the list of "defines" to update.
  49137. * @param scene defines the scene the material belongs to.
  49138. * @returns - boolean indicating that the submesh is ready or not.
  49139. */
  49140. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49141. /**
  49142. * Checks to see if a texture is used in the material.
  49143. * @param defines the list of "defines" to update.
  49144. * @param scene defines the scene to the material belongs to.
  49145. */
  49146. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49147. /**
  49148. * Binds the material data.
  49149. * @param uniformBuffer defines the Uniform buffer to fill in.
  49150. * @param scene defines the scene the material belongs to.
  49151. * @param engine defines the engine the material belongs to.
  49152. * @param isFrozen defines wether the material is frozen or not.
  49153. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49154. */
  49155. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49156. /**
  49157. * Unbinds the material from the mesh.
  49158. * @param activeEffect defines the effect that should be unbound from.
  49159. * @returns true if unbound, otherwise false
  49160. */
  49161. unbind(activeEffect: Effect): boolean;
  49162. /**
  49163. * Returns the texture used for refraction or null if none is used.
  49164. * @param scene defines the scene the material belongs to.
  49165. * @returns - Refraction texture if present. If no refraction texture and refraction
  49166. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49167. */
  49168. private _getRefractionTexture;
  49169. /**
  49170. * Returns true if alpha blending should be disabled.
  49171. */
  49172. readonly disableAlphaBlending: boolean;
  49173. /**
  49174. * Fills the list of render target textures.
  49175. * @param renderTargets the list of render targets to update
  49176. */
  49177. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49178. /**
  49179. * Checks to see if a texture is used in the material.
  49180. * @param texture - Base texture to use.
  49181. * @returns - Boolean specifying if a texture is used in the material.
  49182. */
  49183. hasTexture(texture: BaseTexture): boolean;
  49184. /**
  49185. * Gets a boolean indicating that current material needs to register RTT
  49186. * @returns true if this uses a render target otherwise false.
  49187. */
  49188. hasRenderTargetTextures(): boolean;
  49189. /**
  49190. * Returns an array of the actively used textures.
  49191. * @param activeTextures Array of BaseTextures
  49192. */
  49193. getActiveTextures(activeTextures: BaseTexture[]): void;
  49194. /**
  49195. * Returns the animatable textures.
  49196. * @param animatables Array of animatable textures.
  49197. */
  49198. getAnimatables(animatables: IAnimatable[]): void;
  49199. /**
  49200. * Disposes the resources of the material.
  49201. * @param forceDisposeTextures - Forces the disposal of all textures.
  49202. */
  49203. dispose(forceDisposeTextures?: boolean): void;
  49204. /**
  49205. * Get the current class name of the texture useful for serialization or dynamic coding.
  49206. * @returns "PBRSubSurfaceConfiguration"
  49207. */
  49208. getClassName(): string;
  49209. /**
  49210. * Add fallbacks to the effect fallbacks list.
  49211. * @param defines defines the Base texture to use.
  49212. * @param fallbacks defines the current fallback list.
  49213. * @param currentRank defines the current fallback rank.
  49214. * @returns the new fallback rank.
  49215. */
  49216. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49217. /**
  49218. * Add the required uniforms to the current list.
  49219. * @param uniforms defines the current uniform list.
  49220. */
  49221. static AddUniforms(uniforms: string[]): void;
  49222. /**
  49223. * Add the required samplers to the current list.
  49224. * @param samplers defines the current sampler list.
  49225. */
  49226. static AddSamplers(samplers: string[]): void;
  49227. /**
  49228. * Add the required uniforms to the current buffer.
  49229. * @param uniformBuffer defines the current uniform buffer.
  49230. */
  49231. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49232. /**
  49233. * Makes a duplicate of the current configuration into another one.
  49234. * @param configuration define the config where to copy the info
  49235. */
  49236. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49237. /**
  49238. * Serializes this Sub Surface configuration.
  49239. * @returns - An object with the serialized config.
  49240. */
  49241. serialize(): any;
  49242. /**
  49243. * Parses a anisotropy Configuration from a serialized object.
  49244. * @param source - Serialized object.
  49245. * @param scene Defines the scene we are parsing for
  49246. * @param rootUrl Defines the rootUrl to load from
  49247. */
  49248. parse(source: any, scene: Scene, rootUrl: string): void;
  49249. }
  49250. }
  49251. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49252. /** @hidden */
  49253. export var pbrFragmentDeclaration: {
  49254. name: string;
  49255. shader: string;
  49256. };
  49257. }
  49258. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49259. /** @hidden */
  49260. export var pbrUboDeclaration: {
  49261. name: string;
  49262. shader: string;
  49263. };
  49264. }
  49265. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49266. /** @hidden */
  49267. export var pbrFragmentExtraDeclaration: {
  49268. name: string;
  49269. shader: string;
  49270. };
  49271. }
  49272. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49273. /** @hidden */
  49274. export var pbrFragmentSamplersDeclaration: {
  49275. name: string;
  49276. shader: string;
  49277. };
  49278. }
  49279. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49280. /** @hidden */
  49281. export var pbrHelperFunctions: {
  49282. name: string;
  49283. shader: string;
  49284. };
  49285. }
  49286. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49287. /** @hidden */
  49288. export var harmonicsFunctions: {
  49289. name: string;
  49290. shader: string;
  49291. };
  49292. }
  49293. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49294. /** @hidden */
  49295. export var pbrDirectLightingSetupFunctions: {
  49296. name: string;
  49297. shader: string;
  49298. };
  49299. }
  49300. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49301. /** @hidden */
  49302. export var pbrDirectLightingFalloffFunctions: {
  49303. name: string;
  49304. shader: string;
  49305. };
  49306. }
  49307. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49308. /** @hidden */
  49309. export var pbrBRDFFunctions: {
  49310. name: string;
  49311. shader: string;
  49312. };
  49313. }
  49314. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49315. /** @hidden */
  49316. export var pbrDirectLightingFunctions: {
  49317. name: string;
  49318. shader: string;
  49319. };
  49320. }
  49321. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49322. /** @hidden */
  49323. export var pbrIBLFunctions: {
  49324. name: string;
  49325. shader: string;
  49326. };
  49327. }
  49328. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49329. /** @hidden */
  49330. export var pbrDebug: {
  49331. name: string;
  49332. shader: string;
  49333. };
  49334. }
  49335. declare module "babylonjs/Shaders/pbr.fragment" {
  49336. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49337. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49338. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49339. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49340. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49341. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49342. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49343. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49344. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49345. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49346. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49347. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49348. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49349. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49350. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49351. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49352. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49353. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49354. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49355. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49356. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49357. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49359. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49360. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49361. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49362. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49363. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49364. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49365. /** @hidden */
  49366. export var pbrPixelShader: {
  49367. name: string;
  49368. shader: string;
  49369. };
  49370. }
  49371. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49372. /** @hidden */
  49373. export var pbrVertexDeclaration: {
  49374. name: string;
  49375. shader: string;
  49376. };
  49377. }
  49378. declare module "babylonjs/Shaders/pbr.vertex" {
  49379. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49380. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49382. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49383. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49384. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49385. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49387. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49388. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49389. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49392. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49396. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49398. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49399. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49400. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49401. /** @hidden */
  49402. export var pbrVertexShader: {
  49403. name: string;
  49404. shader: string;
  49405. };
  49406. }
  49407. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49408. import { Nullable } from "babylonjs/types";
  49409. import { Scene } from "babylonjs/scene";
  49410. import { Matrix } from "babylonjs/Maths/math.vector";
  49411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49413. import { Mesh } from "babylonjs/Meshes/mesh";
  49414. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49415. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49416. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49417. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49418. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49419. import { Color3 } from "babylonjs/Maths/math.color";
  49420. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49421. import { Material } from "babylonjs/Materials/material";
  49422. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49423. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49425. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49426. import "babylonjs/Shaders/pbr.fragment";
  49427. import "babylonjs/Shaders/pbr.vertex";
  49428. /**
  49429. * Manages the defines for the PBR Material.
  49430. * @hidden
  49431. */
  49432. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49433. PBR: boolean;
  49434. MAINUV1: boolean;
  49435. MAINUV2: boolean;
  49436. UV1: boolean;
  49437. UV2: boolean;
  49438. ALBEDO: boolean;
  49439. ALBEDODIRECTUV: number;
  49440. VERTEXCOLOR: boolean;
  49441. AMBIENT: boolean;
  49442. AMBIENTDIRECTUV: number;
  49443. AMBIENTINGRAYSCALE: boolean;
  49444. OPACITY: boolean;
  49445. VERTEXALPHA: boolean;
  49446. OPACITYDIRECTUV: number;
  49447. OPACITYRGB: boolean;
  49448. ALPHATEST: boolean;
  49449. DEPTHPREPASS: boolean;
  49450. ALPHABLEND: boolean;
  49451. ALPHAFROMALBEDO: boolean;
  49452. ALPHATESTVALUE: string;
  49453. SPECULAROVERALPHA: boolean;
  49454. RADIANCEOVERALPHA: boolean;
  49455. ALPHAFRESNEL: boolean;
  49456. LINEARALPHAFRESNEL: boolean;
  49457. PREMULTIPLYALPHA: boolean;
  49458. EMISSIVE: boolean;
  49459. EMISSIVEDIRECTUV: number;
  49460. REFLECTIVITY: boolean;
  49461. REFLECTIVITYDIRECTUV: number;
  49462. SPECULARTERM: boolean;
  49463. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49464. MICROSURFACEAUTOMATIC: boolean;
  49465. LODBASEDMICROSFURACE: boolean;
  49466. MICROSURFACEMAP: boolean;
  49467. MICROSURFACEMAPDIRECTUV: number;
  49468. METALLICWORKFLOW: boolean;
  49469. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49470. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49471. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49472. AOSTOREINMETALMAPRED: boolean;
  49473. ENVIRONMENTBRDF: boolean;
  49474. ENVIRONMENTBRDF_RGBD: boolean;
  49475. NORMAL: boolean;
  49476. TANGENT: boolean;
  49477. BUMP: boolean;
  49478. BUMPDIRECTUV: number;
  49479. OBJECTSPACE_NORMALMAP: boolean;
  49480. PARALLAX: boolean;
  49481. PARALLAXOCCLUSION: boolean;
  49482. NORMALXYSCALE: boolean;
  49483. LIGHTMAP: boolean;
  49484. LIGHTMAPDIRECTUV: number;
  49485. USELIGHTMAPASSHADOWMAP: boolean;
  49486. GAMMALIGHTMAP: boolean;
  49487. RGBDLIGHTMAP: boolean;
  49488. REFLECTION: boolean;
  49489. REFLECTIONMAP_3D: boolean;
  49490. REFLECTIONMAP_SPHERICAL: boolean;
  49491. REFLECTIONMAP_PLANAR: boolean;
  49492. REFLECTIONMAP_CUBIC: boolean;
  49493. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49494. REFLECTIONMAP_PROJECTION: boolean;
  49495. REFLECTIONMAP_SKYBOX: boolean;
  49496. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49497. REFLECTIONMAP_EXPLICIT: boolean;
  49498. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49499. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49500. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49501. INVERTCUBICMAP: boolean;
  49502. USESPHERICALFROMREFLECTIONMAP: boolean;
  49503. USEIRRADIANCEMAP: boolean;
  49504. SPHERICAL_HARMONICS: boolean;
  49505. USESPHERICALINVERTEX: boolean;
  49506. REFLECTIONMAP_OPPOSITEZ: boolean;
  49507. LODINREFLECTIONALPHA: boolean;
  49508. GAMMAREFLECTION: boolean;
  49509. RGBDREFLECTION: boolean;
  49510. LINEARSPECULARREFLECTION: boolean;
  49511. RADIANCEOCCLUSION: boolean;
  49512. HORIZONOCCLUSION: boolean;
  49513. INSTANCES: boolean;
  49514. NUM_BONE_INFLUENCERS: number;
  49515. BonesPerMesh: number;
  49516. BONETEXTURE: boolean;
  49517. NONUNIFORMSCALING: boolean;
  49518. MORPHTARGETS: boolean;
  49519. MORPHTARGETS_NORMAL: boolean;
  49520. MORPHTARGETS_TANGENT: boolean;
  49521. MORPHTARGETS_UV: boolean;
  49522. NUM_MORPH_INFLUENCERS: number;
  49523. IMAGEPROCESSING: boolean;
  49524. VIGNETTE: boolean;
  49525. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49526. VIGNETTEBLENDMODEOPAQUE: boolean;
  49527. TONEMAPPING: boolean;
  49528. TONEMAPPING_ACES: boolean;
  49529. CONTRAST: boolean;
  49530. COLORCURVES: boolean;
  49531. COLORGRADING: boolean;
  49532. COLORGRADING3D: boolean;
  49533. SAMPLER3DGREENDEPTH: boolean;
  49534. SAMPLER3DBGRMAP: boolean;
  49535. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49536. EXPOSURE: boolean;
  49537. MULTIVIEW: boolean;
  49538. USEPHYSICALLIGHTFALLOFF: boolean;
  49539. USEGLTFLIGHTFALLOFF: boolean;
  49540. TWOSIDEDLIGHTING: boolean;
  49541. SHADOWFLOAT: boolean;
  49542. CLIPPLANE: boolean;
  49543. CLIPPLANE2: boolean;
  49544. CLIPPLANE3: boolean;
  49545. CLIPPLANE4: boolean;
  49546. POINTSIZE: boolean;
  49547. FOG: boolean;
  49548. LOGARITHMICDEPTH: boolean;
  49549. FORCENORMALFORWARD: boolean;
  49550. SPECULARAA: boolean;
  49551. CLEARCOAT: boolean;
  49552. CLEARCOAT_DEFAULTIOR: boolean;
  49553. CLEARCOAT_TEXTURE: boolean;
  49554. CLEARCOAT_TEXTUREDIRECTUV: number;
  49555. CLEARCOAT_BUMP: boolean;
  49556. CLEARCOAT_BUMPDIRECTUV: number;
  49557. CLEARCOAT_TINT: boolean;
  49558. CLEARCOAT_TINT_TEXTURE: boolean;
  49559. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49560. ANISOTROPIC: boolean;
  49561. ANISOTROPIC_TEXTURE: boolean;
  49562. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49563. BRDF_V_HEIGHT_CORRELATED: boolean;
  49564. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49565. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49566. SHEEN: boolean;
  49567. SHEEN_TEXTURE: boolean;
  49568. SHEEN_TEXTUREDIRECTUV: number;
  49569. SHEEN_LINKWITHALBEDO: boolean;
  49570. SUBSURFACE: boolean;
  49571. SS_REFRACTION: boolean;
  49572. SS_TRANSLUCENCY: boolean;
  49573. SS_SCATERRING: boolean;
  49574. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49575. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49576. SS_REFRACTIONMAP_3D: boolean;
  49577. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49578. SS_LODINREFRACTIONALPHA: boolean;
  49579. SS_GAMMAREFRACTION: boolean;
  49580. SS_RGBDREFRACTION: boolean;
  49581. SS_LINEARSPECULARREFRACTION: boolean;
  49582. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49583. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49584. UNLIT: boolean;
  49585. DEBUGMODE: number;
  49586. /**
  49587. * Initializes the PBR Material defines.
  49588. */
  49589. constructor();
  49590. /**
  49591. * Resets the PBR Material defines.
  49592. */
  49593. reset(): void;
  49594. }
  49595. /**
  49596. * The Physically based material base class of BJS.
  49597. *
  49598. * This offers the main features of a standard PBR material.
  49599. * For more information, please refer to the documentation :
  49600. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49601. */
  49602. export abstract class PBRBaseMaterial extends PushMaterial {
  49603. /**
  49604. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49605. */
  49606. static readonly PBRMATERIAL_OPAQUE: number;
  49607. /**
  49608. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49609. */
  49610. static readonly PBRMATERIAL_ALPHATEST: number;
  49611. /**
  49612. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49613. */
  49614. static readonly PBRMATERIAL_ALPHABLEND: number;
  49615. /**
  49616. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49617. * They are also discarded below the alpha cutoff threshold to improve performances.
  49618. */
  49619. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49620. /**
  49621. * Defines the default value of how much AO map is occluding the analytical lights
  49622. * (point spot...).
  49623. */
  49624. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49625. /**
  49626. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49627. */
  49628. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49629. /**
  49630. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49631. * to enhance interoperability with other engines.
  49632. */
  49633. static readonly LIGHTFALLOFF_GLTF: number;
  49634. /**
  49635. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49636. * to enhance interoperability with other materials.
  49637. */
  49638. static readonly LIGHTFALLOFF_STANDARD: number;
  49639. /**
  49640. * Intensity of the direct lights e.g. the four lights available in your scene.
  49641. * This impacts both the direct diffuse and specular highlights.
  49642. */
  49643. protected _directIntensity: number;
  49644. /**
  49645. * Intensity of the emissive part of the material.
  49646. * This helps controlling the emissive effect without modifying the emissive color.
  49647. */
  49648. protected _emissiveIntensity: number;
  49649. /**
  49650. * Intensity of the environment e.g. how much the environment will light the object
  49651. * either through harmonics for rough material or through the refelction for shiny ones.
  49652. */
  49653. protected _environmentIntensity: number;
  49654. /**
  49655. * This is a special control allowing the reduction of the specular highlights coming from the
  49656. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49657. */
  49658. protected _specularIntensity: number;
  49659. /**
  49660. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49661. */
  49662. private _lightingInfos;
  49663. /**
  49664. * Debug Control allowing disabling the bump map on this material.
  49665. */
  49666. protected _disableBumpMap: boolean;
  49667. /**
  49668. * AKA Diffuse Texture in standard nomenclature.
  49669. */
  49670. protected _albedoTexture: Nullable<BaseTexture>;
  49671. /**
  49672. * AKA Occlusion Texture in other nomenclature.
  49673. */
  49674. protected _ambientTexture: Nullable<BaseTexture>;
  49675. /**
  49676. * AKA Occlusion Texture Intensity in other nomenclature.
  49677. */
  49678. protected _ambientTextureStrength: number;
  49679. /**
  49680. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49681. * 1 means it completely occludes it
  49682. * 0 mean it has no impact
  49683. */
  49684. protected _ambientTextureImpactOnAnalyticalLights: number;
  49685. /**
  49686. * Stores the alpha values in a texture.
  49687. */
  49688. protected _opacityTexture: Nullable<BaseTexture>;
  49689. /**
  49690. * Stores the reflection values in a texture.
  49691. */
  49692. protected _reflectionTexture: Nullable<BaseTexture>;
  49693. /**
  49694. * Stores the emissive values in a texture.
  49695. */
  49696. protected _emissiveTexture: Nullable<BaseTexture>;
  49697. /**
  49698. * AKA Specular texture in other nomenclature.
  49699. */
  49700. protected _reflectivityTexture: Nullable<BaseTexture>;
  49701. /**
  49702. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49703. */
  49704. protected _metallicTexture: Nullable<BaseTexture>;
  49705. /**
  49706. * Specifies the metallic scalar of the metallic/roughness workflow.
  49707. * Can also be used to scale the metalness values of the metallic texture.
  49708. */
  49709. protected _metallic: Nullable<number>;
  49710. /**
  49711. * Specifies the roughness scalar of the metallic/roughness workflow.
  49712. * Can also be used to scale the roughness values of the metallic texture.
  49713. */
  49714. protected _roughness: Nullable<number>;
  49715. /**
  49716. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49717. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49718. */
  49719. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49720. /**
  49721. * Stores surface normal data used to displace a mesh in a texture.
  49722. */
  49723. protected _bumpTexture: Nullable<BaseTexture>;
  49724. /**
  49725. * Stores the pre-calculated light information of a mesh in a texture.
  49726. */
  49727. protected _lightmapTexture: Nullable<BaseTexture>;
  49728. /**
  49729. * The color of a material in ambient lighting.
  49730. */
  49731. protected _ambientColor: Color3;
  49732. /**
  49733. * AKA Diffuse Color in other nomenclature.
  49734. */
  49735. protected _albedoColor: Color3;
  49736. /**
  49737. * AKA Specular Color in other nomenclature.
  49738. */
  49739. protected _reflectivityColor: Color3;
  49740. /**
  49741. * The color applied when light is reflected from a material.
  49742. */
  49743. protected _reflectionColor: Color3;
  49744. /**
  49745. * The color applied when light is emitted from a material.
  49746. */
  49747. protected _emissiveColor: Color3;
  49748. /**
  49749. * AKA Glossiness in other nomenclature.
  49750. */
  49751. protected _microSurface: number;
  49752. /**
  49753. * Specifies that the material will use the light map as a show map.
  49754. */
  49755. protected _useLightmapAsShadowmap: boolean;
  49756. /**
  49757. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49758. * makes the reflect vector face the model (under horizon).
  49759. */
  49760. protected _useHorizonOcclusion: boolean;
  49761. /**
  49762. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49763. * too much the area relying on ambient texture to define their ambient occlusion.
  49764. */
  49765. protected _useRadianceOcclusion: boolean;
  49766. /**
  49767. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49768. */
  49769. protected _useAlphaFromAlbedoTexture: boolean;
  49770. /**
  49771. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49772. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49773. */
  49774. protected _useSpecularOverAlpha: boolean;
  49775. /**
  49776. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49777. */
  49778. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49779. /**
  49780. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49781. */
  49782. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49783. /**
  49784. * Specifies if the metallic texture contains the roughness information in its green channel.
  49785. */
  49786. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49787. /**
  49788. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49789. */
  49790. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49791. /**
  49792. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49793. */
  49794. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49795. /**
  49796. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49797. */
  49798. protected _useAmbientInGrayScale: boolean;
  49799. /**
  49800. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49801. * The material will try to infer what glossiness each pixel should be.
  49802. */
  49803. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49804. /**
  49805. * Defines the falloff type used in this material.
  49806. * It by default is Physical.
  49807. */
  49808. protected _lightFalloff: number;
  49809. /**
  49810. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49811. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49812. */
  49813. protected _useRadianceOverAlpha: boolean;
  49814. /**
  49815. * Allows using an object space normal map (instead of tangent space).
  49816. */
  49817. protected _useObjectSpaceNormalMap: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax mode.
  49820. */
  49821. protected _useParallax: boolean;
  49822. /**
  49823. * Allows using the bump map in parallax occlusion mode.
  49824. */
  49825. protected _useParallaxOcclusion: boolean;
  49826. /**
  49827. * Controls the scale bias of the parallax mode.
  49828. */
  49829. protected _parallaxScaleBias: number;
  49830. /**
  49831. * If sets to true, disables all the lights affecting the material.
  49832. */
  49833. protected _disableLighting: boolean;
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. protected _maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49840. */
  49841. protected _invertNormalMapX: boolean;
  49842. /**
  49843. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49844. */
  49845. protected _invertNormalMapY: boolean;
  49846. /**
  49847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49848. */
  49849. protected _twoSidedLighting: boolean;
  49850. /**
  49851. * Defines the alpha limits in alpha test mode.
  49852. */
  49853. protected _alphaCutOff: number;
  49854. /**
  49855. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49856. */
  49857. protected _forceAlphaTest: boolean;
  49858. /**
  49859. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49860. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49861. */
  49862. protected _useAlphaFresnel: boolean;
  49863. /**
  49864. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49865. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49866. */
  49867. protected _useLinearAlphaFresnel: boolean;
  49868. /**
  49869. * The transparency mode of the material.
  49870. */
  49871. protected _transparencyMode: Nullable<number>;
  49872. /**
  49873. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49874. * from cos thetav and roughness:
  49875. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49876. */
  49877. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49878. /**
  49879. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49880. */
  49881. protected _forceIrradianceInFragment: boolean;
  49882. /**
  49883. * Force normal to face away from face.
  49884. */
  49885. protected _forceNormalForward: boolean;
  49886. /**
  49887. * Enables specular anti aliasing in the PBR shader.
  49888. * It will both interacts on the Geometry for analytical and IBL lighting.
  49889. * It also prefilter the roughness map based on the bump values.
  49890. */
  49891. protected _enableSpecularAntiAliasing: boolean;
  49892. /**
  49893. * Default configuration related to image processing available in the PBR Material.
  49894. */
  49895. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49896. /**
  49897. * Keep track of the image processing observer to allow dispose and replace.
  49898. */
  49899. private _imageProcessingObserver;
  49900. /**
  49901. * Attaches a new image processing configuration to the PBR Material.
  49902. * @param configuration
  49903. */
  49904. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49905. /**
  49906. * Stores the available render targets.
  49907. */
  49908. private _renderTargets;
  49909. /**
  49910. * Sets the global ambient color for the material used in lighting calculations.
  49911. */
  49912. private _globalAmbientColor;
  49913. /**
  49914. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49915. */
  49916. private _useLogarithmicDepth;
  49917. /**
  49918. * If set to true, no lighting calculations will be applied.
  49919. */
  49920. private _unlit;
  49921. private _debugMode;
  49922. /**
  49923. * @hidden
  49924. * This is reserved for the inspector.
  49925. * Defines the material debug mode.
  49926. * It helps seeing only some components of the material while troubleshooting.
  49927. */
  49928. debugMode: number;
  49929. /**
  49930. * @hidden
  49931. * This is reserved for the inspector.
  49932. * Specify from where on screen the debug mode should start.
  49933. * The value goes from -1 (full screen) to 1 (not visible)
  49934. * It helps with side by side comparison against the final render
  49935. * This defaults to -1
  49936. */
  49937. private debugLimit;
  49938. /**
  49939. * @hidden
  49940. * This is reserved for the inspector.
  49941. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49942. * You can use the factor to better multiply the final value.
  49943. */
  49944. private debugFactor;
  49945. /**
  49946. * Defines the clear coat layer parameters for the material.
  49947. */
  49948. readonly clearCoat: PBRClearCoatConfiguration;
  49949. /**
  49950. * Defines the anisotropic parameters for the material.
  49951. */
  49952. readonly anisotropy: PBRAnisotropicConfiguration;
  49953. /**
  49954. * Defines the BRDF parameters for the material.
  49955. */
  49956. readonly brdf: PBRBRDFConfiguration;
  49957. /**
  49958. * Defines the Sheen parameters for the material.
  49959. */
  49960. readonly sheen: PBRSheenConfiguration;
  49961. /**
  49962. * Defines the SubSurface parameters for the material.
  49963. */
  49964. readonly subSurface: PBRSubSurfaceConfiguration;
  49965. /**
  49966. * Custom callback helping to override the default shader used in the material.
  49967. */
  49968. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49969. protected _rebuildInParallel: boolean;
  49970. /**
  49971. * Instantiates a new PBRMaterial instance.
  49972. *
  49973. * @param name The material name
  49974. * @param scene The scene the material will be use in.
  49975. */
  49976. constructor(name: string, scene: Scene);
  49977. /**
  49978. * Gets a boolean indicating that current material needs to register RTT
  49979. */
  49980. readonly hasRenderTargetTextures: boolean;
  49981. /**
  49982. * Gets the name of the material class.
  49983. */
  49984. getClassName(): string;
  49985. /**
  49986. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49987. */
  49988. /**
  49989. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49990. */
  49991. useLogarithmicDepth: boolean;
  49992. /**
  49993. * Gets the current transparency mode.
  49994. */
  49995. /**
  49996. * Sets the transparency mode of the material.
  49997. *
  49998. * | Value | Type | Description |
  49999. * | ----- | ----------------------------------- | ----------- |
  50000. * | 0 | OPAQUE | |
  50001. * | 1 | ALPHATEST | |
  50002. * | 2 | ALPHABLEND | |
  50003. * | 3 | ALPHATESTANDBLEND | |
  50004. *
  50005. */
  50006. transparencyMode: Nullable<number>;
  50007. /**
  50008. * Returns true if alpha blending should be disabled.
  50009. */
  50010. private readonly _disableAlphaBlending;
  50011. /**
  50012. * Specifies whether or not this material should be rendered in alpha blend mode.
  50013. */
  50014. needAlphaBlending(): boolean;
  50015. /**
  50016. * Specifies if the mesh will require alpha blending.
  50017. * @param mesh - BJS mesh.
  50018. */
  50019. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50020. /**
  50021. * Specifies whether or not this material should be rendered in alpha test mode.
  50022. */
  50023. needAlphaTesting(): boolean;
  50024. /**
  50025. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50026. */
  50027. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50028. /**
  50029. * Gets the texture used for the alpha test.
  50030. */
  50031. getAlphaTestTexture(): Nullable<BaseTexture>;
  50032. /**
  50033. * Specifies that the submesh is ready to be used.
  50034. * @param mesh - BJS mesh.
  50035. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50036. * @param useInstances - Specifies that instances should be used.
  50037. * @returns - boolean indicating that the submesh is ready or not.
  50038. */
  50039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50040. /**
  50041. * Specifies if the material uses metallic roughness workflow.
  50042. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50043. */
  50044. isMetallicWorkflow(): boolean;
  50045. private _prepareEffect;
  50046. private _prepareDefines;
  50047. /**
  50048. * Force shader compilation
  50049. */
  50050. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50051. clipPlane: boolean;
  50052. }>): void;
  50053. /**
  50054. * Initializes the uniform buffer layout for the shader.
  50055. */
  50056. buildUniformLayout(): void;
  50057. /**
  50058. * Unbinds the material from the mesh
  50059. */
  50060. unbind(): void;
  50061. /**
  50062. * Binds the submesh data.
  50063. * @param world - The world matrix.
  50064. * @param mesh - The BJS mesh.
  50065. * @param subMesh - A submesh of the BJS mesh.
  50066. */
  50067. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50068. /**
  50069. * Returns the animatable textures.
  50070. * @returns - Array of animatable textures.
  50071. */
  50072. getAnimatables(): IAnimatable[];
  50073. /**
  50074. * Returns the texture used for reflections.
  50075. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50076. */
  50077. private _getReflectionTexture;
  50078. /**
  50079. * Returns an array of the actively used textures.
  50080. * @returns - Array of BaseTextures
  50081. */
  50082. getActiveTextures(): BaseTexture[];
  50083. /**
  50084. * Checks to see if a texture is used in the material.
  50085. * @param texture - Base texture to use.
  50086. * @returns - Boolean specifying if a texture is used in the material.
  50087. */
  50088. hasTexture(texture: BaseTexture): boolean;
  50089. /**
  50090. * Disposes the resources of the material.
  50091. * @param forceDisposeEffect - Forces the disposal of effects.
  50092. * @param forceDisposeTextures - Forces the disposal of all textures.
  50093. */
  50094. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50095. }
  50096. }
  50097. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50098. import { Nullable } from "babylonjs/types";
  50099. import { Scene } from "babylonjs/scene";
  50100. import { Color3 } from "babylonjs/Maths/math.color";
  50101. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50102. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50104. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50105. /**
  50106. * The Physically based material of BJS.
  50107. *
  50108. * This offers the main features of a standard PBR material.
  50109. * For more information, please refer to the documentation :
  50110. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50111. */
  50112. export class PBRMaterial extends PBRBaseMaterial {
  50113. /**
  50114. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50115. */
  50116. static readonly PBRMATERIAL_OPAQUE: number;
  50117. /**
  50118. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50119. */
  50120. static readonly PBRMATERIAL_ALPHATEST: number;
  50121. /**
  50122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50123. */
  50124. static readonly PBRMATERIAL_ALPHABLEND: number;
  50125. /**
  50126. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50127. * They are also discarded below the alpha cutoff threshold to improve performances.
  50128. */
  50129. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50130. /**
  50131. * Defines the default value of how much AO map is occluding the analytical lights
  50132. * (point spot...).
  50133. */
  50134. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50135. /**
  50136. * Intensity of the direct lights e.g. the four lights available in your scene.
  50137. * This impacts both the direct diffuse and specular highlights.
  50138. */
  50139. directIntensity: number;
  50140. /**
  50141. * Intensity of the emissive part of the material.
  50142. * This helps controlling the emissive effect without modifying the emissive color.
  50143. */
  50144. emissiveIntensity: number;
  50145. /**
  50146. * Intensity of the environment e.g. how much the environment will light the object
  50147. * either through harmonics for rough material or through the refelction for shiny ones.
  50148. */
  50149. environmentIntensity: number;
  50150. /**
  50151. * This is a special control allowing the reduction of the specular highlights coming from the
  50152. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50153. */
  50154. specularIntensity: number;
  50155. /**
  50156. * Debug Control allowing disabling the bump map on this material.
  50157. */
  50158. disableBumpMap: boolean;
  50159. /**
  50160. * AKA Diffuse Texture in standard nomenclature.
  50161. */
  50162. albedoTexture: BaseTexture;
  50163. /**
  50164. * AKA Occlusion Texture in other nomenclature.
  50165. */
  50166. ambientTexture: BaseTexture;
  50167. /**
  50168. * AKA Occlusion Texture Intensity in other nomenclature.
  50169. */
  50170. ambientTextureStrength: number;
  50171. /**
  50172. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50173. * 1 means it completely occludes it
  50174. * 0 mean it has no impact
  50175. */
  50176. ambientTextureImpactOnAnalyticalLights: number;
  50177. /**
  50178. * Stores the alpha values in a texture.
  50179. */
  50180. opacityTexture: BaseTexture;
  50181. /**
  50182. * Stores the reflection values in a texture.
  50183. */
  50184. reflectionTexture: Nullable<BaseTexture>;
  50185. /**
  50186. * Stores the emissive values in a texture.
  50187. */
  50188. emissiveTexture: BaseTexture;
  50189. /**
  50190. * AKA Specular texture in other nomenclature.
  50191. */
  50192. reflectivityTexture: BaseTexture;
  50193. /**
  50194. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50195. */
  50196. metallicTexture: BaseTexture;
  50197. /**
  50198. * Specifies the metallic scalar of the metallic/roughness workflow.
  50199. * Can also be used to scale the metalness values of the metallic texture.
  50200. */
  50201. metallic: Nullable<number>;
  50202. /**
  50203. * Specifies the roughness scalar of the metallic/roughness workflow.
  50204. * Can also be used to scale the roughness values of the metallic texture.
  50205. */
  50206. roughness: Nullable<number>;
  50207. /**
  50208. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50209. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50210. */
  50211. microSurfaceTexture: BaseTexture;
  50212. /**
  50213. * Stores surface normal data used to displace a mesh in a texture.
  50214. */
  50215. bumpTexture: BaseTexture;
  50216. /**
  50217. * Stores the pre-calculated light information of a mesh in a texture.
  50218. */
  50219. lightmapTexture: BaseTexture;
  50220. /**
  50221. * Stores the refracted light information in a texture.
  50222. */
  50223. refractionTexture: Nullable<BaseTexture>;
  50224. /**
  50225. * The color of a material in ambient lighting.
  50226. */
  50227. ambientColor: Color3;
  50228. /**
  50229. * AKA Diffuse Color in other nomenclature.
  50230. */
  50231. albedoColor: Color3;
  50232. /**
  50233. * AKA Specular Color in other nomenclature.
  50234. */
  50235. reflectivityColor: Color3;
  50236. /**
  50237. * The color reflected from the material.
  50238. */
  50239. reflectionColor: Color3;
  50240. /**
  50241. * The color emitted from the material.
  50242. */
  50243. emissiveColor: Color3;
  50244. /**
  50245. * AKA Glossiness in other nomenclature.
  50246. */
  50247. microSurface: number;
  50248. /**
  50249. * source material index of refraction (IOR)' / 'destination material IOR.
  50250. */
  50251. indexOfRefraction: number;
  50252. /**
  50253. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50254. */
  50255. invertRefractionY: boolean;
  50256. /**
  50257. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50258. * Materials half opaque for instance using refraction could benefit from this control.
  50259. */
  50260. linkRefractionWithTransparency: boolean;
  50261. /**
  50262. * If true, the light map contains occlusion information instead of lighting info.
  50263. */
  50264. useLightmapAsShadowmap: boolean;
  50265. /**
  50266. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50267. */
  50268. useAlphaFromAlbedoTexture: boolean;
  50269. /**
  50270. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50271. */
  50272. forceAlphaTest: boolean;
  50273. /**
  50274. * Defines the alpha limits in alpha test mode.
  50275. */
  50276. alphaCutOff: number;
  50277. /**
  50278. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50279. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50280. */
  50281. useSpecularOverAlpha: boolean;
  50282. /**
  50283. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50284. */
  50285. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50286. /**
  50287. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50288. */
  50289. useRoughnessFromMetallicTextureAlpha: boolean;
  50290. /**
  50291. * Specifies if the metallic texture contains the roughness information in its green channel.
  50292. */
  50293. useRoughnessFromMetallicTextureGreen: boolean;
  50294. /**
  50295. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50296. */
  50297. useMetallnessFromMetallicTextureBlue: boolean;
  50298. /**
  50299. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50300. */
  50301. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50302. /**
  50303. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50304. */
  50305. useAmbientInGrayScale: boolean;
  50306. /**
  50307. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50308. * The material will try to infer what glossiness each pixel should be.
  50309. */
  50310. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50311. /**
  50312. * BJS is using an harcoded light falloff based on a manually sets up range.
  50313. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50314. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50315. */
  50316. /**
  50317. * BJS is using an harcoded light falloff based on a manually sets up range.
  50318. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50319. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50320. */
  50321. usePhysicalLightFalloff: boolean;
  50322. /**
  50323. * In order to support the falloff compatibility with gltf, a special mode has been added
  50324. * to reproduce the gltf light falloff.
  50325. */
  50326. /**
  50327. * In order to support the falloff compatibility with gltf, a special mode has been added
  50328. * to reproduce the gltf light falloff.
  50329. */
  50330. useGLTFLightFalloff: boolean;
  50331. /**
  50332. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50333. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50334. */
  50335. useRadianceOverAlpha: boolean;
  50336. /**
  50337. * Allows using an object space normal map (instead of tangent space).
  50338. */
  50339. useObjectSpaceNormalMap: boolean;
  50340. /**
  50341. * Allows using the bump map in parallax mode.
  50342. */
  50343. useParallax: boolean;
  50344. /**
  50345. * Allows using the bump map in parallax occlusion mode.
  50346. */
  50347. useParallaxOcclusion: boolean;
  50348. /**
  50349. * Controls the scale bias of the parallax mode.
  50350. */
  50351. parallaxScaleBias: number;
  50352. /**
  50353. * If sets to true, disables all the lights affecting the material.
  50354. */
  50355. disableLighting: boolean;
  50356. /**
  50357. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50358. */
  50359. forceIrradianceInFragment: boolean;
  50360. /**
  50361. * Number of Simultaneous lights allowed on the material.
  50362. */
  50363. maxSimultaneousLights: number;
  50364. /**
  50365. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50366. */
  50367. invertNormalMapX: boolean;
  50368. /**
  50369. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50370. */
  50371. invertNormalMapY: boolean;
  50372. /**
  50373. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50374. */
  50375. twoSidedLighting: boolean;
  50376. /**
  50377. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50378. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50379. */
  50380. useAlphaFresnel: boolean;
  50381. /**
  50382. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50383. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50384. */
  50385. useLinearAlphaFresnel: boolean;
  50386. /**
  50387. * Let user defines the brdf lookup texture used for IBL.
  50388. * A default 8bit version is embedded but you could point at :
  50389. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50390. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50391. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50392. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50393. */
  50394. environmentBRDFTexture: Nullable<BaseTexture>;
  50395. /**
  50396. * Force normal to face away from face.
  50397. */
  50398. forceNormalForward: boolean;
  50399. /**
  50400. * Enables specular anti aliasing in the PBR shader.
  50401. * It will both interacts on the Geometry for analytical and IBL lighting.
  50402. * It also prefilter the roughness map based on the bump values.
  50403. */
  50404. enableSpecularAntiAliasing: boolean;
  50405. /**
  50406. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50407. * makes the reflect vector face the model (under horizon).
  50408. */
  50409. useHorizonOcclusion: boolean;
  50410. /**
  50411. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50412. * too much the area relying on ambient texture to define their ambient occlusion.
  50413. */
  50414. useRadianceOcclusion: boolean;
  50415. /**
  50416. * If set to true, no lighting calculations will be applied.
  50417. */
  50418. unlit: boolean;
  50419. /**
  50420. * Gets the image processing configuration used either in this material.
  50421. */
  50422. /**
  50423. * Sets the Default image processing configuration used either in the this material.
  50424. *
  50425. * If sets to null, the scene one is in use.
  50426. */
  50427. imageProcessingConfiguration: ImageProcessingConfiguration;
  50428. /**
  50429. * Gets wether the color curves effect is enabled.
  50430. */
  50431. /**
  50432. * Sets wether the color curves effect is enabled.
  50433. */
  50434. cameraColorCurvesEnabled: boolean;
  50435. /**
  50436. * Gets wether the color grading effect is enabled.
  50437. */
  50438. /**
  50439. * Gets wether the color grading effect is enabled.
  50440. */
  50441. cameraColorGradingEnabled: boolean;
  50442. /**
  50443. * Gets wether tonemapping is enabled or not.
  50444. */
  50445. /**
  50446. * Sets wether tonemapping is enabled or not
  50447. */
  50448. cameraToneMappingEnabled: boolean;
  50449. /**
  50450. * The camera exposure used on this material.
  50451. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50452. * This corresponds to a photographic exposure.
  50453. */
  50454. /**
  50455. * The camera exposure used on this material.
  50456. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50457. * This corresponds to a photographic exposure.
  50458. */
  50459. cameraExposure: number;
  50460. /**
  50461. * Gets The camera contrast used on this material.
  50462. */
  50463. /**
  50464. * Sets The camera contrast used on this material.
  50465. */
  50466. cameraContrast: number;
  50467. /**
  50468. * Gets the Color Grading 2D Lookup Texture.
  50469. */
  50470. /**
  50471. * Sets the Color Grading 2D Lookup Texture.
  50472. */
  50473. cameraColorGradingTexture: Nullable<BaseTexture>;
  50474. /**
  50475. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50476. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50477. * 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;
  50478. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50479. */
  50480. /**
  50481. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50482. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50483. * 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;
  50484. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50485. */
  50486. cameraColorCurves: Nullable<ColorCurves>;
  50487. /**
  50488. * Instantiates a new PBRMaterial instance.
  50489. *
  50490. * @param name The material name
  50491. * @param scene The scene the material will be use in.
  50492. */
  50493. constructor(name: string, scene: Scene);
  50494. /**
  50495. * Returns the name of this material class.
  50496. */
  50497. getClassName(): string;
  50498. /**
  50499. * Makes a duplicate of the current material.
  50500. * @param name - name to use for the new material.
  50501. */
  50502. clone(name: string): PBRMaterial;
  50503. /**
  50504. * Serializes this PBR Material.
  50505. * @returns - An object with the serialized material.
  50506. */
  50507. serialize(): any;
  50508. /**
  50509. * Parses a PBR Material from a serialized object.
  50510. * @param source - Serialized object.
  50511. * @param scene - BJS scene instance.
  50512. * @param rootUrl - url for the scene object
  50513. * @returns - PBRMaterial
  50514. */
  50515. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50516. }
  50517. }
  50518. declare module "babylonjs/Misc/dds" {
  50519. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50521. import { Nullable } from "babylonjs/types";
  50522. import { Scene } from "babylonjs/scene";
  50523. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50524. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50525. /**
  50526. * Direct draw surface info
  50527. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50528. */
  50529. export interface DDSInfo {
  50530. /**
  50531. * Width of the texture
  50532. */
  50533. width: number;
  50534. /**
  50535. * Width of the texture
  50536. */
  50537. height: number;
  50538. /**
  50539. * Number of Mipmaps for the texture
  50540. * @see https://en.wikipedia.org/wiki/Mipmap
  50541. */
  50542. mipmapCount: number;
  50543. /**
  50544. * If the textures format is a known fourCC format
  50545. * @see https://www.fourcc.org/
  50546. */
  50547. isFourCC: boolean;
  50548. /**
  50549. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50550. */
  50551. isRGB: boolean;
  50552. /**
  50553. * If the texture is a lumincance format
  50554. */
  50555. isLuminance: boolean;
  50556. /**
  50557. * If this is a cube texture
  50558. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50559. */
  50560. isCube: boolean;
  50561. /**
  50562. * If the texture is a compressed format eg. FOURCC_DXT1
  50563. */
  50564. isCompressed: boolean;
  50565. /**
  50566. * The dxgiFormat of the texture
  50567. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50568. */
  50569. dxgiFormat: number;
  50570. /**
  50571. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50572. */
  50573. textureType: number;
  50574. /**
  50575. * Sphericle polynomial created for the dds texture
  50576. */
  50577. sphericalPolynomial?: SphericalPolynomial;
  50578. }
  50579. /**
  50580. * Class used to provide DDS decompression tools
  50581. */
  50582. export class DDSTools {
  50583. /**
  50584. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50585. */
  50586. static StoreLODInAlphaChannel: boolean;
  50587. /**
  50588. * Gets DDS information from an array buffer
  50589. * @param arrayBuffer defines the array buffer to read data from
  50590. * @returns the DDS information
  50591. */
  50592. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50593. private static _FloatView;
  50594. private static _Int32View;
  50595. private static _ToHalfFloat;
  50596. private static _FromHalfFloat;
  50597. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50598. private static _GetHalfFloatRGBAArrayBuffer;
  50599. private static _GetFloatRGBAArrayBuffer;
  50600. private static _GetFloatAsUIntRGBAArrayBuffer;
  50601. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50602. private static _GetRGBAArrayBuffer;
  50603. private static _ExtractLongWordOrder;
  50604. private static _GetRGBArrayBuffer;
  50605. private static _GetLuminanceArrayBuffer;
  50606. /**
  50607. * Uploads DDS Levels to a Babylon Texture
  50608. * @hidden
  50609. */
  50610. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50611. }
  50612. module "babylonjs/Engines/thinEngine" {
  50613. interface ThinEngine {
  50614. /**
  50615. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50616. * @param rootUrl defines the url where the file to load is located
  50617. * @param scene defines the current scene
  50618. * @param lodScale defines scale to apply to the mip map selection
  50619. * @param lodOffset defines offset to apply to the mip map selection
  50620. * @param onLoad defines an optional callback raised when the texture is loaded
  50621. * @param onError defines an optional callback raised if there is an issue to load the texture
  50622. * @param format defines the format of the data
  50623. * @param forcedExtension defines the extension to use to pick the right loader
  50624. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50625. * @returns the cube texture as an InternalTexture
  50626. */
  50627. 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;
  50628. }
  50629. }
  50630. }
  50631. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50632. import { Nullable } from "babylonjs/types";
  50633. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50634. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50635. /**
  50636. * Implementation of the DDS Texture Loader.
  50637. * @hidden
  50638. */
  50639. export class _DDSTextureLoader implements IInternalTextureLoader {
  50640. /**
  50641. * Defines wether the loader supports cascade loading the different faces.
  50642. */
  50643. readonly supportCascades: boolean;
  50644. /**
  50645. * This returns if the loader support the current file information.
  50646. * @param extension defines the file extension of the file being loaded
  50647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50648. * @param fallback defines the fallback internal texture if any
  50649. * @param isBase64 defines whether the texture is encoded as a base64
  50650. * @param isBuffer defines whether the texture data are stored as a buffer
  50651. * @returns true if the loader can load the specified file
  50652. */
  50653. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50654. /**
  50655. * Transform the url before loading if required.
  50656. * @param rootUrl the url of the texture
  50657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50658. * @returns the transformed texture
  50659. */
  50660. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50661. /**
  50662. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50663. * @param rootUrl the url of the texture
  50664. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50665. * @returns the fallback texture
  50666. */
  50667. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50668. /**
  50669. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50670. * @param data contains the texture data
  50671. * @param texture defines the BabylonJS internal texture
  50672. * @param createPolynomials will be true if polynomials have been requested
  50673. * @param onLoad defines the callback to trigger once the texture is ready
  50674. * @param onError defines the callback to trigger in case of error
  50675. */
  50676. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50677. /**
  50678. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50679. * @param data contains the texture data
  50680. * @param texture defines the BabylonJS internal texture
  50681. * @param callback defines the method to call once ready to upload
  50682. */
  50683. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50684. }
  50685. }
  50686. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50687. import { Nullable } from "babylonjs/types";
  50688. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50689. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50690. /**
  50691. * Implementation of the ENV Texture Loader.
  50692. * @hidden
  50693. */
  50694. export class _ENVTextureLoader implements IInternalTextureLoader {
  50695. /**
  50696. * Defines wether the loader supports cascade loading the different faces.
  50697. */
  50698. readonly supportCascades: boolean;
  50699. /**
  50700. * This returns if the loader support the current file information.
  50701. * @param extension defines the file extension of the file being loaded
  50702. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50703. * @param fallback defines the fallback internal texture if any
  50704. * @param isBase64 defines whether the texture is encoded as a base64
  50705. * @param isBuffer defines whether the texture data are stored as a buffer
  50706. * @returns true if the loader can load the specified file
  50707. */
  50708. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50709. /**
  50710. * Transform the url before loading if required.
  50711. * @param rootUrl the url of the texture
  50712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50713. * @returns the transformed texture
  50714. */
  50715. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50716. /**
  50717. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50718. * @param rootUrl the url of the texture
  50719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50720. * @returns the fallback texture
  50721. */
  50722. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50723. /**
  50724. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50725. * @param data contains the texture data
  50726. * @param texture defines the BabylonJS internal texture
  50727. * @param createPolynomials will be true if polynomials have been requested
  50728. * @param onLoad defines the callback to trigger once the texture is ready
  50729. * @param onError defines the callback to trigger in case of error
  50730. */
  50731. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50732. /**
  50733. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50734. * @param data contains the texture data
  50735. * @param texture defines the BabylonJS internal texture
  50736. * @param callback defines the method to call once ready to upload
  50737. */
  50738. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50739. }
  50740. }
  50741. declare module "babylonjs/Misc/khronosTextureContainer" {
  50742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50743. /**
  50744. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50745. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50746. */
  50747. export class KhronosTextureContainer {
  50748. /** contents of the KTX container file */
  50749. arrayBuffer: any;
  50750. private static HEADER_LEN;
  50751. private static COMPRESSED_2D;
  50752. private static COMPRESSED_3D;
  50753. private static TEX_2D;
  50754. private static TEX_3D;
  50755. /**
  50756. * Gets the openGL type
  50757. */
  50758. glType: number;
  50759. /**
  50760. * Gets the openGL type size
  50761. */
  50762. glTypeSize: number;
  50763. /**
  50764. * Gets the openGL format
  50765. */
  50766. glFormat: number;
  50767. /**
  50768. * Gets the openGL internal format
  50769. */
  50770. glInternalFormat: number;
  50771. /**
  50772. * Gets the base internal format
  50773. */
  50774. glBaseInternalFormat: number;
  50775. /**
  50776. * Gets image width in pixel
  50777. */
  50778. pixelWidth: number;
  50779. /**
  50780. * Gets image height in pixel
  50781. */
  50782. pixelHeight: number;
  50783. /**
  50784. * Gets image depth in pixels
  50785. */
  50786. pixelDepth: number;
  50787. /**
  50788. * Gets the number of array elements
  50789. */
  50790. numberOfArrayElements: number;
  50791. /**
  50792. * Gets the number of faces
  50793. */
  50794. numberOfFaces: number;
  50795. /**
  50796. * Gets the number of mipmap levels
  50797. */
  50798. numberOfMipmapLevels: number;
  50799. /**
  50800. * Gets the bytes of key value data
  50801. */
  50802. bytesOfKeyValueData: number;
  50803. /**
  50804. * Gets the load type
  50805. */
  50806. loadType: number;
  50807. /**
  50808. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50809. */
  50810. isInvalid: boolean;
  50811. /**
  50812. * Creates a new KhronosTextureContainer
  50813. * @param arrayBuffer contents of the KTX container file
  50814. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50815. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50816. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50817. */
  50818. constructor(
  50819. /** contents of the KTX container file */
  50820. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50821. /**
  50822. * Uploads KTX content to a Babylon Texture.
  50823. * It is assumed that the texture has already been created & is currently bound
  50824. * @hidden
  50825. */
  50826. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50827. private _upload2DCompressedLevels;
  50828. }
  50829. }
  50830. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50831. import { Nullable } from "babylonjs/types";
  50832. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50833. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50834. /**
  50835. * Implementation of the KTX Texture Loader.
  50836. * @hidden
  50837. */
  50838. export class _KTXTextureLoader implements IInternalTextureLoader {
  50839. /**
  50840. * Defines wether the loader supports cascade loading the different faces.
  50841. */
  50842. readonly supportCascades: boolean;
  50843. /**
  50844. * This returns if the loader support the current file information.
  50845. * @param extension defines the file extension of the file being loaded
  50846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50847. * @param fallback defines the fallback internal texture if any
  50848. * @param isBase64 defines whether the texture is encoded as a base64
  50849. * @param isBuffer defines whether the texture data are stored as a buffer
  50850. * @returns true if the loader can load the specified file
  50851. */
  50852. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50853. /**
  50854. * Transform the url before loading if required.
  50855. * @param rootUrl the url of the texture
  50856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50857. * @returns the transformed texture
  50858. */
  50859. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50860. /**
  50861. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50862. * @param rootUrl the url of the texture
  50863. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50864. * @returns the fallback texture
  50865. */
  50866. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50867. /**
  50868. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50869. * @param data contains the texture data
  50870. * @param texture defines the BabylonJS internal texture
  50871. * @param createPolynomials will be true if polynomials have been requested
  50872. * @param onLoad defines the callback to trigger once the texture is ready
  50873. * @param onError defines the callback to trigger in case of error
  50874. */
  50875. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50876. /**
  50877. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50878. * @param data contains the texture data
  50879. * @param texture defines the BabylonJS internal texture
  50880. * @param callback defines the method to call once ready to upload
  50881. */
  50882. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50883. }
  50884. }
  50885. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50886. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50887. import { Scene } from "babylonjs/scene";
  50888. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50889. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50890. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50891. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50892. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50893. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50895. /**
  50896. * Options for the default xr helper
  50897. */
  50898. export class WebXRDefaultExperienceOptions {
  50899. /**
  50900. * Floor meshes that should be used for teleporting
  50901. */
  50902. floorMeshes: Array<AbstractMesh>;
  50903. }
  50904. /**
  50905. * Default experience which provides a similar setup to the previous webVRExperience
  50906. */
  50907. export class WebXRDefaultExperience {
  50908. /**
  50909. * Base experience
  50910. */
  50911. baseExperience: WebXRExperienceHelper;
  50912. /**
  50913. * Input experience extension
  50914. */
  50915. input: WebXRInput;
  50916. /**
  50917. * Loads the controller models
  50918. */
  50919. controllerModelLoader: WebXRControllerModelLoader;
  50920. /**
  50921. * Enables laser pointer and selection
  50922. */
  50923. pointerSelection: WebXRControllerPointerSelection;
  50924. /**
  50925. * Enables teleportation
  50926. */
  50927. teleportation: WebXRControllerTeleportation;
  50928. /**
  50929. * Enables ui for enetering/exiting xr
  50930. */
  50931. enterExitUI: WebXREnterExitUI;
  50932. /**
  50933. * Default output canvas xr should render to
  50934. */
  50935. outputCanvas: WebXRManagedOutputCanvas;
  50936. /**
  50937. * Creates the default xr experience
  50938. * @param scene scene
  50939. * @param options options for basic configuration
  50940. * @returns resulting WebXRDefaultExperience
  50941. */
  50942. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50943. private constructor();
  50944. /**
  50945. * DIsposes of the experience helper
  50946. */
  50947. dispose(): void;
  50948. }
  50949. }
  50950. declare module "babylonjs/Helpers/sceneHelpers" {
  50951. import { Nullable } from "babylonjs/types";
  50952. import { Mesh } from "babylonjs/Meshes/mesh";
  50953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50954. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50955. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50956. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50957. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50958. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50959. import "babylonjs/Meshes/Builders/boxBuilder";
  50960. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50961. /** @hidden */
  50962. export var _forceSceneHelpersToBundle: boolean;
  50963. module "babylonjs/scene" {
  50964. interface Scene {
  50965. /**
  50966. * Creates a default light for the scene.
  50967. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50968. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50969. */
  50970. createDefaultLight(replace?: boolean): void;
  50971. /**
  50972. * Creates a default camera for the scene.
  50973. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50974. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50975. * @param replace has default false, when true replaces the active camera in the scene
  50976. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50977. */
  50978. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50979. /**
  50980. * Creates a default camera and a default light.
  50981. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50982. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50983. * @param replace has the default false, when true replaces the active camera/light in the scene
  50984. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50985. */
  50986. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50987. /**
  50988. * Creates a new sky box
  50989. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50990. * @param environmentTexture defines the texture to use as environment texture
  50991. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50992. * @param scale defines the overall scale of the skybox
  50993. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50994. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50995. * @returns a new mesh holding the sky box
  50996. */
  50997. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50998. /**
  50999. * Creates a new environment
  51000. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51001. * @param options defines the options you can use to configure the environment
  51002. * @returns the new EnvironmentHelper
  51003. */
  51004. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51005. /**
  51006. * Creates a new VREXperienceHelper
  51007. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51008. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51009. * @returns a new VREXperienceHelper
  51010. */
  51011. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51012. /**
  51013. * Creates a new WebXRDefaultExperience
  51014. * @see http://doc.babylonjs.com/how_to/webxr
  51015. * @param options experience options
  51016. * @returns a promise for a new WebXRDefaultExperience
  51017. */
  51018. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51019. }
  51020. }
  51021. }
  51022. declare module "babylonjs/Helpers/videoDome" {
  51023. import { Scene } from "babylonjs/scene";
  51024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51025. import { Mesh } from "babylonjs/Meshes/mesh";
  51026. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51027. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51028. import "babylonjs/Meshes/Builders/sphereBuilder";
  51029. /**
  51030. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51031. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51032. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51033. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51034. */
  51035. export class VideoDome extends TransformNode {
  51036. /**
  51037. * Define the video source as a Monoscopic panoramic 360 video.
  51038. */
  51039. static readonly MODE_MONOSCOPIC: number;
  51040. /**
  51041. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51042. */
  51043. static readonly MODE_TOPBOTTOM: number;
  51044. /**
  51045. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51046. */
  51047. static readonly MODE_SIDEBYSIDE: number;
  51048. private _halfDome;
  51049. private _useDirectMapping;
  51050. /**
  51051. * The video texture being displayed on the sphere
  51052. */
  51053. protected _videoTexture: VideoTexture;
  51054. /**
  51055. * Gets the video texture being displayed on the sphere
  51056. */
  51057. readonly videoTexture: VideoTexture;
  51058. /**
  51059. * The skybox material
  51060. */
  51061. protected _material: BackgroundMaterial;
  51062. /**
  51063. * The surface used for the skybox
  51064. */
  51065. protected _mesh: Mesh;
  51066. /**
  51067. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51068. */
  51069. private _halfDomeMask;
  51070. /**
  51071. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51072. * Also see the options.resolution property.
  51073. */
  51074. fovMultiplier: number;
  51075. private _videoMode;
  51076. /**
  51077. * Gets or set the current video mode for the video. It can be:
  51078. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51079. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51080. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51081. */
  51082. videoMode: number;
  51083. /**
  51084. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51085. *
  51086. */
  51087. /**
  51088. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51089. */
  51090. halfDome: boolean;
  51091. /**
  51092. * Oberserver used in Stereoscopic VR Mode.
  51093. */
  51094. private _onBeforeCameraRenderObserver;
  51095. /**
  51096. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51097. * @param name Element's name, child elements will append suffixes for their own names.
  51098. * @param urlsOrVideo defines the url(s) or the video element to use
  51099. * @param options An object containing optional or exposed sub element properties
  51100. */
  51101. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51102. resolution?: number;
  51103. clickToPlay?: boolean;
  51104. autoPlay?: boolean;
  51105. loop?: boolean;
  51106. size?: number;
  51107. poster?: string;
  51108. faceForward?: boolean;
  51109. useDirectMapping?: boolean;
  51110. halfDomeMode?: boolean;
  51111. }, scene: Scene);
  51112. private _changeVideoMode;
  51113. /**
  51114. * Releases resources associated with this node.
  51115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51117. */
  51118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51119. }
  51120. }
  51121. declare module "babylonjs/Helpers/index" {
  51122. export * from "babylonjs/Helpers/environmentHelper";
  51123. export * from "babylonjs/Helpers/photoDome";
  51124. export * from "babylonjs/Helpers/sceneHelpers";
  51125. export * from "babylonjs/Helpers/videoDome";
  51126. }
  51127. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51128. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51129. import { IDisposable } from "babylonjs/scene";
  51130. import { Engine } from "babylonjs/Engines/engine";
  51131. /**
  51132. * This class can be used to get instrumentation data from a Babylon engine
  51133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51134. */
  51135. export class EngineInstrumentation implements IDisposable {
  51136. /**
  51137. * Define the instrumented engine.
  51138. */
  51139. engine: Engine;
  51140. private _captureGPUFrameTime;
  51141. private _gpuFrameTimeToken;
  51142. private _gpuFrameTime;
  51143. private _captureShaderCompilationTime;
  51144. private _shaderCompilationTime;
  51145. private _onBeginFrameObserver;
  51146. private _onEndFrameObserver;
  51147. private _onBeforeShaderCompilationObserver;
  51148. private _onAfterShaderCompilationObserver;
  51149. /**
  51150. * Gets the perf counter used for GPU frame time
  51151. */
  51152. readonly gpuFrameTimeCounter: PerfCounter;
  51153. /**
  51154. * Gets the GPU frame time capture status
  51155. */
  51156. /**
  51157. * Enable or disable the GPU frame time capture
  51158. */
  51159. captureGPUFrameTime: boolean;
  51160. /**
  51161. * Gets the perf counter used for shader compilation time
  51162. */
  51163. readonly shaderCompilationTimeCounter: PerfCounter;
  51164. /**
  51165. * Gets the shader compilation time capture status
  51166. */
  51167. /**
  51168. * Enable or disable the shader compilation time capture
  51169. */
  51170. captureShaderCompilationTime: boolean;
  51171. /**
  51172. * Instantiates a new engine instrumentation.
  51173. * This class can be used to get instrumentation data from a Babylon engine
  51174. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51175. * @param engine Defines the engine to instrument
  51176. */
  51177. constructor(
  51178. /**
  51179. * Define the instrumented engine.
  51180. */
  51181. engine: Engine);
  51182. /**
  51183. * Dispose and release associated resources.
  51184. */
  51185. dispose(): void;
  51186. }
  51187. }
  51188. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51189. import { Scene, IDisposable } from "babylonjs/scene";
  51190. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51191. /**
  51192. * This class can be used to get instrumentation data from a Babylon engine
  51193. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51194. */
  51195. export class SceneInstrumentation implements IDisposable {
  51196. /**
  51197. * Defines the scene to instrument
  51198. */
  51199. scene: Scene;
  51200. private _captureActiveMeshesEvaluationTime;
  51201. private _activeMeshesEvaluationTime;
  51202. private _captureRenderTargetsRenderTime;
  51203. private _renderTargetsRenderTime;
  51204. private _captureFrameTime;
  51205. private _frameTime;
  51206. private _captureRenderTime;
  51207. private _renderTime;
  51208. private _captureInterFrameTime;
  51209. private _interFrameTime;
  51210. private _captureParticlesRenderTime;
  51211. private _particlesRenderTime;
  51212. private _captureSpritesRenderTime;
  51213. private _spritesRenderTime;
  51214. private _capturePhysicsTime;
  51215. private _physicsTime;
  51216. private _captureAnimationsTime;
  51217. private _animationsTime;
  51218. private _captureCameraRenderTime;
  51219. private _cameraRenderTime;
  51220. private _onBeforeActiveMeshesEvaluationObserver;
  51221. private _onAfterActiveMeshesEvaluationObserver;
  51222. private _onBeforeRenderTargetsRenderObserver;
  51223. private _onAfterRenderTargetsRenderObserver;
  51224. private _onAfterRenderObserver;
  51225. private _onBeforeDrawPhaseObserver;
  51226. private _onAfterDrawPhaseObserver;
  51227. private _onBeforeAnimationsObserver;
  51228. private _onBeforeParticlesRenderingObserver;
  51229. private _onAfterParticlesRenderingObserver;
  51230. private _onBeforeSpritesRenderingObserver;
  51231. private _onAfterSpritesRenderingObserver;
  51232. private _onBeforePhysicsObserver;
  51233. private _onAfterPhysicsObserver;
  51234. private _onAfterAnimationsObserver;
  51235. private _onBeforeCameraRenderObserver;
  51236. private _onAfterCameraRenderObserver;
  51237. /**
  51238. * Gets the perf counter used for active meshes evaluation time
  51239. */
  51240. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51241. /**
  51242. * Gets the active meshes evaluation time capture status
  51243. */
  51244. /**
  51245. * Enable or disable the active meshes evaluation time capture
  51246. */
  51247. captureActiveMeshesEvaluationTime: boolean;
  51248. /**
  51249. * Gets the perf counter used for render targets render time
  51250. */
  51251. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51252. /**
  51253. * Gets the render targets render time capture status
  51254. */
  51255. /**
  51256. * Enable or disable the render targets render time capture
  51257. */
  51258. captureRenderTargetsRenderTime: boolean;
  51259. /**
  51260. * Gets the perf counter used for particles render time
  51261. */
  51262. readonly particlesRenderTimeCounter: PerfCounter;
  51263. /**
  51264. * Gets the particles render time capture status
  51265. */
  51266. /**
  51267. * Enable or disable the particles render time capture
  51268. */
  51269. captureParticlesRenderTime: boolean;
  51270. /**
  51271. * Gets the perf counter used for sprites render time
  51272. */
  51273. readonly spritesRenderTimeCounter: PerfCounter;
  51274. /**
  51275. * Gets the sprites render time capture status
  51276. */
  51277. /**
  51278. * Enable or disable the sprites render time capture
  51279. */
  51280. captureSpritesRenderTime: boolean;
  51281. /**
  51282. * Gets the perf counter used for physics time
  51283. */
  51284. readonly physicsTimeCounter: PerfCounter;
  51285. /**
  51286. * Gets the physics time capture status
  51287. */
  51288. /**
  51289. * Enable or disable the physics time capture
  51290. */
  51291. capturePhysicsTime: boolean;
  51292. /**
  51293. * Gets the perf counter used for animations time
  51294. */
  51295. readonly animationsTimeCounter: PerfCounter;
  51296. /**
  51297. * Gets the animations time capture status
  51298. */
  51299. /**
  51300. * Enable or disable the animations time capture
  51301. */
  51302. captureAnimationsTime: boolean;
  51303. /**
  51304. * Gets the perf counter used for frame time capture
  51305. */
  51306. readonly frameTimeCounter: PerfCounter;
  51307. /**
  51308. * Gets the frame time capture status
  51309. */
  51310. /**
  51311. * Enable or disable the frame time capture
  51312. */
  51313. captureFrameTime: boolean;
  51314. /**
  51315. * Gets the perf counter used for inter-frames time capture
  51316. */
  51317. readonly interFrameTimeCounter: PerfCounter;
  51318. /**
  51319. * Gets the inter-frames time capture status
  51320. */
  51321. /**
  51322. * Enable or disable the inter-frames time capture
  51323. */
  51324. captureInterFrameTime: boolean;
  51325. /**
  51326. * Gets the perf counter used for render time capture
  51327. */
  51328. readonly renderTimeCounter: PerfCounter;
  51329. /**
  51330. * Gets the render time capture status
  51331. */
  51332. /**
  51333. * Enable or disable the render time capture
  51334. */
  51335. captureRenderTime: boolean;
  51336. /**
  51337. * Gets the perf counter used for camera render time capture
  51338. */
  51339. readonly cameraRenderTimeCounter: PerfCounter;
  51340. /**
  51341. * Gets the camera render time capture status
  51342. */
  51343. /**
  51344. * Enable or disable the camera render time capture
  51345. */
  51346. captureCameraRenderTime: boolean;
  51347. /**
  51348. * Gets the perf counter used for draw calls
  51349. */
  51350. readonly drawCallsCounter: PerfCounter;
  51351. /**
  51352. * Instantiates a new scene instrumentation.
  51353. * This class can be used to get instrumentation data from a Babylon engine
  51354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51355. * @param scene Defines the scene to instrument
  51356. */
  51357. constructor(
  51358. /**
  51359. * Defines the scene to instrument
  51360. */
  51361. scene: Scene);
  51362. /**
  51363. * Dispose and release associated resources.
  51364. */
  51365. dispose(): void;
  51366. }
  51367. }
  51368. declare module "babylonjs/Instrumentation/index" {
  51369. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51370. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51371. export * from "babylonjs/Instrumentation/timeToken";
  51372. }
  51373. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51374. /** @hidden */
  51375. export var glowMapGenerationPixelShader: {
  51376. name: string;
  51377. shader: string;
  51378. };
  51379. }
  51380. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51381. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51383. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51384. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51385. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51386. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51387. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51388. /** @hidden */
  51389. export var glowMapGenerationVertexShader: {
  51390. name: string;
  51391. shader: string;
  51392. };
  51393. }
  51394. declare module "babylonjs/Layers/effectLayer" {
  51395. import { Observable } from "babylonjs/Misc/observable";
  51396. import { Nullable } from "babylonjs/types";
  51397. import { Camera } from "babylonjs/Cameras/camera";
  51398. import { Scene } from "babylonjs/scene";
  51399. import { ISize } from "babylonjs/Maths/math.size";
  51400. import { Color4 } from "babylonjs/Maths/math.color";
  51401. import { Engine } from "babylonjs/Engines/engine";
  51402. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51404. import { Mesh } from "babylonjs/Meshes/mesh";
  51405. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51406. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51407. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51408. import { Effect } from "babylonjs/Materials/effect";
  51409. import { Material } from "babylonjs/Materials/material";
  51410. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51411. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51412. /**
  51413. * Effect layer options. This helps customizing the behaviour
  51414. * of the effect layer.
  51415. */
  51416. export interface IEffectLayerOptions {
  51417. /**
  51418. * Multiplication factor apply to the canvas size to compute the render target size
  51419. * used to generated the objects (the smaller the faster).
  51420. */
  51421. mainTextureRatio: number;
  51422. /**
  51423. * Enforces a fixed size texture to ensure effect stability across devices.
  51424. */
  51425. mainTextureFixedSize?: number;
  51426. /**
  51427. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51428. */
  51429. alphaBlendingMode: number;
  51430. /**
  51431. * The camera attached to the layer.
  51432. */
  51433. camera: Nullable<Camera>;
  51434. /**
  51435. * The rendering group to draw the layer in.
  51436. */
  51437. renderingGroupId: number;
  51438. }
  51439. /**
  51440. * The effect layer Helps adding post process effect blended with the main pass.
  51441. *
  51442. * This can be for instance use to generate glow or higlight effects on the scene.
  51443. *
  51444. * The effect layer class can not be used directly and is intented to inherited from to be
  51445. * customized per effects.
  51446. */
  51447. export abstract class EffectLayer {
  51448. private _vertexBuffers;
  51449. private _indexBuffer;
  51450. private _cachedDefines;
  51451. private _effectLayerMapGenerationEffect;
  51452. private _effectLayerOptions;
  51453. private _mergeEffect;
  51454. protected _scene: Scene;
  51455. protected _engine: Engine;
  51456. protected _maxSize: number;
  51457. protected _mainTextureDesiredSize: ISize;
  51458. protected _mainTexture: RenderTargetTexture;
  51459. protected _shouldRender: boolean;
  51460. protected _postProcesses: PostProcess[];
  51461. protected _textures: BaseTexture[];
  51462. protected _emissiveTextureAndColor: {
  51463. texture: Nullable<BaseTexture>;
  51464. color: Color4;
  51465. };
  51466. /**
  51467. * The name of the layer
  51468. */
  51469. name: string;
  51470. /**
  51471. * The clear color of the texture used to generate the glow map.
  51472. */
  51473. neutralColor: Color4;
  51474. /**
  51475. * Specifies wether the highlight layer is enabled or not.
  51476. */
  51477. isEnabled: boolean;
  51478. /**
  51479. * Gets the camera attached to the layer.
  51480. */
  51481. readonly camera: Nullable<Camera>;
  51482. /**
  51483. * Gets the rendering group id the layer should render in.
  51484. */
  51485. renderingGroupId: number;
  51486. /**
  51487. * An event triggered when the effect layer has been disposed.
  51488. */
  51489. onDisposeObservable: Observable<EffectLayer>;
  51490. /**
  51491. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51492. */
  51493. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51494. /**
  51495. * An event triggered when the generated texture is being merged in the scene.
  51496. */
  51497. onBeforeComposeObservable: Observable<EffectLayer>;
  51498. /**
  51499. * An event triggered when the generated texture has been merged in the scene.
  51500. */
  51501. onAfterComposeObservable: Observable<EffectLayer>;
  51502. /**
  51503. * An event triggered when the efffect layer changes its size.
  51504. */
  51505. onSizeChangedObservable: Observable<EffectLayer>;
  51506. /** @hidden */
  51507. static _SceneComponentInitialization: (scene: Scene) => void;
  51508. /**
  51509. * Instantiates a new effect Layer and references it in the scene.
  51510. * @param name The name of the layer
  51511. * @param scene The scene to use the layer in
  51512. */
  51513. constructor(
  51514. /** The Friendly of the effect in the scene */
  51515. name: string, scene: Scene);
  51516. /**
  51517. * Get the effect name of the layer.
  51518. * @return The effect name
  51519. */
  51520. abstract getEffectName(): string;
  51521. /**
  51522. * Checks for the readiness of the element composing the layer.
  51523. * @param subMesh the mesh to check for
  51524. * @param useInstances specify wether or not to use instances to render the mesh
  51525. * @return true if ready otherwise, false
  51526. */
  51527. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51528. /**
  51529. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51530. * @returns true if the effect requires stencil during the main canvas render pass.
  51531. */
  51532. abstract needStencil(): boolean;
  51533. /**
  51534. * Create the merge effect. This is the shader use to blit the information back
  51535. * to the main canvas at the end of the scene rendering.
  51536. * @returns The effect containing the shader used to merge the effect on the main canvas
  51537. */
  51538. protected abstract _createMergeEffect(): Effect;
  51539. /**
  51540. * Creates the render target textures and post processes used in the effect layer.
  51541. */
  51542. protected abstract _createTextureAndPostProcesses(): void;
  51543. /**
  51544. * Implementation specific of rendering the generating effect on the main canvas.
  51545. * @param effect The effect used to render through
  51546. */
  51547. protected abstract _internalRender(effect: Effect): void;
  51548. /**
  51549. * Sets the required values for both the emissive texture and and the main color.
  51550. */
  51551. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51552. /**
  51553. * Free any resources and references associated to a mesh.
  51554. * Internal use
  51555. * @param mesh The mesh to free.
  51556. */
  51557. abstract _disposeMesh(mesh: Mesh): void;
  51558. /**
  51559. * Serializes this layer (Glow or Highlight for example)
  51560. * @returns a serialized layer object
  51561. */
  51562. abstract serialize?(): any;
  51563. /**
  51564. * Initializes the effect layer with the required options.
  51565. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51566. */
  51567. protected _init(options: Partial<IEffectLayerOptions>): void;
  51568. /**
  51569. * Generates the index buffer of the full screen quad blending to the main canvas.
  51570. */
  51571. private _generateIndexBuffer;
  51572. /**
  51573. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51574. */
  51575. private _generateVertexBuffer;
  51576. /**
  51577. * Sets the main texture desired size which is the closest power of two
  51578. * of the engine canvas size.
  51579. */
  51580. private _setMainTextureSize;
  51581. /**
  51582. * Creates the main texture for the effect layer.
  51583. */
  51584. protected _createMainTexture(): void;
  51585. /**
  51586. * Adds specific effects defines.
  51587. * @param defines The defines to add specifics to.
  51588. */
  51589. protected _addCustomEffectDefines(defines: string[]): void;
  51590. /**
  51591. * Checks for the readiness of the element composing the layer.
  51592. * @param subMesh the mesh to check for
  51593. * @param useInstances specify wether or not to use instances to render the mesh
  51594. * @param emissiveTexture the associated emissive texture used to generate the glow
  51595. * @return true if ready otherwise, false
  51596. */
  51597. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51598. /**
  51599. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51600. */
  51601. render(): void;
  51602. /**
  51603. * Determine if a given mesh will be used in the current effect.
  51604. * @param mesh mesh to test
  51605. * @returns true if the mesh will be used
  51606. */
  51607. hasMesh(mesh: AbstractMesh): boolean;
  51608. /**
  51609. * Returns true if the layer contains information to display, otherwise false.
  51610. * @returns true if the glow layer should be rendered
  51611. */
  51612. shouldRender(): boolean;
  51613. /**
  51614. * Returns true if the mesh should render, otherwise false.
  51615. * @param mesh The mesh to render
  51616. * @returns true if it should render otherwise false
  51617. */
  51618. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51619. /**
  51620. * Returns true if the mesh can be rendered, otherwise false.
  51621. * @param mesh The mesh to render
  51622. * @param material The material used on the mesh
  51623. * @returns true if it can be rendered otherwise false
  51624. */
  51625. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51626. /**
  51627. * Returns true if the mesh should render, otherwise false.
  51628. * @param mesh The mesh to render
  51629. * @returns true if it should render otherwise false
  51630. */
  51631. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51632. /**
  51633. * Renders the submesh passed in parameter to the generation map.
  51634. */
  51635. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51636. /**
  51637. * Rebuild the required buffers.
  51638. * @hidden Internal use only.
  51639. */
  51640. _rebuild(): void;
  51641. /**
  51642. * Dispose only the render target textures and post process.
  51643. */
  51644. private _disposeTextureAndPostProcesses;
  51645. /**
  51646. * Dispose the highlight layer and free resources.
  51647. */
  51648. dispose(): void;
  51649. /**
  51650. * Gets the class name of the effect layer
  51651. * @returns the string with the class name of the effect layer
  51652. */
  51653. getClassName(): string;
  51654. /**
  51655. * Creates an effect layer from parsed effect layer data
  51656. * @param parsedEffectLayer defines effect layer data
  51657. * @param scene defines the current scene
  51658. * @param rootUrl defines the root URL containing the effect layer information
  51659. * @returns a parsed effect Layer
  51660. */
  51661. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51662. }
  51663. }
  51664. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51665. import { Scene } from "babylonjs/scene";
  51666. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51667. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51668. import { AbstractScene } from "babylonjs/abstractScene";
  51669. module "babylonjs/abstractScene" {
  51670. interface AbstractScene {
  51671. /**
  51672. * The list of effect layers (highlights/glow) added to the scene
  51673. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51674. * @see http://doc.babylonjs.com/how_to/glow_layer
  51675. */
  51676. effectLayers: Array<EffectLayer>;
  51677. /**
  51678. * Removes the given effect layer from this scene.
  51679. * @param toRemove defines the effect layer to remove
  51680. * @returns the index of the removed effect layer
  51681. */
  51682. removeEffectLayer(toRemove: EffectLayer): number;
  51683. /**
  51684. * Adds the given effect layer to this scene
  51685. * @param newEffectLayer defines the effect layer to add
  51686. */
  51687. addEffectLayer(newEffectLayer: EffectLayer): void;
  51688. }
  51689. }
  51690. /**
  51691. * Defines the layer scene component responsible to manage any effect layers
  51692. * in a given scene.
  51693. */
  51694. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51695. /**
  51696. * The component name helpfull to identify the component in the list of scene components.
  51697. */
  51698. readonly name: string;
  51699. /**
  51700. * The scene the component belongs to.
  51701. */
  51702. scene: Scene;
  51703. private _engine;
  51704. private _renderEffects;
  51705. private _needStencil;
  51706. private _previousStencilState;
  51707. /**
  51708. * Creates a new instance of the component for the given scene
  51709. * @param scene Defines the scene to register the component in
  51710. */
  51711. constructor(scene: Scene);
  51712. /**
  51713. * Registers the component in a given scene
  51714. */
  51715. register(): void;
  51716. /**
  51717. * Rebuilds the elements related to this component in case of
  51718. * context lost for instance.
  51719. */
  51720. rebuild(): void;
  51721. /**
  51722. * Serializes the component data to the specified json object
  51723. * @param serializationObject The object to serialize to
  51724. */
  51725. serialize(serializationObject: any): void;
  51726. /**
  51727. * Adds all the elements from the container to the scene
  51728. * @param container the container holding the elements
  51729. */
  51730. addFromContainer(container: AbstractScene): void;
  51731. /**
  51732. * Removes all the elements in the container from the scene
  51733. * @param container contains the elements to remove
  51734. * @param dispose if the removed element should be disposed (default: false)
  51735. */
  51736. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51737. /**
  51738. * Disposes the component and the associated ressources.
  51739. */
  51740. dispose(): void;
  51741. private _isReadyForMesh;
  51742. private _renderMainTexture;
  51743. private _setStencil;
  51744. private _setStencilBack;
  51745. private _draw;
  51746. private _drawCamera;
  51747. private _drawRenderingGroup;
  51748. }
  51749. }
  51750. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51751. /** @hidden */
  51752. export var glowMapMergePixelShader: {
  51753. name: string;
  51754. shader: string;
  51755. };
  51756. }
  51757. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51758. /** @hidden */
  51759. export var glowMapMergeVertexShader: {
  51760. name: string;
  51761. shader: string;
  51762. };
  51763. }
  51764. declare module "babylonjs/Layers/glowLayer" {
  51765. import { Nullable } from "babylonjs/types";
  51766. import { Camera } from "babylonjs/Cameras/camera";
  51767. import { Scene } from "babylonjs/scene";
  51768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51770. import { Mesh } from "babylonjs/Meshes/mesh";
  51771. import { Texture } from "babylonjs/Materials/Textures/texture";
  51772. import { Effect } from "babylonjs/Materials/effect";
  51773. import { Material } from "babylonjs/Materials/material";
  51774. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51775. import { Color4 } from "babylonjs/Maths/math.color";
  51776. import "babylonjs/Shaders/glowMapMerge.fragment";
  51777. import "babylonjs/Shaders/glowMapMerge.vertex";
  51778. import "babylonjs/Layers/effectLayerSceneComponent";
  51779. module "babylonjs/abstractScene" {
  51780. interface AbstractScene {
  51781. /**
  51782. * Return a the first highlight layer of the scene with a given name.
  51783. * @param name The name of the highlight layer to look for.
  51784. * @return The highlight layer if found otherwise null.
  51785. */
  51786. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51787. }
  51788. }
  51789. /**
  51790. * Glow layer options. This helps customizing the behaviour
  51791. * of the glow layer.
  51792. */
  51793. export interface IGlowLayerOptions {
  51794. /**
  51795. * Multiplication factor apply to the canvas size to compute the render target size
  51796. * used to generated the glowing objects (the smaller the faster).
  51797. */
  51798. mainTextureRatio: number;
  51799. /**
  51800. * Enforces a fixed size texture to ensure resize independant blur.
  51801. */
  51802. mainTextureFixedSize?: number;
  51803. /**
  51804. * How big is the kernel of the blur texture.
  51805. */
  51806. blurKernelSize: number;
  51807. /**
  51808. * The camera attached to the layer.
  51809. */
  51810. camera: Nullable<Camera>;
  51811. /**
  51812. * Enable MSAA by chosing the number of samples.
  51813. */
  51814. mainTextureSamples?: number;
  51815. /**
  51816. * The rendering group to draw the layer in.
  51817. */
  51818. renderingGroupId: number;
  51819. }
  51820. /**
  51821. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51822. *
  51823. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51824. * glowy meshes to your scene.
  51825. *
  51826. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51827. */
  51828. export class GlowLayer extends EffectLayer {
  51829. /**
  51830. * Effect Name of the layer.
  51831. */
  51832. static readonly EffectName: string;
  51833. /**
  51834. * The default blur kernel size used for the glow.
  51835. */
  51836. static DefaultBlurKernelSize: number;
  51837. /**
  51838. * The default texture size ratio used for the glow.
  51839. */
  51840. static DefaultTextureRatio: number;
  51841. /**
  51842. * Sets the kernel size of the blur.
  51843. */
  51844. /**
  51845. * Gets the kernel size of the blur.
  51846. */
  51847. blurKernelSize: number;
  51848. /**
  51849. * Sets the glow intensity.
  51850. */
  51851. /**
  51852. * Gets the glow intensity.
  51853. */
  51854. intensity: number;
  51855. private _options;
  51856. private _intensity;
  51857. private _horizontalBlurPostprocess1;
  51858. private _verticalBlurPostprocess1;
  51859. private _horizontalBlurPostprocess2;
  51860. private _verticalBlurPostprocess2;
  51861. private _blurTexture1;
  51862. private _blurTexture2;
  51863. private _postProcesses1;
  51864. private _postProcesses2;
  51865. private _includedOnlyMeshes;
  51866. private _excludedMeshes;
  51867. /**
  51868. * Callback used to let the user override the color selection on a per mesh basis
  51869. */
  51870. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51871. /**
  51872. * Callback used to let the user override the texture selection on a per mesh basis
  51873. */
  51874. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51875. /**
  51876. * Instantiates a new glow Layer and references it to the scene.
  51877. * @param name The name of the layer
  51878. * @param scene The scene to use the layer in
  51879. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51880. */
  51881. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51882. /**
  51883. * Get the effect name of the layer.
  51884. * @return The effect name
  51885. */
  51886. getEffectName(): string;
  51887. /**
  51888. * Create the merge effect. This is the shader use to blit the information back
  51889. * to the main canvas at the end of the scene rendering.
  51890. */
  51891. protected _createMergeEffect(): Effect;
  51892. /**
  51893. * Creates the render target textures and post processes used in the glow layer.
  51894. */
  51895. protected _createTextureAndPostProcesses(): void;
  51896. /**
  51897. * Checks for the readiness of the element composing the layer.
  51898. * @param subMesh the mesh to check for
  51899. * @param useInstances specify wether or not to use instances to render the mesh
  51900. * @param emissiveTexture the associated emissive texture used to generate the glow
  51901. * @return true if ready otherwise, false
  51902. */
  51903. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51904. /**
  51905. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51906. */
  51907. needStencil(): boolean;
  51908. /**
  51909. * Returns true if the mesh can be rendered, otherwise false.
  51910. * @param mesh The mesh to render
  51911. * @param material The material used on the mesh
  51912. * @returns true if it can be rendered otherwise false
  51913. */
  51914. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51915. /**
  51916. * Implementation specific of rendering the generating effect on the main canvas.
  51917. * @param effect The effect used to render through
  51918. */
  51919. protected _internalRender(effect: Effect): void;
  51920. /**
  51921. * Sets the required values for both the emissive texture and and the main color.
  51922. */
  51923. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51924. /**
  51925. * Returns true if the mesh should render, otherwise false.
  51926. * @param mesh The mesh to render
  51927. * @returns true if it should render otherwise false
  51928. */
  51929. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51930. /**
  51931. * Adds specific effects defines.
  51932. * @param defines The defines to add specifics to.
  51933. */
  51934. protected _addCustomEffectDefines(defines: string[]): void;
  51935. /**
  51936. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51937. * @param mesh The mesh to exclude from the glow layer
  51938. */
  51939. addExcludedMesh(mesh: Mesh): void;
  51940. /**
  51941. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51942. * @param mesh The mesh to remove
  51943. */
  51944. removeExcludedMesh(mesh: Mesh): void;
  51945. /**
  51946. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51947. * @param mesh The mesh to include in the glow layer
  51948. */
  51949. addIncludedOnlyMesh(mesh: Mesh): void;
  51950. /**
  51951. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51952. * @param mesh The mesh to remove
  51953. */
  51954. removeIncludedOnlyMesh(mesh: Mesh): void;
  51955. /**
  51956. * Determine if a given mesh will be used in the glow layer
  51957. * @param mesh The mesh to test
  51958. * @returns true if the mesh will be highlighted by the current glow layer
  51959. */
  51960. hasMesh(mesh: AbstractMesh): boolean;
  51961. /**
  51962. * Free any resources and references associated to a mesh.
  51963. * Internal use
  51964. * @param mesh The mesh to free.
  51965. * @hidden
  51966. */
  51967. _disposeMesh(mesh: Mesh): void;
  51968. /**
  51969. * Gets the class name of the effect layer
  51970. * @returns the string with the class name of the effect layer
  51971. */
  51972. getClassName(): string;
  51973. /**
  51974. * Serializes this glow layer
  51975. * @returns a serialized glow layer object
  51976. */
  51977. serialize(): any;
  51978. /**
  51979. * Creates a Glow Layer from parsed glow layer data
  51980. * @param parsedGlowLayer defines glow layer data
  51981. * @param scene defines the current scene
  51982. * @param rootUrl defines the root URL containing the glow layer information
  51983. * @returns a parsed Glow Layer
  51984. */
  51985. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51986. }
  51987. }
  51988. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51989. /** @hidden */
  51990. export var glowBlurPostProcessPixelShader: {
  51991. name: string;
  51992. shader: string;
  51993. };
  51994. }
  51995. declare module "babylonjs/Layers/highlightLayer" {
  51996. import { Observable } from "babylonjs/Misc/observable";
  51997. import { Nullable } from "babylonjs/types";
  51998. import { Camera } from "babylonjs/Cameras/camera";
  51999. import { Scene } from "babylonjs/scene";
  52000. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52002. import { Mesh } from "babylonjs/Meshes/mesh";
  52003. import { Effect } from "babylonjs/Materials/effect";
  52004. import { Material } from "babylonjs/Materials/material";
  52005. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52006. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52007. import "babylonjs/Shaders/glowMapMerge.fragment";
  52008. import "babylonjs/Shaders/glowMapMerge.vertex";
  52009. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52010. module "babylonjs/abstractScene" {
  52011. interface AbstractScene {
  52012. /**
  52013. * Return a the first highlight layer of the scene with a given name.
  52014. * @param name The name of the highlight layer to look for.
  52015. * @return The highlight layer if found otherwise null.
  52016. */
  52017. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52018. }
  52019. }
  52020. /**
  52021. * Highlight layer options. This helps customizing the behaviour
  52022. * of the highlight layer.
  52023. */
  52024. export interface IHighlightLayerOptions {
  52025. /**
  52026. * Multiplication factor apply to the canvas size to compute the render target size
  52027. * used to generated the glowing objects (the smaller the faster).
  52028. */
  52029. mainTextureRatio: number;
  52030. /**
  52031. * Enforces a fixed size texture to ensure resize independant blur.
  52032. */
  52033. mainTextureFixedSize?: number;
  52034. /**
  52035. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52036. * of the picture to blur (the smaller the faster).
  52037. */
  52038. blurTextureSizeRatio: number;
  52039. /**
  52040. * How big in texel of the blur texture is the vertical blur.
  52041. */
  52042. blurVerticalSize: number;
  52043. /**
  52044. * How big in texel of the blur texture is the horizontal blur.
  52045. */
  52046. blurHorizontalSize: number;
  52047. /**
  52048. * Alpha blending mode used to apply the blur. Default is combine.
  52049. */
  52050. alphaBlendingMode: number;
  52051. /**
  52052. * The camera attached to the layer.
  52053. */
  52054. camera: Nullable<Camera>;
  52055. /**
  52056. * Should we display highlight as a solid stroke?
  52057. */
  52058. isStroke?: boolean;
  52059. /**
  52060. * The rendering group to draw the layer in.
  52061. */
  52062. renderingGroupId: number;
  52063. }
  52064. /**
  52065. * The highlight layer Helps adding a glow effect around a mesh.
  52066. *
  52067. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52068. * glowy meshes to your scene.
  52069. *
  52070. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52071. */
  52072. export class HighlightLayer extends EffectLayer {
  52073. name: string;
  52074. /**
  52075. * Effect Name of the highlight layer.
  52076. */
  52077. static readonly EffectName: string;
  52078. /**
  52079. * The neutral color used during the preparation of the glow effect.
  52080. * This is black by default as the blend operation is a blend operation.
  52081. */
  52082. static NeutralColor: Color4;
  52083. /**
  52084. * Stencil value used for glowing meshes.
  52085. */
  52086. static GlowingMeshStencilReference: number;
  52087. /**
  52088. * Stencil value used for the other meshes in the scene.
  52089. */
  52090. static NormalMeshStencilReference: number;
  52091. /**
  52092. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52093. */
  52094. innerGlow: boolean;
  52095. /**
  52096. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52097. */
  52098. outerGlow: boolean;
  52099. /**
  52100. * Specifies the horizontal size of the blur.
  52101. */
  52102. /**
  52103. * Gets the horizontal size of the blur.
  52104. */
  52105. blurHorizontalSize: number;
  52106. /**
  52107. * Specifies the vertical size of the blur.
  52108. */
  52109. /**
  52110. * Gets the vertical size of the blur.
  52111. */
  52112. blurVerticalSize: number;
  52113. /**
  52114. * An event triggered when the highlight layer is being blurred.
  52115. */
  52116. onBeforeBlurObservable: Observable<HighlightLayer>;
  52117. /**
  52118. * An event triggered when the highlight layer has been blurred.
  52119. */
  52120. onAfterBlurObservable: Observable<HighlightLayer>;
  52121. private _instanceGlowingMeshStencilReference;
  52122. private _options;
  52123. private _downSamplePostprocess;
  52124. private _horizontalBlurPostprocess;
  52125. private _verticalBlurPostprocess;
  52126. private _blurTexture;
  52127. private _meshes;
  52128. private _excludedMeshes;
  52129. /**
  52130. * Instantiates a new highlight Layer and references it to the scene..
  52131. * @param name The name of the layer
  52132. * @param scene The scene to use the layer in
  52133. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52134. */
  52135. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52136. /**
  52137. * Get the effect name of the layer.
  52138. * @return The effect name
  52139. */
  52140. getEffectName(): string;
  52141. /**
  52142. * Create the merge effect. This is the shader use to blit the information back
  52143. * to the main canvas at the end of the scene rendering.
  52144. */
  52145. protected _createMergeEffect(): Effect;
  52146. /**
  52147. * Creates the render target textures and post processes used in the highlight layer.
  52148. */
  52149. protected _createTextureAndPostProcesses(): void;
  52150. /**
  52151. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52152. */
  52153. needStencil(): boolean;
  52154. /**
  52155. * Checks for the readiness of the element composing the layer.
  52156. * @param subMesh the mesh to check for
  52157. * @param useInstances specify wether or not to use instances to render the mesh
  52158. * @param emissiveTexture the associated emissive texture used to generate the glow
  52159. * @return true if ready otherwise, false
  52160. */
  52161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52162. /**
  52163. * Implementation specific of rendering the generating effect on the main canvas.
  52164. * @param effect The effect used to render through
  52165. */
  52166. protected _internalRender(effect: Effect): void;
  52167. /**
  52168. * Returns true if the layer contains information to display, otherwise false.
  52169. */
  52170. shouldRender(): boolean;
  52171. /**
  52172. * Returns true if the mesh should render, otherwise false.
  52173. * @param mesh The mesh to render
  52174. * @returns true if it should render otherwise false
  52175. */
  52176. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52177. /**
  52178. * Sets the required values for both the emissive texture and and the main color.
  52179. */
  52180. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52181. /**
  52182. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52183. * @param mesh The mesh to exclude from the highlight layer
  52184. */
  52185. addExcludedMesh(mesh: Mesh): void;
  52186. /**
  52187. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52188. * @param mesh The mesh to highlight
  52189. */
  52190. removeExcludedMesh(mesh: Mesh): void;
  52191. /**
  52192. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52193. * @param mesh mesh to test
  52194. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52195. */
  52196. hasMesh(mesh: AbstractMesh): boolean;
  52197. /**
  52198. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52199. * @param mesh The mesh to highlight
  52200. * @param color The color of the highlight
  52201. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52202. */
  52203. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52204. /**
  52205. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52206. * @param mesh The mesh to highlight
  52207. */
  52208. removeMesh(mesh: Mesh): void;
  52209. /**
  52210. * Force the stencil to the normal expected value for none glowing parts
  52211. */
  52212. private _defaultStencilReference;
  52213. /**
  52214. * Free any resources and references associated to a mesh.
  52215. * Internal use
  52216. * @param mesh The mesh to free.
  52217. * @hidden
  52218. */
  52219. _disposeMesh(mesh: Mesh): void;
  52220. /**
  52221. * Dispose the highlight layer and free resources.
  52222. */
  52223. dispose(): void;
  52224. /**
  52225. * Gets the class name of the effect layer
  52226. * @returns the string with the class name of the effect layer
  52227. */
  52228. getClassName(): string;
  52229. /**
  52230. * Serializes this Highlight layer
  52231. * @returns a serialized Highlight layer object
  52232. */
  52233. serialize(): any;
  52234. /**
  52235. * Creates a Highlight layer from parsed Highlight layer data
  52236. * @param parsedHightlightLayer defines the Highlight layer data
  52237. * @param scene defines the current scene
  52238. * @param rootUrl defines the root URL containing the Highlight layer information
  52239. * @returns a parsed Highlight layer
  52240. */
  52241. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52242. }
  52243. }
  52244. declare module "babylonjs/Layers/layerSceneComponent" {
  52245. import { Scene } from "babylonjs/scene";
  52246. import { ISceneComponent } from "babylonjs/sceneComponent";
  52247. import { Layer } from "babylonjs/Layers/layer";
  52248. import { AbstractScene } from "babylonjs/abstractScene";
  52249. module "babylonjs/abstractScene" {
  52250. interface AbstractScene {
  52251. /**
  52252. * The list of layers (background and foreground) of the scene
  52253. */
  52254. layers: Array<Layer>;
  52255. }
  52256. }
  52257. /**
  52258. * Defines the layer scene component responsible to manage any layers
  52259. * in a given scene.
  52260. */
  52261. export class LayerSceneComponent implements ISceneComponent {
  52262. /**
  52263. * The component name helpfull to identify the component in the list of scene components.
  52264. */
  52265. readonly name: string;
  52266. /**
  52267. * The scene the component belongs to.
  52268. */
  52269. scene: Scene;
  52270. private _engine;
  52271. /**
  52272. * Creates a new instance of the component for the given scene
  52273. * @param scene Defines the scene to register the component in
  52274. */
  52275. constructor(scene: Scene);
  52276. /**
  52277. * Registers the component in a given scene
  52278. */
  52279. register(): void;
  52280. /**
  52281. * Rebuilds the elements related to this component in case of
  52282. * context lost for instance.
  52283. */
  52284. rebuild(): void;
  52285. /**
  52286. * Disposes the component and the associated ressources.
  52287. */
  52288. dispose(): void;
  52289. private _draw;
  52290. private _drawCameraPredicate;
  52291. private _drawCameraBackground;
  52292. private _drawCameraForeground;
  52293. private _drawRenderTargetPredicate;
  52294. private _drawRenderTargetBackground;
  52295. private _drawRenderTargetForeground;
  52296. /**
  52297. * Adds all the elements from the container to the scene
  52298. * @param container the container holding the elements
  52299. */
  52300. addFromContainer(container: AbstractScene): void;
  52301. /**
  52302. * Removes all the elements in the container from the scene
  52303. * @param container contains the elements to remove
  52304. * @param dispose if the removed element should be disposed (default: false)
  52305. */
  52306. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52307. }
  52308. }
  52309. declare module "babylonjs/Shaders/layer.fragment" {
  52310. /** @hidden */
  52311. export var layerPixelShader: {
  52312. name: string;
  52313. shader: string;
  52314. };
  52315. }
  52316. declare module "babylonjs/Shaders/layer.vertex" {
  52317. /** @hidden */
  52318. export var layerVertexShader: {
  52319. name: string;
  52320. shader: string;
  52321. };
  52322. }
  52323. declare module "babylonjs/Layers/layer" {
  52324. import { Observable } from "babylonjs/Misc/observable";
  52325. import { Nullable } from "babylonjs/types";
  52326. import { Scene } from "babylonjs/scene";
  52327. import { Vector2 } from "babylonjs/Maths/math.vector";
  52328. import { Color4 } from "babylonjs/Maths/math.color";
  52329. import { Texture } from "babylonjs/Materials/Textures/texture";
  52330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52331. import "babylonjs/Shaders/layer.fragment";
  52332. import "babylonjs/Shaders/layer.vertex";
  52333. /**
  52334. * This represents a full screen 2d layer.
  52335. * This can be useful to display a picture in the background of your scene for instance.
  52336. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52337. */
  52338. export class Layer {
  52339. /**
  52340. * Define the name of the layer.
  52341. */
  52342. name: string;
  52343. /**
  52344. * Define the texture the layer should display.
  52345. */
  52346. texture: Nullable<Texture>;
  52347. /**
  52348. * Is the layer in background or foreground.
  52349. */
  52350. isBackground: boolean;
  52351. /**
  52352. * Define the color of the layer (instead of texture).
  52353. */
  52354. color: Color4;
  52355. /**
  52356. * Define the scale of the layer in order to zoom in out of the texture.
  52357. */
  52358. scale: Vector2;
  52359. /**
  52360. * Define an offset for the layer in order to shift the texture.
  52361. */
  52362. offset: Vector2;
  52363. /**
  52364. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52365. */
  52366. alphaBlendingMode: number;
  52367. /**
  52368. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52369. * Alpha test will not mix with the background color in case of transparency.
  52370. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52371. */
  52372. alphaTest: boolean;
  52373. /**
  52374. * Define a mask to restrict the layer to only some of the scene cameras.
  52375. */
  52376. layerMask: number;
  52377. /**
  52378. * Define the list of render target the layer is visible into.
  52379. */
  52380. renderTargetTextures: RenderTargetTexture[];
  52381. /**
  52382. * Define if the layer is only used in renderTarget or if it also
  52383. * renders in the main frame buffer of the canvas.
  52384. */
  52385. renderOnlyInRenderTargetTextures: boolean;
  52386. private _scene;
  52387. private _vertexBuffers;
  52388. private _indexBuffer;
  52389. private _effect;
  52390. private _alphaTestEffect;
  52391. /**
  52392. * An event triggered when the layer is disposed.
  52393. */
  52394. onDisposeObservable: Observable<Layer>;
  52395. private _onDisposeObserver;
  52396. /**
  52397. * Back compatibility with callback before the onDisposeObservable existed.
  52398. * The set callback will be triggered when the layer has been disposed.
  52399. */
  52400. onDispose: () => void;
  52401. /**
  52402. * An event triggered before rendering the scene
  52403. */
  52404. onBeforeRenderObservable: Observable<Layer>;
  52405. private _onBeforeRenderObserver;
  52406. /**
  52407. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52408. * The set callback will be triggered just before rendering the layer.
  52409. */
  52410. onBeforeRender: () => void;
  52411. /**
  52412. * An event triggered after rendering the scene
  52413. */
  52414. onAfterRenderObservable: Observable<Layer>;
  52415. private _onAfterRenderObserver;
  52416. /**
  52417. * Back compatibility with callback before the onAfterRenderObservable existed.
  52418. * The set callback will be triggered just after rendering the layer.
  52419. */
  52420. onAfterRender: () => void;
  52421. /**
  52422. * Instantiates a new layer.
  52423. * This represents a full screen 2d layer.
  52424. * This can be useful to display a picture in the background of your scene for instance.
  52425. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52426. * @param name Define the name of the layer in the scene
  52427. * @param imgUrl Define the url of the texture to display in the layer
  52428. * @param scene Define the scene the layer belongs to
  52429. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52430. * @param color Defines a color for the layer
  52431. */
  52432. constructor(
  52433. /**
  52434. * Define the name of the layer.
  52435. */
  52436. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52437. private _createIndexBuffer;
  52438. /** @hidden */
  52439. _rebuild(): void;
  52440. /**
  52441. * Renders the layer in the scene.
  52442. */
  52443. render(): void;
  52444. /**
  52445. * Disposes and releases the associated ressources.
  52446. */
  52447. dispose(): void;
  52448. }
  52449. }
  52450. declare module "babylonjs/Layers/index" {
  52451. export * from "babylonjs/Layers/effectLayer";
  52452. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52453. export * from "babylonjs/Layers/glowLayer";
  52454. export * from "babylonjs/Layers/highlightLayer";
  52455. export * from "babylonjs/Layers/layer";
  52456. export * from "babylonjs/Layers/layerSceneComponent";
  52457. }
  52458. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52459. /** @hidden */
  52460. export var lensFlarePixelShader: {
  52461. name: string;
  52462. shader: string;
  52463. };
  52464. }
  52465. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52466. /** @hidden */
  52467. export var lensFlareVertexShader: {
  52468. name: string;
  52469. shader: string;
  52470. };
  52471. }
  52472. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52473. import { Scene } from "babylonjs/scene";
  52474. import { Vector3 } from "babylonjs/Maths/math.vector";
  52475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52476. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52477. import "babylonjs/Shaders/lensFlare.fragment";
  52478. import "babylonjs/Shaders/lensFlare.vertex";
  52479. import { Viewport } from "babylonjs/Maths/math.viewport";
  52480. /**
  52481. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52482. * It is usually composed of several `lensFlare`.
  52483. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52484. */
  52485. export class LensFlareSystem {
  52486. /**
  52487. * Define the name of the lens flare system
  52488. */
  52489. name: string;
  52490. /**
  52491. * List of lens flares used in this system.
  52492. */
  52493. lensFlares: LensFlare[];
  52494. /**
  52495. * Define a limit from the border the lens flare can be visible.
  52496. */
  52497. borderLimit: number;
  52498. /**
  52499. * Define a viewport border we do not want to see the lens flare in.
  52500. */
  52501. viewportBorder: number;
  52502. /**
  52503. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52504. */
  52505. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52506. /**
  52507. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52508. */
  52509. layerMask: number;
  52510. /**
  52511. * Define the id of the lens flare system in the scene.
  52512. * (equal to name by default)
  52513. */
  52514. id: string;
  52515. private _scene;
  52516. private _emitter;
  52517. private _vertexBuffers;
  52518. private _indexBuffer;
  52519. private _effect;
  52520. private _positionX;
  52521. private _positionY;
  52522. private _isEnabled;
  52523. /** @hidden */
  52524. static _SceneComponentInitialization: (scene: Scene) => void;
  52525. /**
  52526. * Instantiates a lens flare system.
  52527. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52528. * It is usually composed of several `lensFlare`.
  52529. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52530. * @param name Define the name of the lens flare system in the scene
  52531. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52532. * @param scene Define the scene the lens flare system belongs to
  52533. */
  52534. constructor(
  52535. /**
  52536. * Define the name of the lens flare system
  52537. */
  52538. name: string, emitter: any, scene: Scene);
  52539. /**
  52540. * Define if the lens flare system is enabled.
  52541. */
  52542. isEnabled: boolean;
  52543. /**
  52544. * Get the scene the effects belongs to.
  52545. * @returns the scene holding the lens flare system
  52546. */
  52547. getScene(): Scene;
  52548. /**
  52549. * Get the emitter of the lens flare system.
  52550. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52551. * @returns the emitter of the lens flare system
  52552. */
  52553. getEmitter(): any;
  52554. /**
  52555. * Set the emitter of the lens flare system.
  52556. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52557. * @param newEmitter Define the new emitter of the system
  52558. */
  52559. setEmitter(newEmitter: any): void;
  52560. /**
  52561. * Get the lens flare system emitter position.
  52562. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52563. * @returns the position
  52564. */
  52565. getEmitterPosition(): Vector3;
  52566. /**
  52567. * @hidden
  52568. */
  52569. computeEffectivePosition(globalViewport: Viewport): boolean;
  52570. /** @hidden */
  52571. _isVisible(): boolean;
  52572. /**
  52573. * @hidden
  52574. */
  52575. render(): boolean;
  52576. /**
  52577. * Dispose and release the lens flare with its associated resources.
  52578. */
  52579. dispose(): void;
  52580. /**
  52581. * Parse a lens flare system from a JSON repressentation
  52582. * @param parsedLensFlareSystem Define the JSON to parse
  52583. * @param scene Define the scene the parsed system should be instantiated in
  52584. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52585. * @returns the parsed system
  52586. */
  52587. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52588. /**
  52589. * Serialize the current Lens Flare System into a JSON representation.
  52590. * @returns the serialized JSON
  52591. */
  52592. serialize(): any;
  52593. }
  52594. }
  52595. declare module "babylonjs/LensFlares/lensFlare" {
  52596. import { Nullable } from "babylonjs/types";
  52597. import { Color3 } from "babylonjs/Maths/math.color";
  52598. import { Texture } from "babylonjs/Materials/Textures/texture";
  52599. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52600. /**
  52601. * This represents one of the lens effect in a `lensFlareSystem`.
  52602. * It controls one of the indiviual texture used in the effect.
  52603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52604. */
  52605. export class LensFlare {
  52606. /**
  52607. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52608. */
  52609. size: number;
  52610. /**
  52611. * 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.
  52612. */
  52613. position: number;
  52614. /**
  52615. * Define the lens color.
  52616. */
  52617. color: Color3;
  52618. /**
  52619. * Define the lens texture.
  52620. */
  52621. texture: Nullable<Texture>;
  52622. /**
  52623. * Define the alpha mode to render this particular lens.
  52624. */
  52625. alphaMode: number;
  52626. private _system;
  52627. /**
  52628. * Creates a new Lens Flare.
  52629. * This represents one of the lens effect in a `lensFlareSystem`.
  52630. * It controls one of the indiviual texture used in the effect.
  52631. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52632. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52633. * @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.
  52634. * @param color Define the lens color
  52635. * @param imgUrl Define the lens texture url
  52636. * @param system Define the `lensFlareSystem` this flare is part of
  52637. * @returns The newly created Lens Flare
  52638. */
  52639. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52640. /**
  52641. * Instantiates a new Lens Flare.
  52642. * This represents one of the lens effect in a `lensFlareSystem`.
  52643. * It controls one of the indiviual texture used in the effect.
  52644. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52645. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52646. * @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.
  52647. * @param color Define the lens color
  52648. * @param imgUrl Define the lens texture url
  52649. * @param system Define the `lensFlareSystem` this flare is part of
  52650. */
  52651. constructor(
  52652. /**
  52653. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52654. */
  52655. size: number,
  52656. /**
  52657. * 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.
  52658. */
  52659. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52660. /**
  52661. * Dispose and release the lens flare with its associated resources.
  52662. */
  52663. dispose(): void;
  52664. }
  52665. }
  52666. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52667. import { Nullable } from "babylonjs/types";
  52668. import { Scene } from "babylonjs/scene";
  52669. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52670. import { AbstractScene } from "babylonjs/abstractScene";
  52671. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52672. module "babylonjs/abstractScene" {
  52673. interface AbstractScene {
  52674. /**
  52675. * The list of lens flare system added to the scene
  52676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52677. */
  52678. lensFlareSystems: Array<LensFlareSystem>;
  52679. /**
  52680. * Removes the given lens flare system from this scene.
  52681. * @param toRemove The lens flare system to remove
  52682. * @returns The index of the removed lens flare system
  52683. */
  52684. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52685. /**
  52686. * Adds the given lens flare system to this scene
  52687. * @param newLensFlareSystem The lens flare system to add
  52688. */
  52689. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52690. /**
  52691. * Gets a lens flare system using its name
  52692. * @param name defines the name to look for
  52693. * @returns the lens flare system or null if not found
  52694. */
  52695. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52696. /**
  52697. * Gets a lens flare system using its id
  52698. * @param id defines the id to look for
  52699. * @returns the lens flare system or null if not found
  52700. */
  52701. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52702. }
  52703. }
  52704. /**
  52705. * Defines the lens flare scene component responsible to manage any lens flares
  52706. * in a given scene.
  52707. */
  52708. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52709. /**
  52710. * The component name helpfull to identify the component in the list of scene components.
  52711. */
  52712. readonly name: string;
  52713. /**
  52714. * The scene the component belongs to.
  52715. */
  52716. scene: Scene;
  52717. /**
  52718. * Creates a new instance of the component for the given scene
  52719. * @param scene Defines the scene to register the component in
  52720. */
  52721. constructor(scene: Scene);
  52722. /**
  52723. * Registers the component in a given scene
  52724. */
  52725. register(): void;
  52726. /**
  52727. * Rebuilds the elements related to this component in case of
  52728. * context lost for instance.
  52729. */
  52730. rebuild(): void;
  52731. /**
  52732. * Adds all the elements from the container to the scene
  52733. * @param container the container holding the elements
  52734. */
  52735. addFromContainer(container: AbstractScene): void;
  52736. /**
  52737. * Removes all the elements in the container from the scene
  52738. * @param container contains the elements to remove
  52739. * @param dispose if the removed element should be disposed (default: false)
  52740. */
  52741. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52742. /**
  52743. * Serializes the component data to the specified json object
  52744. * @param serializationObject The object to serialize to
  52745. */
  52746. serialize(serializationObject: any): void;
  52747. /**
  52748. * Disposes the component and the associated ressources.
  52749. */
  52750. dispose(): void;
  52751. private _draw;
  52752. }
  52753. }
  52754. declare module "babylonjs/LensFlares/index" {
  52755. export * from "babylonjs/LensFlares/lensFlare";
  52756. export * from "babylonjs/LensFlares/lensFlareSystem";
  52757. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52758. }
  52759. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52760. import { Scene } from "babylonjs/scene";
  52761. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52762. import { AbstractScene } from "babylonjs/abstractScene";
  52763. /**
  52764. * Defines the shadow generator component responsible to manage any shadow generators
  52765. * in a given scene.
  52766. */
  52767. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52768. /**
  52769. * The component name helpfull to identify the component in the list of scene components.
  52770. */
  52771. readonly name: string;
  52772. /**
  52773. * The scene the component belongs to.
  52774. */
  52775. scene: Scene;
  52776. /**
  52777. * Creates a new instance of the component for the given scene
  52778. * @param scene Defines the scene to register the component in
  52779. */
  52780. constructor(scene: Scene);
  52781. /**
  52782. * Registers the component in a given scene
  52783. */
  52784. register(): void;
  52785. /**
  52786. * Rebuilds the elements related to this component in case of
  52787. * context lost for instance.
  52788. */
  52789. rebuild(): void;
  52790. /**
  52791. * Serializes the component data to the specified json object
  52792. * @param serializationObject The object to serialize to
  52793. */
  52794. serialize(serializationObject: any): void;
  52795. /**
  52796. * Adds all the elements from the container to the scene
  52797. * @param container the container holding the elements
  52798. */
  52799. addFromContainer(container: AbstractScene): void;
  52800. /**
  52801. * Removes all the elements in the container from the scene
  52802. * @param container contains the elements to remove
  52803. * @param dispose if the removed element should be disposed (default: false)
  52804. */
  52805. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52806. /**
  52807. * Rebuilds the elements related to this component in case of
  52808. * context lost for instance.
  52809. */
  52810. dispose(): void;
  52811. private _gatherRenderTargets;
  52812. }
  52813. }
  52814. declare module "babylonjs/Lights/Shadows/index" {
  52815. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52816. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52817. }
  52818. declare module "babylonjs/Lights/pointLight" {
  52819. import { Scene } from "babylonjs/scene";
  52820. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52822. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52823. import { Effect } from "babylonjs/Materials/effect";
  52824. /**
  52825. * A point light is a light defined by an unique point in world space.
  52826. * The light is emitted in every direction from this point.
  52827. * A good example of a point light is a standard light bulb.
  52828. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52829. */
  52830. export class PointLight extends ShadowLight {
  52831. private _shadowAngle;
  52832. /**
  52833. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52834. * This specifies what angle the shadow will use to be created.
  52835. *
  52836. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52837. */
  52838. /**
  52839. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52840. * This specifies what angle the shadow will use to be created.
  52841. *
  52842. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52843. */
  52844. shadowAngle: number;
  52845. /**
  52846. * Gets the direction if it has been set.
  52847. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52848. */
  52849. /**
  52850. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52851. */
  52852. direction: Vector3;
  52853. /**
  52854. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52855. * A PointLight emits the light in every direction.
  52856. * It can cast shadows.
  52857. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52858. * ```javascript
  52859. * var pointLight = new PointLight("pl", camera.position, scene);
  52860. * ```
  52861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52862. * @param name The light friendly name
  52863. * @param position The position of the point light in the scene
  52864. * @param scene The scene the lights belongs to
  52865. */
  52866. constructor(name: string, position: Vector3, scene: Scene);
  52867. /**
  52868. * Returns the string "PointLight"
  52869. * @returns the class name
  52870. */
  52871. getClassName(): string;
  52872. /**
  52873. * Returns the integer 0.
  52874. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52875. */
  52876. getTypeID(): number;
  52877. /**
  52878. * Specifies wether or not the shadowmap should be a cube texture.
  52879. * @returns true if the shadowmap needs to be a cube texture.
  52880. */
  52881. needCube(): boolean;
  52882. /**
  52883. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52884. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52885. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52886. */
  52887. getShadowDirection(faceIndex?: number): Vector3;
  52888. /**
  52889. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52890. * - fov = PI / 2
  52891. * - aspect ratio : 1.0
  52892. * - z-near and far equal to the active camera minZ and maxZ.
  52893. * Returns the PointLight.
  52894. */
  52895. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52896. protected _buildUniformLayout(): void;
  52897. /**
  52898. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52899. * @param effect The effect to update
  52900. * @param lightIndex The index of the light in the effect to update
  52901. * @returns The point light
  52902. */
  52903. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52904. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52905. /**
  52906. * Prepares the list of defines specific to the light type.
  52907. * @param defines the list of defines
  52908. * @param lightIndex defines the index of the light for the effect
  52909. */
  52910. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52911. }
  52912. }
  52913. declare module "babylonjs/Lights/index" {
  52914. export * from "babylonjs/Lights/light";
  52915. export * from "babylonjs/Lights/shadowLight";
  52916. export * from "babylonjs/Lights/Shadows/index";
  52917. export * from "babylonjs/Lights/directionalLight";
  52918. export * from "babylonjs/Lights/hemisphericLight";
  52919. export * from "babylonjs/Lights/pointLight";
  52920. export * from "babylonjs/Lights/spotLight";
  52921. }
  52922. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52923. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52924. /**
  52925. * Header information of HDR texture files.
  52926. */
  52927. export interface HDRInfo {
  52928. /**
  52929. * The height of the texture in pixels.
  52930. */
  52931. height: number;
  52932. /**
  52933. * The width of the texture in pixels.
  52934. */
  52935. width: number;
  52936. /**
  52937. * The index of the beginning of the data in the binary file.
  52938. */
  52939. dataPosition: number;
  52940. }
  52941. /**
  52942. * This groups tools to convert HDR texture to native colors array.
  52943. */
  52944. export class HDRTools {
  52945. private static Ldexp;
  52946. private static Rgbe2float;
  52947. private static readStringLine;
  52948. /**
  52949. * Reads header information from an RGBE texture stored in a native array.
  52950. * More information on this format are available here:
  52951. * https://en.wikipedia.org/wiki/RGBE_image_format
  52952. *
  52953. * @param uint8array The binary file stored in native array.
  52954. * @return The header information.
  52955. */
  52956. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52957. /**
  52958. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52959. * This RGBE texture needs to store the information as a panorama.
  52960. *
  52961. * More information on this format are available here:
  52962. * https://en.wikipedia.org/wiki/RGBE_image_format
  52963. *
  52964. * @param buffer The binary file stored in an array buffer.
  52965. * @param size The expected size of the extracted cubemap.
  52966. * @return The Cube Map information.
  52967. */
  52968. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52969. /**
  52970. * Returns the pixels data extracted from an RGBE texture.
  52971. * This pixels will be stored left to right up to down in the R G B order in one array.
  52972. *
  52973. * More information on this format are available here:
  52974. * https://en.wikipedia.org/wiki/RGBE_image_format
  52975. *
  52976. * @param uint8array The binary file stored in an array buffer.
  52977. * @param hdrInfo The header information of the file.
  52978. * @return The pixels data in RGB right to left up to down order.
  52979. */
  52980. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52981. private static RGBE_ReadPixels_RLE;
  52982. }
  52983. }
  52984. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52985. import { Nullable } from "babylonjs/types";
  52986. import { Scene } from "babylonjs/scene";
  52987. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52989. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52990. /**
  52991. * This represents a texture coming from an HDR input.
  52992. *
  52993. * The only supported format is currently panorama picture stored in RGBE format.
  52994. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52995. */
  52996. export class HDRCubeTexture extends BaseTexture {
  52997. private static _facesMapping;
  52998. private _generateHarmonics;
  52999. private _noMipmap;
  53000. private _textureMatrix;
  53001. private _size;
  53002. private _onLoad;
  53003. private _onError;
  53004. /**
  53005. * The texture URL.
  53006. */
  53007. url: string;
  53008. /**
  53009. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53010. */
  53011. coordinatesMode: number;
  53012. protected _isBlocking: boolean;
  53013. /**
  53014. * Sets wether or not the texture is blocking during loading.
  53015. */
  53016. /**
  53017. * Gets wether or not the texture is blocking during loading.
  53018. */
  53019. isBlocking: boolean;
  53020. protected _rotationY: number;
  53021. /**
  53022. * Sets texture matrix rotation angle around Y axis in radians.
  53023. */
  53024. /**
  53025. * Gets texture matrix rotation angle around Y axis radians.
  53026. */
  53027. rotationY: number;
  53028. /**
  53029. * Gets or sets the center of the bounding box associated with the cube texture
  53030. * It must define where the camera used to render the texture was set
  53031. */
  53032. boundingBoxPosition: Vector3;
  53033. private _boundingBoxSize;
  53034. /**
  53035. * Gets or sets the size of the bounding box associated with the cube texture
  53036. * When defined, the cubemap will switch to local mode
  53037. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53038. * @example https://www.babylonjs-playground.com/#RNASML
  53039. */
  53040. boundingBoxSize: Vector3;
  53041. /**
  53042. * Instantiates an HDRTexture from the following parameters.
  53043. *
  53044. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53045. * @param scene The scene the texture will be used in
  53046. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53047. * @param noMipmap Forces to not generate the mipmap if true
  53048. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53049. * @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)
  53050. * @param reserved Reserved flag for internal use.
  53051. */
  53052. 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>);
  53053. /**
  53054. * Get the current class name of the texture useful for serialization or dynamic coding.
  53055. * @returns "HDRCubeTexture"
  53056. */
  53057. getClassName(): string;
  53058. /**
  53059. * Occurs when the file is raw .hdr file.
  53060. */
  53061. private loadTexture;
  53062. clone(): HDRCubeTexture;
  53063. delayLoad(): void;
  53064. /**
  53065. * Get the texture reflection matrix used to rotate/transform the reflection.
  53066. * @returns the reflection matrix
  53067. */
  53068. getReflectionTextureMatrix(): Matrix;
  53069. /**
  53070. * Set the texture reflection matrix used to rotate/transform the reflection.
  53071. * @param value Define the reflection matrix to set
  53072. */
  53073. setReflectionTextureMatrix(value: Matrix): void;
  53074. /**
  53075. * Parses a JSON representation of an HDR Texture in order to create the texture
  53076. * @param parsedTexture Define the JSON representation
  53077. * @param scene Define the scene the texture should be created in
  53078. * @param rootUrl Define the root url in case we need to load relative dependencies
  53079. * @returns the newly created texture after parsing
  53080. */
  53081. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53082. serialize(): any;
  53083. }
  53084. }
  53085. declare module "babylonjs/Physics/physicsEngine" {
  53086. import { Nullable } from "babylonjs/types";
  53087. import { Vector3 } from "babylonjs/Maths/math.vector";
  53088. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53089. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53090. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53091. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53092. /**
  53093. * Class used to control physics engine
  53094. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53095. */
  53096. export class PhysicsEngine implements IPhysicsEngine {
  53097. private _physicsPlugin;
  53098. /**
  53099. * Global value used to control the smallest number supported by the simulation
  53100. */
  53101. static Epsilon: number;
  53102. private _impostors;
  53103. private _joints;
  53104. /**
  53105. * Gets the gravity vector used by the simulation
  53106. */
  53107. gravity: Vector3;
  53108. /**
  53109. * Factory used to create the default physics plugin.
  53110. * @returns The default physics plugin
  53111. */
  53112. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53113. /**
  53114. * Creates a new Physics Engine
  53115. * @param gravity defines the gravity vector used by the simulation
  53116. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53117. */
  53118. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53119. /**
  53120. * Sets the gravity vector used by the simulation
  53121. * @param gravity defines the gravity vector to use
  53122. */
  53123. setGravity(gravity: Vector3): void;
  53124. /**
  53125. * Set the time step of the physics engine.
  53126. * Default is 1/60.
  53127. * To slow it down, enter 1/600 for example.
  53128. * To speed it up, 1/30
  53129. * @param newTimeStep defines the new timestep to apply to this world.
  53130. */
  53131. setTimeStep(newTimeStep?: number): void;
  53132. /**
  53133. * Get the time step of the physics engine.
  53134. * @returns the current time step
  53135. */
  53136. getTimeStep(): number;
  53137. /**
  53138. * Release all resources
  53139. */
  53140. dispose(): void;
  53141. /**
  53142. * Gets the name of the current physics plugin
  53143. * @returns the name of the plugin
  53144. */
  53145. getPhysicsPluginName(): string;
  53146. /**
  53147. * Adding a new impostor for the impostor tracking.
  53148. * This will be done by the impostor itself.
  53149. * @param impostor the impostor to add
  53150. */
  53151. addImpostor(impostor: PhysicsImpostor): void;
  53152. /**
  53153. * Remove an impostor from the engine.
  53154. * This impostor and its mesh will not longer be updated by the physics engine.
  53155. * @param impostor the impostor to remove
  53156. */
  53157. removeImpostor(impostor: PhysicsImpostor): void;
  53158. /**
  53159. * Add a joint to the physics engine
  53160. * @param mainImpostor defines the main impostor to which the joint is added.
  53161. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53162. * @param joint defines the joint that will connect both impostors.
  53163. */
  53164. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53165. /**
  53166. * Removes a joint from the simulation
  53167. * @param mainImpostor defines the impostor used with the joint
  53168. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53169. * @param joint defines the joint to remove
  53170. */
  53171. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53172. /**
  53173. * Called by the scene. No need to call it.
  53174. * @param delta defines the timespam between frames
  53175. */
  53176. _step(delta: number): void;
  53177. /**
  53178. * Gets the current plugin used to run the simulation
  53179. * @returns current plugin
  53180. */
  53181. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53182. /**
  53183. * Gets the list of physic impostors
  53184. * @returns an array of PhysicsImpostor
  53185. */
  53186. getImpostors(): Array<PhysicsImpostor>;
  53187. /**
  53188. * Gets the impostor for a physics enabled object
  53189. * @param object defines the object impersonated by the impostor
  53190. * @returns the PhysicsImpostor or null if not found
  53191. */
  53192. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53193. /**
  53194. * Gets the impostor for a physics body object
  53195. * @param body defines physics body used by the impostor
  53196. * @returns the PhysicsImpostor or null if not found
  53197. */
  53198. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53199. /**
  53200. * Does a raycast in the physics world
  53201. * @param from when should the ray start?
  53202. * @param to when should the ray end?
  53203. * @returns PhysicsRaycastResult
  53204. */
  53205. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53206. }
  53207. }
  53208. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53209. import { Nullable } from "babylonjs/types";
  53210. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53212. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53213. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53214. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53215. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53216. /** @hidden */
  53217. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53218. private _useDeltaForWorldStep;
  53219. world: any;
  53220. name: string;
  53221. private _physicsMaterials;
  53222. private _fixedTimeStep;
  53223. private _cannonRaycastResult;
  53224. private _raycastResult;
  53225. private _physicsBodysToRemoveAfterStep;
  53226. BJSCANNON: any;
  53227. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53228. setGravity(gravity: Vector3): void;
  53229. setTimeStep(timeStep: number): void;
  53230. getTimeStep(): number;
  53231. executeStep(delta: number): void;
  53232. private _removeMarkedPhysicsBodiesFromWorld;
  53233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53234. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53235. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53236. private _processChildMeshes;
  53237. removePhysicsBody(impostor: PhysicsImpostor): void;
  53238. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53239. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53240. private _addMaterial;
  53241. private _checkWithEpsilon;
  53242. private _createShape;
  53243. private _createHeightmap;
  53244. private _minus90X;
  53245. private _plus90X;
  53246. private _tmpPosition;
  53247. private _tmpDeltaPosition;
  53248. private _tmpUnityRotation;
  53249. private _updatePhysicsBodyTransformation;
  53250. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53251. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53252. isSupported(): boolean;
  53253. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53254. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53255. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53256. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53257. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53258. getBodyMass(impostor: PhysicsImpostor): number;
  53259. getBodyFriction(impostor: PhysicsImpostor): number;
  53260. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53261. getBodyRestitution(impostor: PhysicsImpostor): number;
  53262. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53263. sleepBody(impostor: PhysicsImpostor): void;
  53264. wakeUpBody(impostor: PhysicsImpostor): void;
  53265. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53266. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53267. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53268. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53269. getRadius(impostor: PhysicsImpostor): number;
  53270. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53271. dispose(): void;
  53272. private _extendNamespace;
  53273. /**
  53274. * Does a raycast in the physics world
  53275. * @param from when should the ray start?
  53276. * @param to when should the ray end?
  53277. * @returns PhysicsRaycastResult
  53278. */
  53279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53280. }
  53281. }
  53282. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53283. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53284. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53285. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53287. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53288. import { Nullable } from "babylonjs/types";
  53289. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53290. /** @hidden */
  53291. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53292. world: any;
  53293. name: string;
  53294. BJSOIMO: any;
  53295. private _raycastResult;
  53296. constructor(iterations?: number, oimoInjection?: any);
  53297. setGravity(gravity: Vector3): void;
  53298. setTimeStep(timeStep: number): void;
  53299. getTimeStep(): number;
  53300. private _tmpImpostorsArray;
  53301. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53302. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53303. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53304. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53305. private _tmpPositionVector;
  53306. removePhysicsBody(impostor: PhysicsImpostor): void;
  53307. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53308. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53309. isSupported(): boolean;
  53310. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53311. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53312. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53313. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53314. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53315. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53316. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53317. getBodyMass(impostor: PhysicsImpostor): number;
  53318. getBodyFriction(impostor: PhysicsImpostor): number;
  53319. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53320. getBodyRestitution(impostor: PhysicsImpostor): number;
  53321. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53322. sleepBody(impostor: PhysicsImpostor): void;
  53323. wakeUpBody(impostor: PhysicsImpostor): void;
  53324. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53325. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53326. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53327. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53328. getRadius(impostor: PhysicsImpostor): number;
  53329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53330. dispose(): void;
  53331. /**
  53332. * Does a raycast in the physics world
  53333. * @param from when should the ray start?
  53334. * @param to when should the ray end?
  53335. * @returns PhysicsRaycastResult
  53336. */
  53337. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53338. }
  53339. }
  53340. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53341. import { Nullable } from "babylonjs/types";
  53342. import { Scene } from "babylonjs/scene";
  53343. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53344. import { Color4 } from "babylonjs/Maths/math.color";
  53345. import { Mesh } from "babylonjs/Meshes/mesh";
  53346. /**
  53347. * Class containing static functions to help procedurally build meshes
  53348. */
  53349. export class RibbonBuilder {
  53350. /**
  53351. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53352. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53353. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53354. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53355. * * 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
  53356. * * 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
  53357. * * 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
  53358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53361. * * 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
  53362. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53363. * * 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
  53364. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53366. * @param name defines the name of the mesh
  53367. * @param options defines the options used to create the mesh
  53368. * @param scene defines the hosting scene
  53369. * @returns the ribbon mesh
  53370. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53372. */
  53373. static CreateRibbon(name: string, options: {
  53374. pathArray: Vector3[][];
  53375. closeArray?: boolean;
  53376. closePath?: boolean;
  53377. offset?: number;
  53378. updatable?: boolean;
  53379. sideOrientation?: number;
  53380. frontUVs?: Vector4;
  53381. backUVs?: Vector4;
  53382. instance?: Mesh;
  53383. invertUV?: boolean;
  53384. uvs?: Vector2[];
  53385. colors?: Color4[];
  53386. }, scene?: Nullable<Scene>): Mesh;
  53387. }
  53388. }
  53389. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53390. import { Nullable } from "babylonjs/types";
  53391. import { Scene } from "babylonjs/scene";
  53392. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53393. import { Mesh } from "babylonjs/Meshes/mesh";
  53394. /**
  53395. * Class containing static functions to help procedurally build meshes
  53396. */
  53397. export class ShapeBuilder {
  53398. /**
  53399. * 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.
  53400. * * 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.
  53401. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53402. * * 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.
  53403. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53404. * * 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
  53405. * * 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
  53406. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53411. * @param name defines the name of the mesh
  53412. * @param options defines the options used to create the mesh
  53413. * @param scene defines the hosting scene
  53414. * @returns the extruded shape mesh
  53415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53417. */
  53418. static ExtrudeShape(name: string, options: {
  53419. shape: Vector3[];
  53420. path: Vector3[];
  53421. scale?: number;
  53422. rotation?: number;
  53423. cap?: number;
  53424. updatable?: boolean;
  53425. sideOrientation?: number;
  53426. frontUVs?: Vector4;
  53427. backUVs?: Vector4;
  53428. instance?: Mesh;
  53429. invertUV?: boolean;
  53430. }, scene?: Nullable<Scene>): Mesh;
  53431. /**
  53432. * Creates an custom extruded shape mesh.
  53433. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53434. * * 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.
  53435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53436. * * 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
  53437. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53438. * * 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
  53439. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53440. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53441. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53442. * * 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
  53443. * * 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
  53444. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53447. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53449. * @param name defines the name of the mesh
  53450. * @param options defines the options used to create the mesh
  53451. * @param scene defines the hosting scene
  53452. * @returns the custom extruded shape mesh
  53453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53454. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53456. */
  53457. static ExtrudeShapeCustom(name: string, options: {
  53458. shape: Vector3[];
  53459. path: Vector3[];
  53460. scaleFunction?: any;
  53461. rotationFunction?: any;
  53462. ribbonCloseArray?: boolean;
  53463. ribbonClosePath?: boolean;
  53464. cap?: number;
  53465. updatable?: boolean;
  53466. sideOrientation?: number;
  53467. frontUVs?: Vector4;
  53468. backUVs?: Vector4;
  53469. instance?: Mesh;
  53470. invertUV?: boolean;
  53471. }, scene?: Nullable<Scene>): Mesh;
  53472. private static _ExtrudeShapeGeneric;
  53473. }
  53474. }
  53475. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53476. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53477. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53478. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53479. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53480. import { Nullable } from "babylonjs/types";
  53481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53482. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53483. /**
  53484. * AmmoJS Physics plugin
  53485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53486. * @see https://github.com/kripken/ammo.js/
  53487. */
  53488. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53489. private _useDeltaForWorldStep;
  53490. /**
  53491. * Reference to the Ammo library
  53492. */
  53493. bjsAMMO: any;
  53494. /**
  53495. * Created ammoJS world which physics bodies are added to
  53496. */
  53497. world: any;
  53498. /**
  53499. * Name of the plugin
  53500. */
  53501. name: string;
  53502. private _timeStep;
  53503. private _fixedTimeStep;
  53504. private _maxSteps;
  53505. private _tmpQuaternion;
  53506. private _tmpAmmoTransform;
  53507. private _tmpAmmoQuaternion;
  53508. private _tmpAmmoConcreteContactResultCallback;
  53509. private _collisionConfiguration;
  53510. private _dispatcher;
  53511. private _overlappingPairCache;
  53512. private _solver;
  53513. private _softBodySolver;
  53514. private _tmpAmmoVectorA;
  53515. private _tmpAmmoVectorB;
  53516. private _tmpAmmoVectorC;
  53517. private _tmpAmmoVectorD;
  53518. private _tmpContactCallbackResult;
  53519. private _tmpAmmoVectorRCA;
  53520. private _tmpAmmoVectorRCB;
  53521. private _raycastResult;
  53522. private static readonly DISABLE_COLLISION_FLAG;
  53523. private static readonly KINEMATIC_FLAG;
  53524. private static readonly DISABLE_DEACTIVATION_FLAG;
  53525. /**
  53526. * Initializes the ammoJS plugin
  53527. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53528. * @param ammoInjection can be used to inject your own ammo reference
  53529. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53530. */
  53531. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53532. /**
  53533. * Sets the gravity of the physics world (m/(s^2))
  53534. * @param gravity Gravity to set
  53535. */
  53536. setGravity(gravity: Vector3): void;
  53537. /**
  53538. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53539. * @param timeStep timestep to use in seconds
  53540. */
  53541. setTimeStep(timeStep: number): void;
  53542. /**
  53543. * 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)
  53544. * @param fixedTimeStep fixedTimeStep to use in seconds
  53545. */
  53546. setFixedTimeStep(fixedTimeStep: number): void;
  53547. /**
  53548. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53549. * @param maxSteps the maximum number of steps by the physics engine per frame
  53550. */
  53551. setMaxSteps(maxSteps: number): void;
  53552. /**
  53553. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53554. * @returns the current timestep in seconds
  53555. */
  53556. getTimeStep(): number;
  53557. private _isImpostorInContact;
  53558. private _isImpostorPairInContact;
  53559. private _stepSimulation;
  53560. /**
  53561. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53562. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53563. * After the step the babylon meshes are set to the position of the physics imposters
  53564. * @param delta amount of time to step forward
  53565. * @param impostors array of imposters to update before/after the step
  53566. */
  53567. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53568. /**
  53569. * Update babylon mesh to match physics world object
  53570. * @param impostor imposter to match
  53571. */
  53572. private _afterSoftStep;
  53573. /**
  53574. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53575. * @param impostor imposter to match
  53576. */
  53577. private _ropeStep;
  53578. /**
  53579. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53580. * @param impostor imposter to match
  53581. */
  53582. private _softbodyOrClothStep;
  53583. private _tmpVector;
  53584. private _tmpMatrix;
  53585. /**
  53586. * Applies an impulse on the imposter
  53587. * @param impostor imposter to apply impulse to
  53588. * @param force amount of force to be applied to the imposter
  53589. * @param contactPoint the location to apply the impulse on the imposter
  53590. */
  53591. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53592. /**
  53593. * Applies a force on the imposter
  53594. * @param impostor imposter to apply force
  53595. * @param force amount of force to be applied to the imposter
  53596. * @param contactPoint the location to apply the force on the imposter
  53597. */
  53598. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53599. /**
  53600. * Creates a physics body using the plugin
  53601. * @param impostor the imposter to create the physics body on
  53602. */
  53603. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53604. /**
  53605. * Removes the physics body from the imposter and disposes of the body's memory
  53606. * @param impostor imposter to remove the physics body from
  53607. */
  53608. removePhysicsBody(impostor: PhysicsImpostor): void;
  53609. /**
  53610. * Generates a joint
  53611. * @param impostorJoint the imposter joint to create the joint with
  53612. */
  53613. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53614. /**
  53615. * Removes a joint
  53616. * @param impostorJoint the imposter joint to remove the joint from
  53617. */
  53618. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53619. private _addMeshVerts;
  53620. /**
  53621. * Initialise the soft body vertices to match its object's (mesh) vertices
  53622. * Softbody vertices (nodes) are in world space and to match this
  53623. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53624. * @param impostor to create the softbody for
  53625. */
  53626. private _softVertexData;
  53627. /**
  53628. * Create an impostor's soft body
  53629. * @param impostor to create the softbody for
  53630. */
  53631. private _createSoftbody;
  53632. /**
  53633. * Create cloth for an impostor
  53634. * @param impostor to create the softbody for
  53635. */
  53636. private _createCloth;
  53637. /**
  53638. * Create rope for an impostor
  53639. * @param impostor to create the softbody for
  53640. */
  53641. private _createRope;
  53642. private _addHullVerts;
  53643. private _createShape;
  53644. /**
  53645. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53646. * @param impostor imposter containing the physics body and babylon object
  53647. */
  53648. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53649. /**
  53650. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53651. * @param impostor imposter containing the physics body and babylon object
  53652. * @param newPosition new position
  53653. * @param newRotation new rotation
  53654. */
  53655. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53656. /**
  53657. * If this plugin is supported
  53658. * @returns true if its supported
  53659. */
  53660. isSupported(): boolean;
  53661. /**
  53662. * Sets the linear velocity of the physics body
  53663. * @param impostor imposter to set the velocity on
  53664. * @param velocity velocity to set
  53665. */
  53666. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53667. /**
  53668. * Sets the angular velocity of the physics body
  53669. * @param impostor imposter to set the velocity on
  53670. * @param velocity velocity to set
  53671. */
  53672. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53673. /**
  53674. * gets the linear velocity
  53675. * @param impostor imposter to get linear velocity from
  53676. * @returns linear velocity
  53677. */
  53678. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53679. /**
  53680. * gets the angular velocity
  53681. * @param impostor imposter to get angular velocity from
  53682. * @returns angular velocity
  53683. */
  53684. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53685. /**
  53686. * Sets the mass of physics body
  53687. * @param impostor imposter to set the mass on
  53688. * @param mass mass to set
  53689. */
  53690. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53691. /**
  53692. * Gets the mass of the physics body
  53693. * @param impostor imposter to get the mass from
  53694. * @returns mass
  53695. */
  53696. getBodyMass(impostor: PhysicsImpostor): number;
  53697. /**
  53698. * Gets friction of the impostor
  53699. * @param impostor impostor to get friction from
  53700. * @returns friction value
  53701. */
  53702. getBodyFriction(impostor: PhysicsImpostor): number;
  53703. /**
  53704. * Sets friction of the impostor
  53705. * @param impostor impostor to set friction on
  53706. * @param friction friction value
  53707. */
  53708. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53709. /**
  53710. * Gets restitution of the impostor
  53711. * @param impostor impostor to get restitution from
  53712. * @returns restitution value
  53713. */
  53714. getBodyRestitution(impostor: PhysicsImpostor): number;
  53715. /**
  53716. * Sets resitution of the impostor
  53717. * @param impostor impostor to set resitution on
  53718. * @param restitution resitution value
  53719. */
  53720. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53721. /**
  53722. * Gets pressure inside the impostor
  53723. * @param impostor impostor to get pressure from
  53724. * @returns pressure value
  53725. */
  53726. getBodyPressure(impostor: PhysicsImpostor): number;
  53727. /**
  53728. * Sets pressure inside a soft body impostor
  53729. * Cloth and rope must remain 0 pressure
  53730. * @param impostor impostor to set pressure on
  53731. * @param pressure pressure value
  53732. */
  53733. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53734. /**
  53735. * Gets stiffness of the impostor
  53736. * @param impostor impostor to get stiffness from
  53737. * @returns pressure value
  53738. */
  53739. getBodyStiffness(impostor: PhysicsImpostor): number;
  53740. /**
  53741. * Sets stiffness of the impostor
  53742. * @param impostor impostor to set stiffness on
  53743. * @param stiffness stiffness value from 0 to 1
  53744. */
  53745. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53746. /**
  53747. * Gets velocityIterations of the impostor
  53748. * @param impostor impostor to get velocity iterations from
  53749. * @returns velocityIterations value
  53750. */
  53751. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53752. /**
  53753. * Sets velocityIterations of the impostor
  53754. * @param impostor impostor to set velocity iterations on
  53755. * @param velocityIterations velocityIterations value
  53756. */
  53757. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53758. /**
  53759. * Gets positionIterations of the impostor
  53760. * @param impostor impostor to get position iterations from
  53761. * @returns positionIterations value
  53762. */
  53763. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53764. /**
  53765. * Sets positionIterations of the impostor
  53766. * @param impostor impostor to set position on
  53767. * @param positionIterations positionIterations value
  53768. */
  53769. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53770. /**
  53771. * Append an anchor to a cloth object
  53772. * @param impostor is the cloth impostor to add anchor to
  53773. * @param otherImpostor is the rigid impostor to anchor to
  53774. * @param width ratio across width from 0 to 1
  53775. * @param height ratio up height from 0 to 1
  53776. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53777. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53778. */
  53779. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53780. /**
  53781. * Append an hook to a rope object
  53782. * @param impostor is the rope impostor to add hook to
  53783. * @param otherImpostor is the rigid impostor to hook to
  53784. * @param length ratio along the rope from 0 to 1
  53785. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53786. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53787. */
  53788. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53789. /**
  53790. * Sleeps the physics body and stops it from being active
  53791. * @param impostor impostor to sleep
  53792. */
  53793. sleepBody(impostor: PhysicsImpostor): void;
  53794. /**
  53795. * Activates the physics body
  53796. * @param impostor impostor to activate
  53797. */
  53798. wakeUpBody(impostor: PhysicsImpostor): void;
  53799. /**
  53800. * Updates the distance parameters of the joint
  53801. * @param joint joint to update
  53802. * @param maxDistance maximum distance of the joint
  53803. * @param minDistance minimum distance of the joint
  53804. */
  53805. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53806. /**
  53807. * Sets a motor on the joint
  53808. * @param joint joint to set motor on
  53809. * @param speed speed of the motor
  53810. * @param maxForce maximum force of the motor
  53811. * @param motorIndex index of the motor
  53812. */
  53813. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53814. /**
  53815. * Sets the motors limit
  53816. * @param joint joint to set limit on
  53817. * @param upperLimit upper limit
  53818. * @param lowerLimit lower limit
  53819. */
  53820. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53821. /**
  53822. * Syncs the position and rotation of a mesh with the impostor
  53823. * @param mesh mesh to sync
  53824. * @param impostor impostor to update the mesh with
  53825. */
  53826. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53827. /**
  53828. * Gets the radius of the impostor
  53829. * @param impostor impostor to get radius from
  53830. * @returns the radius
  53831. */
  53832. getRadius(impostor: PhysicsImpostor): number;
  53833. /**
  53834. * Gets the box size of the impostor
  53835. * @param impostor impostor to get box size from
  53836. * @param result the resulting box size
  53837. */
  53838. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53839. /**
  53840. * Disposes of the impostor
  53841. */
  53842. dispose(): void;
  53843. /**
  53844. * Does a raycast in the physics world
  53845. * @param from when should the ray start?
  53846. * @param to when should the ray end?
  53847. * @returns PhysicsRaycastResult
  53848. */
  53849. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53850. }
  53851. }
  53852. declare module "babylonjs/Probes/reflectionProbe" {
  53853. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53854. import { Vector3 } from "babylonjs/Maths/math.vector";
  53855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53856. import { Nullable } from "babylonjs/types";
  53857. import { Scene } from "babylonjs/scene";
  53858. module "babylonjs/abstractScene" {
  53859. interface AbstractScene {
  53860. /**
  53861. * The list of reflection probes added to the scene
  53862. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53863. */
  53864. reflectionProbes: Array<ReflectionProbe>;
  53865. /**
  53866. * Removes the given reflection probe from this scene.
  53867. * @param toRemove The reflection probe to remove
  53868. * @returns The index of the removed reflection probe
  53869. */
  53870. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53871. /**
  53872. * Adds the given reflection probe to this scene.
  53873. * @param newReflectionProbe The reflection probe to add
  53874. */
  53875. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53876. }
  53877. }
  53878. /**
  53879. * Class used to generate realtime reflection / refraction cube textures
  53880. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53881. */
  53882. export class ReflectionProbe {
  53883. /** defines the name of the probe */
  53884. name: string;
  53885. private _scene;
  53886. private _renderTargetTexture;
  53887. private _projectionMatrix;
  53888. private _viewMatrix;
  53889. private _target;
  53890. private _add;
  53891. private _attachedMesh;
  53892. private _invertYAxis;
  53893. /** Gets or sets probe position (center of the cube map) */
  53894. position: Vector3;
  53895. /**
  53896. * Creates a new reflection probe
  53897. * @param name defines the name of the probe
  53898. * @param size defines the texture resolution (for each face)
  53899. * @param scene defines the hosting scene
  53900. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53901. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53902. */
  53903. constructor(
  53904. /** defines the name of the probe */
  53905. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53906. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53907. samples: number;
  53908. /** Gets or sets the refresh rate to use (on every frame by default) */
  53909. refreshRate: number;
  53910. /**
  53911. * Gets the hosting scene
  53912. * @returns a Scene
  53913. */
  53914. getScene(): Scene;
  53915. /** Gets the internal CubeTexture used to render to */
  53916. readonly cubeTexture: RenderTargetTexture;
  53917. /** Gets the list of meshes to render */
  53918. readonly renderList: Nullable<AbstractMesh[]>;
  53919. /**
  53920. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53921. * @param mesh defines the mesh to attach to
  53922. */
  53923. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53924. /**
  53925. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53926. * @param renderingGroupId The rendering group id corresponding to its index
  53927. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53928. */
  53929. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53930. /**
  53931. * Clean all associated resources
  53932. */
  53933. dispose(): void;
  53934. /**
  53935. * Converts the reflection probe information to a readable string for debug purpose.
  53936. * @param fullDetails Supports for multiple levels of logging within scene loading
  53937. * @returns the human readable reflection probe info
  53938. */
  53939. toString(fullDetails?: boolean): string;
  53940. /**
  53941. * Get the class name of the relfection probe.
  53942. * @returns "ReflectionProbe"
  53943. */
  53944. getClassName(): string;
  53945. /**
  53946. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53947. * @returns The JSON representation of the texture
  53948. */
  53949. serialize(): any;
  53950. /**
  53951. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53952. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53953. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53954. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53955. * @returns The parsed reflection probe if successful
  53956. */
  53957. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53958. }
  53959. }
  53960. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53961. /** @hidden */
  53962. export var _BabylonLoaderRegistered: boolean;
  53963. }
  53964. declare module "babylonjs/Loading/Plugins/index" {
  53965. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53966. }
  53967. declare module "babylonjs/Loading/index" {
  53968. export * from "babylonjs/Loading/loadingScreen";
  53969. export * from "babylonjs/Loading/Plugins/index";
  53970. export * from "babylonjs/Loading/sceneLoader";
  53971. export * from "babylonjs/Loading/sceneLoaderFlags";
  53972. }
  53973. declare module "babylonjs/Materials/Background/index" {
  53974. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53975. }
  53976. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53977. import { Scene } from "babylonjs/scene";
  53978. import { Color3 } from "babylonjs/Maths/math.color";
  53979. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53981. /**
  53982. * The Physically based simple base material of BJS.
  53983. *
  53984. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53985. * It is used as the base class for both the specGloss and metalRough conventions.
  53986. */
  53987. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53988. /**
  53989. * Number of Simultaneous lights allowed on the material.
  53990. */
  53991. maxSimultaneousLights: number;
  53992. /**
  53993. * If sets to true, disables all the lights affecting the material.
  53994. */
  53995. disableLighting: boolean;
  53996. /**
  53997. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53998. */
  53999. environmentTexture: BaseTexture;
  54000. /**
  54001. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54002. */
  54003. invertNormalMapX: boolean;
  54004. /**
  54005. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54006. */
  54007. invertNormalMapY: boolean;
  54008. /**
  54009. * Normal map used in the model.
  54010. */
  54011. normalTexture: BaseTexture;
  54012. /**
  54013. * Emissivie color used to self-illuminate the model.
  54014. */
  54015. emissiveColor: Color3;
  54016. /**
  54017. * Emissivie texture used to self-illuminate the model.
  54018. */
  54019. emissiveTexture: BaseTexture;
  54020. /**
  54021. * Occlusion Channel Strenght.
  54022. */
  54023. occlusionStrength: number;
  54024. /**
  54025. * Occlusion Texture of the material (adding extra occlusion effects).
  54026. */
  54027. occlusionTexture: BaseTexture;
  54028. /**
  54029. * Defines the alpha limits in alpha test mode.
  54030. */
  54031. alphaCutOff: number;
  54032. /**
  54033. * Gets the current double sided mode.
  54034. */
  54035. /**
  54036. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54037. */
  54038. doubleSided: boolean;
  54039. /**
  54040. * Stores the pre-calculated light information of a mesh in a texture.
  54041. */
  54042. lightmapTexture: BaseTexture;
  54043. /**
  54044. * If true, the light map contains occlusion information instead of lighting info.
  54045. */
  54046. useLightmapAsShadowmap: boolean;
  54047. /**
  54048. * Instantiates a new PBRMaterial instance.
  54049. *
  54050. * @param name The material name
  54051. * @param scene The scene the material will be use in.
  54052. */
  54053. constructor(name: string, scene: Scene);
  54054. getClassName(): string;
  54055. }
  54056. }
  54057. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54058. import { Scene } from "babylonjs/scene";
  54059. import { Color3 } from "babylonjs/Maths/math.color";
  54060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54061. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54062. /**
  54063. * The PBR material of BJS following the metal roughness convention.
  54064. *
  54065. * This fits to the PBR convention in the GLTF definition:
  54066. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54067. */
  54068. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54069. /**
  54070. * The base color has two different interpretations depending on the value of metalness.
  54071. * When the material is a metal, the base color is the specific measured reflectance value
  54072. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54073. * of the material.
  54074. */
  54075. baseColor: Color3;
  54076. /**
  54077. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54078. * well as opacity information in the alpha channel.
  54079. */
  54080. baseTexture: BaseTexture;
  54081. /**
  54082. * Specifies the metallic scalar value of the material.
  54083. * Can also be used to scale the metalness values of the metallic texture.
  54084. */
  54085. metallic: number;
  54086. /**
  54087. * Specifies the roughness scalar value of the material.
  54088. * Can also be used to scale the roughness values of the metallic texture.
  54089. */
  54090. roughness: number;
  54091. /**
  54092. * Texture containing both the metallic value in the B channel and the
  54093. * roughness value in the G channel to keep better precision.
  54094. */
  54095. metallicRoughnessTexture: BaseTexture;
  54096. /**
  54097. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54098. *
  54099. * @param name The material name
  54100. * @param scene The scene the material will be use in.
  54101. */
  54102. constructor(name: string, scene: Scene);
  54103. /**
  54104. * Return the currrent class name of the material.
  54105. */
  54106. getClassName(): string;
  54107. /**
  54108. * Makes a duplicate of the current material.
  54109. * @param name - name to use for the new material.
  54110. */
  54111. clone(name: string): PBRMetallicRoughnessMaterial;
  54112. /**
  54113. * Serialize the material to a parsable JSON object.
  54114. */
  54115. serialize(): any;
  54116. /**
  54117. * Parses a JSON object correponding to the serialize function.
  54118. */
  54119. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54120. }
  54121. }
  54122. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54123. import { Scene } from "babylonjs/scene";
  54124. import { Color3 } from "babylonjs/Maths/math.color";
  54125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54126. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54127. /**
  54128. * The PBR material of BJS following the specular glossiness convention.
  54129. *
  54130. * This fits to the PBR convention in the GLTF definition:
  54131. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54132. */
  54133. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54134. /**
  54135. * Specifies the diffuse color of the material.
  54136. */
  54137. diffuseColor: Color3;
  54138. /**
  54139. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54140. * channel.
  54141. */
  54142. diffuseTexture: BaseTexture;
  54143. /**
  54144. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54145. */
  54146. specularColor: Color3;
  54147. /**
  54148. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54149. */
  54150. glossiness: number;
  54151. /**
  54152. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54153. */
  54154. specularGlossinessTexture: BaseTexture;
  54155. /**
  54156. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54157. *
  54158. * @param name The material name
  54159. * @param scene The scene the material will be use in.
  54160. */
  54161. constructor(name: string, scene: Scene);
  54162. /**
  54163. * Return the currrent class name of the material.
  54164. */
  54165. getClassName(): string;
  54166. /**
  54167. * Makes a duplicate of the current material.
  54168. * @param name - name to use for the new material.
  54169. */
  54170. clone(name: string): PBRSpecularGlossinessMaterial;
  54171. /**
  54172. * Serialize the material to a parsable JSON object.
  54173. */
  54174. serialize(): any;
  54175. /**
  54176. * Parses a JSON object correponding to the serialize function.
  54177. */
  54178. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54179. }
  54180. }
  54181. declare module "babylonjs/Materials/PBR/index" {
  54182. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54183. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54184. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54185. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54186. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54187. }
  54188. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54189. import { Nullable } from "babylonjs/types";
  54190. import { Scene } from "babylonjs/scene";
  54191. import { Matrix } from "babylonjs/Maths/math.vector";
  54192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54193. /**
  54194. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54195. * It can help converting any input color in a desired output one. This can then be used to create effects
  54196. * from sepia, black and white to sixties or futuristic rendering...
  54197. *
  54198. * The only supported format is currently 3dl.
  54199. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54200. */
  54201. export class ColorGradingTexture extends BaseTexture {
  54202. /**
  54203. * The current texture matrix. (will always be identity in color grading texture)
  54204. */
  54205. private _textureMatrix;
  54206. /**
  54207. * The texture URL.
  54208. */
  54209. url: string;
  54210. /**
  54211. * Empty line regex stored for GC.
  54212. */
  54213. private static _noneEmptyLineRegex;
  54214. private _engine;
  54215. /**
  54216. * Instantiates a ColorGradingTexture from the following parameters.
  54217. *
  54218. * @param url The location of the color gradind data (currently only supporting 3dl)
  54219. * @param scene The scene the texture will be used in
  54220. */
  54221. constructor(url: string, scene: Scene);
  54222. /**
  54223. * Returns the texture matrix used in most of the material.
  54224. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54225. */
  54226. getTextureMatrix(): Matrix;
  54227. /**
  54228. * Occurs when the file being loaded is a .3dl LUT file.
  54229. */
  54230. private load3dlTexture;
  54231. /**
  54232. * Starts the loading process of the texture.
  54233. */
  54234. private loadTexture;
  54235. /**
  54236. * Clones the color gradind texture.
  54237. */
  54238. clone(): ColorGradingTexture;
  54239. /**
  54240. * Called during delayed load for textures.
  54241. */
  54242. delayLoad(): void;
  54243. /**
  54244. * Parses a color grading texture serialized by Babylon.
  54245. * @param parsedTexture The texture information being parsedTexture
  54246. * @param scene The scene to load the texture in
  54247. * @param rootUrl The root url of the data assets to load
  54248. * @return A color gradind texture
  54249. */
  54250. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54251. /**
  54252. * Serializes the LUT texture to json format.
  54253. */
  54254. serialize(): any;
  54255. }
  54256. }
  54257. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54259. import { Scene } from "babylonjs/scene";
  54260. import { Nullable } from "babylonjs/types";
  54261. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54262. /**
  54263. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54264. */
  54265. export class EquiRectangularCubeTexture extends BaseTexture {
  54266. /** The six faces of the cube. */
  54267. private static _FacesMapping;
  54268. private _noMipmap;
  54269. private _onLoad;
  54270. private _onError;
  54271. /** The size of the cubemap. */
  54272. private _size;
  54273. /** The buffer of the image. */
  54274. private _buffer;
  54275. /** The width of the input image. */
  54276. private _width;
  54277. /** The height of the input image. */
  54278. private _height;
  54279. /** The URL to the image. */
  54280. url: string;
  54281. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54282. coordinatesMode: number;
  54283. /**
  54284. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54285. * @param url The location of the image
  54286. * @param scene The scene the texture will be used in
  54287. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54288. * @param noMipmap Forces to not generate the mipmap if true
  54289. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54290. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54291. * @param onLoad — defines a callback called when texture is loaded
  54292. * @param onError — defines a callback called if there is an error
  54293. */
  54294. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54295. /**
  54296. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54297. */
  54298. private loadImage;
  54299. /**
  54300. * Convert the image buffer into a cubemap and create a CubeTexture.
  54301. */
  54302. private loadTexture;
  54303. /**
  54304. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54305. * @param buffer The ArrayBuffer that should be converted.
  54306. * @returns The buffer as Float32Array.
  54307. */
  54308. private getFloat32ArrayFromArrayBuffer;
  54309. /**
  54310. * Get the current class name of the texture useful for serialization or dynamic coding.
  54311. * @returns "EquiRectangularCubeTexture"
  54312. */
  54313. getClassName(): string;
  54314. /**
  54315. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54316. * @returns A clone of the current EquiRectangularCubeTexture.
  54317. */
  54318. clone(): EquiRectangularCubeTexture;
  54319. }
  54320. }
  54321. declare module "babylonjs/Misc/tga" {
  54322. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54323. /**
  54324. * Based on jsTGALoader - Javascript loader for TGA file
  54325. * By Vincent Thibault
  54326. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54327. */
  54328. export class TGATools {
  54329. private static _TYPE_INDEXED;
  54330. private static _TYPE_RGB;
  54331. private static _TYPE_GREY;
  54332. private static _TYPE_RLE_INDEXED;
  54333. private static _TYPE_RLE_RGB;
  54334. private static _TYPE_RLE_GREY;
  54335. private static _ORIGIN_MASK;
  54336. private static _ORIGIN_SHIFT;
  54337. private static _ORIGIN_BL;
  54338. private static _ORIGIN_BR;
  54339. private static _ORIGIN_UL;
  54340. private static _ORIGIN_UR;
  54341. /**
  54342. * Gets the header of a TGA file
  54343. * @param data defines the TGA data
  54344. * @returns the header
  54345. */
  54346. static GetTGAHeader(data: Uint8Array): any;
  54347. /**
  54348. * Uploads TGA content to a Babylon Texture
  54349. * @hidden
  54350. */
  54351. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54352. /** @hidden */
  54353. 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;
  54354. /** @hidden */
  54355. 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;
  54356. /** @hidden */
  54357. 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;
  54358. /** @hidden */
  54359. 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;
  54360. /** @hidden */
  54361. 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;
  54362. /** @hidden */
  54363. 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;
  54364. }
  54365. }
  54366. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54367. import { Nullable } from "babylonjs/types";
  54368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54369. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54370. /**
  54371. * Implementation of the TGA Texture Loader.
  54372. * @hidden
  54373. */
  54374. export class _TGATextureLoader implements IInternalTextureLoader {
  54375. /**
  54376. * Defines wether the loader supports cascade loading the different faces.
  54377. */
  54378. readonly supportCascades: boolean;
  54379. /**
  54380. * This returns if the loader support the current file information.
  54381. * @param extension defines the file extension of the file being loaded
  54382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54383. * @param fallback defines the fallback internal texture if any
  54384. * @param isBase64 defines whether the texture is encoded as a base64
  54385. * @param isBuffer defines whether the texture data are stored as a buffer
  54386. * @returns true if the loader can load the specified file
  54387. */
  54388. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54389. /**
  54390. * Transform the url before loading if required.
  54391. * @param rootUrl the url of the texture
  54392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54393. * @returns the transformed texture
  54394. */
  54395. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54396. /**
  54397. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54398. * @param rootUrl the url of the texture
  54399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54400. * @returns the fallback texture
  54401. */
  54402. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54403. /**
  54404. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54405. * @param data contains the texture data
  54406. * @param texture defines the BabylonJS internal texture
  54407. * @param createPolynomials will be true if polynomials have been requested
  54408. * @param onLoad defines the callback to trigger once the texture is ready
  54409. * @param onError defines the callback to trigger in case of error
  54410. */
  54411. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54412. /**
  54413. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54414. * @param data contains the texture data
  54415. * @param texture defines the BabylonJS internal texture
  54416. * @param callback defines the method to call once ready to upload
  54417. */
  54418. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54419. }
  54420. }
  54421. declare module "babylonjs/Misc/basis" {
  54422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54423. /**
  54424. * Info about the .basis files
  54425. */
  54426. class BasisFileInfo {
  54427. /**
  54428. * If the file has alpha
  54429. */
  54430. hasAlpha: boolean;
  54431. /**
  54432. * Info about each image of the basis file
  54433. */
  54434. images: Array<{
  54435. levels: Array<{
  54436. width: number;
  54437. height: number;
  54438. transcodedPixels: ArrayBufferView;
  54439. }>;
  54440. }>;
  54441. }
  54442. /**
  54443. * Result of transcoding a basis file
  54444. */
  54445. class TranscodeResult {
  54446. /**
  54447. * Info about the .basis file
  54448. */
  54449. fileInfo: BasisFileInfo;
  54450. /**
  54451. * Format to use when loading the file
  54452. */
  54453. format: number;
  54454. }
  54455. /**
  54456. * Configuration options for the Basis transcoder
  54457. */
  54458. export class BasisTranscodeConfiguration {
  54459. /**
  54460. * Supported compression formats used to determine the supported output format of the transcoder
  54461. */
  54462. supportedCompressionFormats?: {
  54463. /**
  54464. * etc1 compression format
  54465. */
  54466. etc1?: boolean;
  54467. /**
  54468. * s3tc compression format
  54469. */
  54470. s3tc?: boolean;
  54471. /**
  54472. * pvrtc compression format
  54473. */
  54474. pvrtc?: boolean;
  54475. /**
  54476. * etc2 compression format
  54477. */
  54478. etc2?: boolean;
  54479. };
  54480. /**
  54481. * If mipmap levels should be loaded for transcoded images (Default: true)
  54482. */
  54483. loadMipmapLevels?: boolean;
  54484. /**
  54485. * Index of a single image to load (Default: all images)
  54486. */
  54487. loadSingleImage?: number;
  54488. }
  54489. /**
  54490. * Used to load .Basis files
  54491. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54492. */
  54493. export class BasisTools {
  54494. private static _IgnoreSupportedFormats;
  54495. /**
  54496. * URL to use when loading the basis transcoder
  54497. */
  54498. static JSModuleURL: string;
  54499. /**
  54500. * URL to use when loading the wasm module for the transcoder
  54501. */
  54502. static WasmModuleURL: string;
  54503. /**
  54504. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54505. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54506. * @returns internal format corresponding to the Basis format
  54507. */
  54508. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54509. private static _WorkerPromise;
  54510. private static _Worker;
  54511. private static _actionId;
  54512. private static _CreateWorkerAsync;
  54513. /**
  54514. * Transcodes a loaded image file to compressed pixel data
  54515. * @param imageData image data to transcode
  54516. * @param config configuration options for the transcoding
  54517. * @returns a promise resulting in the transcoded image
  54518. */
  54519. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54520. /**
  54521. * Loads a texture from the transcode result
  54522. * @param texture texture load to
  54523. * @param transcodeResult the result of transcoding the basis file to load from
  54524. */
  54525. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54526. }
  54527. }
  54528. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54529. import { Nullable } from "babylonjs/types";
  54530. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54531. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54532. /**
  54533. * Loader for .basis file format
  54534. */
  54535. export class _BasisTextureLoader implements IInternalTextureLoader {
  54536. /**
  54537. * Defines whether the loader supports cascade loading the different faces.
  54538. */
  54539. readonly supportCascades: boolean;
  54540. /**
  54541. * This returns if the loader support the current file information.
  54542. * @param extension defines the file extension of the file being loaded
  54543. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54544. * @param fallback defines the fallback internal texture if any
  54545. * @param isBase64 defines whether the texture is encoded as a base64
  54546. * @param isBuffer defines whether the texture data are stored as a buffer
  54547. * @returns true if the loader can load the specified file
  54548. */
  54549. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54550. /**
  54551. * Transform the url before loading if required.
  54552. * @param rootUrl the url of the texture
  54553. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54554. * @returns the transformed texture
  54555. */
  54556. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54557. /**
  54558. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54559. * @param rootUrl the url of the texture
  54560. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54561. * @returns the fallback texture
  54562. */
  54563. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54564. /**
  54565. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54566. * @param data contains the texture data
  54567. * @param texture defines the BabylonJS internal texture
  54568. * @param createPolynomials will be true if polynomials have been requested
  54569. * @param onLoad defines the callback to trigger once the texture is ready
  54570. * @param onError defines the callback to trigger in case of error
  54571. */
  54572. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54573. /**
  54574. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54575. * @param data contains the texture data
  54576. * @param texture defines the BabylonJS internal texture
  54577. * @param callback defines the method to call once ready to upload
  54578. */
  54579. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54580. }
  54581. }
  54582. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54583. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54584. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54585. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54586. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54587. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54588. }
  54589. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54590. import { Scene } from "babylonjs/scene";
  54591. import { Texture } from "babylonjs/Materials/Textures/texture";
  54592. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54593. /**
  54594. * 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.
  54595. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54596. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54597. */
  54598. export class CustomProceduralTexture extends ProceduralTexture {
  54599. private _animate;
  54600. private _time;
  54601. private _config;
  54602. private _texturePath;
  54603. /**
  54604. * Instantiates a new Custom Procedural Texture.
  54605. * 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.
  54606. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54608. * @param name Define the name of the texture
  54609. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54610. * @param size Define the size of the texture to create
  54611. * @param scene Define the scene the texture belongs to
  54612. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54613. * @param generateMipMaps Define if the texture should creates mip maps or not
  54614. */
  54615. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54616. private _loadJson;
  54617. /**
  54618. * Is the texture ready to be used ? (rendered at least once)
  54619. * @returns true if ready, otherwise, false.
  54620. */
  54621. isReady(): boolean;
  54622. /**
  54623. * Render the texture to its associated render target.
  54624. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54625. */
  54626. render(useCameraPostProcess?: boolean): void;
  54627. /**
  54628. * Update the list of dependant textures samplers in the shader.
  54629. */
  54630. updateTextures(): void;
  54631. /**
  54632. * Update the uniform values of the procedural texture in the shader.
  54633. */
  54634. updateShaderUniforms(): void;
  54635. /**
  54636. * Define if the texture animates or not.
  54637. */
  54638. animate: boolean;
  54639. }
  54640. }
  54641. declare module "babylonjs/Shaders/noise.fragment" {
  54642. /** @hidden */
  54643. export var noisePixelShader: {
  54644. name: string;
  54645. shader: string;
  54646. };
  54647. }
  54648. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54649. import { Nullable } from "babylonjs/types";
  54650. import { Scene } from "babylonjs/scene";
  54651. import { Texture } from "babylonjs/Materials/Textures/texture";
  54652. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54653. import "babylonjs/Shaders/noise.fragment";
  54654. /**
  54655. * Class used to generate noise procedural textures
  54656. */
  54657. export class NoiseProceduralTexture extends ProceduralTexture {
  54658. private _time;
  54659. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54660. brightness: number;
  54661. /** Defines the number of octaves to process */
  54662. octaves: number;
  54663. /** Defines the level of persistence (0.8 by default) */
  54664. persistence: number;
  54665. /** Gets or sets animation speed factor (default is 1) */
  54666. animationSpeedFactor: number;
  54667. /**
  54668. * Creates a new NoiseProceduralTexture
  54669. * @param name defines the name fo the texture
  54670. * @param size defines the size of the texture (default is 256)
  54671. * @param scene defines the hosting scene
  54672. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54673. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54674. */
  54675. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54676. private _updateShaderUniforms;
  54677. protected _getDefines(): string;
  54678. /** Generate the current state of the procedural texture */
  54679. render(useCameraPostProcess?: boolean): void;
  54680. /**
  54681. * Serializes this noise procedural texture
  54682. * @returns a serialized noise procedural texture object
  54683. */
  54684. serialize(): any;
  54685. /**
  54686. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54687. * @param parsedTexture defines parsed texture data
  54688. * @param scene defines the current scene
  54689. * @param rootUrl defines the root URL containing noise procedural texture information
  54690. * @returns a parsed NoiseProceduralTexture
  54691. */
  54692. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54693. }
  54694. }
  54695. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54696. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54697. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54698. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54699. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54700. }
  54701. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54702. import { Nullable } from "babylonjs/types";
  54703. import { Scene } from "babylonjs/scene";
  54704. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54706. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54707. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54708. /**
  54709. * Raw cube texture where the raw buffers are passed in
  54710. */
  54711. export class RawCubeTexture extends CubeTexture {
  54712. /**
  54713. * Creates a cube texture where the raw buffers are passed in.
  54714. * @param scene defines the scene the texture is attached to
  54715. * @param data defines the array of data to use to create each face
  54716. * @param size defines the size of the textures
  54717. * @param format defines the format of the data
  54718. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54719. * @param generateMipMaps defines if the engine should generate the mip levels
  54720. * @param invertY defines if data must be stored with Y axis inverted
  54721. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54722. * @param compression defines the compression used (null by default)
  54723. */
  54724. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54725. /**
  54726. * Updates the raw cube texture.
  54727. * @param data defines the data to store
  54728. * @param format defines the data format
  54729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54730. * @param invertY defines if data must be stored with Y axis inverted
  54731. * @param compression defines the compression used (null by default)
  54732. * @param level defines which level of the texture to update
  54733. */
  54734. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54735. /**
  54736. * Updates a raw cube texture with RGBD encoded data.
  54737. * @param data defines the array of data [mipmap][face] to use to create each face
  54738. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54739. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54740. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54741. * @returns a promsie that resolves when the operation is complete
  54742. */
  54743. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54744. /**
  54745. * Clones the raw cube texture.
  54746. * @return a new cube texture
  54747. */
  54748. clone(): CubeTexture;
  54749. /** @hidden */
  54750. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54751. }
  54752. }
  54753. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54754. import { Scene } from "babylonjs/scene";
  54755. import { Texture } from "babylonjs/Materials/Textures/texture";
  54756. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54757. /**
  54758. * Class used to store 3D textures containing user data
  54759. */
  54760. export class RawTexture3D extends Texture {
  54761. /** Gets or sets the texture format to use */
  54762. format: number;
  54763. private _engine;
  54764. /**
  54765. * Create a new RawTexture3D
  54766. * @param data defines the data of the texture
  54767. * @param width defines the width of the texture
  54768. * @param height defines the height of the texture
  54769. * @param depth defines the depth of the texture
  54770. * @param format defines the texture format to use
  54771. * @param scene defines the hosting scene
  54772. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54773. * @param invertY defines if texture must be stored with Y axis inverted
  54774. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54775. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54776. */
  54777. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54778. /** Gets or sets the texture format to use */
  54779. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54780. /**
  54781. * Update the texture with new data
  54782. * @param data defines the data to store in the texture
  54783. */
  54784. update(data: ArrayBufferView): void;
  54785. }
  54786. }
  54787. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54788. import { Scene } from "babylonjs/scene";
  54789. import { Plane } from "babylonjs/Maths/math.plane";
  54790. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54791. /**
  54792. * Creates a refraction texture used by refraction channel of the standard material.
  54793. * It is like a mirror but to see through a material.
  54794. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54795. */
  54796. export class RefractionTexture extends RenderTargetTexture {
  54797. /**
  54798. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54799. * 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.
  54800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54801. */
  54802. refractionPlane: Plane;
  54803. /**
  54804. * Define how deep under the surface we should see.
  54805. */
  54806. depth: number;
  54807. /**
  54808. * Creates a refraction texture used by refraction channel of the standard material.
  54809. * It is like a mirror but to see through a material.
  54810. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54811. * @param name Define the texture name
  54812. * @param size Define the size of the underlying texture
  54813. * @param scene Define the scene the refraction belongs to
  54814. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54815. */
  54816. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54817. /**
  54818. * Clone the refraction texture.
  54819. * @returns the cloned texture
  54820. */
  54821. clone(): RefractionTexture;
  54822. /**
  54823. * Serialize the texture to a JSON representation you could use in Parse later on
  54824. * @returns the serialized JSON representation
  54825. */
  54826. serialize(): any;
  54827. }
  54828. }
  54829. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54830. import { Nullable } from "babylonjs/types";
  54831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54832. import { Matrix } from "babylonjs/Maths/math.vector";
  54833. import { Engine } from "babylonjs/Engines/engine";
  54834. import { Scene } from "babylonjs/scene";
  54835. /**
  54836. * Defines the options related to the creation of an HtmlElementTexture
  54837. */
  54838. export interface IHtmlElementTextureOptions {
  54839. /**
  54840. * Defines wether mip maps should be created or not.
  54841. */
  54842. generateMipMaps?: boolean;
  54843. /**
  54844. * Defines the sampling mode of the texture.
  54845. */
  54846. samplingMode?: number;
  54847. /**
  54848. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54849. */
  54850. engine: Nullable<Engine>;
  54851. /**
  54852. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54853. */
  54854. scene: Nullable<Scene>;
  54855. }
  54856. /**
  54857. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54858. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54859. * is automatically managed.
  54860. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54861. * in your application.
  54862. *
  54863. * As the update is not automatic, you need to call them manually.
  54864. */
  54865. export class HtmlElementTexture extends BaseTexture {
  54866. /**
  54867. * The texture URL.
  54868. */
  54869. element: HTMLVideoElement | HTMLCanvasElement;
  54870. private static readonly DefaultOptions;
  54871. private _textureMatrix;
  54872. private _engine;
  54873. private _isVideo;
  54874. private _generateMipMaps;
  54875. private _samplingMode;
  54876. /**
  54877. * Instantiates a HtmlElementTexture from the following parameters.
  54878. *
  54879. * @param name Defines the name of the texture
  54880. * @param element Defines the video or canvas the texture is filled with
  54881. * @param options Defines the other none mandatory texture creation options
  54882. */
  54883. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54884. private _createInternalTexture;
  54885. /**
  54886. * Returns the texture matrix used in most of the material.
  54887. */
  54888. getTextureMatrix(): Matrix;
  54889. /**
  54890. * Updates the content of the texture.
  54891. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54892. */
  54893. update(invertY?: Nullable<boolean>): void;
  54894. }
  54895. }
  54896. declare module "babylonjs/Materials/Textures/index" {
  54897. export * from "babylonjs/Materials/Textures/baseTexture";
  54898. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54899. export * from "babylonjs/Materials/Textures/cubeTexture";
  54900. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54901. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54902. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54903. export * from "babylonjs/Materials/Textures/internalTexture";
  54904. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54905. export * from "babylonjs/Materials/Textures/Loaders/index";
  54906. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54907. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54908. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54909. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54910. export * from "babylonjs/Materials/Textures/rawTexture";
  54911. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54912. export * from "babylonjs/Materials/Textures/refractionTexture";
  54913. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54914. export * from "babylonjs/Materials/Textures/texture";
  54915. export * from "babylonjs/Materials/Textures/videoTexture";
  54916. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54917. }
  54918. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54919. /**
  54920. * Enum used to define the target of a block
  54921. */
  54922. export enum NodeMaterialBlockTargets {
  54923. /** Vertex shader */
  54924. Vertex = 1,
  54925. /** Fragment shader */
  54926. Fragment = 2,
  54927. /** Neutral */
  54928. Neutral = 4,
  54929. /** Vertex and Fragment */
  54930. VertexAndFragment = 3
  54931. }
  54932. }
  54933. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54934. /**
  54935. * Defines the kind of connection point for node based material
  54936. */
  54937. export enum NodeMaterialBlockConnectionPointTypes {
  54938. /** Float */
  54939. Float = 1,
  54940. /** Int */
  54941. Int = 2,
  54942. /** Vector2 */
  54943. Vector2 = 4,
  54944. /** Vector3 */
  54945. Vector3 = 8,
  54946. /** Vector4 */
  54947. Vector4 = 16,
  54948. /** Color3 */
  54949. Color3 = 32,
  54950. /** Color4 */
  54951. Color4 = 64,
  54952. /** Matrix */
  54953. Matrix = 128,
  54954. /** Detect type based on connection */
  54955. AutoDetect = 1024,
  54956. /** Output type that will be defined by input type */
  54957. BasedOnInput = 2048
  54958. }
  54959. }
  54960. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54961. /**
  54962. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54963. */
  54964. export enum NodeMaterialBlockConnectionPointMode {
  54965. /** Value is an uniform */
  54966. Uniform = 0,
  54967. /** Value is a mesh attribute */
  54968. Attribute = 1,
  54969. /** Value is a varying between vertex and fragment shaders */
  54970. Varying = 2,
  54971. /** Mode is undefined */
  54972. Undefined = 3
  54973. }
  54974. }
  54975. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54976. /**
  54977. * Enum used to define system values e.g. values automatically provided by the system
  54978. */
  54979. export enum NodeMaterialSystemValues {
  54980. /** World */
  54981. World = 1,
  54982. /** View */
  54983. View = 2,
  54984. /** Projection */
  54985. Projection = 3,
  54986. /** ViewProjection */
  54987. ViewProjection = 4,
  54988. /** WorldView */
  54989. WorldView = 5,
  54990. /** WorldViewProjection */
  54991. WorldViewProjection = 6,
  54992. /** CameraPosition */
  54993. CameraPosition = 7,
  54994. /** Fog Color */
  54995. FogColor = 8,
  54996. /** Delta time */
  54997. DeltaTime = 9
  54998. }
  54999. }
  55000. declare module "babylonjs/Materials/Node/Enums/index" {
  55001. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55002. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55003. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55004. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55005. }
  55006. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55008. /**
  55009. * Root class for all node material optimizers
  55010. */
  55011. export class NodeMaterialOptimizer {
  55012. /**
  55013. * Function used to optimize a NodeMaterial graph
  55014. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55015. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55016. */
  55017. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55018. }
  55019. }
  55020. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55024. import { Scene } from "babylonjs/scene";
  55025. /**
  55026. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55027. */
  55028. export class TransformBlock extends NodeMaterialBlock {
  55029. /**
  55030. * Defines the value to use to complement W value to transform it to a Vector4
  55031. */
  55032. complementW: number;
  55033. /**
  55034. * Defines the value to use to complement z value to transform it to a Vector4
  55035. */
  55036. complementZ: number;
  55037. /**
  55038. * Creates a new TransformBlock
  55039. * @param name defines the block name
  55040. */
  55041. constructor(name: string);
  55042. /**
  55043. * Gets the current class name
  55044. * @returns the class name
  55045. */
  55046. getClassName(): string;
  55047. /**
  55048. * Gets the vector input
  55049. */
  55050. readonly vector: NodeMaterialConnectionPoint;
  55051. /**
  55052. * Gets the output component
  55053. */
  55054. readonly output: NodeMaterialConnectionPoint;
  55055. /**
  55056. * Gets the matrix transform input
  55057. */
  55058. readonly transform: NodeMaterialConnectionPoint;
  55059. protected _buildBlock(state: NodeMaterialBuildState): this;
  55060. serialize(): any;
  55061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55062. protected _dumpPropertiesCode(): string;
  55063. }
  55064. }
  55065. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55069. /**
  55070. * Block used to output the vertex position
  55071. */
  55072. export class VertexOutputBlock extends NodeMaterialBlock {
  55073. /**
  55074. * Creates a new VertexOutputBlock
  55075. * @param name defines the block name
  55076. */
  55077. constructor(name: string);
  55078. /**
  55079. * Gets the current class name
  55080. * @returns the class name
  55081. */
  55082. getClassName(): string;
  55083. /**
  55084. * Gets the vector input component
  55085. */
  55086. readonly vector: NodeMaterialConnectionPoint;
  55087. protected _buildBlock(state: NodeMaterialBuildState): this;
  55088. }
  55089. }
  55090. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55094. /**
  55095. * Block used to output the final color
  55096. */
  55097. export class FragmentOutputBlock extends NodeMaterialBlock {
  55098. /**
  55099. * Create a new FragmentOutputBlock
  55100. * @param name defines the block name
  55101. */
  55102. constructor(name: string);
  55103. /**
  55104. * Gets the current class name
  55105. * @returns the class name
  55106. */
  55107. getClassName(): string;
  55108. /**
  55109. * Gets the rgba input component
  55110. */
  55111. readonly rgba: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the rgb input component
  55114. */
  55115. readonly rgb: NodeMaterialConnectionPoint;
  55116. /**
  55117. * Gets the a input component
  55118. */
  55119. readonly a: NodeMaterialConnectionPoint;
  55120. protected _buildBlock(state: NodeMaterialBuildState): this;
  55121. }
  55122. }
  55123. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55129. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55130. import { Effect } from "babylonjs/Materials/effect";
  55131. import { Mesh } from "babylonjs/Meshes/mesh";
  55132. import { Nullable } from "babylonjs/types";
  55133. import { Scene } from "babylonjs/scene";
  55134. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55135. /**
  55136. * Block used to read a reflection texture from a sampler
  55137. */
  55138. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55139. private _define3DName;
  55140. private _defineCubicName;
  55141. private _defineExplicitName;
  55142. private _defineProjectionName;
  55143. private _defineLocalCubicName;
  55144. private _defineSphericalName;
  55145. private _definePlanarName;
  55146. private _defineEquirectangularName;
  55147. private _defineMirroredEquirectangularFixedName;
  55148. private _defineEquirectangularFixedName;
  55149. private _defineSkyboxName;
  55150. private _cubeSamplerName;
  55151. private _2DSamplerName;
  55152. private _positionUVWName;
  55153. private _directionWName;
  55154. private _reflectionCoordsName;
  55155. private _reflection2DCoordsName;
  55156. private _reflectionColorName;
  55157. private _reflectionMatrixName;
  55158. /**
  55159. * Gets or sets the texture associated with the node
  55160. */
  55161. texture: Nullable<BaseTexture>;
  55162. /**
  55163. * Create a new TextureBlock
  55164. * @param name defines the block name
  55165. */
  55166. constructor(name: string);
  55167. /**
  55168. * Gets the current class name
  55169. * @returns the class name
  55170. */
  55171. getClassName(): string;
  55172. /**
  55173. * Gets the world position input component
  55174. */
  55175. readonly position: NodeMaterialConnectionPoint;
  55176. /**
  55177. * Gets the world position input component
  55178. */
  55179. readonly worldPosition: NodeMaterialConnectionPoint;
  55180. /**
  55181. * Gets the world normal input component
  55182. */
  55183. readonly worldNormal: NodeMaterialConnectionPoint;
  55184. /**
  55185. * Gets the world input component
  55186. */
  55187. readonly world: NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the camera (or eye) position component
  55190. */
  55191. readonly cameraPosition: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the view input component
  55194. */
  55195. readonly view: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the rgb output component
  55198. */
  55199. readonly rgb: NodeMaterialConnectionPoint;
  55200. /**
  55201. * Gets the r output component
  55202. */
  55203. readonly r: NodeMaterialConnectionPoint;
  55204. /**
  55205. * Gets the g output component
  55206. */
  55207. readonly g: NodeMaterialConnectionPoint;
  55208. /**
  55209. * Gets the b output component
  55210. */
  55211. readonly b: NodeMaterialConnectionPoint;
  55212. autoConfigure(material: NodeMaterial): void;
  55213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55214. isReady(): boolean;
  55215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55216. private _injectVertexCode;
  55217. private _writeOutput;
  55218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55219. serialize(): any;
  55220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55221. }
  55222. }
  55223. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55225. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55226. import { Scene } from "babylonjs/scene";
  55227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55228. import { Matrix } from "babylonjs/Maths/math.vector";
  55229. import { Mesh } from "babylonjs/Meshes/mesh";
  55230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55231. import { Observable } from "babylonjs/Misc/observable";
  55232. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55233. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55234. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55235. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55236. import { Nullable } from "babylonjs/types";
  55237. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55238. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55239. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55240. /**
  55241. * Interface used to configure the node material editor
  55242. */
  55243. export interface INodeMaterialEditorOptions {
  55244. /** Define the URl to load node editor script */
  55245. editorURL?: string;
  55246. }
  55247. /** @hidden */
  55248. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55249. /** BONES */
  55250. NUM_BONE_INFLUENCERS: number;
  55251. BonesPerMesh: number;
  55252. BONETEXTURE: boolean;
  55253. /** MORPH TARGETS */
  55254. MORPHTARGETS: boolean;
  55255. MORPHTARGETS_NORMAL: boolean;
  55256. MORPHTARGETS_TANGENT: boolean;
  55257. MORPHTARGETS_UV: boolean;
  55258. NUM_MORPH_INFLUENCERS: number;
  55259. /** IMAGE PROCESSING */
  55260. IMAGEPROCESSING: boolean;
  55261. VIGNETTE: boolean;
  55262. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55263. VIGNETTEBLENDMODEOPAQUE: boolean;
  55264. TONEMAPPING: boolean;
  55265. TONEMAPPING_ACES: boolean;
  55266. CONTRAST: boolean;
  55267. EXPOSURE: boolean;
  55268. COLORCURVES: boolean;
  55269. COLORGRADING: boolean;
  55270. COLORGRADING3D: boolean;
  55271. SAMPLER3DGREENDEPTH: boolean;
  55272. SAMPLER3DBGRMAP: boolean;
  55273. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55274. /** MISC. */
  55275. BUMPDIRECTUV: number;
  55276. constructor();
  55277. setValue(name: string, value: boolean): void;
  55278. }
  55279. /**
  55280. * Class used to configure NodeMaterial
  55281. */
  55282. export interface INodeMaterialOptions {
  55283. /**
  55284. * Defines if blocks should emit comments
  55285. */
  55286. emitComments: boolean;
  55287. }
  55288. /**
  55289. * Class used to create a node based material built by assembling shader blocks
  55290. */
  55291. export class NodeMaterial extends PushMaterial {
  55292. private static _BuildIdGenerator;
  55293. private _options;
  55294. private _vertexCompilationState;
  55295. private _fragmentCompilationState;
  55296. private _sharedData;
  55297. private _buildId;
  55298. private _buildWasSuccessful;
  55299. private _cachedWorldViewMatrix;
  55300. private _cachedWorldViewProjectionMatrix;
  55301. private _optimizers;
  55302. private _animationFrame;
  55303. /** Define the URl to load node editor script */
  55304. static EditorURL: string;
  55305. private BJSNODEMATERIALEDITOR;
  55306. /** Get the inspector from bundle or global */
  55307. private _getGlobalNodeMaterialEditor;
  55308. /**
  55309. * 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)
  55310. */
  55311. ignoreAlpha: boolean;
  55312. /**
  55313. * Defines the maximum number of lights that can be used in the material
  55314. */
  55315. maxSimultaneousLights: number;
  55316. /**
  55317. * Observable raised when the material is built
  55318. */
  55319. onBuildObservable: Observable<NodeMaterial>;
  55320. /**
  55321. * Gets or sets the root nodes of the material vertex shader
  55322. */
  55323. _vertexOutputNodes: NodeMaterialBlock[];
  55324. /**
  55325. * Gets or sets the root nodes of the material fragment (pixel) shader
  55326. */
  55327. _fragmentOutputNodes: NodeMaterialBlock[];
  55328. /** Gets or sets options to control the node material overall behavior */
  55329. options: INodeMaterialOptions;
  55330. /**
  55331. * Default configuration related to image processing available in the standard Material.
  55332. */
  55333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55334. /**
  55335. * Gets the image processing configuration used either in this material.
  55336. */
  55337. /**
  55338. * Sets the Default image processing configuration used either in the this material.
  55339. *
  55340. * If sets to null, the scene one is in use.
  55341. */
  55342. imageProcessingConfiguration: ImageProcessingConfiguration;
  55343. /**
  55344. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55345. */
  55346. attachedBlocks: NodeMaterialBlock[];
  55347. /**
  55348. * Create a new node based material
  55349. * @param name defines the material name
  55350. * @param scene defines the hosting scene
  55351. * @param options defines creation option
  55352. */
  55353. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55354. /**
  55355. * Gets the current class name of the material e.g. "NodeMaterial"
  55356. * @returns the class name
  55357. */
  55358. getClassName(): string;
  55359. /**
  55360. * Keep track of the image processing observer to allow dispose and replace.
  55361. */
  55362. private _imageProcessingObserver;
  55363. /**
  55364. * Attaches a new image processing configuration to the Standard Material.
  55365. * @param configuration
  55366. */
  55367. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55368. /**
  55369. * Get a block by its name
  55370. * @param name defines the name of the block to retrieve
  55371. * @returns the required block or null if not found
  55372. */
  55373. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55374. /**
  55375. * Get a block by its name
  55376. * @param predicate defines the predicate used to find the good candidate
  55377. * @returns the required block or null if not found
  55378. */
  55379. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55380. /**
  55381. * Get an input block by its name
  55382. * @param predicate defines the predicate used to find the good candidate
  55383. * @returns the required input block or null if not found
  55384. */
  55385. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55386. /**
  55387. * Gets the list of input blocks attached to this material
  55388. * @returns an array of InputBlocks
  55389. */
  55390. getInputBlocks(): InputBlock[];
  55391. /**
  55392. * Adds a new optimizer to the list of optimizers
  55393. * @param optimizer defines the optimizers to add
  55394. * @returns the current material
  55395. */
  55396. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55397. /**
  55398. * Remove an optimizer from the list of optimizers
  55399. * @param optimizer defines the optimizers to remove
  55400. * @returns the current material
  55401. */
  55402. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55403. /**
  55404. * Add a new block to the list of output nodes
  55405. * @param node defines the node to add
  55406. * @returns the current material
  55407. */
  55408. addOutputNode(node: NodeMaterialBlock): this;
  55409. /**
  55410. * Remove a block from the list of root nodes
  55411. * @param node defines the node to remove
  55412. * @returns the current material
  55413. */
  55414. removeOutputNode(node: NodeMaterialBlock): this;
  55415. private _addVertexOutputNode;
  55416. private _removeVertexOutputNode;
  55417. private _addFragmentOutputNode;
  55418. private _removeFragmentOutputNode;
  55419. /**
  55420. * Specifies if the material will require alpha blending
  55421. * @returns a boolean specifying if alpha blending is needed
  55422. */
  55423. needAlphaBlending(): boolean;
  55424. /**
  55425. * Specifies if this material should be rendered in alpha test mode
  55426. * @returns a boolean specifying if an alpha test is needed.
  55427. */
  55428. needAlphaTesting(): boolean;
  55429. private _initializeBlock;
  55430. private _resetDualBlocks;
  55431. /**
  55432. * Build the material and generates the inner effect
  55433. * @param verbose defines if the build should log activity
  55434. */
  55435. build(verbose?: boolean): void;
  55436. /**
  55437. * Runs an otpimization phase to try to improve the shader code
  55438. */
  55439. optimize(): void;
  55440. private _prepareDefinesForAttributes;
  55441. /**
  55442. * Get if the submesh is ready to be used and all its information available.
  55443. * Child classes can use it to update shaders
  55444. * @param mesh defines the mesh to check
  55445. * @param subMesh defines which submesh to check
  55446. * @param useInstances specifies that instances should be used
  55447. * @returns a boolean indicating that the submesh is ready or not
  55448. */
  55449. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55450. /**
  55451. * Get a string representing the shaders built by the current node graph
  55452. */
  55453. readonly compiledShaders: string;
  55454. /**
  55455. * Binds the world matrix to the material
  55456. * @param world defines the world transformation matrix
  55457. */
  55458. bindOnlyWorldMatrix(world: Matrix): void;
  55459. /**
  55460. * Binds the submesh to this material by preparing the effect and shader to draw
  55461. * @param world defines the world transformation matrix
  55462. * @param mesh defines the mesh containing the submesh
  55463. * @param subMesh defines the submesh to bind the material to
  55464. */
  55465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55466. /**
  55467. * Gets the active textures from the material
  55468. * @returns an array of textures
  55469. */
  55470. getActiveTextures(): BaseTexture[];
  55471. /**
  55472. * Gets the list of texture blocks
  55473. * @returns an array of texture blocks
  55474. */
  55475. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55476. /**
  55477. * Specifies if the material uses a texture
  55478. * @param texture defines the texture to check against the material
  55479. * @returns a boolean specifying if the material uses the texture
  55480. */
  55481. hasTexture(texture: BaseTexture): boolean;
  55482. /**
  55483. * Disposes the material
  55484. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55485. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55486. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55487. */
  55488. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55489. /** Creates the node editor window. */
  55490. private _createNodeEditor;
  55491. /**
  55492. * Launch the node material editor
  55493. * @param config Define the configuration of the editor
  55494. * @return a promise fulfilled when the node editor is visible
  55495. */
  55496. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55497. /**
  55498. * Clear the current material
  55499. */
  55500. clear(): void;
  55501. /**
  55502. * Clear the current material and set it to a default state
  55503. */
  55504. setToDefault(): void;
  55505. /**
  55506. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55507. * @param url defines the url to load from
  55508. * @returns a promise that will fullfil when the material is fully loaded
  55509. */
  55510. loadAsync(url: string): Promise<unknown>;
  55511. private _gatherBlocks;
  55512. /**
  55513. * Generate a string containing the code declaration required to create an equivalent of this material
  55514. * @returns a string
  55515. */
  55516. generateCode(): string;
  55517. /**
  55518. * Serializes this material in a JSON representation
  55519. * @returns the serialized material object
  55520. */
  55521. serialize(): any;
  55522. private _restoreConnections;
  55523. /**
  55524. * Clear the current graph and load a new one from a serialization object
  55525. * @param source defines the JSON representation of the material
  55526. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55527. */
  55528. loadFromSerialization(source: any, rootUrl?: string): void;
  55529. /**
  55530. * Creates a node material from parsed material data
  55531. * @param source defines the JSON representation of the material
  55532. * @param scene defines the hosting scene
  55533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55534. * @returns a new node material
  55535. */
  55536. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55537. /**
  55538. * Creates a new node material set to default basic configuration
  55539. * @param name defines the name of the material
  55540. * @param scene defines the hosting scene
  55541. * @returns a new NodeMaterial
  55542. */
  55543. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55544. }
  55545. }
  55546. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55549. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55552. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55553. import { Effect } from "babylonjs/Materials/effect";
  55554. import { Mesh } from "babylonjs/Meshes/mesh";
  55555. import { Nullable } from "babylonjs/types";
  55556. import { Texture } from "babylonjs/Materials/Textures/texture";
  55557. import { Scene } from "babylonjs/scene";
  55558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55559. /**
  55560. * Block used to read a texture from a sampler
  55561. */
  55562. export class TextureBlock extends NodeMaterialBlock {
  55563. private _defineName;
  55564. private _linearDefineName;
  55565. private _samplerName;
  55566. private _transformedUVName;
  55567. private _textureTransformName;
  55568. private _textureInfoName;
  55569. private _mainUVName;
  55570. private _mainUVDefineName;
  55571. /**
  55572. * Gets or sets the texture associated with the node
  55573. */
  55574. texture: Nullable<Texture>;
  55575. /**
  55576. * Create a new TextureBlock
  55577. * @param name defines the block name
  55578. */
  55579. constructor(name: string);
  55580. /**
  55581. * Gets the current class name
  55582. * @returns the class name
  55583. */
  55584. getClassName(): string;
  55585. /**
  55586. * Gets the uv input component
  55587. */
  55588. readonly uv: NodeMaterialConnectionPoint;
  55589. /**
  55590. * Gets the rgba output component
  55591. */
  55592. readonly rgba: NodeMaterialConnectionPoint;
  55593. /**
  55594. * Gets the rgb output component
  55595. */
  55596. readonly rgb: NodeMaterialConnectionPoint;
  55597. /**
  55598. * Gets the r output component
  55599. */
  55600. readonly r: NodeMaterialConnectionPoint;
  55601. /**
  55602. * Gets the g output component
  55603. */
  55604. readonly g: NodeMaterialConnectionPoint;
  55605. /**
  55606. * Gets the b output component
  55607. */
  55608. readonly b: NodeMaterialConnectionPoint;
  55609. /**
  55610. * Gets the a output component
  55611. */
  55612. readonly a: NodeMaterialConnectionPoint;
  55613. readonly target: NodeMaterialBlockTargets;
  55614. autoConfigure(material: NodeMaterial): void;
  55615. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55616. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55617. isReady(): boolean;
  55618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55619. private readonly _isMixed;
  55620. private _injectVertexCode;
  55621. private _writeOutput;
  55622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55623. protected _dumpPropertiesCode(): string;
  55624. serialize(): any;
  55625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55626. }
  55627. }
  55628. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55631. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55632. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55633. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55634. import { Scene } from "babylonjs/scene";
  55635. /**
  55636. * Class used to store shared data between 2 NodeMaterialBuildState
  55637. */
  55638. export class NodeMaterialBuildStateSharedData {
  55639. /**
  55640. * Gets the list of emitted varyings
  55641. */
  55642. temps: string[];
  55643. /**
  55644. * Gets the list of emitted varyings
  55645. */
  55646. varyings: string[];
  55647. /**
  55648. * Gets the varying declaration string
  55649. */
  55650. varyingDeclaration: string;
  55651. /**
  55652. * Input blocks
  55653. */
  55654. inputBlocks: InputBlock[];
  55655. /**
  55656. * Input blocks
  55657. */
  55658. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55659. /**
  55660. * Bindable blocks (Blocks that need to set data to the effect)
  55661. */
  55662. bindableBlocks: NodeMaterialBlock[];
  55663. /**
  55664. * List of blocks that can provide a compilation fallback
  55665. */
  55666. blocksWithFallbacks: NodeMaterialBlock[];
  55667. /**
  55668. * List of blocks that can provide a define update
  55669. */
  55670. blocksWithDefines: NodeMaterialBlock[];
  55671. /**
  55672. * List of blocks that can provide a repeatable content
  55673. */
  55674. repeatableContentBlocks: NodeMaterialBlock[];
  55675. /**
  55676. * List of blocks that can provide a dynamic list of uniforms
  55677. */
  55678. dynamicUniformBlocks: NodeMaterialBlock[];
  55679. /**
  55680. * List of blocks that can block the isReady function for the material
  55681. */
  55682. blockingBlocks: NodeMaterialBlock[];
  55683. /**
  55684. * Gets the list of animated inputs
  55685. */
  55686. animatedInputs: InputBlock[];
  55687. /**
  55688. * Build Id used to avoid multiple recompilations
  55689. */
  55690. buildId: number;
  55691. /** List of emitted variables */
  55692. variableNames: {
  55693. [key: string]: number;
  55694. };
  55695. /** List of emitted defines */
  55696. defineNames: {
  55697. [key: string]: number;
  55698. };
  55699. /** Should emit comments? */
  55700. emitComments: boolean;
  55701. /** Emit build activity */
  55702. verbose: boolean;
  55703. /** Gets or sets the hosting scene */
  55704. scene: Scene;
  55705. /**
  55706. * Gets the compilation hints emitted at compilation time
  55707. */
  55708. hints: {
  55709. needWorldViewMatrix: boolean;
  55710. needWorldViewProjectionMatrix: boolean;
  55711. needAlphaBlending: boolean;
  55712. needAlphaTesting: boolean;
  55713. };
  55714. /**
  55715. * List of compilation checks
  55716. */
  55717. checks: {
  55718. emitVertex: boolean;
  55719. emitFragment: boolean;
  55720. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55721. };
  55722. /** Creates a new shared data */
  55723. constructor();
  55724. /**
  55725. * Emits console errors and exceptions if there is a failing check
  55726. */
  55727. emitErrors(): void;
  55728. }
  55729. }
  55730. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55731. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55732. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55733. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55734. /**
  55735. * Class used to store node based material build state
  55736. */
  55737. export class NodeMaterialBuildState {
  55738. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55739. supportUniformBuffers: boolean;
  55740. /**
  55741. * Gets the list of emitted attributes
  55742. */
  55743. attributes: string[];
  55744. /**
  55745. * Gets the list of emitted uniforms
  55746. */
  55747. uniforms: string[];
  55748. /**
  55749. * Gets the list of emitted constants
  55750. */
  55751. constants: string[];
  55752. /**
  55753. * Gets the list of emitted uniform buffers
  55754. */
  55755. uniformBuffers: string[];
  55756. /**
  55757. * Gets the list of emitted samplers
  55758. */
  55759. samplers: string[];
  55760. /**
  55761. * Gets the list of emitted functions
  55762. */
  55763. functions: {
  55764. [key: string]: string;
  55765. };
  55766. /**
  55767. * Gets the list of emitted extensions
  55768. */
  55769. extensions: {
  55770. [key: string]: string;
  55771. };
  55772. /**
  55773. * Gets the target of the compilation state
  55774. */
  55775. target: NodeMaterialBlockTargets;
  55776. /**
  55777. * Gets the list of emitted counters
  55778. */
  55779. counters: {
  55780. [key: string]: number;
  55781. };
  55782. /**
  55783. * Shared data between multiple NodeMaterialBuildState instances
  55784. */
  55785. sharedData: NodeMaterialBuildStateSharedData;
  55786. /** @hidden */
  55787. _vertexState: NodeMaterialBuildState;
  55788. /** @hidden */
  55789. _attributeDeclaration: string;
  55790. /** @hidden */
  55791. _uniformDeclaration: string;
  55792. /** @hidden */
  55793. _constantDeclaration: string;
  55794. /** @hidden */
  55795. _samplerDeclaration: string;
  55796. /** @hidden */
  55797. _varyingTransfer: string;
  55798. private _repeatableContentAnchorIndex;
  55799. /** @hidden */
  55800. _builtCompilationString: string;
  55801. /**
  55802. * Gets the emitted compilation strings
  55803. */
  55804. compilationString: string;
  55805. /**
  55806. * Finalize the compilation strings
  55807. * @param state defines the current compilation state
  55808. */
  55809. finalize(state: NodeMaterialBuildState): void;
  55810. /** @hidden */
  55811. readonly _repeatableContentAnchor: string;
  55812. /** @hidden */
  55813. _getFreeVariableName(prefix: string): string;
  55814. /** @hidden */
  55815. _getFreeDefineName(prefix: string): string;
  55816. /** @hidden */
  55817. _excludeVariableName(name: string): void;
  55818. /** @hidden */
  55819. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55820. /** @hidden */
  55821. _emitExtension(name: string, extension: string): void;
  55822. /** @hidden */
  55823. _emitFunction(name: string, code: string, comments: string): void;
  55824. /** @hidden */
  55825. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55826. replaceStrings?: {
  55827. search: RegExp;
  55828. replace: string;
  55829. }[];
  55830. repeatKey?: string;
  55831. }): string;
  55832. /** @hidden */
  55833. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55834. repeatKey?: string;
  55835. removeAttributes?: boolean;
  55836. removeUniforms?: boolean;
  55837. removeVaryings?: boolean;
  55838. removeIfDef?: boolean;
  55839. replaceStrings?: {
  55840. search: RegExp;
  55841. replace: string;
  55842. }[];
  55843. }, storeKey?: string): void;
  55844. /** @hidden */
  55845. _registerTempVariable(name: string): boolean;
  55846. /** @hidden */
  55847. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55848. /** @hidden */
  55849. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55850. /** @hidden */
  55851. _emitFloat(value: number): string;
  55852. }
  55853. }
  55854. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55855. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55857. import { Nullable } from "babylonjs/types";
  55858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55859. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55860. import { Effect } from "babylonjs/Materials/effect";
  55861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55862. import { Mesh } from "babylonjs/Meshes/mesh";
  55863. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55864. import { Scene } from "babylonjs/scene";
  55865. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55866. /**
  55867. * Defines a block that can be used inside a node based material
  55868. */
  55869. export class NodeMaterialBlock {
  55870. private _buildId;
  55871. private _buildTarget;
  55872. private _target;
  55873. private _isFinalMerger;
  55874. private _isInput;
  55875. /** @hidden */
  55876. _codeVariableName: string;
  55877. /** @hidden */
  55878. _inputs: NodeMaterialConnectionPoint[];
  55879. /** @hidden */
  55880. _outputs: NodeMaterialConnectionPoint[];
  55881. /** @hidden */
  55882. _preparationId: number;
  55883. /**
  55884. * Gets or sets the name of the block
  55885. */
  55886. name: string;
  55887. /**
  55888. * Gets or sets the unique id of the node
  55889. */
  55890. uniqueId: number;
  55891. /**
  55892. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55893. */
  55894. readonly isFinalMerger: boolean;
  55895. /**
  55896. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55897. */
  55898. readonly isInput: boolean;
  55899. /**
  55900. * Gets or sets the build Id
  55901. */
  55902. buildId: number;
  55903. /**
  55904. * Gets or sets the target of the block
  55905. */
  55906. target: NodeMaterialBlockTargets;
  55907. /**
  55908. * Gets the list of input points
  55909. */
  55910. readonly inputs: NodeMaterialConnectionPoint[];
  55911. /** Gets the list of output points */
  55912. readonly outputs: NodeMaterialConnectionPoint[];
  55913. /**
  55914. * Find an input by its name
  55915. * @param name defines the name of the input to look for
  55916. * @returns the input or null if not found
  55917. */
  55918. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55919. /**
  55920. * Find an output by its name
  55921. * @param name defines the name of the outputto look for
  55922. * @returns the output or null if not found
  55923. */
  55924. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55925. /**
  55926. * Creates a new NodeMaterialBlock
  55927. * @param name defines the block name
  55928. * @param target defines the target of that block (Vertex by default)
  55929. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55930. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55931. */
  55932. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55933. /**
  55934. * Initialize the block and prepare the context for build
  55935. * @param state defines the state that will be used for the build
  55936. */
  55937. initialize(state: NodeMaterialBuildState): void;
  55938. /**
  55939. * Bind data to effect. Will only be called for blocks with isBindable === true
  55940. * @param effect defines the effect to bind data to
  55941. * @param nodeMaterial defines the hosting NodeMaterial
  55942. * @param mesh defines the mesh that will be rendered
  55943. */
  55944. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55945. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55946. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55947. protected _writeFloat(value: number): string;
  55948. /**
  55949. * Gets the current class name e.g. "NodeMaterialBlock"
  55950. * @returns the class name
  55951. */
  55952. getClassName(): string;
  55953. /**
  55954. * Register a new input. Must be called inside a block constructor
  55955. * @param name defines the connection point name
  55956. * @param type defines the connection point type
  55957. * @param isOptional defines a boolean indicating that this input can be omitted
  55958. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55959. * @returns the current block
  55960. */
  55961. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55962. /**
  55963. * Register a new output. Must be called inside a block constructor
  55964. * @param name defines the connection point name
  55965. * @param type defines the connection point type
  55966. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55967. * @returns the current block
  55968. */
  55969. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55970. /**
  55971. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55972. * @param forOutput defines an optional connection point to check compatibility with
  55973. * @returns the first available input or null
  55974. */
  55975. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55976. /**
  55977. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55978. * @param forBlock defines an optional block to check compatibility with
  55979. * @returns the first available input or null
  55980. */
  55981. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55982. /**
  55983. * Gets the sibling of the given output
  55984. * @param current defines the current output
  55985. * @returns the next output in the list or null
  55986. */
  55987. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55988. /**
  55989. * Connect current block with another block
  55990. * @param other defines the block to connect with
  55991. * @param options define the various options to help pick the right connections
  55992. * @returns the current block
  55993. */
  55994. connectTo(other: NodeMaterialBlock, options?: {
  55995. input?: string;
  55996. output?: string;
  55997. outputSwizzle?: string;
  55998. }): this | undefined;
  55999. protected _buildBlock(state: NodeMaterialBuildState): void;
  56000. /**
  56001. * Add uniforms, samplers and uniform buffers at compilation time
  56002. * @param state defines the state to update
  56003. * @param nodeMaterial defines the node material requesting the update
  56004. * @param defines defines the material defines to update
  56005. */
  56006. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56007. /**
  56008. * Add potential fallbacks if shader compilation fails
  56009. * @param mesh defines the mesh to be rendered
  56010. * @param fallbacks defines the current prioritized list of fallbacks
  56011. */
  56012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56013. /**
  56014. * Initialize defines for shader compilation
  56015. * @param mesh defines the mesh to be rendered
  56016. * @param nodeMaterial defines the node material requesting the update
  56017. * @param defines defines the material defines to update
  56018. * @param useInstances specifies that instances should be used
  56019. */
  56020. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56021. /**
  56022. * Update defines for shader compilation
  56023. * @param mesh defines the mesh to be rendered
  56024. * @param nodeMaterial defines the node material requesting the update
  56025. * @param defines defines the material defines to update
  56026. * @param useInstances specifies that instances should be used
  56027. */
  56028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56029. /**
  56030. * Lets the block try to connect some inputs automatically
  56031. * @param material defines the hosting NodeMaterial
  56032. */
  56033. autoConfigure(material: NodeMaterial): void;
  56034. /**
  56035. * Function called when a block is declared as repeatable content generator
  56036. * @param vertexShaderState defines the current compilation state for the vertex shader
  56037. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56038. * @param mesh defines the mesh to be rendered
  56039. * @param defines defines the material defines to update
  56040. */
  56041. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56042. /**
  56043. * Checks if the block is ready
  56044. * @param mesh defines the mesh to be rendered
  56045. * @param nodeMaterial defines the node material requesting the update
  56046. * @param defines defines the material defines to update
  56047. * @param useInstances specifies that instances should be used
  56048. * @returns true if the block is ready
  56049. */
  56050. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56051. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56052. private _processBuild;
  56053. /**
  56054. * Compile the current node and generate the shader code
  56055. * @param state defines the current compilation state (uniforms, samplers, current string)
  56056. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56057. * @returns true if already built
  56058. */
  56059. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56060. protected _inputRename(name: string): string;
  56061. protected _outputRename(name: string): string;
  56062. protected _dumpPropertiesCode(): string;
  56063. /** @hidden */
  56064. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56065. /**
  56066. * Clone the current block to a new identical block
  56067. * @param scene defines the hosting scene
  56068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56069. * @returns a copy of the current block
  56070. */
  56071. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56072. /**
  56073. * Serializes this block in a JSON representation
  56074. * @returns the serialized block object
  56075. */
  56076. serialize(): any;
  56077. /** @hidden */
  56078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56079. }
  56080. }
  56081. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56082. /**
  56083. * Enum defining the type of animations supported by InputBlock
  56084. */
  56085. export enum AnimatedInputBlockTypes {
  56086. /** No animation */
  56087. None = 0,
  56088. /** Time based animation. Will only work for floats */
  56089. Time = 1
  56090. }
  56091. }
  56092. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56094. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56095. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56096. import { Nullable } from "babylonjs/types";
  56097. import { Effect } from "babylonjs/Materials/effect";
  56098. import { Matrix } from "babylonjs/Maths/math.vector";
  56099. import { Scene } from "babylonjs/scene";
  56100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56102. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56103. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56104. /**
  56105. * Block used to expose an input value
  56106. */
  56107. export class InputBlock extends NodeMaterialBlock {
  56108. private _mode;
  56109. private _associatedVariableName;
  56110. private _storedValue;
  56111. private _valueCallback;
  56112. private _type;
  56113. private _animationType;
  56114. /** Gets or set a value used to limit the range of float values */
  56115. min: number;
  56116. /** Gets or set a value used to limit the range of float values */
  56117. max: number;
  56118. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56119. matrixMode: number;
  56120. /** @hidden */
  56121. _systemValue: Nullable<NodeMaterialSystemValues>;
  56122. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56123. visibleInInspector: boolean;
  56124. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56125. isConstant: boolean;
  56126. /**
  56127. * Gets or sets the connection point type (default is float)
  56128. */
  56129. readonly type: NodeMaterialBlockConnectionPointTypes;
  56130. /**
  56131. * Creates a new InputBlock
  56132. * @param name defines the block name
  56133. * @param target defines the target of that block (Vertex by default)
  56134. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56135. */
  56136. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56137. /**
  56138. * Gets the output component
  56139. */
  56140. readonly output: NodeMaterialConnectionPoint;
  56141. /**
  56142. * Set the source of this connection point to a vertex attribute
  56143. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56144. * @returns the current connection point
  56145. */
  56146. setAsAttribute(attributeName?: string): InputBlock;
  56147. /**
  56148. * Set the source of this connection point to a system value
  56149. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56150. * @returns the current connection point
  56151. */
  56152. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56153. /**
  56154. * Gets or sets the value of that point.
  56155. * Please note that this value will be ignored if valueCallback is defined
  56156. */
  56157. value: any;
  56158. /**
  56159. * Gets or sets a callback used to get the value of that point.
  56160. * Please note that setting this value will force the connection point to ignore the value property
  56161. */
  56162. valueCallback: () => any;
  56163. /**
  56164. * Gets or sets the associated variable name in the shader
  56165. */
  56166. associatedVariableName: string;
  56167. /** Gets or sets the type of animation applied to the input */
  56168. animationType: AnimatedInputBlockTypes;
  56169. /**
  56170. * Gets a boolean indicating that this connection point not defined yet
  56171. */
  56172. readonly isUndefined: boolean;
  56173. /**
  56174. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56175. * In this case the connection point name must be the name of the uniform to use.
  56176. * Can only be set on inputs
  56177. */
  56178. isUniform: boolean;
  56179. /**
  56180. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56181. * In this case the connection point name must be the name of the attribute to use
  56182. * Can only be set on inputs
  56183. */
  56184. isAttribute: boolean;
  56185. /**
  56186. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56187. * Can only be set on exit points
  56188. */
  56189. isVarying: boolean;
  56190. /**
  56191. * Gets a boolean indicating that the current connection point is a system value
  56192. */
  56193. readonly isSystemValue: boolean;
  56194. /**
  56195. * Gets or sets the current well known value or null if not defined as a system value
  56196. */
  56197. systemValue: Nullable<NodeMaterialSystemValues>;
  56198. /**
  56199. * Gets the current class name
  56200. * @returns the class name
  56201. */
  56202. getClassName(): string;
  56203. /**
  56204. * Animate the input if animationType !== None
  56205. * @param scene defines the rendering scene
  56206. */
  56207. animate(scene: Scene): void;
  56208. private _emitDefine;
  56209. initialize(state: NodeMaterialBuildState): void;
  56210. /**
  56211. * Set the input block to its default value (based on its type)
  56212. */
  56213. setDefaultValue(): void;
  56214. private _emitConstant;
  56215. private _emit;
  56216. /** @hidden */
  56217. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56218. /** @hidden */
  56219. _transmit(effect: Effect, scene: Scene): void;
  56220. protected _buildBlock(state: NodeMaterialBuildState): void;
  56221. protected _dumpPropertiesCode(): string;
  56222. serialize(): any;
  56223. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56224. }
  56225. }
  56226. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56227. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56228. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56229. import { Nullable } from "babylonjs/types";
  56230. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56232. /**
  56233. * Defines a connection point for a block
  56234. */
  56235. export class NodeMaterialConnectionPoint {
  56236. /** @hidden */
  56237. _ownerBlock: NodeMaterialBlock;
  56238. /** @hidden */
  56239. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56240. private _endpoints;
  56241. private _associatedVariableName;
  56242. /** @hidden */
  56243. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56244. /** @hidden */
  56245. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56246. private _type;
  56247. /** @hidden */
  56248. _enforceAssociatedVariableName: boolean;
  56249. /**
  56250. * Gets or sets the additional types supported by this connection point
  56251. */
  56252. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56253. /**
  56254. * Gets or sets the additional types excluded by this connection point
  56255. */
  56256. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56257. /**
  56258. * Gets or sets the associated variable name in the shader
  56259. */
  56260. associatedVariableName: string;
  56261. /**
  56262. * Gets or sets the connection point type (default is float)
  56263. */
  56264. type: NodeMaterialBlockConnectionPointTypes;
  56265. /**
  56266. * Gets or sets the connection point name
  56267. */
  56268. name: string;
  56269. /**
  56270. * Gets or sets a boolean indicating that this connection point can be omitted
  56271. */
  56272. isOptional: boolean;
  56273. /**
  56274. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56275. */
  56276. define: string;
  56277. /** Gets or sets the target of that connection point */
  56278. target: NodeMaterialBlockTargets;
  56279. /**
  56280. * Gets a boolean indicating that the current point is connected
  56281. */
  56282. readonly isConnected: boolean;
  56283. /**
  56284. * Gets a boolean indicating that the current point is connected to an input block
  56285. */
  56286. readonly isConnectedToInputBlock: boolean;
  56287. /**
  56288. * Gets a the connected input block (if any)
  56289. */
  56290. readonly connectInputBlock: Nullable<InputBlock>;
  56291. /** Get the other side of the connection (if any) */
  56292. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56293. /** Get the block that owns this connection point */
  56294. readonly ownerBlock: NodeMaterialBlock;
  56295. /** Get the block connected on the other side of this connection (if any) */
  56296. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56297. /** Get the block connected on the endpoints of this connection (if any) */
  56298. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56299. /** Gets the list of connected endpoints */
  56300. readonly endpoints: NodeMaterialConnectionPoint[];
  56301. /** Gets a boolean indicating if that output point is connected to at least one input */
  56302. readonly hasEndpoints: boolean;
  56303. /**
  56304. * Creates a new connection point
  56305. * @param name defines the connection point name
  56306. * @param ownerBlock defines the block hosting this connection point
  56307. */
  56308. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56309. /**
  56310. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56311. * @returns the class name
  56312. */
  56313. getClassName(): string;
  56314. /**
  56315. * Gets an boolean indicating if the current point can be connected to another point
  56316. * @param connectionPoint defines the other connection point
  56317. * @returns true if the connection is possible
  56318. */
  56319. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56320. /**
  56321. * Connect this point to another connection point
  56322. * @param connectionPoint defines the other connection point
  56323. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56324. * @returns the current connection point
  56325. */
  56326. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56327. /**
  56328. * Disconnect this point from one of his endpoint
  56329. * @param endpoint defines the other connection point
  56330. * @returns the current connection point
  56331. */
  56332. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56333. /**
  56334. * Serializes this point in a JSON representation
  56335. * @returns the serialized point object
  56336. */
  56337. serialize(): any;
  56338. }
  56339. }
  56340. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56344. import { Mesh } from "babylonjs/Meshes/mesh";
  56345. import { Effect } from "babylonjs/Materials/effect";
  56346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56347. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56348. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56349. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56350. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56351. /**
  56352. * Block used to add support for vertex skinning (bones)
  56353. */
  56354. export class BonesBlock extends NodeMaterialBlock {
  56355. /**
  56356. * Creates a new BonesBlock
  56357. * @param name defines the block name
  56358. */
  56359. constructor(name: string);
  56360. /**
  56361. * Initialize the block and prepare the context for build
  56362. * @param state defines the state that will be used for the build
  56363. */
  56364. initialize(state: NodeMaterialBuildState): void;
  56365. /**
  56366. * Gets the current class name
  56367. * @returns the class name
  56368. */
  56369. getClassName(): string;
  56370. /**
  56371. * Gets the matrix indices input component
  56372. */
  56373. readonly matricesIndices: NodeMaterialConnectionPoint;
  56374. /**
  56375. * Gets the matrix weights input component
  56376. */
  56377. readonly matricesWeights: NodeMaterialConnectionPoint;
  56378. /**
  56379. * Gets the extra matrix indices input component
  56380. */
  56381. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56382. /**
  56383. * Gets the extra matrix weights input component
  56384. */
  56385. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56386. /**
  56387. * Gets the world input component
  56388. */
  56389. readonly world: NodeMaterialConnectionPoint;
  56390. /**
  56391. * Gets the output component
  56392. */
  56393. readonly output: NodeMaterialConnectionPoint;
  56394. autoConfigure(material: NodeMaterial): void;
  56395. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56398. protected _buildBlock(state: NodeMaterialBuildState): this;
  56399. }
  56400. }
  56401. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56404. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56406. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56407. /**
  56408. * Block used to add support for instances
  56409. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56410. */
  56411. export class InstancesBlock extends NodeMaterialBlock {
  56412. /**
  56413. * Creates a new InstancesBlock
  56414. * @param name defines the block name
  56415. */
  56416. constructor(name: string);
  56417. /**
  56418. * Gets the current class name
  56419. * @returns the class name
  56420. */
  56421. getClassName(): string;
  56422. /**
  56423. * Gets the first world row input component
  56424. */
  56425. readonly world0: NodeMaterialConnectionPoint;
  56426. /**
  56427. * Gets the second world row input component
  56428. */
  56429. readonly world1: NodeMaterialConnectionPoint;
  56430. /**
  56431. * Gets the third world row input component
  56432. */
  56433. readonly world2: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the forth world row input component
  56436. */
  56437. readonly world3: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the world input component
  56440. */
  56441. readonly world: NodeMaterialConnectionPoint;
  56442. /**
  56443. * Gets the output component
  56444. */
  56445. readonly output: NodeMaterialConnectionPoint;
  56446. autoConfigure(material: NodeMaterial): void;
  56447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56448. protected _buildBlock(state: NodeMaterialBuildState): this;
  56449. }
  56450. }
  56451. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56456. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56457. import { Effect } from "babylonjs/Materials/effect";
  56458. import { Mesh } from "babylonjs/Meshes/mesh";
  56459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56461. /**
  56462. * Block used to add morph targets support to vertex shader
  56463. */
  56464. export class MorphTargetsBlock extends NodeMaterialBlock {
  56465. private _repeatableContentAnchor;
  56466. private _repeatebleContentGenerated;
  56467. /**
  56468. * Create a new MorphTargetsBlock
  56469. * @param name defines the block name
  56470. */
  56471. constructor(name: string);
  56472. /**
  56473. * Gets the current class name
  56474. * @returns the class name
  56475. */
  56476. getClassName(): string;
  56477. /**
  56478. * Gets the position input component
  56479. */
  56480. readonly position: NodeMaterialConnectionPoint;
  56481. /**
  56482. * Gets the normal input component
  56483. */
  56484. readonly normal: NodeMaterialConnectionPoint;
  56485. /**
  56486. * Gets the tangent input component
  56487. */
  56488. readonly tangent: NodeMaterialConnectionPoint;
  56489. /**
  56490. * Gets the tangent input component
  56491. */
  56492. readonly uv: NodeMaterialConnectionPoint;
  56493. /**
  56494. * Gets the position output component
  56495. */
  56496. readonly positionOutput: NodeMaterialConnectionPoint;
  56497. /**
  56498. * Gets the normal output component
  56499. */
  56500. readonly normalOutput: NodeMaterialConnectionPoint;
  56501. /**
  56502. * Gets the tangent output component
  56503. */
  56504. readonly tangentOutput: NodeMaterialConnectionPoint;
  56505. /**
  56506. * Gets the tangent output component
  56507. */
  56508. readonly uvOutput: NodeMaterialConnectionPoint;
  56509. initialize(state: NodeMaterialBuildState): void;
  56510. autoConfigure(material: NodeMaterial): void;
  56511. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56512. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56513. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56514. protected _buildBlock(state: NodeMaterialBuildState): this;
  56515. }
  56516. }
  56517. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56521. import { Nullable } from "babylonjs/types";
  56522. import { Scene } from "babylonjs/scene";
  56523. import { Effect } from "babylonjs/Materials/effect";
  56524. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56525. import { Mesh } from "babylonjs/Meshes/mesh";
  56526. import { Light } from "babylonjs/Lights/light";
  56527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56528. /**
  56529. * Block used to get data information from a light
  56530. */
  56531. export class LightInformationBlock extends NodeMaterialBlock {
  56532. private _lightDataUniformName;
  56533. private _lightColorUniformName;
  56534. private _lightTypeDefineName;
  56535. /**
  56536. * Gets or sets the light associated with this block
  56537. */
  56538. light: Nullable<Light>;
  56539. /**
  56540. * Creates a new LightInformationBlock
  56541. * @param name defines the block name
  56542. */
  56543. constructor(name: string);
  56544. /**
  56545. * Gets the current class name
  56546. * @returns the class name
  56547. */
  56548. getClassName(): string;
  56549. /**
  56550. * Gets the world position input component
  56551. */
  56552. readonly worldPosition: NodeMaterialConnectionPoint;
  56553. /**
  56554. * Gets the direction output component
  56555. */
  56556. readonly direction: NodeMaterialConnectionPoint;
  56557. /**
  56558. * Gets the direction output component
  56559. */
  56560. readonly color: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the direction output component
  56563. */
  56564. readonly intensity: NodeMaterialConnectionPoint;
  56565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56567. protected _buildBlock(state: NodeMaterialBuildState): this;
  56568. serialize(): any;
  56569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56570. }
  56571. }
  56572. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56573. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56574. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56575. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56576. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56577. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56578. }
  56579. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56584. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56585. import { Effect } from "babylonjs/Materials/effect";
  56586. import { Mesh } from "babylonjs/Meshes/mesh";
  56587. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56588. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56589. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56590. /**
  56591. * Block used to add image processing support to fragment shader
  56592. */
  56593. export class ImageProcessingBlock extends NodeMaterialBlock {
  56594. /**
  56595. * Create a new ImageProcessingBlock
  56596. * @param name defines the block name
  56597. */
  56598. constructor(name: string);
  56599. /**
  56600. * Gets the current class name
  56601. * @returns the class name
  56602. */
  56603. getClassName(): string;
  56604. /**
  56605. * Gets the color input component
  56606. */
  56607. readonly color: NodeMaterialConnectionPoint;
  56608. /**
  56609. * Gets the output component
  56610. */
  56611. readonly output: NodeMaterialConnectionPoint;
  56612. /**
  56613. * Initialize the block and prepare the context for build
  56614. * @param state defines the state that will be used for the build
  56615. */
  56616. initialize(state: NodeMaterialBuildState): void;
  56617. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56620. protected _buildBlock(state: NodeMaterialBuildState): this;
  56621. }
  56622. }
  56623. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56627. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56629. import { Effect } from "babylonjs/Materials/effect";
  56630. import { Mesh } from "babylonjs/Meshes/mesh";
  56631. import { Scene } from "babylonjs/scene";
  56632. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56633. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56634. /**
  56635. * Block used to pertub normals based on a normal map
  56636. */
  56637. export class PerturbNormalBlock extends NodeMaterialBlock {
  56638. private _tangentSpaceParameterName;
  56639. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56640. invertX: boolean;
  56641. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56642. invertY: boolean;
  56643. /**
  56644. * Create a new PerturbNormalBlock
  56645. * @param name defines the block name
  56646. */
  56647. constructor(name: string);
  56648. /**
  56649. * Gets the current class name
  56650. * @returns the class name
  56651. */
  56652. getClassName(): string;
  56653. /**
  56654. * Gets the world position input component
  56655. */
  56656. readonly worldPosition: NodeMaterialConnectionPoint;
  56657. /**
  56658. * Gets the world normal input component
  56659. */
  56660. readonly worldNormal: NodeMaterialConnectionPoint;
  56661. /**
  56662. * Gets the uv input component
  56663. */
  56664. readonly uv: NodeMaterialConnectionPoint;
  56665. /**
  56666. * Gets the normal map color input component
  56667. */
  56668. readonly normalMapColor: NodeMaterialConnectionPoint;
  56669. /**
  56670. * Gets the strength input component
  56671. */
  56672. readonly strength: NodeMaterialConnectionPoint;
  56673. /**
  56674. * Gets the output component
  56675. */
  56676. readonly output: NodeMaterialConnectionPoint;
  56677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56679. autoConfigure(material: NodeMaterial): void;
  56680. protected _buildBlock(state: NodeMaterialBuildState): this;
  56681. protected _dumpPropertiesCode(): string;
  56682. serialize(): any;
  56683. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56684. }
  56685. }
  56686. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56690. /**
  56691. * Block used to discard a pixel if a value is smaller than a cutoff
  56692. */
  56693. export class DiscardBlock extends NodeMaterialBlock {
  56694. /**
  56695. * Create a new DiscardBlock
  56696. * @param name defines the block name
  56697. */
  56698. constructor(name: string);
  56699. /**
  56700. * Gets the current class name
  56701. * @returns the class name
  56702. */
  56703. getClassName(): string;
  56704. /**
  56705. * Gets the color input component
  56706. */
  56707. readonly value: NodeMaterialConnectionPoint;
  56708. /**
  56709. * Gets the cutoff input component
  56710. */
  56711. readonly cutoff: NodeMaterialConnectionPoint;
  56712. protected _buildBlock(state: NodeMaterialBuildState): this;
  56713. }
  56714. }
  56715. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56716. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56717. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56718. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56719. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56720. }
  56721. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56724. import { Mesh } from "babylonjs/Meshes/mesh";
  56725. import { Effect } from "babylonjs/Materials/effect";
  56726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56728. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56729. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56730. /**
  56731. * Block used to add support for scene fog
  56732. */
  56733. export class FogBlock extends NodeMaterialBlock {
  56734. private _fogDistanceName;
  56735. private _fogParameters;
  56736. /**
  56737. * Create a new FogBlock
  56738. * @param name defines the block name
  56739. */
  56740. constructor(name: string);
  56741. /**
  56742. * Gets the current class name
  56743. * @returns the class name
  56744. */
  56745. getClassName(): string;
  56746. /**
  56747. * Gets the world position input component
  56748. */
  56749. readonly worldPosition: NodeMaterialConnectionPoint;
  56750. /**
  56751. * Gets the view input component
  56752. */
  56753. readonly view: NodeMaterialConnectionPoint;
  56754. /**
  56755. * Gets the color input component
  56756. */
  56757. readonly input: NodeMaterialConnectionPoint;
  56758. /**
  56759. * Gets the fog color input component
  56760. */
  56761. readonly fogColor: NodeMaterialConnectionPoint;
  56762. /**
  56763. * Gets the output component
  56764. */
  56765. readonly output: NodeMaterialConnectionPoint;
  56766. autoConfigure(material: NodeMaterial): void;
  56767. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56768. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56769. protected _buildBlock(state: NodeMaterialBuildState): this;
  56770. }
  56771. }
  56772. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56778. import { Effect } from "babylonjs/Materials/effect";
  56779. import { Mesh } from "babylonjs/Meshes/mesh";
  56780. import { Light } from "babylonjs/Lights/light";
  56781. import { Nullable } from "babylonjs/types";
  56782. import { Scene } from "babylonjs/scene";
  56783. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56784. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56785. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56786. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56787. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56788. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56789. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56790. /**
  56791. * Block used to add light in the fragment shader
  56792. */
  56793. export class LightBlock extends NodeMaterialBlock {
  56794. private _lightId;
  56795. /**
  56796. * Gets or sets the light associated with this block
  56797. */
  56798. light: Nullable<Light>;
  56799. /**
  56800. * Create a new LightBlock
  56801. * @param name defines the block name
  56802. */
  56803. constructor(name: string);
  56804. /**
  56805. * Gets the current class name
  56806. * @returns the class name
  56807. */
  56808. getClassName(): string;
  56809. /**
  56810. * Gets the world position input component
  56811. */
  56812. readonly worldPosition: NodeMaterialConnectionPoint;
  56813. /**
  56814. * Gets the world normal input component
  56815. */
  56816. readonly worldNormal: NodeMaterialConnectionPoint;
  56817. /**
  56818. * Gets the camera (or eye) position component
  56819. */
  56820. readonly cameraPosition: NodeMaterialConnectionPoint;
  56821. /**
  56822. * Gets the glossiness component
  56823. */
  56824. readonly glossiness: NodeMaterialConnectionPoint;
  56825. /**
  56826. * Gets the glossinness power component
  56827. */
  56828. readonly glossPower: NodeMaterialConnectionPoint;
  56829. /**
  56830. * Gets the diffuse color component
  56831. */
  56832. readonly diffuseColor: NodeMaterialConnectionPoint;
  56833. /**
  56834. * Gets the specular color component
  56835. */
  56836. readonly specularColor: NodeMaterialConnectionPoint;
  56837. /**
  56838. * Gets the diffuse output component
  56839. */
  56840. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56841. /**
  56842. * Gets the specular output component
  56843. */
  56844. readonly specularOutput: NodeMaterialConnectionPoint;
  56845. autoConfigure(material: NodeMaterial): void;
  56846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56847. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56849. private _injectVertexCode;
  56850. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56851. serialize(): any;
  56852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56853. }
  56854. }
  56855. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56856. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56857. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56858. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56859. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56860. }
  56861. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56862. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56863. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56864. }
  56865. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56869. /**
  56870. * Block used to multiply 2 values
  56871. */
  56872. export class MultiplyBlock extends NodeMaterialBlock {
  56873. /**
  56874. * Creates a new MultiplyBlock
  56875. * @param name defines the block name
  56876. */
  56877. constructor(name: string);
  56878. /**
  56879. * Gets the current class name
  56880. * @returns the class name
  56881. */
  56882. getClassName(): string;
  56883. /**
  56884. * Gets the left operand input component
  56885. */
  56886. readonly left: NodeMaterialConnectionPoint;
  56887. /**
  56888. * Gets the right operand input component
  56889. */
  56890. readonly right: NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the output component
  56893. */
  56894. readonly output: NodeMaterialConnectionPoint;
  56895. protected _buildBlock(state: NodeMaterialBuildState): this;
  56896. }
  56897. }
  56898. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56902. /**
  56903. * Block used to add 2 vectors
  56904. */
  56905. export class AddBlock extends NodeMaterialBlock {
  56906. /**
  56907. * Creates a new AddBlock
  56908. * @param name defines the block name
  56909. */
  56910. constructor(name: string);
  56911. /**
  56912. * Gets the current class name
  56913. * @returns the class name
  56914. */
  56915. getClassName(): string;
  56916. /**
  56917. * Gets the left operand input component
  56918. */
  56919. readonly left: NodeMaterialConnectionPoint;
  56920. /**
  56921. * Gets the right operand input component
  56922. */
  56923. readonly right: NodeMaterialConnectionPoint;
  56924. /**
  56925. * Gets the output component
  56926. */
  56927. readonly output: NodeMaterialConnectionPoint;
  56928. protected _buildBlock(state: NodeMaterialBuildState): this;
  56929. }
  56930. }
  56931. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56935. /**
  56936. * Block used to scale a vector by a float
  56937. */
  56938. export class ScaleBlock extends NodeMaterialBlock {
  56939. /**
  56940. * Creates a new ScaleBlock
  56941. * @param name defines the block name
  56942. */
  56943. constructor(name: string);
  56944. /**
  56945. * Gets the current class name
  56946. * @returns the class name
  56947. */
  56948. getClassName(): string;
  56949. /**
  56950. * Gets the input component
  56951. */
  56952. readonly input: NodeMaterialConnectionPoint;
  56953. /**
  56954. * Gets the factor input component
  56955. */
  56956. readonly factor: NodeMaterialConnectionPoint;
  56957. /**
  56958. * Gets the output component
  56959. */
  56960. readonly output: NodeMaterialConnectionPoint;
  56961. protected _buildBlock(state: NodeMaterialBuildState): this;
  56962. }
  56963. }
  56964. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56968. import { Scene } from "babylonjs/scene";
  56969. /**
  56970. * Block used to clamp a float
  56971. */
  56972. export class ClampBlock extends NodeMaterialBlock {
  56973. /** Gets or sets the minimum range */
  56974. minimum: number;
  56975. /** Gets or sets the maximum range */
  56976. maximum: number;
  56977. /**
  56978. * Creates a new ClampBlock
  56979. * @param name defines the block name
  56980. */
  56981. constructor(name: string);
  56982. /**
  56983. * Gets the current class name
  56984. * @returns the class name
  56985. */
  56986. getClassName(): string;
  56987. /**
  56988. * Gets the value input component
  56989. */
  56990. readonly value: NodeMaterialConnectionPoint;
  56991. /**
  56992. * Gets the output component
  56993. */
  56994. readonly output: NodeMaterialConnectionPoint;
  56995. protected _buildBlock(state: NodeMaterialBuildState): this;
  56996. protected _dumpPropertiesCode(): string;
  56997. serialize(): any;
  56998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56999. }
  57000. }
  57001. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57005. /**
  57006. * Block used to apply a cross product between 2 vectors
  57007. */
  57008. export class CrossBlock extends NodeMaterialBlock {
  57009. /**
  57010. * Creates a new CrossBlock
  57011. * @param name defines the block name
  57012. */
  57013. constructor(name: string);
  57014. /**
  57015. * Gets the current class name
  57016. * @returns the class name
  57017. */
  57018. getClassName(): string;
  57019. /**
  57020. * Gets the left operand input component
  57021. */
  57022. readonly left: NodeMaterialConnectionPoint;
  57023. /**
  57024. * Gets the right operand input component
  57025. */
  57026. readonly right: NodeMaterialConnectionPoint;
  57027. /**
  57028. * Gets the output component
  57029. */
  57030. readonly output: NodeMaterialConnectionPoint;
  57031. protected _buildBlock(state: NodeMaterialBuildState): this;
  57032. }
  57033. }
  57034. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57038. /**
  57039. * Block used to apply a dot product between 2 vectors
  57040. */
  57041. export class DotBlock extends NodeMaterialBlock {
  57042. /**
  57043. * Creates a new DotBlock
  57044. * @param name defines the block name
  57045. */
  57046. constructor(name: string);
  57047. /**
  57048. * Gets the current class name
  57049. * @returns the class name
  57050. */
  57051. getClassName(): string;
  57052. /**
  57053. * Gets the left operand input component
  57054. */
  57055. readonly left: NodeMaterialConnectionPoint;
  57056. /**
  57057. * Gets the right operand input component
  57058. */
  57059. readonly right: NodeMaterialConnectionPoint;
  57060. /**
  57061. * Gets the output component
  57062. */
  57063. readonly output: NodeMaterialConnectionPoint;
  57064. protected _buildBlock(state: NodeMaterialBuildState): this;
  57065. }
  57066. }
  57067. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57071. import { Vector2 } from "babylonjs/Maths/math.vector";
  57072. import { Scene } from "babylonjs/scene";
  57073. /**
  57074. * Block used to remap a float from a range to a new one
  57075. */
  57076. export class RemapBlock extends NodeMaterialBlock {
  57077. /**
  57078. * Gets or sets the source range
  57079. */
  57080. sourceRange: Vector2;
  57081. /**
  57082. * Gets or sets the target range
  57083. */
  57084. targetRange: Vector2;
  57085. /**
  57086. * Creates a new RemapBlock
  57087. * @param name defines the block name
  57088. */
  57089. constructor(name: string);
  57090. /**
  57091. * Gets the current class name
  57092. * @returns the class name
  57093. */
  57094. getClassName(): string;
  57095. /**
  57096. * Gets the input component
  57097. */
  57098. readonly input: NodeMaterialConnectionPoint;
  57099. /**
  57100. * Gets the source min input component
  57101. */
  57102. readonly sourceMin: NodeMaterialConnectionPoint;
  57103. /**
  57104. * Gets the source max input component
  57105. */
  57106. readonly sourceMax: NodeMaterialConnectionPoint;
  57107. /**
  57108. * Gets the target min input component
  57109. */
  57110. readonly targetMin: NodeMaterialConnectionPoint;
  57111. /**
  57112. * Gets the target max input component
  57113. */
  57114. readonly targetMax: NodeMaterialConnectionPoint;
  57115. /**
  57116. * Gets the output component
  57117. */
  57118. readonly output: NodeMaterialConnectionPoint;
  57119. protected _buildBlock(state: NodeMaterialBuildState): this;
  57120. protected _dumpPropertiesCode(): string;
  57121. serialize(): any;
  57122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57123. }
  57124. }
  57125. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57129. /**
  57130. * Block used to normalize a vector
  57131. */
  57132. export class NormalizeBlock extends NodeMaterialBlock {
  57133. /**
  57134. * Creates a new NormalizeBlock
  57135. * @param name defines the block name
  57136. */
  57137. constructor(name: string);
  57138. /**
  57139. * Gets the current class name
  57140. * @returns the class name
  57141. */
  57142. getClassName(): string;
  57143. /**
  57144. * Gets the input component
  57145. */
  57146. readonly input: NodeMaterialConnectionPoint;
  57147. /**
  57148. * Gets the output component
  57149. */
  57150. readonly output: NodeMaterialConnectionPoint;
  57151. protected _buildBlock(state: NodeMaterialBuildState): this;
  57152. }
  57153. }
  57154. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57158. import { Scene } from "babylonjs/scene";
  57159. /**
  57160. * Operations supported by the Trigonometry block
  57161. */
  57162. export enum TrigonometryBlockOperations {
  57163. /** Cos */
  57164. Cos = 0,
  57165. /** Sin */
  57166. Sin = 1,
  57167. /** Abs */
  57168. Abs = 2,
  57169. /** Exp */
  57170. Exp = 3,
  57171. /** Exp2 */
  57172. Exp2 = 4,
  57173. /** Round */
  57174. Round = 5,
  57175. /** Floor */
  57176. Floor = 6,
  57177. /** Ceiling */
  57178. Ceiling = 7,
  57179. /** Square root */
  57180. Sqrt = 8,
  57181. /** Log */
  57182. Log = 9,
  57183. /** Tangent */
  57184. Tan = 10,
  57185. /** Arc tangent */
  57186. ArcTan = 11,
  57187. /** Arc cosinus */
  57188. ArcCos = 12,
  57189. /** Arc sinus */
  57190. ArcSin = 13,
  57191. /** Fraction */
  57192. Fract = 14,
  57193. /** Sign */
  57194. Sign = 15,
  57195. /** To radians (from degrees) */
  57196. Radians = 16,
  57197. /** To degrees (from radians) */
  57198. Degrees = 17
  57199. }
  57200. /**
  57201. * Block used to apply trigonometry operation to floats
  57202. */
  57203. export class TrigonometryBlock extends NodeMaterialBlock {
  57204. /**
  57205. * Gets or sets the operation applied by the block
  57206. */
  57207. operation: TrigonometryBlockOperations;
  57208. /**
  57209. * Creates a new TrigonometryBlock
  57210. * @param name defines the block name
  57211. */
  57212. constructor(name: string);
  57213. /**
  57214. * Gets the current class name
  57215. * @returns the class name
  57216. */
  57217. getClassName(): string;
  57218. /**
  57219. * Gets the input component
  57220. */
  57221. readonly input: NodeMaterialConnectionPoint;
  57222. /**
  57223. * Gets the output component
  57224. */
  57225. readonly output: NodeMaterialConnectionPoint;
  57226. protected _buildBlock(state: NodeMaterialBuildState): this;
  57227. serialize(): any;
  57228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57229. }
  57230. }
  57231. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57233. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57234. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57235. /**
  57236. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57237. */
  57238. export class ColorMergerBlock extends NodeMaterialBlock {
  57239. /**
  57240. * Create a new ColorMergerBlock
  57241. * @param name defines the block name
  57242. */
  57243. constructor(name: string);
  57244. /**
  57245. * Gets the current class name
  57246. * @returns the class name
  57247. */
  57248. getClassName(): string;
  57249. /**
  57250. * Gets the r component (input)
  57251. */
  57252. readonly r: NodeMaterialConnectionPoint;
  57253. /**
  57254. * Gets the g component (input)
  57255. */
  57256. readonly g: NodeMaterialConnectionPoint;
  57257. /**
  57258. * Gets the b component (input)
  57259. */
  57260. readonly b: NodeMaterialConnectionPoint;
  57261. /**
  57262. * Gets the a component (input)
  57263. */
  57264. readonly a: NodeMaterialConnectionPoint;
  57265. /**
  57266. * Gets the rgba component (output)
  57267. */
  57268. readonly rgba: NodeMaterialConnectionPoint;
  57269. /**
  57270. * Gets the rgb component (output)
  57271. */
  57272. readonly rgb: NodeMaterialConnectionPoint;
  57273. protected _buildBlock(state: NodeMaterialBuildState): this;
  57274. }
  57275. }
  57276. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57280. /**
  57281. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57282. */
  57283. export class VectorMergerBlock extends NodeMaterialBlock {
  57284. /**
  57285. * Create a new VectorMergerBlock
  57286. * @param name defines the block name
  57287. */
  57288. constructor(name: string);
  57289. /**
  57290. * Gets the current class name
  57291. * @returns the class name
  57292. */
  57293. getClassName(): string;
  57294. /**
  57295. * Gets the x component (input)
  57296. */
  57297. readonly x: NodeMaterialConnectionPoint;
  57298. /**
  57299. * Gets the y component (input)
  57300. */
  57301. readonly y: NodeMaterialConnectionPoint;
  57302. /**
  57303. * Gets the z component (input)
  57304. */
  57305. readonly z: NodeMaterialConnectionPoint;
  57306. /**
  57307. * Gets the w component (input)
  57308. */
  57309. readonly w: NodeMaterialConnectionPoint;
  57310. /**
  57311. * Gets the xyzw component (output)
  57312. */
  57313. readonly xyzw: NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the xyz component (output)
  57316. */
  57317. readonly xyz: NodeMaterialConnectionPoint;
  57318. /**
  57319. * Gets the xy component (output)
  57320. */
  57321. readonly xy: NodeMaterialConnectionPoint;
  57322. protected _buildBlock(state: NodeMaterialBuildState): this;
  57323. }
  57324. }
  57325. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57329. /**
  57330. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57331. */
  57332. export class ColorSplitterBlock extends NodeMaterialBlock {
  57333. /**
  57334. * Create a new ColorSplitterBlock
  57335. * @param name defines the block name
  57336. */
  57337. constructor(name: string);
  57338. /**
  57339. * Gets the current class name
  57340. * @returns the class name
  57341. */
  57342. getClassName(): string;
  57343. /**
  57344. * Gets the rgba component (input)
  57345. */
  57346. readonly rgba: NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the rgb component (input)
  57349. */
  57350. readonly rgbIn: NodeMaterialConnectionPoint;
  57351. /**
  57352. * Gets the rgb component (output)
  57353. */
  57354. readonly rgbOut: NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the r component (output)
  57357. */
  57358. readonly r: NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the g component (output)
  57361. */
  57362. readonly g: NodeMaterialConnectionPoint;
  57363. /**
  57364. * Gets the b component (output)
  57365. */
  57366. readonly b: NodeMaterialConnectionPoint;
  57367. /**
  57368. * Gets the a component (output)
  57369. */
  57370. readonly a: NodeMaterialConnectionPoint;
  57371. protected _inputRename(name: string): string;
  57372. protected _outputRename(name: string): string;
  57373. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57374. }
  57375. }
  57376. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57377. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57380. /**
  57381. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57382. */
  57383. export class VectorSplitterBlock extends NodeMaterialBlock {
  57384. /**
  57385. * Create a new VectorSplitterBlock
  57386. * @param name defines the block name
  57387. */
  57388. constructor(name: string);
  57389. /**
  57390. * Gets the current class name
  57391. * @returns the class name
  57392. */
  57393. getClassName(): string;
  57394. /**
  57395. * Gets the xyzw component (input)
  57396. */
  57397. readonly xyzw: NodeMaterialConnectionPoint;
  57398. /**
  57399. * Gets the xyz component (input)
  57400. */
  57401. readonly xyzIn: NodeMaterialConnectionPoint;
  57402. /**
  57403. * Gets the xy component (input)
  57404. */
  57405. readonly xyIn: NodeMaterialConnectionPoint;
  57406. /**
  57407. * Gets the xyz component (output)
  57408. */
  57409. readonly xyzOut: NodeMaterialConnectionPoint;
  57410. /**
  57411. * Gets the xy component (output)
  57412. */
  57413. readonly xyOut: NodeMaterialConnectionPoint;
  57414. /**
  57415. * Gets the x component (output)
  57416. */
  57417. readonly x: NodeMaterialConnectionPoint;
  57418. /**
  57419. * Gets the y component (output)
  57420. */
  57421. readonly y: NodeMaterialConnectionPoint;
  57422. /**
  57423. * Gets the z component (output)
  57424. */
  57425. readonly z: NodeMaterialConnectionPoint;
  57426. /**
  57427. * Gets the w component (output)
  57428. */
  57429. readonly w: NodeMaterialConnectionPoint;
  57430. protected _inputRename(name: string): string;
  57431. protected _outputRename(name: string): string;
  57432. protected _buildBlock(state: NodeMaterialBuildState): this;
  57433. }
  57434. }
  57435. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57439. /**
  57440. * Block used to lerp 2 values
  57441. */
  57442. export class LerpBlock extends NodeMaterialBlock {
  57443. /**
  57444. * Creates a new LerpBlock
  57445. * @param name defines the block name
  57446. */
  57447. constructor(name: string);
  57448. /**
  57449. * Gets the current class name
  57450. * @returns the class name
  57451. */
  57452. getClassName(): string;
  57453. /**
  57454. * Gets the left operand input component
  57455. */
  57456. readonly left: NodeMaterialConnectionPoint;
  57457. /**
  57458. * Gets the right operand input component
  57459. */
  57460. readonly right: NodeMaterialConnectionPoint;
  57461. /**
  57462. * Gets the gradient operand input component
  57463. */
  57464. readonly gradient: NodeMaterialConnectionPoint;
  57465. /**
  57466. * Gets the output component
  57467. */
  57468. readonly output: NodeMaterialConnectionPoint;
  57469. protected _buildBlock(state: NodeMaterialBuildState): this;
  57470. }
  57471. }
  57472. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57476. /**
  57477. * Block used to divide 2 vectors
  57478. */
  57479. export class DivideBlock extends NodeMaterialBlock {
  57480. /**
  57481. * Creates a new DivideBlock
  57482. * @param name defines the block name
  57483. */
  57484. constructor(name: string);
  57485. /**
  57486. * Gets the current class name
  57487. * @returns the class name
  57488. */
  57489. getClassName(): string;
  57490. /**
  57491. * Gets the left operand input component
  57492. */
  57493. readonly left: NodeMaterialConnectionPoint;
  57494. /**
  57495. * Gets the right operand input component
  57496. */
  57497. readonly right: NodeMaterialConnectionPoint;
  57498. /**
  57499. * Gets the output component
  57500. */
  57501. readonly output: NodeMaterialConnectionPoint;
  57502. protected _buildBlock(state: NodeMaterialBuildState): this;
  57503. }
  57504. }
  57505. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57507. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57509. /**
  57510. * Block used to subtract 2 vectors
  57511. */
  57512. export class SubtractBlock extends NodeMaterialBlock {
  57513. /**
  57514. * Creates a new SubtractBlock
  57515. * @param name defines the block name
  57516. */
  57517. constructor(name: string);
  57518. /**
  57519. * Gets the current class name
  57520. * @returns the class name
  57521. */
  57522. getClassName(): string;
  57523. /**
  57524. * Gets the left operand input component
  57525. */
  57526. readonly left: NodeMaterialConnectionPoint;
  57527. /**
  57528. * Gets the right operand input component
  57529. */
  57530. readonly right: NodeMaterialConnectionPoint;
  57531. /**
  57532. * Gets the output component
  57533. */
  57534. readonly output: NodeMaterialConnectionPoint;
  57535. protected _buildBlock(state: NodeMaterialBuildState): this;
  57536. }
  57537. }
  57538. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57542. /**
  57543. * Block used to step a value
  57544. */
  57545. export class StepBlock extends NodeMaterialBlock {
  57546. /**
  57547. * Creates a new StepBlock
  57548. * @param name defines the block name
  57549. */
  57550. constructor(name: string);
  57551. /**
  57552. * Gets the current class name
  57553. * @returns the class name
  57554. */
  57555. getClassName(): string;
  57556. /**
  57557. * Gets the value operand input component
  57558. */
  57559. readonly value: NodeMaterialConnectionPoint;
  57560. /**
  57561. * Gets the edge operand input component
  57562. */
  57563. readonly edge: NodeMaterialConnectionPoint;
  57564. /**
  57565. * Gets the output component
  57566. */
  57567. readonly output: NodeMaterialConnectionPoint;
  57568. protected _buildBlock(state: NodeMaterialBuildState): this;
  57569. }
  57570. }
  57571. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57575. /**
  57576. * Block used to get the opposite (1 - x) of a value
  57577. */
  57578. export class OneMinusBlock extends NodeMaterialBlock {
  57579. /**
  57580. * Creates a new OneMinusBlock
  57581. * @param name defines the block name
  57582. */
  57583. constructor(name: string);
  57584. /**
  57585. * Gets the current class name
  57586. * @returns the class name
  57587. */
  57588. getClassName(): string;
  57589. /**
  57590. * Gets the input component
  57591. */
  57592. readonly input: NodeMaterialConnectionPoint;
  57593. /**
  57594. * Gets the output component
  57595. */
  57596. readonly output: NodeMaterialConnectionPoint;
  57597. protected _buildBlock(state: NodeMaterialBuildState): this;
  57598. }
  57599. }
  57600. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57601. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57602. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57603. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57604. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57605. /**
  57606. * Block used to get the view direction
  57607. */
  57608. export class ViewDirectionBlock extends NodeMaterialBlock {
  57609. /**
  57610. * Creates a new ViewDirectionBlock
  57611. * @param name defines the block name
  57612. */
  57613. constructor(name: string);
  57614. /**
  57615. * Gets the current class name
  57616. * @returns the class name
  57617. */
  57618. getClassName(): string;
  57619. /**
  57620. * Gets the world position component
  57621. */
  57622. readonly worldPosition: NodeMaterialConnectionPoint;
  57623. /**
  57624. * Gets the camera position component
  57625. */
  57626. readonly cameraPosition: NodeMaterialConnectionPoint;
  57627. /**
  57628. * Gets the output component
  57629. */
  57630. readonly output: NodeMaterialConnectionPoint;
  57631. autoConfigure(material: NodeMaterial): void;
  57632. protected _buildBlock(state: NodeMaterialBuildState): this;
  57633. }
  57634. }
  57635. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57639. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57640. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57641. /**
  57642. * Block used to compute fresnel value
  57643. */
  57644. export class FresnelBlock extends NodeMaterialBlock {
  57645. /**
  57646. * Create a new FresnelBlock
  57647. * @param name defines the block name
  57648. */
  57649. constructor(name: string);
  57650. /**
  57651. * Gets the current class name
  57652. * @returns the class name
  57653. */
  57654. getClassName(): string;
  57655. /**
  57656. * Gets the world normal input component
  57657. */
  57658. readonly worldNormal: NodeMaterialConnectionPoint;
  57659. /**
  57660. * Gets the view direction input component
  57661. */
  57662. readonly viewDirection: NodeMaterialConnectionPoint;
  57663. /**
  57664. * Gets the bias input component
  57665. */
  57666. readonly bias: NodeMaterialConnectionPoint;
  57667. /**
  57668. * Gets the camera (or eye) position component
  57669. */
  57670. readonly power: NodeMaterialConnectionPoint;
  57671. /**
  57672. * Gets the fresnel output component
  57673. */
  57674. readonly fresnel: NodeMaterialConnectionPoint;
  57675. autoConfigure(material: NodeMaterial): void;
  57676. protected _buildBlock(state: NodeMaterialBuildState): this;
  57677. }
  57678. }
  57679. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57683. /**
  57684. * Block used to get the max of 2 values
  57685. */
  57686. export class MaxBlock extends NodeMaterialBlock {
  57687. /**
  57688. * Creates a new MaxBlock
  57689. * @param name defines the block name
  57690. */
  57691. constructor(name: string);
  57692. /**
  57693. * Gets the current class name
  57694. * @returns the class name
  57695. */
  57696. getClassName(): string;
  57697. /**
  57698. * Gets the left operand input component
  57699. */
  57700. readonly left: NodeMaterialConnectionPoint;
  57701. /**
  57702. * Gets the right operand input component
  57703. */
  57704. readonly right: NodeMaterialConnectionPoint;
  57705. /**
  57706. * Gets the output component
  57707. */
  57708. readonly output: NodeMaterialConnectionPoint;
  57709. protected _buildBlock(state: NodeMaterialBuildState): this;
  57710. }
  57711. }
  57712. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57716. /**
  57717. * Block used to get the min of 2 values
  57718. */
  57719. export class MinBlock extends NodeMaterialBlock {
  57720. /**
  57721. * Creates a new MinBlock
  57722. * @param name defines the block name
  57723. */
  57724. constructor(name: string);
  57725. /**
  57726. * Gets the current class name
  57727. * @returns the class name
  57728. */
  57729. getClassName(): string;
  57730. /**
  57731. * Gets the left operand input component
  57732. */
  57733. readonly left: NodeMaterialConnectionPoint;
  57734. /**
  57735. * Gets the right operand input component
  57736. */
  57737. readonly right: NodeMaterialConnectionPoint;
  57738. /**
  57739. * Gets the output component
  57740. */
  57741. readonly output: NodeMaterialConnectionPoint;
  57742. protected _buildBlock(state: NodeMaterialBuildState): this;
  57743. }
  57744. }
  57745. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57749. /**
  57750. * Block used to get the distance between 2 values
  57751. */
  57752. export class DistanceBlock extends NodeMaterialBlock {
  57753. /**
  57754. * Creates a new DistanceBlock
  57755. * @param name defines the block name
  57756. */
  57757. constructor(name: string);
  57758. /**
  57759. * Gets the current class name
  57760. * @returns the class name
  57761. */
  57762. getClassName(): string;
  57763. /**
  57764. * Gets the left operand input component
  57765. */
  57766. readonly left: NodeMaterialConnectionPoint;
  57767. /**
  57768. * Gets the right operand input component
  57769. */
  57770. readonly right: NodeMaterialConnectionPoint;
  57771. /**
  57772. * Gets the output component
  57773. */
  57774. readonly output: NodeMaterialConnectionPoint;
  57775. protected _buildBlock(state: NodeMaterialBuildState): this;
  57776. }
  57777. }
  57778. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57782. /**
  57783. * Block used to get the length of a vector
  57784. */
  57785. export class LengthBlock extends NodeMaterialBlock {
  57786. /**
  57787. * Creates a new LengthBlock
  57788. * @param name defines the block name
  57789. */
  57790. constructor(name: string);
  57791. /**
  57792. * Gets the current class name
  57793. * @returns the class name
  57794. */
  57795. getClassName(): string;
  57796. /**
  57797. * Gets the value input component
  57798. */
  57799. readonly value: NodeMaterialConnectionPoint;
  57800. /**
  57801. * Gets the output component
  57802. */
  57803. readonly output: NodeMaterialConnectionPoint;
  57804. protected _buildBlock(state: NodeMaterialBuildState): this;
  57805. }
  57806. }
  57807. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57811. /**
  57812. * Block used to get negative version of a value (i.e. x * -1)
  57813. */
  57814. export class NegateBlock extends NodeMaterialBlock {
  57815. /**
  57816. * Creates a new NegateBlock
  57817. * @param name defines the block name
  57818. */
  57819. constructor(name: string);
  57820. /**
  57821. * Gets the current class name
  57822. * @returns the class name
  57823. */
  57824. getClassName(): string;
  57825. /**
  57826. * Gets the value input component
  57827. */
  57828. readonly value: NodeMaterialConnectionPoint;
  57829. /**
  57830. * Gets the output component
  57831. */
  57832. readonly output: NodeMaterialConnectionPoint;
  57833. protected _buildBlock(state: NodeMaterialBuildState): this;
  57834. }
  57835. }
  57836. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57840. /**
  57841. * Block used to get the value of the first parameter raised to the power of the second
  57842. */
  57843. export class PowBlock extends NodeMaterialBlock {
  57844. /**
  57845. * Creates a new PowBlock
  57846. * @param name defines the block name
  57847. */
  57848. constructor(name: string);
  57849. /**
  57850. * Gets the current class name
  57851. * @returns the class name
  57852. */
  57853. getClassName(): string;
  57854. /**
  57855. * Gets the value operand input component
  57856. */
  57857. readonly value: NodeMaterialConnectionPoint;
  57858. /**
  57859. * Gets the power operand input component
  57860. */
  57861. readonly power: NodeMaterialConnectionPoint;
  57862. /**
  57863. * Gets the output component
  57864. */
  57865. readonly output: NodeMaterialConnectionPoint;
  57866. protected _buildBlock(state: NodeMaterialBuildState): this;
  57867. }
  57868. }
  57869. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57874. /**
  57875. * Block used to get a random number
  57876. */
  57877. export class RandomNumberBlock extends NodeMaterialBlock {
  57878. /**
  57879. * Creates a new RandomNumberBlock
  57880. * @param name defines the block name
  57881. */
  57882. constructor(name: string);
  57883. /**
  57884. * Gets the current class name
  57885. * @returns the class name
  57886. */
  57887. getClassName(): string;
  57888. /**
  57889. * Gets the seed input component
  57890. */
  57891. readonly seed: NodeMaterialConnectionPoint;
  57892. /**
  57893. * Gets the output component
  57894. */
  57895. readonly output: NodeMaterialConnectionPoint;
  57896. protected _buildBlock(state: NodeMaterialBuildState): this;
  57897. }
  57898. }
  57899. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57903. /**
  57904. * Block used to compute arc tangent of 2 values
  57905. */
  57906. export class ArcTan2Block extends NodeMaterialBlock {
  57907. /**
  57908. * Creates a new ArcTan2Block
  57909. * @param name defines the block name
  57910. */
  57911. constructor(name: string);
  57912. /**
  57913. * Gets the current class name
  57914. * @returns the class name
  57915. */
  57916. getClassName(): string;
  57917. /**
  57918. * Gets the x operand input component
  57919. */
  57920. readonly x: NodeMaterialConnectionPoint;
  57921. /**
  57922. * Gets the y operand input component
  57923. */
  57924. readonly y: NodeMaterialConnectionPoint;
  57925. /**
  57926. * Gets the output component
  57927. */
  57928. readonly output: NodeMaterialConnectionPoint;
  57929. protected _buildBlock(state: NodeMaterialBuildState): this;
  57930. }
  57931. }
  57932. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  57933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57936. /**
  57937. * Block used to smooth step a value
  57938. */
  57939. export class SmoothStepBlock extends NodeMaterialBlock {
  57940. /**
  57941. * Creates a new SmoothStepBlock
  57942. * @param name defines the block name
  57943. */
  57944. constructor(name: string);
  57945. /**
  57946. * Gets the current class name
  57947. * @returns the class name
  57948. */
  57949. getClassName(): string;
  57950. /**
  57951. * Gets the value operand input component
  57952. */
  57953. readonly value: NodeMaterialConnectionPoint;
  57954. /**
  57955. * Gets the first edge operand input component
  57956. */
  57957. readonly edge0: NodeMaterialConnectionPoint;
  57958. /**
  57959. * Gets the second edge operand input component
  57960. */
  57961. readonly edge1: NodeMaterialConnectionPoint;
  57962. /**
  57963. * Gets the output component
  57964. */
  57965. readonly output: NodeMaterialConnectionPoint;
  57966. protected _buildBlock(state: NodeMaterialBuildState): this;
  57967. }
  57968. }
  57969. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  57970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57973. /**
  57974. * Block used to get the reciprocal (1 / x) of a value
  57975. */
  57976. export class ReciprocalBlock extends NodeMaterialBlock {
  57977. /**
  57978. * Creates a new ReciprocalBlock
  57979. * @param name defines the block name
  57980. */
  57981. constructor(name: string);
  57982. /**
  57983. * Gets the current class name
  57984. * @returns the class name
  57985. */
  57986. getClassName(): string;
  57987. /**
  57988. * Gets the input component
  57989. */
  57990. readonly input: NodeMaterialConnectionPoint;
  57991. /**
  57992. * Gets the output component
  57993. */
  57994. readonly output: NodeMaterialConnectionPoint;
  57995. protected _buildBlock(state: NodeMaterialBuildState): this;
  57996. }
  57997. }
  57998. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  57999. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58002. /**
  58003. * Block used to replace a color by another one
  58004. */
  58005. export class ReplaceColorBlock extends NodeMaterialBlock {
  58006. /**
  58007. * Creates a new ReplaceColorBlock
  58008. * @param name defines the block name
  58009. */
  58010. constructor(name: string);
  58011. /**
  58012. * Gets the current class name
  58013. * @returns the class name
  58014. */
  58015. getClassName(): string;
  58016. /**
  58017. * Gets the value input component
  58018. */
  58019. readonly value: NodeMaterialConnectionPoint;
  58020. /**
  58021. * Gets the reference input component
  58022. */
  58023. readonly reference: NodeMaterialConnectionPoint;
  58024. /**
  58025. * Gets the distance input component
  58026. */
  58027. readonly distance: NodeMaterialConnectionPoint;
  58028. /**
  58029. * Gets the replacement input component
  58030. */
  58031. readonly replacement: NodeMaterialConnectionPoint;
  58032. /**
  58033. * Gets the output component
  58034. */
  58035. readonly output: NodeMaterialConnectionPoint;
  58036. protected _buildBlock(state: NodeMaterialBuildState): this;
  58037. }
  58038. }
  58039. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58042. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58043. /**
  58044. * Block used to posterize a value
  58045. * @see https://en.wikipedia.org/wiki/Posterization
  58046. */
  58047. export class PosterizeBlock extends NodeMaterialBlock {
  58048. /**
  58049. * Creates a new PosterizeBlock
  58050. * @param name defines the block name
  58051. */
  58052. constructor(name: string);
  58053. /**
  58054. * Gets the current class name
  58055. * @returns the class name
  58056. */
  58057. getClassName(): string;
  58058. /**
  58059. * Gets the value input component
  58060. */
  58061. readonly value: NodeMaterialConnectionPoint;
  58062. /**
  58063. * Gets the steps input component
  58064. */
  58065. readonly steps: NodeMaterialConnectionPoint;
  58066. /**
  58067. * Gets the output component
  58068. */
  58069. readonly output: NodeMaterialConnectionPoint;
  58070. protected _buildBlock(state: NodeMaterialBuildState): this;
  58071. }
  58072. }
  58073. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58077. import { Scene } from "babylonjs/scene";
  58078. /**
  58079. * Operations supported by the Wave block
  58080. */
  58081. export enum WaveBlockKind {
  58082. /** SawTooth */
  58083. SawTooth = 0,
  58084. /** Square */
  58085. Square = 1,
  58086. /** Triangle */
  58087. Triangle = 2
  58088. }
  58089. /**
  58090. * Block used to apply wave operation to floats
  58091. */
  58092. export class WaveBlock extends NodeMaterialBlock {
  58093. /**
  58094. * Gets or sets the kibnd of wave to be applied by the block
  58095. */
  58096. kind: WaveBlockKind;
  58097. /**
  58098. * Creates a new WaveBlock
  58099. * @param name defines the block name
  58100. */
  58101. constructor(name: string);
  58102. /**
  58103. * Gets the current class name
  58104. * @returns the class name
  58105. */
  58106. getClassName(): string;
  58107. /**
  58108. * Gets the input component
  58109. */
  58110. readonly input: NodeMaterialConnectionPoint;
  58111. /**
  58112. * Gets the output component
  58113. */
  58114. readonly output: NodeMaterialConnectionPoint;
  58115. protected _buildBlock(state: NodeMaterialBuildState): this;
  58116. serialize(): any;
  58117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58118. }
  58119. }
  58120. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58124. import { Color3 } from "babylonjs/Maths/math.color";
  58125. import { Scene } from "babylonjs/scene";
  58126. /**
  58127. * Class used to store a color step for the GradientBlock
  58128. */
  58129. export class GradientBlockColorStep {
  58130. /**
  58131. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58132. */
  58133. step: number;
  58134. /**
  58135. * Gets or sets the color associated with this step
  58136. */
  58137. color: Color3;
  58138. /**
  58139. * Creates a new GradientBlockColorStep
  58140. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58141. * @param color defines the color associated with this step
  58142. */
  58143. constructor(
  58144. /**
  58145. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58146. */
  58147. step: number,
  58148. /**
  58149. * Gets or sets the color associated with this step
  58150. */
  58151. color: Color3);
  58152. }
  58153. /**
  58154. * Block used to return a color from a gradient based on an input value between 0 and 1
  58155. */
  58156. export class GradientBlock extends NodeMaterialBlock {
  58157. colorSteps: GradientBlockColorStep[];
  58158. /**
  58159. * Creates a new GradientBlock
  58160. * @param name defines the block name
  58161. */
  58162. constructor(name: string);
  58163. /**
  58164. * Gets the current class name
  58165. * @returns the class name
  58166. */
  58167. getClassName(): string;
  58168. /**
  58169. * Gets the gradient input component
  58170. */
  58171. readonly gradient: NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the output component
  58174. */
  58175. readonly output: NodeMaterialConnectionPoint;
  58176. private _writeColorConstant;
  58177. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58178. serialize(): any;
  58179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58180. protected _dumpPropertiesCode(): string;
  58181. }
  58182. }
  58183. declare module "babylonjs/Materials/Node/Blocks/index" {
  58184. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58185. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58186. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58187. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58188. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58189. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58190. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58191. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58192. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58193. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58194. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58195. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58196. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58197. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58198. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58199. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58200. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58201. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58202. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58203. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58204. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58205. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58206. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58207. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58208. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58209. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58210. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58211. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58212. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58213. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58214. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58215. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58216. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58217. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58218. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58219. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58220. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58221. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58222. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58223. }
  58224. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58225. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58226. }
  58227. declare module "babylonjs/Materials/Node/index" {
  58228. export * from "babylonjs/Materials/Node/Enums/index";
  58229. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58230. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58231. export * from "babylonjs/Materials/Node/nodeMaterial";
  58232. export * from "babylonjs/Materials/Node/Blocks/index";
  58233. export * from "babylonjs/Materials/Node/Optimizers/index";
  58234. }
  58235. declare module "babylonjs/Materials/effectRenderer" {
  58236. import { Nullable } from "babylonjs/types";
  58237. import { Texture } from "babylonjs/Materials/Textures/texture";
  58238. import { Engine } from "babylonjs/Engines/engine";
  58239. import { Viewport } from "babylonjs/Maths/math.viewport";
  58240. import { Observable } from "babylonjs/Misc/observable";
  58241. import { Effect } from "babylonjs/Materials/effect";
  58242. import "babylonjs/Shaders/postprocess.vertex";
  58243. /**
  58244. * Effect Render Options
  58245. */
  58246. export interface IEffectRendererOptions {
  58247. /**
  58248. * Defines the vertices positions.
  58249. */
  58250. positions?: number[];
  58251. /**
  58252. * Defines the indices.
  58253. */
  58254. indices?: number[];
  58255. }
  58256. /**
  58257. * Helper class to render one or more effects
  58258. */
  58259. export class EffectRenderer {
  58260. private engine;
  58261. private static _DefaultOptions;
  58262. private _vertexBuffers;
  58263. private _indexBuffer;
  58264. private _ringBufferIndex;
  58265. private _ringScreenBuffer;
  58266. private _fullscreenViewport;
  58267. private _getNextFrameBuffer;
  58268. /**
  58269. * Creates an effect renderer
  58270. * @param engine the engine to use for rendering
  58271. * @param options defines the options of the effect renderer
  58272. */
  58273. constructor(engine: Engine, options?: IEffectRendererOptions);
  58274. /**
  58275. * Sets the current viewport in normalized coordinates 0-1
  58276. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58277. */
  58278. setViewport(viewport?: Viewport): void;
  58279. /**
  58280. * Binds the embedded attributes buffer to the effect.
  58281. * @param effect Defines the effect to bind the attributes for
  58282. */
  58283. bindBuffers(effect: Effect): void;
  58284. /**
  58285. * Sets the current effect wrapper to use during draw.
  58286. * The effect needs to be ready before calling this api.
  58287. * This also sets the default full screen position attribute.
  58288. * @param effectWrapper Defines the effect to draw with
  58289. */
  58290. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58291. /**
  58292. * Draws a full screen quad.
  58293. */
  58294. draw(): void;
  58295. /**
  58296. * renders one or more effects to a specified texture
  58297. * @param effectWrappers list of effects to renderer
  58298. * @param outputTexture texture to draw to, if null it will render to the screen
  58299. */
  58300. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58301. /**
  58302. * Disposes of the effect renderer
  58303. */
  58304. dispose(): void;
  58305. }
  58306. /**
  58307. * Options to create an EffectWrapper
  58308. */
  58309. interface EffectWrapperCreationOptions {
  58310. /**
  58311. * Engine to use to create the effect
  58312. */
  58313. engine: Engine;
  58314. /**
  58315. * Fragment shader for the effect
  58316. */
  58317. fragmentShader: string;
  58318. /**
  58319. * Vertex shader for the effect
  58320. */
  58321. vertexShader?: string;
  58322. /**
  58323. * Attributes to use in the shader
  58324. */
  58325. attributeNames?: Array<string>;
  58326. /**
  58327. * Uniforms to use in the shader
  58328. */
  58329. uniformNames?: Array<string>;
  58330. /**
  58331. * Texture sampler names to use in the shader
  58332. */
  58333. samplerNames?: Array<string>;
  58334. /**
  58335. * The friendly name of the effect displayed in Spector.
  58336. */
  58337. name?: string;
  58338. }
  58339. /**
  58340. * Wraps an effect to be used for rendering
  58341. */
  58342. export class EffectWrapper {
  58343. /**
  58344. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58345. */
  58346. onApplyObservable: Observable<{}>;
  58347. /**
  58348. * The underlying effect
  58349. */
  58350. effect: Effect;
  58351. /**
  58352. * Creates an effect to be renderer
  58353. * @param creationOptions options to create the effect
  58354. */
  58355. constructor(creationOptions: EffectWrapperCreationOptions);
  58356. /**
  58357. * Disposes of the effect wrapper
  58358. */
  58359. dispose(): void;
  58360. }
  58361. }
  58362. declare module "babylonjs/Materials/index" {
  58363. export * from "babylonjs/Materials/Background/index";
  58364. export * from "babylonjs/Materials/colorCurves";
  58365. export * from "babylonjs/Materials/iEffectFallbacks";
  58366. export * from "babylonjs/Materials/effectFallbacks";
  58367. export * from "babylonjs/Materials/effect";
  58368. export * from "babylonjs/Materials/fresnelParameters";
  58369. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58370. export * from "babylonjs/Materials/material";
  58371. export * from "babylonjs/Materials/materialDefines";
  58372. export * from "babylonjs/Materials/materialHelper";
  58373. export * from "babylonjs/Materials/multiMaterial";
  58374. export * from "babylonjs/Materials/PBR/index";
  58375. export * from "babylonjs/Materials/pushMaterial";
  58376. export * from "babylonjs/Materials/shaderMaterial";
  58377. export * from "babylonjs/Materials/standardMaterial";
  58378. export * from "babylonjs/Materials/Textures/index";
  58379. export * from "babylonjs/Materials/uniformBuffer";
  58380. export * from "babylonjs/Materials/materialFlags";
  58381. export * from "babylonjs/Materials/Node/index";
  58382. export * from "babylonjs/Materials/effectRenderer";
  58383. }
  58384. declare module "babylonjs/Maths/index" {
  58385. export * from "babylonjs/Maths/math.scalar";
  58386. export * from "babylonjs/Maths/math";
  58387. export * from "babylonjs/Maths/sphericalPolynomial";
  58388. }
  58389. declare module "babylonjs/Misc/workerPool" {
  58390. import { IDisposable } from "babylonjs/scene";
  58391. /**
  58392. * Helper class to push actions to a pool of workers.
  58393. */
  58394. export class WorkerPool implements IDisposable {
  58395. private _workerInfos;
  58396. private _pendingActions;
  58397. /**
  58398. * Constructor
  58399. * @param workers Array of workers to use for actions
  58400. */
  58401. constructor(workers: Array<Worker>);
  58402. /**
  58403. * Terminates all workers and clears any pending actions.
  58404. */
  58405. dispose(): void;
  58406. /**
  58407. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58408. * pended until a worker has completed its action.
  58409. * @param action The action to perform. Call onComplete when the action is complete.
  58410. */
  58411. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58412. private _execute;
  58413. }
  58414. }
  58415. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58416. import { IDisposable } from "babylonjs/scene";
  58417. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58418. /**
  58419. * Configuration for Draco compression
  58420. */
  58421. export interface IDracoCompressionConfiguration {
  58422. /**
  58423. * Configuration for the decoder.
  58424. */
  58425. decoder: {
  58426. /**
  58427. * The url to the WebAssembly module.
  58428. */
  58429. wasmUrl?: string;
  58430. /**
  58431. * The url to the WebAssembly binary.
  58432. */
  58433. wasmBinaryUrl?: string;
  58434. /**
  58435. * The url to the fallback JavaScript module.
  58436. */
  58437. fallbackUrl?: string;
  58438. };
  58439. }
  58440. /**
  58441. * Draco compression (https://google.github.io/draco/)
  58442. *
  58443. * This class wraps the Draco module.
  58444. *
  58445. * **Encoder**
  58446. *
  58447. * The encoder is not currently implemented.
  58448. *
  58449. * **Decoder**
  58450. *
  58451. * 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.
  58452. *
  58453. * To update the configuration, use the following code:
  58454. * ```javascript
  58455. * DracoCompression.Configuration = {
  58456. * decoder: {
  58457. * wasmUrl: "<url to the WebAssembly library>",
  58458. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58459. * fallbackUrl: "<url to the fallback JavaScript library>",
  58460. * }
  58461. * };
  58462. * ```
  58463. *
  58464. * 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.
  58465. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58466. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58467. *
  58468. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58469. * ```javascript
  58470. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58471. * ```
  58472. *
  58473. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58474. */
  58475. export class DracoCompression implements IDisposable {
  58476. private _workerPoolPromise?;
  58477. private _decoderModulePromise?;
  58478. /**
  58479. * The configuration. Defaults to the following urls:
  58480. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58481. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58482. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58483. */
  58484. static Configuration: IDracoCompressionConfiguration;
  58485. /**
  58486. * Returns true if the decoder configuration is available.
  58487. */
  58488. static readonly DecoderAvailable: boolean;
  58489. /**
  58490. * Default number of workers to create when creating the draco compression object.
  58491. */
  58492. static DefaultNumWorkers: number;
  58493. private static GetDefaultNumWorkers;
  58494. private static _Default;
  58495. /**
  58496. * Default instance for the draco compression object.
  58497. */
  58498. static readonly Default: DracoCompression;
  58499. /**
  58500. * Constructor
  58501. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58502. */
  58503. constructor(numWorkers?: number);
  58504. /**
  58505. * Stop all async operations and release resources.
  58506. */
  58507. dispose(): void;
  58508. /**
  58509. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58510. * @returns a promise that resolves when ready
  58511. */
  58512. whenReadyAsync(): Promise<void>;
  58513. /**
  58514. * Decode Draco compressed mesh data to vertex data.
  58515. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58516. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58517. * @returns A promise that resolves with the decoded vertex data
  58518. */
  58519. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58520. [kind: string]: number;
  58521. }): Promise<VertexData>;
  58522. }
  58523. }
  58524. declare module "babylonjs/Meshes/Compression/index" {
  58525. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58526. }
  58527. declare module "babylonjs/Meshes/csg" {
  58528. import { Nullable } from "babylonjs/types";
  58529. import { Scene } from "babylonjs/scene";
  58530. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58531. import { Mesh } from "babylonjs/Meshes/mesh";
  58532. import { Material } from "babylonjs/Materials/material";
  58533. /**
  58534. * Class for building Constructive Solid Geometry
  58535. */
  58536. export class CSG {
  58537. private polygons;
  58538. /**
  58539. * The world matrix
  58540. */
  58541. matrix: Matrix;
  58542. /**
  58543. * Stores the position
  58544. */
  58545. position: Vector3;
  58546. /**
  58547. * Stores the rotation
  58548. */
  58549. rotation: Vector3;
  58550. /**
  58551. * Stores the rotation quaternion
  58552. */
  58553. rotationQuaternion: Nullable<Quaternion>;
  58554. /**
  58555. * Stores the scaling vector
  58556. */
  58557. scaling: Vector3;
  58558. /**
  58559. * Convert the Mesh to CSG
  58560. * @param mesh The Mesh to convert to CSG
  58561. * @returns A new CSG from the Mesh
  58562. */
  58563. static FromMesh(mesh: Mesh): CSG;
  58564. /**
  58565. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58566. * @param polygons Polygons used to construct a CSG solid
  58567. */
  58568. private static FromPolygons;
  58569. /**
  58570. * Clones, or makes a deep copy, of the CSG
  58571. * @returns A new CSG
  58572. */
  58573. clone(): CSG;
  58574. /**
  58575. * Unions this CSG with another CSG
  58576. * @param csg The CSG to union against this CSG
  58577. * @returns The unioned CSG
  58578. */
  58579. union(csg: CSG): CSG;
  58580. /**
  58581. * Unions this CSG with another CSG in place
  58582. * @param csg The CSG to union against this CSG
  58583. */
  58584. unionInPlace(csg: CSG): void;
  58585. /**
  58586. * Subtracts this CSG with another CSG
  58587. * @param csg The CSG to subtract against this CSG
  58588. * @returns A new CSG
  58589. */
  58590. subtract(csg: CSG): CSG;
  58591. /**
  58592. * Subtracts this CSG with another CSG in place
  58593. * @param csg The CSG to subtact against this CSG
  58594. */
  58595. subtractInPlace(csg: CSG): void;
  58596. /**
  58597. * Intersect this CSG with another CSG
  58598. * @param csg The CSG to intersect against this CSG
  58599. * @returns A new CSG
  58600. */
  58601. intersect(csg: CSG): CSG;
  58602. /**
  58603. * Intersects this CSG with another CSG in place
  58604. * @param csg The CSG to intersect against this CSG
  58605. */
  58606. intersectInPlace(csg: CSG): void;
  58607. /**
  58608. * Return a new CSG solid with solid and empty space switched. This solid is
  58609. * not modified.
  58610. * @returns A new CSG solid with solid and empty space switched
  58611. */
  58612. inverse(): CSG;
  58613. /**
  58614. * Inverses the CSG in place
  58615. */
  58616. inverseInPlace(): void;
  58617. /**
  58618. * This is used to keep meshes transformations so they can be restored
  58619. * when we build back a Babylon Mesh
  58620. * NB : All CSG operations are performed in world coordinates
  58621. * @param csg The CSG to copy the transform attributes from
  58622. * @returns This CSG
  58623. */
  58624. copyTransformAttributes(csg: CSG): CSG;
  58625. /**
  58626. * Build Raw mesh from CSG
  58627. * Coordinates here are in world space
  58628. * @param name The name of the mesh geometry
  58629. * @param scene The Scene
  58630. * @param keepSubMeshes Specifies if the submeshes should be kept
  58631. * @returns A new Mesh
  58632. */
  58633. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58634. /**
  58635. * Build Mesh from CSG taking material and transforms into account
  58636. * @param name The name of the Mesh
  58637. * @param material The material of the Mesh
  58638. * @param scene The Scene
  58639. * @param keepSubMeshes Specifies if submeshes should be kept
  58640. * @returns The new Mesh
  58641. */
  58642. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58643. }
  58644. }
  58645. declare module "babylonjs/Meshes/trailMesh" {
  58646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58647. import { Mesh } from "babylonjs/Meshes/mesh";
  58648. import { Scene } from "babylonjs/scene";
  58649. /**
  58650. * Class used to create a trail following a mesh
  58651. */
  58652. export class TrailMesh extends Mesh {
  58653. private _generator;
  58654. private _autoStart;
  58655. private _running;
  58656. private _diameter;
  58657. private _length;
  58658. private _sectionPolygonPointsCount;
  58659. private _sectionVectors;
  58660. private _sectionNormalVectors;
  58661. private _beforeRenderObserver;
  58662. /**
  58663. * @constructor
  58664. * @param name The value used by scene.getMeshByName() to do a lookup.
  58665. * @param generator The mesh to generate a trail.
  58666. * @param scene The scene to add this mesh to.
  58667. * @param diameter Diameter of trailing mesh. Default is 1.
  58668. * @param length Length of trailing mesh. Default is 60.
  58669. * @param autoStart Automatically start trailing mesh. Default true.
  58670. */
  58671. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58672. /**
  58673. * "TrailMesh"
  58674. * @returns "TrailMesh"
  58675. */
  58676. getClassName(): string;
  58677. private _createMesh;
  58678. /**
  58679. * Start trailing mesh.
  58680. */
  58681. start(): void;
  58682. /**
  58683. * Stop trailing mesh.
  58684. */
  58685. stop(): void;
  58686. /**
  58687. * Update trailing mesh geometry.
  58688. */
  58689. update(): void;
  58690. /**
  58691. * Returns a new TrailMesh object.
  58692. * @param name is a string, the name given to the new mesh
  58693. * @param newGenerator use new generator object for cloned trail mesh
  58694. * @returns a new mesh
  58695. */
  58696. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58697. /**
  58698. * Serializes this trail mesh
  58699. * @param serializationObject object to write serialization to
  58700. */
  58701. serialize(serializationObject: any): void;
  58702. /**
  58703. * Parses a serialized trail mesh
  58704. * @param parsedMesh the serialized mesh
  58705. * @param scene the scene to create the trail mesh in
  58706. * @returns the created trail mesh
  58707. */
  58708. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58709. }
  58710. }
  58711. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58712. import { Nullable } from "babylonjs/types";
  58713. import { Scene } from "babylonjs/scene";
  58714. import { Vector4 } from "babylonjs/Maths/math.vector";
  58715. import { Color4 } from "babylonjs/Maths/math.color";
  58716. import { Mesh } from "babylonjs/Meshes/mesh";
  58717. /**
  58718. * Class containing static functions to help procedurally build meshes
  58719. */
  58720. export class TiledBoxBuilder {
  58721. /**
  58722. * Creates a box mesh
  58723. * 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)
  58724. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58728. * @param name defines the name of the mesh
  58729. * @param options defines the options used to create the mesh
  58730. * @param scene defines the hosting scene
  58731. * @returns the box mesh
  58732. */
  58733. static CreateTiledBox(name: string, options: {
  58734. pattern?: number;
  58735. width?: number;
  58736. height?: number;
  58737. depth?: number;
  58738. tileSize?: number;
  58739. tileWidth?: number;
  58740. tileHeight?: number;
  58741. alignHorizontal?: number;
  58742. alignVertical?: number;
  58743. faceUV?: Vector4[];
  58744. faceColors?: Color4[];
  58745. sideOrientation?: number;
  58746. updatable?: boolean;
  58747. }, scene?: Nullable<Scene>): Mesh;
  58748. }
  58749. }
  58750. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58751. import { Vector4 } from "babylonjs/Maths/math.vector";
  58752. import { Mesh } from "babylonjs/Meshes/mesh";
  58753. /**
  58754. * Class containing static functions to help procedurally build meshes
  58755. */
  58756. export class TorusKnotBuilder {
  58757. /**
  58758. * Creates a torus knot mesh
  58759. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58760. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58761. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58762. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58766. * @param name defines the name of the mesh
  58767. * @param options defines the options used to create the mesh
  58768. * @param scene defines the hosting scene
  58769. * @returns the torus knot mesh
  58770. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58771. */
  58772. static CreateTorusKnot(name: string, options: {
  58773. radius?: number;
  58774. tube?: number;
  58775. radialSegments?: number;
  58776. tubularSegments?: number;
  58777. p?: number;
  58778. q?: number;
  58779. updatable?: boolean;
  58780. sideOrientation?: number;
  58781. frontUVs?: Vector4;
  58782. backUVs?: Vector4;
  58783. }, scene: any): Mesh;
  58784. }
  58785. }
  58786. declare module "babylonjs/Meshes/polygonMesh" {
  58787. import { Scene } from "babylonjs/scene";
  58788. import { Vector2 } from "babylonjs/Maths/math.vector";
  58789. import { Mesh } from "babylonjs/Meshes/mesh";
  58790. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58791. import { Path2 } from "babylonjs/Maths/math.path";
  58792. /**
  58793. * Polygon
  58794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58795. */
  58796. export class Polygon {
  58797. /**
  58798. * Creates a rectangle
  58799. * @param xmin bottom X coord
  58800. * @param ymin bottom Y coord
  58801. * @param xmax top X coord
  58802. * @param ymax top Y coord
  58803. * @returns points that make the resulting rectation
  58804. */
  58805. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58806. /**
  58807. * Creates a circle
  58808. * @param radius radius of circle
  58809. * @param cx scale in x
  58810. * @param cy scale in y
  58811. * @param numberOfSides number of sides that make up the circle
  58812. * @returns points that make the resulting circle
  58813. */
  58814. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58815. /**
  58816. * Creates a polygon from input string
  58817. * @param input Input polygon data
  58818. * @returns the parsed points
  58819. */
  58820. static Parse(input: string): Vector2[];
  58821. /**
  58822. * Starts building a polygon from x and y coordinates
  58823. * @param x x coordinate
  58824. * @param y y coordinate
  58825. * @returns the started path2
  58826. */
  58827. static StartingAt(x: number, y: number): Path2;
  58828. }
  58829. /**
  58830. * Builds a polygon
  58831. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58832. */
  58833. export class PolygonMeshBuilder {
  58834. private _points;
  58835. private _outlinepoints;
  58836. private _holes;
  58837. private _name;
  58838. private _scene;
  58839. private _epoints;
  58840. private _eholes;
  58841. private _addToepoint;
  58842. /**
  58843. * Babylon reference to the earcut plugin.
  58844. */
  58845. bjsEarcut: any;
  58846. /**
  58847. * Creates a PolygonMeshBuilder
  58848. * @param name name of the builder
  58849. * @param contours Path of the polygon
  58850. * @param scene scene to add to when creating the mesh
  58851. * @param earcutInjection can be used to inject your own earcut reference
  58852. */
  58853. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58854. /**
  58855. * Adds a whole within the polygon
  58856. * @param hole Array of points defining the hole
  58857. * @returns this
  58858. */
  58859. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58860. /**
  58861. * Creates the polygon
  58862. * @param updatable If the mesh should be updatable
  58863. * @param depth The depth of the mesh created
  58864. * @returns the created mesh
  58865. */
  58866. build(updatable?: boolean, depth?: number): Mesh;
  58867. /**
  58868. * Creates the polygon
  58869. * @param depth The depth of the mesh created
  58870. * @returns the created VertexData
  58871. */
  58872. buildVertexData(depth?: number): VertexData;
  58873. /**
  58874. * Adds a side to the polygon
  58875. * @param positions points that make the polygon
  58876. * @param normals normals of the polygon
  58877. * @param uvs uvs of the polygon
  58878. * @param indices indices of the polygon
  58879. * @param bounds bounds of the polygon
  58880. * @param points points of the polygon
  58881. * @param depth depth of the polygon
  58882. * @param flip flip of the polygon
  58883. */
  58884. private addSide;
  58885. }
  58886. }
  58887. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58888. import { Scene } from "babylonjs/scene";
  58889. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58890. import { Color4 } from "babylonjs/Maths/math.color";
  58891. import { Mesh } from "babylonjs/Meshes/mesh";
  58892. import { Nullable } from "babylonjs/types";
  58893. /**
  58894. * Class containing static functions to help procedurally build meshes
  58895. */
  58896. export class PolygonBuilder {
  58897. /**
  58898. * Creates a polygon mesh
  58899. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58900. * * 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
  58901. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58904. * * Remember you can only change the shape positions, not their number when updating a polygon
  58905. * @param name defines the name of the mesh
  58906. * @param options defines the options used to create the mesh
  58907. * @param scene defines the hosting scene
  58908. * @param earcutInjection can be used to inject your own earcut reference
  58909. * @returns the polygon mesh
  58910. */
  58911. static CreatePolygon(name: string, options: {
  58912. shape: Vector3[];
  58913. holes?: Vector3[][];
  58914. depth?: number;
  58915. faceUV?: Vector4[];
  58916. faceColors?: Color4[];
  58917. updatable?: boolean;
  58918. sideOrientation?: number;
  58919. frontUVs?: Vector4;
  58920. backUVs?: Vector4;
  58921. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58922. /**
  58923. * Creates an extruded polygon mesh, with depth in the Y direction.
  58924. * * 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)
  58925. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58926. * @param name defines the name of the mesh
  58927. * @param options defines the options used to create the mesh
  58928. * @param scene defines the hosting scene
  58929. * @param earcutInjection can be used to inject your own earcut reference
  58930. * @returns the polygon mesh
  58931. */
  58932. static ExtrudePolygon(name: string, options: {
  58933. shape: Vector3[];
  58934. holes?: Vector3[][];
  58935. depth?: number;
  58936. faceUV?: Vector4[];
  58937. faceColors?: Color4[];
  58938. updatable?: boolean;
  58939. sideOrientation?: number;
  58940. frontUVs?: Vector4;
  58941. backUVs?: Vector4;
  58942. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58943. }
  58944. }
  58945. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58946. import { Scene } from "babylonjs/scene";
  58947. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58948. import { Mesh } from "babylonjs/Meshes/mesh";
  58949. import { Nullable } from "babylonjs/types";
  58950. /**
  58951. * Class containing static functions to help procedurally build meshes
  58952. */
  58953. export class LatheBuilder {
  58954. /**
  58955. * Creates lathe mesh.
  58956. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58957. * * 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
  58958. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58959. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58960. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58961. * * 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
  58962. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58963. * * 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
  58964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58968. * @param name defines the name of the mesh
  58969. * @param options defines the options used to create the mesh
  58970. * @param scene defines the hosting scene
  58971. * @returns the lathe mesh
  58972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58973. */
  58974. static CreateLathe(name: string, options: {
  58975. shape: Vector3[];
  58976. radius?: number;
  58977. tessellation?: number;
  58978. clip?: number;
  58979. arc?: number;
  58980. closed?: boolean;
  58981. updatable?: boolean;
  58982. sideOrientation?: number;
  58983. frontUVs?: Vector4;
  58984. backUVs?: Vector4;
  58985. cap?: number;
  58986. invertUV?: boolean;
  58987. }, scene?: Nullable<Scene>): Mesh;
  58988. }
  58989. }
  58990. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58991. import { Nullable } from "babylonjs/types";
  58992. import { Scene } from "babylonjs/scene";
  58993. import { Vector4 } from "babylonjs/Maths/math.vector";
  58994. import { Mesh } from "babylonjs/Meshes/mesh";
  58995. /**
  58996. * Class containing static functions to help procedurally build meshes
  58997. */
  58998. export class TiledPlaneBuilder {
  58999. /**
  59000. * Creates a tiled plane mesh
  59001. * * The parameter `pattern` will, depending on value, do nothing or
  59002. * * * flip (reflect about central vertical) alternate tiles across and up
  59003. * * * flip every tile on alternate rows
  59004. * * * rotate (180 degs) alternate tiles across and up
  59005. * * * rotate every tile on alternate rows
  59006. * * * flip and rotate alternate tiles across and up
  59007. * * * flip and rotate every tile on alternate rows
  59008. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59009. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59011. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59012. * * 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)
  59013. * * 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)
  59014. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59015. * @param name defines the name of the mesh
  59016. * @param options defines the options used to create the mesh
  59017. * @param scene defines the hosting scene
  59018. * @returns the box mesh
  59019. */
  59020. static CreateTiledPlane(name: string, options: {
  59021. pattern?: number;
  59022. tileSize?: number;
  59023. tileWidth?: number;
  59024. tileHeight?: number;
  59025. size?: number;
  59026. width?: number;
  59027. height?: number;
  59028. alignHorizontal?: number;
  59029. alignVertical?: number;
  59030. sideOrientation?: number;
  59031. frontUVs?: Vector4;
  59032. backUVs?: Vector4;
  59033. updatable?: boolean;
  59034. }, scene?: Nullable<Scene>): Mesh;
  59035. }
  59036. }
  59037. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59038. import { Nullable } from "babylonjs/types";
  59039. import { Scene } from "babylonjs/scene";
  59040. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59041. import { Mesh } from "babylonjs/Meshes/mesh";
  59042. /**
  59043. * Class containing static functions to help procedurally build meshes
  59044. */
  59045. export class TubeBuilder {
  59046. /**
  59047. * Creates a tube mesh.
  59048. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59049. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59050. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59051. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59052. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59053. * * 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)
  59054. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59055. * * 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
  59056. * * 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
  59057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59059. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59061. * @param name defines the name of the mesh
  59062. * @param options defines the options used to create the mesh
  59063. * @param scene defines the hosting scene
  59064. * @returns the tube mesh
  59065. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59066. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59067. */
  59068. static CreateTube(name: string, options: {
  59069. path: Vector3[];
  59070. radius?: number;
  59071. tessellation?: number;
  59072. radiusFunction?: {
  59073. (i: number, distance: number): number;
  59074. };
  59075. cap?: number;
  59076. arc?: number;
  59077. updatable?: boolean;
  59078. sideOrientation?: number;
  59079. frontUVs?: Vector4;
  59080. backUVs?: Vector4;
  59081. instance?: Mesh;
  59082. invertUV?: boolean;
  59083. }, scene?: Nullable<Scene>): Mesh;
  59084. }
  59085. }
  59086. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59087. import { Scene } from "babylonjs/scene";
  59088. import { Vector4 } from "babylonjs/Maths/math.vector";
  59089. import { Mesh } from "babylonjs/Meshes/mesh";
  59090. import { Nullable } from "babylonjs/types";
  59091. /**
  59092. * Class containing static functions to help procedurally build meshes
  59093. */
  59094. export class IcoSphereBuilder {
  59095. /**
  59096. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59097. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59098. * * 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`)
  59099. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59100. * * 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
  59101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59104. * @param name defines the name of the mesh
  59105. * @param options defines the options used to create the mesh
  59106. * @param scene defines the hosting scene
  59107. * @returns the icosahedron mesh
  59108. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59109. */
  59110. static CreateIcoSphere(name: string, options: {
  59111. radius?: number;
  59112. radiusX?: number;
  59113. radiusY?: number;
  59114. radiusZ?: number;
  59115. flat?: boolean;
  59116. subdivisions?: number;
  59117. sideOrientation?: number;
  59118. frontUVs?: Vector4;
  59119. backUVs?: Vector4;
  59120. updatable?: boolean;
  59121. }, scene?: Nullable<Scene>): Mesh;
  59122. }
  59123. }
  59124. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59125. import { Vector3 } from "babylonjs/Maths/math.vector";
  59126. import { Mesh } from "babylonjs/Meshes/mesh";
  59127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59128. /**
  59129. * Class containing static functions to help procedurally build meshes
  59130. */
  59131. export class DecalBuilder {
  59132. /**
  59133. * Creates a decal mesh.
  59134. * 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
  59135. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59136. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59137. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59138. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59139. * @param name defines the name of the mesh
  59140. * @param sourceMesh defines the mesh where the decal must be applied
  59141. * @param options defines the options used to create the mesh
  59142. * @param scene defines the hosting scene
  59143. * @returns the decal mesh
  59144. * @see https://doc.babylonjs.com/how_to/decals
  59145. */
  59146. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59147. position?: Vector3;
  59148. normal?: Vector3;
  59149. size?: Vector3;
  59150. angle?: number;
  59151. }): Mesh;
  59152. }
  59153. }
  59154. declare module "babylonjs/Meshes/meshBuilder" {
  59155. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59156. import { Nullable } from "babylonjs/types";
  59157. import { Scene } from "babylonjs/scene";
  59158. import { Mesh } from "babylonjs/Meshes/mesh";
  59159. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59160. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59162. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59163. import { Plane } from "babylonjs/Maths/math.plane";
  59164. /**
  59165. * Class containing static functions to help procedurally build meshes
  59166. */
  59167. export class MeshBuilder {
  59168. /**
  59169. * Creates a box mesh
  59170. * * The parameter `size` sets the size (float) of each box side (default 1)
  59171. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59172. * * 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)
  59173. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59177. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59178. * @param name defines the name of the mesh
  59179. * @param options defines the options used to create the mesh
  59180. * @param scene defines the hosting scene
  59181. * @returns the box mesh
  59182. */
  59183. static CreateBox(name: string, options: {
  59184. size?: number;
  59185. width?: number;
  59186. height?: number;
  59187. depth?: number;
  59188. faceUV?: Vector4[];
  59189. faceColors?: Color4[];
  59190. sideOrientation?: number;
  59191. frontUVs?: Vector4;
  59192. backUVs?: Vector4;
  59193. updatable?: boolean;
  59194. }, scene?: Nullable<Scene>): Mesh;
  59195. /**
  59196. * Creates a tiled box mesh
  59197. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59199. * @param name defines the name of the mesh
  59200. * @param options defines the options used to create the mesh
  59201. * @param scene defines the hosting scene
  59202. * @returns the tiled box mesh
  59203. */
  59204. static CreateTiledBox(name: string, options: {
  59205. pattern?: number;
  59206. size?: number;
  59207. width?: number;
  59208. height?: number;
  59209. depth: number;
  59210. tileSize?: number;
  59211. tileWidth?: number;
  59212. tileHeight?: number;
  59213. faceUV?: Vector4[];
  59214. faceColors?: Color4[];
  59215. alignHorizontal?: number;
  59216. alignVertical?: number;
  59217. sideOrientation?: number;
  59218. updatable?: boolean;
  59219. }, scene?: Nullable<Scene>): Mesh;
  59220. /**
  59221. * Creates a sphere mesh
  59222. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59223. * * 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`)
  59224. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59225. * * 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
  59226. * * 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)
  59227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59228. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59230. * @param name defines the name of the mesh
  59231. * @param options defines the options used to create the mesh
  59232. * @param scene defines the hosting scene
  59233. * @returns the sphere mesh
  59234. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59235. */
  59236. static CreateSphere(name: string, options: {
  59237. segments?: number;
  59238. diameter?: number;
  59239. diameterX?: number;
  59240. diameterY?: number;
  59241. diameterZ?: number;
  59242. arc?: number;
  59243. slice?: number;
  59244. sideOrientation?: number;
  59245. frontUVs?: Vector4;
  59246. backUVs?: Vector4;
  59247. updatable?: boolean;
  59248. }, scene?: Nullable<Scene>): Mesh;
  59249. /**
  59250. * Creates a plane polygonal mesh. By default, this is a disc
  59251. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59252. * * 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
  59253. * * 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
  59254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59257. * @param name defines the name of the mesh
  59258. * @param options defines the options used to create the mesh
  59259. * @param scene defines the hosting scene
  59260. * @returns the plane polygonal mesh
  59261. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59262. */
  59263. static CreateDisc(name: string, options: {
  59264. radius?: number;
  59265. tessellation?: number;
  59266. arc?: number;
  59267. updatable?: boolean;
  59268. sideOrientation?: number;
  59269. frontUVs?: Vector4;
  59270. backUVs?: Vector4;
  59271. }, scene?: Nullable<Scene>): Mesh;
  59272. /**
  59273. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59274. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59275. * * 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`)
  59276. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59277. * * 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
  59278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59281. * @param name defines the name of the mesh
  59282. * @param options defines the options used to create the mesh
  59283. * @param scene defines the hosting scene
  59284. * @returns the icosahedron mesh
  59285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59286. */
  59287. static CreateIcoSphere(name: string, options: {
  59288. radius?: number;
  59289. radiusX?: number;
  59290. radiusY?: number;
  59291. radiusZ?: number;
  59292. flat?: boolean;
  59293. subdivisions?: number;
  59294. sideOrientation?: number;
  59295. frontUVs?: Vector4;
  59296. backUVs?: Vector4;
  59297. updatable?: boolean;
  59298. }, scene?: Nullable<Scene>): Mesh;
  59299. /**
  59300. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59301. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59302. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59303. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59304. * * 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
  59305. * * 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
  59306. * * 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
  59307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59310. * * 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
  59311. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59312. * * 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
  59313. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59315. * @param name defines the name of the mesh
  59316. * @param options defines the options used to create the mesh
  59317. * @param scene defines the hosting scene
  59318. * @returns the ribbon mesh
  59319. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59320. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59321. */
  59322. static CreateRibbon(name: string, options: {
  59323. pathArray: Vector3[][];
  59324. closeArray?: boolean;
  59325. closePath?: boolean;
  59326. offset?: number;
  59327. updatable?: boolean;
  59328. sideOrientation?: number;
  59329. frontUVs?: Vector4;
  59330. backUVs?: Vector4;
  59331. instance?: Mesh;
  59332. invertUV?: boolean;
  59333. uvs?: Vector2[];
  59334. colors?: Color4[];
  59335. }, scene?: Nullable<Scene>): Mesh;
  59336. /**
  59337. * Creates a cylinder or a cone mesh
  59338. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59339. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59340. * * 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.
  59341. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59342. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59343. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59344. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59345. * * 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).
  59346. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59347. * * 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).
  59348. * * 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
  59349. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59350. * * 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
  59351. * * 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.
  59352. * * If `enclose` is false, a ring surface is one element.
  59353. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59354. * * 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
  59355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59358. * @param name defines the name of the mesh
  59359. * @param options defines the options used to create the mesh
  59360. * @param scene defines the hosting scene
  59361. * @returns the cylinder mesh
  59362. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59363. */
  59364. static CreateCylinder(name: string, options: {
  59365. height?: number;
  59366. diameterTop?: number;
  59367. diameterBottom?: number;
  59368. diameter?: number;
  59369. tessellation?: number;
  59370. subdivisions?: number;
  59371. arc?: number;
  59372. faceColors?: Color4[];
  59373. faceUV?: Vector4[];
  59374. updatable?: boolean;
  59375. hasRings?: boolean;
  59376. enclose?: boolean;
  59377. cap?: number;
  59378. sideOrientation?: number;
  59379. frontUVs?: Vector4;
  59380. backUVs?: Vector4;
  59381. }, scene?: Nullable<Scene>): Mesh;
  59382. /**
  59383. * Creates a torus mesh
  59384. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59385. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59386. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59390. * @param name defines the name of the mesh
  59391. * @param options defines the options used to create the mesh
  59392. * @param scene defines the hosting scene
  59393. * @returns the torus mesh
  59394. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59395. */
  59396. static CreateTorus(name: string, options: {
  59397. diameter?: number;
  59398. thickness?: number;
  59399. tessellation?: number;
  59400. updatable?: boolean;
  59401. sideOrientation?: number;
  59402. frontUVs?: Vector4;
  59403. backUVs?: Vector4;
  59404. }, scene?: Nullable<Scene>): Mesh;
  59405. /**
  59406. * Creates a torus knot mesh
  59407. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59408. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59409. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59410. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59414. * @param name defines the name of the mesh
  59415. * @param options defines the options used to create the mesh
  59416. * @param scene defines the hosting scene
  59417. * @returns the torus knot mesh
  59418. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59419. */
  59420. static CreateTorusKnot(name: string, options: {
  59421. radius?: number;
  59422. tube?: number;
  59423. radialSegments?: number;
  59424. tubularSegments?: number;
  59425. p?: number;
  59426. q?: number;
  59427. updatable?: boolean;
  59428. sideOrientation?: number;
  59429. frontUVs?: Vector4;
  59430. backUVs?: Vector4;
  59431. }, scene?: Nullable<Scene>): Mesh;
  59432. /**
  59433. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59434. * * 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
  59435. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59436. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59437. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59438. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59439. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59440. * * 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
  59441. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59444. * @param name defines the name of the new line system
  59445. * @param options defines the options used to create the line system
  59446. * @param scene defines the hosting scene
  59447. * @returns a new line system mesh
  59448. */
  59449. static CreateLineSystem(name: string, options: {
  59450. lines: Vector3[][];
  59451. updatable?: boolean;
  59452. instance?: Nullable<LinesMesh>;
  59453. colors?: Nullable<Color4[][]>;
  59454. useVertexAlpha?: boolean;
  59455. }, scene: Nullable<Scene>): LinesMesh;
  59456. /**
  59457. * Creates a line mesh
  59458. * 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
  59459. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59460. * * The parameter `points` is an array successive Vector3
  59461. * * 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
  59462. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59463. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59464. * * When updating an instance, remember that only point positions can change, not the number of points
  59465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59467. * @param name defines the name of the new line system
  59468. * @param options defines the options used to create the line system
  59469. * @param scene defines the hosting scene
  59470. * @returns a new line mesh
  59471. */
  59472. static CreateLines(name: string, options: {
  59473. points: Vector3[];
  59474. updatable?: boolean;
  59475. instance?: Nullable<LinesMesh>;
  59476. colors?: Color4[];
  59477. useVertexAlpha?: boolean;
  59478. }, scene?: Nullable<Scene>): LinesMesh;
  59479. /**
  59480. * Creates a dashed line mesh
  59481. * * 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
  59482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59483. * * The parameter `points` is an array successive Vector3
  59484. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59485. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59486. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59487. * * 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
  59488. * * When updating an instance, remember that only point positions can change, not the number of points
  59489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59490. * @param name defines the name of the mesh
  59491. * @param options defines the options used to create the mesh
  59492. * @param scene defines the hosting scene
  59493. * @returns the dashed line mesh
  59494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59495. */
  59496. static CreateDashedLines(name: string, options: {
  59497. points: Vector3[];
  59498. dashSize?: number;
  59499. gapSize?: number;
  59500. dashNb?: number;
  59501. updatable?: boolean;
  59502. instance?: LinesMesh;
  59503. }, scene?: Nullable<Scene>): LinesMesh;
  59504. /**
  59505. * 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.
  59506. * * 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.
  59507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59508. * * 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.
  59509. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59510. * * 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
  59511. * * 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
  59512. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59517. * @param name defines the name of the mesh
  59518. * @param options defines the options used to create the mesh
  59519. * @param scene defines the hosting scene
  59520. * @returns the extruded shape mesh
  59521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59523. */
  59524. static ExtrudeShape(name: string, options: {
  59525. shape: Vector3[];
  59526. path: Vector3[];
  59527. scale?: number;
  59528. rotation?: number;
  59529. cap?: number;
  59530. updatable?: boolean;
  59531. sideOrientation?: number;
  59532. frontUVs?: Vector4;
  59533. backUVs?: Vector4;
  59534. instance?: Mesh;
  59535. invertUV?: boolean;
  59536. }, scene?: Nullable<Scene>): Mesh;
  59537. /**
  59538. * Creates an custom extruded shape mesh.
  59539. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59540. * * 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.
  59541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59542. * * 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
  59543. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59544. * * 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
  59545. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59546. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59547. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59548. * * 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
  59549. * * 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
  59550. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59555. * @param name defines the name of the mesh
  59556. * @param options defines the options used to create the mesh
  59557. * @param scene defines the hosting scene
  59558. * @returns the custom extruded shape mesh
  59559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59562. */
  59563. static ExtrudeShapeCustom(name: string, options: {
  59564. shape: Vector3[];
  59565. path: Vector3[];
  59566. scaleFunction?: any;
  59567. rotationFunction?: any;
  59568. ribbonCloseArray?: boolean;
  59569. ribbonClosePath?: boolean;
  59570. cap?: number;
  59571. updatable?: boolean;
  59572. sideOrientation?: number;
  59573. frontUVs?: Vector4;
  59574. backUVs?: Vector4;
  59575. instance?: Mesh;
  59576. invertUV?: boolean;
  59577. }, scene?: Nullable<Scene>): Mesh;
  59578. /**
  59579. * Creates lathe mesh.
  59580. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59581. * * 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
  59582. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59583. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59584. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59585. * * 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
  59586. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59587. * * 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
  59588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59592. * @param name defines the name of the mesh
  59593. * @param options defines the options used to create the mesh
  59594. * @param scene defines the hosting scene
  59595. * @returns the lathe mesh
  59596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59597. */
  59598. static CreateLathe(name: string, options: {
  59599. shape: Vector3[];
  59600. radius?: number;
  59601. tessellation?: number;
  59602. clip?: number;
  59603. arc?: number;
  59604. closed?: boolean;
  59605. updatable?: boolean;
  59606. sideOrientation?: number;
  59607. frontUVs?: Vector4;
  59608. backUVs?: Vector4;
  59609. cap?: number;
  59610. invertUV?: boolean;
  59611. }, scene?: Nullable<Scene>): Mesh;
  59612. /**
  59613. * Creates a tiled plane mesh
  59614. * * You can set a limited pattern arrangement with the tiles
  59615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59618. * @param name defines the name of the mesh
  59619. * @param options defines the options used to create the mesh
  59620. * @param scene defines the hosting scene
  59621. * @returns the plane mesh
  59622. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59623. */
  59624. static CreateTiledPlane(name: string, options: {
  59625. pattern?: number;
  59626. tileSize?: number;
  59627. tileWidth?: number;
  59628. tileHeight?: number;
  59629. size?: number;
  59630. width?: number;
  59631. height?: number;
  59632. alignHorizontal?: number;
  59633. alignVertical?: number;
  59634. sideOrientation?: number;
  59635. frontUVs?: Vector4;
  59636. backUVs?: Vector4;
  59637. updatable?: boolean;
  59638. }, scene?: Nullable<Scene>): Mesh;
  59639. /**
  59640. * Creates a plane mesh
  59641. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59642. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59643. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59647. * @param name defines the name of the mesh
  59648. * @param options defines the options used to create the mesh
  59649. * @param scene defines the hosting scene
  59650. * @returns the plane mesh
  59651. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59652. */
  59653. static CreatePlane(name: string, options: {
  59654. size?: number;
  59655. width?: number;
  59656. height?: number;
  59657. sideOrientation?: number;
  59658. frontUVs?: Vector4;
  59659. backUVs?: Vector4;
  59660. updatable?: boolean;
  59661. sourcePlane?: Plane;
  59662. }, scene?: Nullable<Scene>): Mesh;
  59663. /**
  59664. * Creates a ground mesh
  59665. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59666. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59668. * @param name defines the name of the mesh
  59669. * @param options defines the options used to create the mesh
  59670. * @param scene defines the hosting scene
  59671. * @returns the ground mesh
  59672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59673. */
  59674. static CreateGround(name: string, options: {
  59675. width?: number;
  59676. height?: number;
  59677. subdivisions?: number;
  59678. subdivisionsX?: number;
  59679. subdivisionsY?: number;
  59680. updatable?: boolean;
  59681. }, scene?: Nullable<Scene>): Mesh;
  59682. /**
  59683. * Creates a tiled ground mesh
  59684. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59685. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59686. * * 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
  59687. * * 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
  59688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59689. * @param name defines the name of the mesh
  59690. * @param options defines the options used to create the mesh
  59691. * @param scene defines the hosting scene
  59692. * @returns the tiled ground mesh
  59693. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59694. */
  59695. static CreateTiledGround(name: string, options: {
  59696. xmin: number;
  59697. zmin: number;
  59698. xmax: number;
  59699. zmax: number;
  59700. subdivisions?: {
  59701. w: number;
  59702. h: number;
  59703. };
  59704. precision?: {
  59705. w: number;
  59706. h: number;
  59707. };
  59708. updatable?: boolean;
  59709. }, scene?: Nullable<Scene>): Mesh;
  59710. /**
  59711. * Creates a ground mesh from a height map
  59712. * * The parameter `url` sets the URL of the height map image resource.
  59713. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59714. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59715. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59716. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59717. * * 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.
  59718. * * 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).
  59719. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59721. * @param name defines the name of the mesh
  59722. * @param url defines the url to the height map
  59723. * @param options defines the options used to create the mesh
  59724. * @param scene defines the hosting scene
  59725. * @returns the ground mesh
  59726. * @see https://doc.babylonjs.com/babylon101/height_map
  59727. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59728. */
  59729. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59730. width?: number;
  59731. height?: number;
  59732. subdivisions?: number;
  59733. minHeight?: number;
  59734. maxHeight?: number;
  59735. colorFilter?: Color3;
  59736. alphaFilter?: number;
  59737. updatable?: boolean;
  59738. onReady?: (mesh: GroundMesh) => void;
  59739. }, scene?: Nullable<Scene>): GroundMesh;
  59740. /**
  59741. * Creates a polygon mesh
  59742. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59743. * * 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
  59744. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59747. * * Remember you can only change the shape positions, not their number when updating a polygon
  59748. * @param name defines the name of the mesh
  59749. * @param options defines the options used to create the mesh
  59750. * @param scene defines the hosting scene
  59751. * @param earcutInjection can be used to inject your own earcut reference
  59752. * @returns the polygon mesh
  59753. */
  59754. static CreatePolygon(name: string, options: {
  59755. shape: Vector3[];
  59756. holes?: Vector3[][];
  59757. depth?: number;
  59758. faceUV?: Vector4[];
  59759. faceColors?: Color4[];
  59760. updatable?: boolean;
  59761. sideOrientation?: number;
  59762. frontUVs?: Vector4;
  59763. backUVs?: Vector4;
  59764. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59765. /**
  59766. * Creates an extruded polygon mesh, with depth in the Y direction.
  59767. * * 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)
  59768. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59769. * @param name defines the name of the mesh
  59770. * @param options defines the options used to create the mesh
  59771. * @param scene defines the hosting scene
  59772. * @param earcutInjection can be used to inject your own earcut reference
  59773. * @returns the polygon mesh
  59774. */
  59775. static ExtrudePolygon(name: string, options: {
  59776. shape: Vector3[];
  59777. holes?: Vector3[][];
  59778. depth?: number;
  59779. faceUV?: Vector4[];
  59780. faceColors?: Color4[];
  59781. updatable?: boolean;
  59782. sideOrientation?: number;
  59783. frontUVs?: Vector4;
  59784. backUVs?: Vector4;
  59785. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59786. /**
  59787. * Creates a tube mesh.
  59788. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59789. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59790. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59791. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59792. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59793. * * 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)
  59794. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59795. * * 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
  59796. * * 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
  59797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59801. * @param name defines the name of the mesh
  59802. * @param options defines the options used to create the mesh
  59803. * @param scene defines the hosting scene
  59804. * @returns the tube mesh
  59805. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59806. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59807. */
  59808. static CreateTube(name: string, options: {
  59809. path: Vector3[];
  59810. radius?: number;
  59811. tessellation?: number;
  59812. radiusFunction?: {
  59813. (i: number, distance: number): number;
  59814. };
  59815. cap?: number;
  59816. arc?: number;
  59817. updatable?: boolean;
  59818. sideOrientation?: number;
  59819. frontUVs?: Vector4;
  59820. backUVs?: Vector4;
  59821. instance?: Mesh;
  59822. invertUV?: boolean;
  59823. }, scene?: Nullable<Scene>): Mesh;
  59824. /**
  59825. * Creates a polyhedron mesh
  59826. * * 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
  59827. * * The parameter `size` (positive float, default 1) sets the polygon size
  59828. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59829. * * 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`
  59830. * * 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
  59831. * * 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)`)
  59832. * * 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
  59833. * * 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
  59834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59837. * @param name defines the name of the mesh
  59838. * @param options defines the options used to create the mesh
  59839. * @param scene defines the hosting scene
  59840. * @returns the polyhedron mesh
  59841. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59842. */
  59843. static CreatePolyhedron(name: string, options: {
  59844. type?: number;
  59845. size?: number;
  59846. sizeX?: number;
  59847. sizeY?: number;
  59848. sizeZ?: number;
  59849. custom?: any;
  59850. faceUV?: Vector4[];
  59851. faceColors?: Color4[];
  59852. flat?: boolean;
  59853. updatable?: boolean;
  59854. sideOrientation?: number;
  59855. frontUVs?: Vector4;
  59856. backUVs?: Vector4;
  59857. }, scene?: Nullable<Scene>): Mesh;
  59858. /**
  59859. * Creates a decal mesh.
  59860. * 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
  59861. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59862. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59863. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59864. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59865. * @param name defines the name of the mesh
  59866. * @param sourceMesh defines the mesh where the decal must be applied
  59867. * @param options defines the options used to create the mesh
  59868. * @param scene defines the hosting scene
  59869. * @returns the decal mesh
  59870. * @see https://doc.babylonjs.com/how_to/decals
  59871. */
  59872. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59873. position?: Vector3;
  59874. normal?: Vector3;
  59875. size?: Vector3;
  59876. angle?: number;
  59877. }): Mesh;
  59878. }
  59879. }
  59880. declare module "babylonjs/Meshes/meshSimplification" {
  59881. import { Mesh } from "babylonjs/Meshes/mesh";
  59882. /**
  59883. * A simplifier interface for future simplification implementations
  59884. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59885. */
  59886. export interface ISimplifier {
  59887. /**
  59888. * Simplification of a given mesh according to the given settings.
  59889. * Since this requires computation, it is assumed that the function runs async.
  59890. * @param settings The settings of the simplification, including quality and distance
  59891. * @param successCallback A callback that will be called after the mesh was simplified.
  59892. * @param errorCallback in case of an error, this callback will be called. optional.
  59893. */
  59894. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59895. }
  59896. /**
  59897. * Expected simplification settings.
  59898. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59899. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59900. */
  59901. export interface ISimplificationSettings {
  59902. /**
  59903. * Gets or sets the expected quality
  59904. */
  59905. quality: number;
  59906. /**
  59907. * Gets or sets the distance when this optimized version should be used
  59908. */
  59909. distance: number;
  59910. /**
  59911. * Gets an already optimized mesh
  59912. */
  59913. optimizeMesh?: boolean;
  59914. }
  59915. /**
  59916. * Class used to specify simplification options
  59917. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59918. */
  59919. export class SimplificationSettings implements ISimplificationSettings {
  59920. /** expected quality */
  59921. quality: number;
  59922. /** distance when this optimized version should be used */
  59923. distance: number;
  59924. /** already optimized mesh */
  59925. optimizeMesh?: boolean | undefined;
  59926. /**
  59927. * Creates a SimplificationSettings
  59928. * @param quality expected quality
  59929. * @param distance distance when this optimized version should be used
  59930. * @param optimizeMesh already optimized mesh
  59931. */
  59932. constructor(
  59933. /** expected quality */
  59934. quality: number,
  59935. /** distance when this optimized version should be used */
  59936. distance: number,
  59937. /** already optimized mesh */
  59938. optimizeMesh?: boolean | undefined);
  59939. }
  59940. /**
  59941. * Interface used to define a simplification task
  59942. */
  59943. export interface ISimplificationTask {
  59944. /**
  59945. * Array of settings
  59946. */
  59947. settings: Array<ISimplificationSettings>;
  59948. /**
  59949. * Simplification type
  59950. */
  59951. simplificationType: SimplificationType;
  59952. /**
  59953. * Mesh to simplify
  59954. */
  59955. mesh: Mesh;
  59956. /**
  59957. * Callback called on success
  59958. */
  59959. successCallback?: () => void;
  59960. /**
  59961. * Defines if parallel processing can be used
  59962. */
  59963. parallelProcessing: boolean;
  59964. }
  59965. /**
  59966. * Queue used to order the simplification tasks
  59967. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59968. */
  59969. export class SimplificationQueue {
  59970. private _simplificationArray;
  59971. /**
  59972. * Gets a boolean indicating that the process is still running
  59973. */
  59974. running: boolean;
  59975. /**
  59976. * Creates a new queue
  59977. */
  59978. constructor();
  59979. /**
  59980. * Adds a new simplification task
  59981. * @param task defines a task to add
  59982. */
  59983. addTask(task: ISimplificationTask): void;
  59984. /**
  59985. * Execute next task
  59986. */
  59987. executeNext(): void;
  59988. /**
  59989. * Execute a simplification task
  59990. * @param task defines the task to run
  59991. */
  59992. runSimplification(task: ISimplificationTask): void;
  59993. private getSimplifier;
  59994. }
  59995. /**
  59996. * The implemented types of simplification
  59997. * At the moment only Quadratic Error Decimation is implemented
  59998. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59999. */
  60000. export enum SimplificationType {
  60001. /** Quadratic error decimation */
  60002. QUADRATIC = 0
  60003. }
  60004. }
  60005. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60006. import { Scene } from "babylonjs/scene";
  60007. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60008. import { ISceneComponent } from "babylonjs/sceneComponent";
  60009. module "babylonjs/scene" {
  60010. interface Scene {
  60011. /** @hidden (Backing field) */
  60012. _simplificationQueue: SimplificationQueue;
  60013. /**
  60014. * Gets or sets the simplification queue attached to the scene
  60015. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60016. */
  60017. simplificationQueue: SimplificationQueue;
  60018. }
  60019. }
  60020. module "babylonjs/Meshes/mesh" {
  60021. interface Mesh {
  60022. /**
  60023. * Simplify the mesh according to the given array of settings.
  60024. * Function will return immediately and will simplify async
  60025. * @param settings a collection of simplification settings
  60026. * @param parallelProcessing should all levels calculate parallel or one after the other
  60027. * @param simplificationType the type of simplification to run
  60028. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60029. * @returns the current mesh
  60030. */
  60031. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60032. }
  60033. }
  60034. /**
  60035. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60036. * created in a scene
  60037. */
  60038. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60039. /**
  60040. * The component name helpfull to identify the component in the list of scene components.
  60041. */
  60042. readonly name: string;
  60043. /**
  60044. * The scene the component belongs to.
  60045. */
  60046. scene: Scene;
  60047. /**
  60048. * Creates a new instance of the component for the given scene
  60049. * @param scene Defines the scene to register the component in
  60050. */
  60051. constructor(scene: Scene);
  60052. /**
  60053. * Registers the component in a given scene
  60054. */
  60055. register(): void;
  60056. /**
  60057. * Rebuilds the elements related to this component in case of
  60058. * context lost for instance.
  60059. */
  60060. rebuild(): void;
  60061. /**
  60062. * Disposes the component and the associated ressources
  60063. */
  60064. dispose(): void;
  60065. private _beforeCameraUpdate;
  60066. }
  60067. }
  60068. declare module "babylonjs/Meshes/Builders/index" {
  60069. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60070. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60071. export * from "babylonjs/Meshes/Builders/discBuilder";
  60072. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60073. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60074. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60075. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60076. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60077. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60078. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60079. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60080. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60081. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60082. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60083. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60084. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60085. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60086. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60087. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60088. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60089. }
  60090. declare module "babylonjs/Meshes/index" {
  60091. export * from "babylonjs/Meshes/abstractMesh";
  60092. export * from "babylonjs/Meshes/buffer";
  60093. export * from "babylonjs/Meshes/Compression/index";
  60094. export * from "babylonjs/Meshes/csg";
  60095. export * from "babylonjs/Meshes/geometry";
  60096. export * from "babylonjs/Meshes/groundMesh";
  60097. export * from "babylonjs/Meshes/trailMesh";
  60098. export * from "babylonjs/Meshes/instancedMesh";
  60099. export * from "babylonjs/Meshes/linesMesh";
  60100. export * from "babylonjs/Meshes/mesh";
  60101. export * from "babylonjs/Meshes/mesh.vertexData";
  60102. export * from "babylonjs/Meshes/meshBuilder";
  60103. export * from "babylonjs/Meshes/meshSimplification";
  60104. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60105. export * from "babylonjs/Meshes/polygonMesh";
  60106. export * from "babylonjs/Meshes/subMesh";
  60107. export * from "babylonjs/Meshes/meshLODLevel";
  60108. export * from "babylonjs/Meshes/transformNode";
  60109. export * from "babylonjs/Meshes/Builders/index";
  60110. export * from "babylonjs/Meshes/dataBuffer";
  60111. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60112. }
  60113. declare module "babylonjs/Morph/index" {
  60114. export * from "babylonjs/Morph/morphTarget";
  60115. export * from "babylonjs/Morph/morphTargetManager";
  60116. }
  60117. declare module "babylonjs/Navigation/INavigationEngine" {
  60118. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60119. import { Vector3 } from "babylonjs/Maths/math";
  60120. import { Mesh } from "babylonjs/Meshes/mesh";
  60121. import { Scene } from "babylonjs/scene";
  60122. /**
  60123. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60124. */
  60125. export interface INavigationEnginePlugin {
  60126. /**
  60127. * plugin name
  60128. */
  60129. name: string;
  60130. /**
  60131. * Creates a navigation mesh
  60132. * @param meshes array of all the geometry used to compute the navigatio mesh
  60133. * @param parameters bunch of parameters used to filter geometry
  60134. */
  60135. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60136. /**
  60137. * Create a navigation mesh debug mesh
  60138. * @param scene is where the mesh will be added
  60139. * @returns debug display mesh
  60140. */
  60141. createDebugNavMesh(scene: Scene): Mesh;
  60142. /**
  60143. * Get a navigation mesh constrained position, closest to the parameter position
  60144. * @param position world position
  60145. * @returns the closest point to position constrained by the navigation mesh
  60146. */
  60147. getClosestPoint(position: Vector3): Vector3;
  60148. /**
  60149. * Get a navigation mesh constrained position, within a particular radius
  60150. * @param position world position
  60151. * @param maxRadius the maximum distance to the constrained world position
  60152. * @returns the closest point to position constrained by the navigation mesh
  60153. */
  60154. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60155. /**
  60156. * Compute the final position from a segment made of destination-position
  60157. * @param position world position
  60158. * @param destination world position
  60159. * @returns the resulting point along the navmesh
  60160. */
  60161. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60162. /**
  60163. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60164. * @param start world position
  60165. * @param end world position
  60166. * @returns array containing world position composing the path
  60167. */
  60168. computePath(start: Vector3, end: Vector3): Vector3[];
  60169. /**
  60170. * If this plugin is supported
  60171. * @returns true if plugin is supported
  60172. */
  60173. isSupported(): boolean;
  60174. /**
  60175. * Create a new Crowd so you can add agents
  60176. * @param maxAgents the maximum agent count in the crowd
  60177. * @param maxAgentRadius the maximum radius an agent can have
  60178. * @param scene to attach the crowd to
  60179. * @returns the crowd you can add agents to
  60180. */
  60181. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60182. /**
  60183. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60184. * The queries will try to find a solution within those bounds
  60185. * default is (1,1,1)
  60186. * @param extent x,y,z value that define the extent around the queries point of reference
  60187. */
  60188. setDefaultQueryExtent(extent: Vector3): void;
  60189. /**
  60190. * Get the Bounding box extent specified by setDefaultQueryExtent
  60191. * @returns the box extent values
  60192. */
  60193. getDefaultQueryExtent(): Vector3;
  60194. /**
  60195. * Release all resources
  60196. */
  60197. dispose(): void;
  60198. }
  60199. /**
  60200. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60201. */
  60202. export interface ICrowd {
  60203. /**
  60204. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60205. * You can attach anything to that node. The node position is updated in the scene update tick.
  60206. * @param pos world position that will be constrained by the navigation mesh
  60207. * @param parameters agent parameters
  60208. * @param transform hooked to the agent that will be update by the scene
  60209. * @returns agent index
  60210. */
  60211. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60212. /**
  60213. * Returns the agent position in world space
  60214. * @param index agent index returned by addAgent
  60215. * @returns world space position
  60216. */
  60217. getAgentPosition(index: number): Vector3;
  60218. /**
  60219. * Gets the agent velocity in world space
  60220. * @param index agent index returned by addAgent
  60221. * @returns world space velocity
  60222. */
  60223. getAgentVelocity(index: number): Vector3;
  60224. /**
  60225. * remove a particular agent previously created
  60226. * @param index agent index returned by addAgent
  60227. */
  60228. removeAgent(index: number): void;
  60229. /**
  60230. * get the list of all agents attached to this crowd
  60231. * @returns list of agent indices
  60232. */
  60233. getAgents(): number[];
  60234. /**
  60235. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60236. * @param deltaTime in seconds
  60237. */
  60238. update(deltaTime: number): void;
  60239. /**
  60240. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60241. * @param index agent index returned by addAgent
  60242. * @param destination targeted world position
  60243. */
  60244. agentGoto(index: number, destination: Vector3): void;
  60245. /**
  60246. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60247. * The queries will try to find a solution within those bounds
  60248. * default is (1,1,1)
  60249. * @param extent x,y,z value that define the extent around the queries point of reference
  60250. */
  60251. setDefaultQueryExtent(extent: Vector3): void;
  60252. /**
  60253. * Get the Bounding box extent specified by setDefaultQueryExtent
  60254. * @returns the box extent values
  60255. */
  60256. getDefaultQueryExtent(): Vector3;
  60257. /**
  60258. * Release all resources
  60259. */
  60260. dispose(): void;
  60261. }
  60262. /**
  60263. * Configures an agent
  60264. */
  60265. export interface IAgentParameters {
  60266. /**
  60267. * Agent radius. [Limit: >= 0]
  60268. */
  60269. radius: number;
  60270. /**
  60271. * Agent height. [Limit: > 0]
  60272. */
  60273. height: number;
  60274. /**
  60275. * Maximum allowed acceleration. [Limit: >= 0]
  60276. */
  60277. maxAcceleration: number;
  60278. /**
  60279. * Maximum allowed speed. [Limit: >= 0]
  60280. */
  60281. maxSpeed: number;
  60282. /**
  60283. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60284. */
  60285. collisionQueryRange: number;
  60286. /**
  60287. * The path visibility optimization range. [Limit: > 0]
  60288. */
  60289. pathOptimizationRange: number;
  60290. /**
  60291. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60292. */
  60293. separationWeight: number;
  60294. }
  60295. /**
  60296. * Configures the navigation mesh creation
  60297. */
  60298. export interface INavMeshParameters {
  60299. /**
  60300. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60301. */
  60302. cs: number;
  60303. /**
  60304. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60305. */
  60306. ch: number;
  60307. /**
  60308. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60309. */
  60310. walkableSlopeAngle: number;
  60311. /**
  60312. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60313. * be considered walkable. [Limit: >= 3] [Units: vx]
  60314. */
  60315. walkableHeight: number;
  60316. /**
  60317. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60318. */
  60319. walkableClimb: number;
  60320. /**
  60321. * The distance to erode/shrink the walkable area of the heightfield away from
  60322. * obstructions. [Limit: >=0] [Units: vx]
  60323. */
  60324. walkableRadius: number;
  60325. /**
  60326. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60327. */
  60328. maxEdgeLen: number;
  60329. /**
  60330. * The maximum distance a simplfied contour's border edges should deviate
  60331. * the original raw contour. [Limit: >=0] [Units: vx]
  60332. */
  60333. maxSimplificationError: number;
  60334. /**
  60335. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60336. */
  60337. minRegionArea: number;
  60338. /**
  60339. * Any regions with a span count smaller than this value will, if possible,
  60340. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60341. */
  60342. mergeRegionArea: number;
  60343. /**
  60344. * The maximum number of vertices allowed for polygons generated during the
  60345. * contour to polygon conversion process. [Limit: >= 3]
  60346. */
  60347. maxVertsPerPoly: number;
  60348. /**
  60349. * Sets the sampling distance to use when generating the detail mesh.
  60350. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60351. */
  60352. detailSampleDist: number;
  60353. /**
  60354. * The maximum distance the detail mesh surface should deviate from heightfield
  60355. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60356. */
  60357. detailSampleMaxError: number;
  60358. }
  60359. }
  60360. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60361. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60362. import { Mesh } from "babylonjs/Meshes/mesh";
  60363. import { Scene } from "babylonjs/scene";
  60364. import { Vector3 } from "babylonjs/Maths/math";
  60365. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60366. /**
  60367. * RecastJS navigation plugin
  60368. */
  60369. export class RecastJSPlugin implements INavigationEnginePlugin {
  60370. /**
  60371. * Reference to the Recast library
  60372. */
  60373. bjsRECAST: any;
  60374. /**
  60375. * plugin name
  60376. */
  60377. name: string;
  60378. /**
  60379. * the first navmesh created. We might extend this to support multiple navmeshes
  60380. */
  60381. navMesh: any;
  60382. /**
  60383. * Initializes the recastJS plugin
  60384. * @param recastInjection can be used to inject your own recast reference
  60385. */
  60386. constructor(recastInjection?: any);
  60387. /**
  60388. * Creates a navigation mesh
  60389. * @param meshes array of all the geometry used to compute the navigatio mesh
  60390. * @param parameters bunch of parameters used to filter geometry
  60391. */
  60392. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60393. /**
  60394. * Create a navigation mesh debug mesh
  60395. * @param scene is where the mesh will be added
  60396. * @returns debug display mesh
  60397. */
  60398. createDebugNavMesh(scene: Scene): Mesh;
  60399. /**
  60400. * Get a navigation mesh constrained position, closest to the parameter position
  60401. * @param position world position
  60402. * @returns the closest point to position constrained by the navigation mesh
  60403. */
  60404. getClosestPoint(position: Vector3): Vector3;
  60405. /**
  60406. * Get a navigation mesh constrained position, within a particular radius
  60407. * @param position world position
  60408. * @param maxRadius the maximum distance to the constrained world position
  60409. * @returns the closest point to position constrained by the navigation mesh
  60410. */
  60411. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60412. /**
  60413. * Compute the final position from a segment made of destination-position
  60414. * @param position world position
  60415. * @param destination world position
  60416. * @returns the resulting point along the navmesh
  60417. */
  60418. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60419. /**
  60420. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60421. * @param start world position
  60422. * @param end world position
  60423. * @returns array containing world position composing the path
  60424. */
  60425. computePath(start: Vector3, end: Vector3): Vector3[];
  60426. /**
  60427. * Create a new Crowd so you can add agents
  60428. * @param maxAgents the maximum agent count in the crowd
  60429. * @param maxAgentRadius the maximum radius an agent can have
  60430. * @param scene to attach the crowd to
  60431. * @returns the crowd you can add agents to
  60432. */
  60433. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60434. /**
  60435. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60436. * The queries will try to find a solution within those bounds
  60437. * default is (1,1,1)
  60438. * @param extent x,y,z value that define the extent around the queries point of reference
  60439. */
  60440. setDefaultQueryExtent(extent: Vector3): void;
  60441. /**
  60442. * Get the Bounding box extent specified by setDefaultQueryExtent
  60443. * @returns the box extent values
  60444. */
  60445. getDefaultQueryExtent(): Vector3;
  60446. /**
  60447. * Disposes
  60448. */
  60449. dispose(): void;
  60450. /**
  60451. * If this plugin is supported
  60452. * @returns true if plugin is supported
  60453. */
  60454. isSupported(): boolean;
  60455. }
  60456. /**
  60457. * Recast detour crowd implementation
  60458. */
  60459. export class RecastJSCrowd implements ICrowd {
  60460. /**
  60461. * Recast/detour plugin
  60462. */
  60463. bjsRECASTPlugin: RecastJSPlugin;
  60464. /**
  60465. * Link to the detour crowd
  60466. */
  60467. recastCrowd: any;
  60468. /**
  60469. * One transform per agent
  60470. */
  60471. transforms: TransformNode[];
  60472. /**
  60473. * All agents created
  60474. */
  60475. agents: number[];
  60476. /**
  60477. * Link to the scene is kept to unregister the crowd from the scene
  60478. */
  60479. private _scene;
  60480. /**
  60481. * Observer for crowd updates
  60482. */
  60483. private _onBeforeAnimationsObserver;
  60484. /**
  60485. * Constructor
  60486. * @param plugin recastJS plugin
  60487. * @param maxAgents the maximum agent count in the crowd
  60488. * @param maxAgentRadius the maximum radius an agent can have
  60489. * @param scene to attach the crowd to
  60490. * @returns the crowd you can add agents to
  60491. */
  60492. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60493. /**
  60494. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60495. * You can attach anything to that node. The node position is updated in the scene update tick.
  60496. * @param pos world position that will be constrained by the navigation mesh
  60497. * @param parameters agent parameters
  60498. * @param transform hooked to the agent that will be update by the scene
  60499. * @returns agent index
  60500. */
  60501. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60502. /**
  60503. * Returns the agent position in world space
  60504. * @param index agent index returned by addAgent
  60505. * @returns world space position
  60506. */
  60507. getAgentPosition(index: number): Vector3;
  60508. /**
  60509. * Returns the agent velocity in world space
  60510. * @param index agent index returned by addAgent
  60511. * @returns world space velocity
  60512. */
  60513. getAgentVelocity(index: number): Vector3;
  60514. /**
  60515. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60516. * @param index agent index returned by addAgent
  60517. * @param destination targeted world position
  60518. */
  60519. agentGoto(index: number, destination: Vector3): void;
  60520. /**
  60521. * remove a particular agent previously created
  60522. * @param index agent index returned by addAgent
  60523. */
  60524. removeAgent(index: number): void;
  60525. /**
  60526. * get the list of all agents attached to this crowd
  60527. * @returns list of agent indices
  60528. */
  60529. getAgents(): number[];
  60530. /**
  60531. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60532. * @param deltaTime in seconds
  60533. */
  60534. update(deltaTime: number): void;
  60535. /**
  60536. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60537. * The queries will try to find a solution within those bounds
  60538. * default is (1,1,1)
  60539. * @param extent x,y,z value that define the extent around the queries point of reference
  60540. */
  60541. setDefaultQueryExtent(extent: Vector3): void;
  60542. /**
  60543. * Get the Bounding box extent specified by setDefaultQueryExtent
  60544. * @returns the box extent values
  60545. */
  60546. getDefaultQueryExtent(): Vector3;
  60547. /**
  60548. * Release all resources
  60549. */
  60550. dispose(): void;
  60551. }
  60552. }
  60553. declare module "babylonjs/Navigation/Plugins/index" {
  60554. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60555. }
  60556. declare module "babylonjs/Navigation/index" {
  60557. export * from "babylonjs/Navigation/INavigationEngine";
  60558. export * from "babylonjs/Navigation/Plugins/index";
  60559. }
  60560. declare module "babylonjs/Offline/database" {
  60561. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60562. /**
  60563. * Class used to enable access to IndexedDB
  60564. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60565. */
  60566. export class Database implements IOfflineProvider {
  60567. private _callbackManifestChecked;
  60568. private _currentSceneUrl;
  60569. private _db;
  60570. private _enableSceneOffline;
  60571. private _enableTexturesOffline;
  60572. private _manifestVersionFound;
  60573. private _mustUpdateRessources;
  60574. private _hasReachedQuota;
  60575. private _isSupported;
  60576. private _idbFactory;
  60577. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60578. private static IsUASupportingBlobStorage;
  60579. /**
  60580. * Gets a boolean indicating if Database storate is enabled (off by default)
  60581. */
  60582. static IDBStorageEnabled: boolean;
  60583. /**
  60584. * Gets a boolean indicating if scene must be saved in the database
  60585. */
  60586. readonly enableSceneOffline: boolean;
  60587. /**
  60588. * Gets a boolean indicating if textures must be saved in the database
  60589. */
  60590. readonly enableTexturesOffline: boolean;
  60591. /**
  60592. * Creates a new Database
  60593. * @param urlToScene defines the url to load the scene
  60594. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60595. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60596. */
  60597. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60598. private static _ParseURL;
  60599. private static _ReturnFullUrlLocation;
  60600. private _checkManifestFile;
  60601. /**
  60602. * Open the database and make it available
  60603. * @param successCallback defines the callback to call on success
  60604. * @param errorCallback defines the callback to call on error
  60605. */
  60606. open(successCallback: () => void, errorCallback: () => void): void;
  60607. /**
  60608. * Loads an image from the database
  60609. * @param url defines the url to load from
  60610. * @param image defines the target DOM image
  60611. */
  60612. loadImage(url: string, image: HTMLImageElement): void;
  60613. private _loadImageFromDBAsync;
  60614. private _saveImageIntoDBAsync;
  60615. private _checkVersionFromDB;
  60616. private _loadVersionFromDBAsync;
  60617. private _saveVersionIntoDBAsync;
  60618. /**
  60619. * Loads a file from database
  60620. * @param url defines the URL to load from
  60621. * @param sceneLoaded defines a callback to call on success
  60622. * @param progressCallBack defines a callback to call when progress changed
  60623. * @param errorCallback defines a callback to call on error
  60624. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60625. */
  60626. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60627. private _loadFileAsync;
  60628. private _saveFileAsync;
  60629. /**
  60630. * Validates if xhr data is correct
  60631. * @param xhr defines the request to validate
  60632. * @param dataType defines the expected data type
  60633. * @returns true if data is correct
  60634. */
  60635. private static _ValidateXHRData;
  60636. }
  60637. }
  60638. declare module "babylonjs/Offline/index" {
  60639. export * from "babylonjs/Offline/database";
  60640. export * from "babylonjs/Offline/IOfflineProvider";
  60641. }
  60642. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60643. /** @hidden */
  60644. export var gpuUpdateParticlesPixelShader: {
  60645. name: string;
  60646. shader: string;
  60647. };
  60648. }
  60649. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60650. /** @hidden */
  60651. export var gpuUpdateParticlesVertexShader: {
  60652. name: string;
  60653. shader: string;
  60654. };
  60655. }
  60656. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60657. /** @hidden */
  60658. export var clipPlaneFragmentDeclaration2: {
  60659. name: string;
  60660. shader: string;
  60661. };
  60662. }
  60663. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60664. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60665. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60666. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60667. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60668. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60669. /** @hidden */
  60670. export var gpuRenderParticlesPixelShader: {
  60671. name: string;
  60672. shader: string;
  60673. };
  60674. }
  60675. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60676. /** @hidden */
  60677. export var clipPlaneVertexDeclaration2: {
  60678. name: string;
  60679. shader: string;
  60680. };
  60681. }
  60682. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60683. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60684. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60685. /** @hidden */
  60686. export var gpuRenderParticlesVertexShader: {
  60687. name: string;
  60688. shader: string;
  60689. };
  60690. }
  60691. declare module "babylonjs/Particles/gpuParticleSystem" {
  60692. import { Nullable } from "babylonjs/types";
  60693. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60694. import { Observable } from "babylonjs/Misc/observable";
  60695. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60696. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60697. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60698. import { Scene, IDisposable } from "babylonjs/scene";
  60699. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60700. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60701. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60702. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60703. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60704. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60705. /**
  60706. * This represents a GPU particle system in Babylon
  60707. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60708. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60709. */
  60710. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60711. /**
  60712. * The layer mask we are rendering the particles through.
  60713. */
  60714. layerMask: number;
  60715. private _capacity;
  60716. private _activeCount;
  60717. private _currentActiveCount;
  60718. private _accumulatedCount;
  60719. private _renderEffect;
  60720. private _updateEffect;
  60721. private _buffer0;
  60722. private _buffer1;
  60723. private _spriteBuffer;
  60724. private _updateVAO;
  60725. private _renderVAO;
  60726. private _targetIndex;
  60727. private _sourceBuffer;
  60728. private _targetBuffer;
  60729. private _engine;
  60730. private _currentRenderId;
  60731. private _started;
  60732. private _stopped;
  60733. private _timeDelta;
  60734. private _randomTexture;
  60735. private _randomTexture2;
  60736. private _attributesStrideSize;
  60737. private _updateEffectOptions;
  60738. private _randomTextureSize;
  60739. private _actualFrame;
  60740. private readonly _rawTextureWidth;
  60741. /**
  60742. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60743. */
  60744. static readonly IsSupported: boolean;
  60745. /**
  60746. * An event triggered when the system is disposed.
  60747. */
  60748. onDisposeObservable: Observable<GPUParticleSystem>;
  60749. /**
  60750. * Gets the maximum number of particles active at the same time.
  60751. * @returns The max number of active particles.
  60752. */
  60753. getCapacity(): number;
  60754. /**
  60755. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60756. * to override the particles.
  60757. */
  60758. forceDepthWrite: boolean;
  60759. /**
  60760. * Gets or set the number of active particles
  60761. */
  60762. activeParticleCount: number;
  60763. private _preWarmDone;
  60764. /**
  60765. * Is this system ready to be used/rendered
  60766. * @return true if the system is ready
  60767. */
  60768. isReady(): boolean;
  60769. /**
  60770. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60771. * @returns True if it has been started, otherwise false.
  60772. */
  60773. isStarted(): boolean;
  60774. /**
  60775. * Starts the particle system and begins to emit
  60776. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60777. */
  60778. start(delay?: number): void;
  60779. /**
  60780. * Stops the particle system.
  60781. */
  60782. stop(): void;
  60783. /**
  60784. * Remove all active particles
  60785. */
  60786. reset(): void;
  60787. /**
  60788. * Returns the string "GPUParticleSystem"
  60789. * @returns a string containing the class name
  60790. */
  60791. getClassName(): string;
  60792. private _colorGradientsTexture;
  60793. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60794. /**
  60795. * Adds a new color gradient
  60796. * @param gradient defines the gradient to use (between 0 and 1)
  60797. * @param color1 defines the color to affect to the specified gradient
  60798. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60799. * @returns the current particle system
  60800. */
  60801. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60802. /**
  60803. * Remove a specific color gradient
  60804. * @param gradient defines the gradient to remove
  60805. * @returns the current particle system
  60806. */
  60807. removeColorGradient(gradient: number): GPUParticleSystem;
  60808. private _angularSpeedGradientsTexture;
  60809. private _sizeGradientsTexture;
  60810. private _velocityGradientsTexture;
  60811. private _limitVelocityGradientsTexture;
  60812. private _dragGradientsTexture;
  60813. private _addFactorGradient;
  60814. /**
  60815. * Adds a new size gradient
  60816. * @param gradient defines the gradient to use (between 0 and 1)
  60817. * @param factor defines the size factor to affect to the specified gradient
  60818. * @returns the current particle system
  60819. */
  60820. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60821. /**
  60822. * Remove a specific size gradient
  60823. * @param gradient defines the gradient to remove
  60824. * @returns the current particle system
  60825. */
  60826. removeSizeGradient(gradient: number): GPUParticleSystem;
  60827. /**
  60828. * Adds a new angular speed gradient
  60829. * @param gradient defines the gradient to use (between 0 and 1)
  60830. * @param factor defines the angular speed to affect to the specified gradient
  60831. * @returns the current particle system
  60832. */
  60833. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60834. /**
  60835. * Remove a specific angular speed gradient
  60836. * @param gradient defines the gradient to remove
  60837. * @returns the current particle system
  60838. */
  60839. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60840. /**
  60841. * Adds a new velocity gradient
  60842. * @param gradient defines the gradient to use (between 0 and 1)
  60843. * @param factor defines the velocity to affect to the specified gradient
  60844. * @returns the current particle system
  60845. */
  60846. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60847. /**
  60848. * Remove a specific velocity gradient
  60849. * @param gradient defines the gradient to remove
  60850. * @returns the current particle system
  60851. */
  60852. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60853. /**
  60854. * Adds a new limit velocity gradient
  60855. * @param gradient defines the gradient to use (between 0 and 1)
  60856. * @param factor defines the limit velocity value to affect to the specified gradient
  60857. * @returns the current particle system
  60858. */
  60859. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60860. /**
  60861. * Remove a specific limit velocity gradient
  60862. * @param gradient defines the gradient to remove
  60863. * @returns the current particle system
  60864. */
  60865. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60866. /**
  60867. * Adds a new drag gradient
  60868. * @param gradient defines the gradient to use (between 0 and 1)
  60869. * @param factor defines the drag value to affect to the specified gradient
  60870. * @returns the current particle system
  60871. */
  60872. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60873. /**
  60874. * Remove a specific drag gradient
  60875. * @param gradient defines the gradient to remove
  60876. * @returns the current particle system
  60877. */
  60878. removeDragGradient(gradient: number): GPUParticleSystem;
  60879. /**
  60880. * Not supported by GPUParticleSystem
  60881. * @param gradient defines the gradient to use (between 0 and 1)
  60882. * @param factor defines the emit rate value to affect to the specified gradient
  60883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60884. * @returns the current particle system
  60885. */
  60886. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60887. /**
  60888. * Not supported by GPUParticleSystem
  60889. * @param gradient defines the gradient to remove
  60890. * @returns the current particle system
  60891. */
  60892. removeEmitRateGradient(gradient: number): IParticleSystem;
  60893. /**
  60894. * Not supported by GPUParticleSystem
  60895. * @param gradient defines the gradient to use (between 0 and 1)
  60896. * @param factor defines the start size value to affect to the specified gradient
  60897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60898. * @returns the current particle system
  60899. */
  60900. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60901. /**
  60902. * Not supported by GPUParticleSystem
  60903. * @param gradient defines the gradient to remove
  60904. * @returns the current particle system
  60905. */
  60906. removeStartSizeGradient(gradient: number): IParticleSystem;
  60907. /**
  60908. * Not supported by GPUParticleSystem
  60909. * @param gradient defines the gradient to use (between 0 and 1)
  60910. * @param min defines the color remap minimal range
  60911. * @param max defines the color remap maximal range
  60912. * @returns the current particle system
  60913. */
  60914. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60915. /**
  60916. * Not supported by GPUParticleSystem
  60917. * @param gradient defines the gradient to remove
  60918. * @returns the current particle system
  60919. */
  60920. removeColorRemapGradient(): IParticleSystem;
  60921. /**
  60922. * Not supported by GPUParticleSystem
  60923. * @param gradient defines the gradient to use (between 0 and 1)
  60924. * @param min defines the alpha remap minimal range
  60925. * @param max defines the alpha remap maximal range
  60926. * @returns the current particle system
  60927. */
  60928. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60929. /**
  60930. * Not supported by GPUParticleSystem
  60931. * @param gradient defines the gradient to remove
  60932. * @returns the current particle system
  60933. */
  60934. removeAlphaRemapGradient(): IParticleSystem;
  60935. /**
  60936. * Not supported by GPUParticleSystem
  60937. * @param gradient defines the gradient to use (between 0 and 1)
  60938. * @param color defines the color to affect to the specified gradient
  60939. * @returns the current particle system
  60940. */
  60941. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60942. /**
  60943. * Not supported by GPUParticleSystem
  60944. * @param gradient defines the gradient to remove
  60945. * @returns the current particle system
  60946. */
  60947. removeRampGradient(): IParticleSystem;
  60948. /**
  60949. * Not supported by GPUParticleSystem
  60950. * @returns the list of ramp gradients
  60951. */
  60952. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60953. /**
  60954. * Not supported by GPUParticleSystem
  60955. * Gets or sets a boolean indicating that ramp gradients must be used
  60956. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60957. */
  60958. useRampGradients: boolean;
  60959. /**
  60960. * Not supported by GPUParticleSystem
  60961. * @param gradient defines the gradient to use (between 0 and 1)
  60962. * @param factor defines the life time factor to affect to the specified gradient
  60963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60964. * @returns the current particle system
  60965. */
  60966. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60967. /**
  60968. * Not supported by GPUParticleSystem
  60969. * @param gradient defines the gradient to remove
  60970. * @returns the current particle system
  60971. */
  60972. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60973. /**
  60974. * Instantiates a GPU particle system.
  60975. * 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.
  60976. * @param name The name of the particle system
  60977. * @param options The options used to create the system
  60978. * @param scene The scene the particle system belongs to
  60979. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60980. */
  60981. constructor(name: string, options: Partial<{
  60982. capacity: number;
  60983. randomTextureSize: number;
  60984. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60985. protected _reset(): void;
  60986. private _createUpdateVAO;
  60987. private _createRenderVAO;
  60988. private _initialize;
  60989. /** @hidden */
  60990. _recreateUpdateEffect(): void;
  60991. /** @hidden */
  60992. _recreateRenderEffect(): void;
  60993. /**
  60994. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60995. * @param preWarm defines if we are in the pre-warmimg phase
  60996. */
  60997. animate(preWarm?: boolean): void;
  60998. private _createFactorGradientTexture;
  60999. private _createSizeGradientTexture;
  61000. private _createAngularSpeedGradientTexture;
  61001. private _createVelocityGradientTexture;
  61002. private _createLimitVelocityGradientTexture;
  61003. private _createDragGradientTexture;
  61004. private _createColorGradientTexture;
  61005. /**
  61006. * Renders the particle system in its current state
  61007. * @param preWarm defines if the system should only update the particles but not render them
  61008. * @returns the current number of particles
  61009. */
  61010. render(preWarm?: boolean): number;
  61011. /**
  61012. * Rebuilds the particle system
  61013. */
  61014. rebuild(): void;
  61015. private _releaseBuffers;
  61016. private _releaseVAOs;
  61017. /**
  61018. * Disposes the particle system and free the associated resources
  61019. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61020. */
  61021. dispose(disposeTexture?: boolean): void;
  61022. /**
  61023. * Clones the particle system.
  61024. * @param name The name of the cloned object
  61025. * @param newEmitter The new emitter to use
  61026. * @returns the cloned particle system
  61027. */
  61028. clone(name: string, newEmitter: any): GPUParticleSystem;
  61029. /**
  61030. * Serializes the particle system to a JSON object.
  61031. * @returns the JSON object
  61032. */
  61033. serialize(): any;
  61034. /**
  61035. * Parses a JSON object to create a GPU particle system.
  61036. * @param parsedParticleSystem The JSON object to parse
  61037. * @param scene The scene to create the particle system in
  61038. * @param rootUrl The root url to use to load external dependencies like texture
  61039. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61040. * @returns the parsed GPU particle system
  61041. */
  61042. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61043. }
  61044. }
  61045. declare module "babylonjs/Particles/particleSystemSet" {
  61046. import { Nullable } from "babylonjs/types";
  61047. import { Color3 } from "babylonjs/Maths/math.color";
  61048. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61050. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61051. import { Scene, IDisposable } from "babylonjs/scene";
  61052. /**
  61053. * Represents a set of particle systems working together to create a specific effect
  61054. */
  61055. export class ParticleSystemSet implements IDisposable {
  61056. private _emitterCreationOptions;
  61057. private _emitterNode;
  61058. /**
  61059. * Gets the particle system list
  61060. */
  61061. systems: IParticleSystem[];
  61062. /**
  61063. * Gets the emitter node used with this set
  61064. */
  61065. readonly emitterNode: Nullable<TransformNode>;
  61066. /**
  61067. * Creates a new emitter mesh as a sphere
  61068. * @param options defines the options used to create the sphere
  61069. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61070. * @param scene defines the hosting scene
  61071. */
  61072. setEmitterAsSphere(options: {
  61073. diameter: number;
  61074. segments: number;
  61075. color: Color3;
  61076. }, renderingGroupId: number, scene: Scene): void;
  61077. /**
  61078. * Starts all particle systems of the set
  61079. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61080. */
  61081. start(emitter?: AbstractMesh): void;
  61082. /**
  61083. * Release all associated resources
  61084. */
  61085. dispose(): void;
  61086. /**
  61087. * Serialize the set into a JSON compatible object
  61088. * @returns a JSON compatible representation of the set
  61089. */
  61090. serialize(): any;
  61091. /**
  61092. * Parse a new ParticleSystemSet from a serialized source
  61093. * @param data defines a JSON compatible representation of the set
  61094. * @param scene defines the hosting scene
  61095. * @param gpu defines if we want GPU particles or CPU particles
  61096. * @returns a new ParticleSystemSet
  61097. */
  61098. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61099. }
  61100. }
  61101. declare module "babylonjs/Particles/particleHelper" {
  61102. import { Nullable } from "babylonjs/types";
  61103. import { Scene } from "babylonjs/scene";
  61104. import { Vector3 } from "babylonjs/Maths/math.vector";
  61105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61106. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61107. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61108. /**
  61109. * This class is made for on one-liner static method to help creating particle system set.
  61110. */
  61111. export class ParticleHelper {
  61112. /**
  61113. * Gets or sets base Assets URL
  61114. */
  61115. static BaseAssetsUrl: string;
  61116. /**
  61117. * Create a default particle system that you can tweak
  61118. * @param emitter defines the emitter to use
  61119. * @param capacity defines the system capacity (default is 500 particles)
  61120. * @param scene defines the hosting scene
  61121. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61122. * @returns the new Particle system
  61123. */
  61124. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61125. /**
  61126. * This is the main static method (one-liner) of this helper to create different particle systems
  61127. * @param type This string represents the type to the particle system to create
  61128. * @param scene The scene where the particle system should live
  61129. * @param gpu If the system will use gpu
  61130. * @returns the ParticleSystemSet created
  61131. */
  61132. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61133. /**
  61134. * Static function used to export a particle system to a ParticleSystemSet variable.
  61135. * Please note that the emitter shape is not exported
  61136. * @param systems defines the particle systems to export
  61137. * @returns the created particle system set
  61138. */
  61139. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61140. }
  61141. }
  61142. declare module "babylonjs/Particles/particleSystemComponent" {
  61143. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61144. import { Effect } from "babylonjs/Materials/effect";
  61145. import "babylonjs/Shaders/particles.vertex";
  61146. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61147. module "babylonjs/Engines/engine" {
  61148. interface Engine {
  61149. /**
  61150. * Create an effect to use with particle systems.
  61151. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61152. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61153. * @param uniformsNames defines a list of attribute names
  61154. * @param samplers defines an array of string used to represent textures
  61155. * @param defines defines the string containing the defines to use to compile the shaders
  61156. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61157. * @param onCompiled defines a function to call when the effect creation is successful
  61158. * @param onError defines a function to call when the effect creation has failed
  61159. * @returns the new Effect
  61160. */
  61161. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61162. }
  61163. }
  61164. module "babylonjs/Meshes/mesh" {
  61165. interface Mesh {
  61166. /**
  61167. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61168. * @returns an array of IParticleSystem
  61169. */
  61170. getEmittedParticleSystems(): IParticleSystem[];
  61171. /**
  61172. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61173. * @returns an array of IParticleSystem
  61174. */
  61175. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61176. }
  61177. }
  61178. /**
  61179. * @hidden
  61180. */
  61181. export var _IDoNeedToBeInTheBuild: number;
  61182. }
  61183. declare module "babylonjs/Particles/index" {
  61184. export * from "babylonjs/Particles/baseParticleSystem";
  61185. export * from "babylonjs/Particles/EmitterTypes/index";
  61186. export * from "babylonjs/Particles/gpuParticleSystem";
  61187. export * from "babylonjs/Particles/IParticleSystem";
  61188. export * from "babylonjs/Particles/particle";
  61189. export * from "babylonjs/Particles/particleHelper";
  61190. export * from "babylonjs/Particles/particleSystem";
  61191. export * from "babylonjs/Particles/particleSystemComponent";
  61192. export * from "babylonjs/Particles/particleSystemSet";
  61193. export * from "babylonjs/Particles/solidParticle";
  61194. export * from "babylonjs/Particles/solidParticleSystem";
  61195. export * from "babylonjs/Particles/subEmitter";
  61196. }
  61197. declare module "babylonjs/Physics/physicsEngineComponent" {
  61198. import { Nullable } from "babylonjs/types";
  61199. import { Observable, Observer } from "babylonjs/Misc/observable";
  61200. import { Vector3 } from "babylonjs/Maths/math.vector";
  61201. import { Mesh } from "babylonjs/Meshes/mesh";
  61202. import { ISceneComponent } from "babylonjs/sceneComponent";
  61203. import { Scene } from "babylonjs/scene";
  61204. import { Node } from "babylonjs/node";
  61205. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61206. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61207. module "babylonjs/scene" {
  61208. interface Scene {
  61209. /** @hidden (Backing field) */
  61210. _physicsEngine: Nullable<IPhysicsEngine>;
  61211. /**
  61212. * Gets the current physics engine
  61213. * @returns a IPhysicsEngine or null if none attached
  61214. */
  61215. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61216. /**
  61217. * Enables physics to the current scene
  61218. * @param gravity defines the scene's gravity for the physics engine
  61219. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61220. * @return a boolean indicating if the physics engine was initialized
  61221. */
  61222. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61223. /**
  61224. * Disables and disposes the physics engine associated with the scene
  61225. */
  61226. disablePhysicsEngine(): void;
  61227. /**
  61228. * Gets a boolean indicating if there is an active physics engine
  61229. * @returns a boolean indicating if there is an active physics engine
  61230. */
  61231. isPhysicsEnabled(): boolean;
  61232. /**
  61233. * Deletes a physics compound impostor
  61234. * @param compound defines the compound to delete
  61235. */
  61236. deleteCompoundImpostor(compound: any): void;
  61237. /**
  61238. * An event triggered when physic simulation is about to be run
  61239. */
  61240. onBeforePhysicsObservable: Observable<Scene>;
  61241. /**
  61242. * An event triggered when physic simulation has been done
  61243. */
  61244. onAfterPhysicsObservable: Observable<Scene>;
  61245. }
  61246. }
  61247. module "babylonjs/Meshes/abstractMesh" {
  61248. interface AbstractMesh {
  61249. /** @hidden */
  61250. _physicsImpostor: Nullable<PhysicsImpostor>;
  61251. /**
  61252. * Gets or sets impostor used for physic simulation
  61253. * @see http://doc.babylonjs.com/features/physics_engine
  61254. */
  61255. physicsImpostor: Nullable<PhysicsImpostor>;
  61256. /**
  61257. * Gets the current physics impostor
  61258. * @see http://doc.babylonjs.com/features/physics_engine
  61259. * @returns a physics impostor or null
  61260. */
  61261. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61262. /** Apply a physic impulse to the mesh
  61263. * @param force defines the force to apply
  61264. * @param contactPoint defines where to apply the force
  61265. * @returns the current mesh
  61266. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61267. */
  61268. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61269. /**
  61270. * Creates a physic joint between two meshes
  61271. * @param otherMesh defines the other mesh to use
  61272. * @param pivot1 defines the pivot to use on this mesh
  61273. * @param pivot2 defines the pivot to use on the other mesh
  61274. * @param options defines additional options (can be plugin dependent)
  61275. * @returns the current mesh
  61276. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61277. */
  61278. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61279. /** @hidden */
  61280. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61281. }
  61282. }
  61283. /**
  61284. * Defines the physics engine scene component responsible to manage a physics engine
  61285. */
  61286. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61287. /**
  61288. * The component name helpful to identify the component in the list of scene components.
  61289. */
  61290. readonly name: string;
  61291. /**
  61292. * The scene the component belongs to.
  61293. */
  61294. scene: Scene;
  61295. /**
  61296. * Creates a new instance of the component for the given scene
  61297. * @param scene Defines the scene to register the component in
  61298. */
  61299. constructor(scene: Scene);
  61300. /**
  61301. * Registers the component in a given scene
  61302. */
  61303. register(): void;
  61304. /**
  61305. * Rebuilds the elements related to this component in case of
  61306. * context lost for instance.
  61307. */
  61308. rebuild(): void;
  61309. /**
  61310. * Disposes the component and the associated ressources
  61311. */
  61312. dispose(): void;
  61313. }
  61314. }
  61315. declare module "babylonjs/Physics/physicsHelper" {
  61316. import { Nullable } from "babylonjs/types";
  61317. import { Vector3 } from "babylonjs/Maths/math.vector";
  61318. import { Mesh } from "babylonjs/Meshes/mesh";
  61319. import { Scene } from "babylonjs/scene";
  61320. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61321. /**
  61322. * A helper for physics simulations
  61323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61324. */
  61325. export class PhysicsHelper {
  61326. private _scene;
  61327. private _physicsEngine;
  61328. /**
  61329. * Initializes the Physics helper
  61330. * @param scene Babylon.js scene
  61331. */
  61332. constructor(scene: Scene);
  61333. /**
  61334. * Applies a radial explosion impulse
  61335. * @param origin the origin of the explosion
  61336. * @param radiusOrEventOptions the radius or the options of radial explosion
  61337. * @param strength the explosion strength
  61338. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61339. * @returns A physics radial explosion event, or null
  61340. */
  61341. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61342. /**
  61343. * Applies a radial explosion force
  61344. * @param origin the origin of the explosion
  61345. * @param radiusOrEventOptions the radius or the options of radial explosion
  61346. * @param strength the explosion strength
  61347. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61348. * @returns A physics radial explosion event, or null
  61349. */
  61350. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61351. /**
  61352. * Creates a gravitational field
  61353. * @param origin the origin of the explosion
  61354. * @param radiusOrEventOptions the radius or the options of radial explosion
  61355. * @param strength the explosion strength
  61356. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61357. * @returns A physics gravitational field event, or null
  61358. */
  61359. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61360. /**
  61361. * Creates a physics updraft event
  61362. * @param origin the origin of the updraft
  61363. * @param radiusOrEventOptions the radius or the options of the updraft
  61364. * @param strength the strength of the updraft
  61365. * @param height the height of the updraft
  61366. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61367. * @returns A physics updraft event, or null
  61368. */
  61369. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61370. /**
  61371. * Creates a physics vortex event
  61372. * @param origin the of the vortex
  61373. * @param radiusOrEventOptions the radius or the options of the vortex
  61374. * @param strength the strength of the vortex
  61375. * @param height the height of the vortex
  61376. * @returns a Physics vortex event, or null
  61377. * A physics vortex event or null
  61378. */
  61379. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61380. }
  61381. /**
  61382. * Represents a physics radial explosion event
  61383. */
  61384. class PhysicsRadialExplosionEvent {
  61385. private _scene;
  61386. private _options;
  61387. private _sphere;
  61388. private _dataFetched;
  61389. /**
  61390. * Initializes a radial explosioin event
  61391. * @param _scene BabylonJS scene
  61392. * @param _options The options for the vortex event
  61393. */
  61394. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61395. /**
  61396. * Returns the data related to the radial explosion event (sphere).
  61397. * @returns The radial explosion event data
  61398. */
  61399. getData(): PhysicsRadialExplosionEventData;
  61400. /**
  61401. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61402. * @param impostor A physics imposter
  61403. * @param origin the origin of the explosion
  61404. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61405. */
  61406. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61407. /**
  61408. * Triggers affecterd impostors callbacks
  61409. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61410. */
  61411. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61412. /**
  61413. * Disposes the sphere.
  61414. * @param force Specifies if the sphere should be disposed by force
  61415. */
  61416. dispose(force?: boolean): void;
  61417. /*** Helpers ***/
  61418. private _prepareSphere;
  61419. private _intersectsWithSphere;
  61420. }
  61421. /**
  61422. * Represents a gravitational field event
  61423. */
  61424. class PhysicsGravitationalFieldEvent {
  61425. private _physicsHelper;
  61426. private _scene;
  61427. private _origin;
  61428. private _options;
  61429. private _tickCallback;
  61430. private _sphere;
  61431. private _dataFetched;
  61432. /**
  61433. * Initializes the physics gravitational field event
  61434. * @param _physicsHelper A physics helper
  61435. * @param _scene BabylonJS scene
  61436. * @param _origin The origin position of the gravitational field event
  61437. * @param _options The options for the vortex event
  61438. */
  61439. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61440. /**
  61441. * Returns the data related to the gravitational field event (sphere).
  61442. * @returns A gravitational field event
  61443. */
  61444. getData(): PhysicsGravitationalFieldEventData;
  61445. /**
  61446. * Enables the gravitational field.
  61447. */
  61448. enable(): void;
  61449. /**
  61450. * Disables the gravitational field.
  61451. */
  61452. disable(): void;
  61453. /**
  61454. * Disposes the sphere.
  61455. * @param force The force to dispose from the gravitational field event
  61456. */
  61457. dispose(force?: boolean): void;
  61458. private _tick;
  61459. }
  61460. /**
  61461. * Represents a physics updraft event
  61462. */
  61463. class PhysicsUpdraftEvent {
  61464. private _scene;
  61465. private _origin;
  61466. private _options;
  61467. private _physicsEngine;
  61468. private _originTop;
  61469. private _originDirection;
  61470. private _tickCallback;
  61471. private _cylinder;
  61472. private _cylinderPosition;
  61473. private _dataFetched;
  61474. /**
  61475. * Initializes the physics updraft event
  61476. * @param _scene BabylonJS scene
  61477. * @param _origin The origin position of the updraft
  61478. * @param _options The options for the updraft event
  61479. */
  61480. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61481. /**
  61482. * Returns the data related to the updraft event (cylinder).
  61483. * @returns A physics updraft event
  61484. */
  61485. getData(): PhysicsUpdraftEventData;
  61486. /**
  61487. * Enables the updraft.
  61488. */
  61489. enable(): void;
  61490. /**
  61491. * Disables the updraft.
  61492. */
  61493. disable(): void;
  61494. /**
  61495. * Disposes the cylinder.
  61496. * @param force Specifies if the updraft should be disposed by force
  61497. */
  61498. dispose(force?: boolean): void;
  61499. private getImpostorHitData;
  61500. private _tick;
  61501. /*** Helpers ***/
  61502. private _prepareCylinder;
  61503. private _intersectsWithCylinder;
  61504. }
  61505. /**
  61506. * Represents a physics vortex event
  61507. */
  61508. class PhysicsVortexEvent {
  61509. private _scene;
  61510. private _origin;
  61511. private _options;
  61512. private _physicsEngine;
  61513. private _originTop;
  61514. private _tickCallback;
  61515. private _cylinder;
  61516. private _cylinderPosition;
  61517. private _dataFetched;
  61518. /**
  61519. * Initializes the physics vortex event
  61520. * @param _scene The BabylonJS scene
  61521. * @param _origin The origin position of the vortex
  61522. * @param _options The options for the vortex event
  61523. */
  61524. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61525. /**
  61526. * Returns the data related to the vortex event (cylinder).
  61527. * @returns The physics vortex event data
  61528. */
  61529. getData(): PhysicsVortexEventData;
  61530. /**
  61531. * Enables the vortex.
  61532. */
  61533. enable(): void;
  61534. /**
  61535. * Disables the cortex.
  61536. */
  61537. disable(): void;
  61538. /**
  61539. * Disposes the sphere.
  61540. * @param force
  61541. */
  61542. dispose(force?: boolean): void;
  61543. private getImpostorHitData;
  61544. private _tick;
  61545. /*** Helpers ***/
  61546. private _prepareCylinder;
  61547. private _intersectsWithCylinder;
  61548. }
  61549. /**
  61550. * Options fot the radial explosion event
  61551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61552. */
  61553. export class PhysicsRadialExplosionEventOptions {
  61554. /**
  61555. * The radius of the sphere for the radial explosion.
  61556. */
  61557. radius: number;
  61558. /**
  61559. * The strenth of the explosion.
  61560. */
  61561. strength: number;
  61562. /**
  61563. * The strenght of the force in correspondence to the distance of the affected object
  61564. */
  61565. falloff: PhysicsRadialImpulseFalloff;
  61566. /**
  61567. * Sphere options for the radial explosion.
  61568. */
  61569. sphere: {
  61570. segments: number;
  61571. diameter: number;
  61572. };
  61573. /**
  61574. * Sphere options for the radial explosion.
  61575. */
  61576. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61577. }
  61578. /**
  61579. * Options fot the updraft event
  61580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61581. */
  61582. export class PhysicsUpdraftEventOptions {
  61583. /**
  61584. * The radius of the cylinder for the vortex
  61585. */
  61586. radius: number;
  61587. /**
  61588. * The strenth of the updraft.
  61589. */
  61590. strength: number;
  61591. /**
  61592. * The height of the cylinder for the updraft.
  61593. */
  61594. height: number;
  61595. /**
  61596. * The mode for the the updraft.
  61597. */
  61598. updraftMode: PhysicsUpdraftMode;
  61599. }
  61600. /**
  61601. * Options fot the vortex event
  61602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61603. */
  61604. export class PhysicsVortexEventOptions {
  61605. /**
  61606. * The radius of the cylinder for the vortex
  61607. */
  61608. radius: number;
  61609. /**
  61610. * The strenth of the vortex.
  61611. */
  61612. strength: number;
  61613. /**
  61614. * The height of the cylinder for the vortex.
  61615. */
  61616. height: number;
  61617. /**
  61618. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61619. */
  61620. centripetalForceThreshold: number;
  61621. /**
  61622. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61623. */
  61624. centripetalForceMultiplier: number;
  61625. /**
  61626. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61627. */
  61628. centrifugalForceMultiplier: number;
  61629. /**
  61630. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61631. */
  61632. updraftForceMultiplier: number;
  61633. }
  61634. /**
  61635. * The strenght of the force in correspondence to the distance of the affected object
  61636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61637. */
  61638. export enum PhysicsRadialImpulseFalloff {
  61639. /** Defines that impulse is constant in strength across it's whole radius */
  61640. Constant = 0,
  61641. /** Defines that impulse gets weaker if it's further from the origin */
  61642. Linear = 1
  61643. }
  61644. /**
  61645. * The strength of the force in correspondence to the distance of the affected object
  61646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61647. */
  61648. export enum PhysicsUpdraftMode {
  61649. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61650. Center = 0,
  61651. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61652. Perpendicular = 1
  61653. }
  61654. /**
  61655. * Interface for a physics hit data
  61656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61657. */
  61658. export interface PhysicsHitData {
  61659. /**
  61660. * The force applied at the contact point
  61661. */
  61662. force: Vector3;
  61663. /**
  61664. * The contact point
  61665. */
  61666. contactPoint: Vector3;
  61667. /**
  61668. * The distance from the origin to the contact point
  61669. */
  61670. distanceFromOrigin: number;
  61671. }
  61672. /**
  61673. * Interface for radial explosion event data
  61674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61675. */
  61676. export interface PhysicsRadialExplosionEventData {
  61677. /**
  61678. * A sphere used for the radial explosion event
  61679. */
  61680. sphere: Mesh;
  61681. }
  61682. /**
  61683. * Interface for gravitational field event data
  61684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61685. */
  61686. export interface PhysicsGravitationalFieldEventData {
  61687. /**
  61688. * A sphere mesh used for the gravitational field event
  61689. */
  61690. sphere: Mesh;
  61691. }
  61692. /**
  61693. * Interface for updraft event data
  61694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61695. */
  61696. export interface PhysicsUpdraftEventData {
  61697. /**
  61698. * A cylinder used for the updraft event
  61699. */
  61700. cylinder: Mesh;
  61701. }
  61702. /**
  61703. * Interface for vortex event data
  61704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61705. */
  61706. export interface PhysicsVortexEventData {
  61707. /**
  61708. * A cylinder used for the vortex event
  61709. */
  61710. cylinder: Mesh;
  61711. }
  61712. /**
  61713. * Interface for an affected physics impostor
  61714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61715. */
  61716. export interface PhysicsAffectedImpostorWithData {
  61717. /**
  61718. * The impostor affected by the effect
  61719. */
  61720. impostor: PhysicsImpostor;
  61721. /**
  61722. * The data about the hit/horce from the explosion
  61723. */
  61724. hitData: PhysicsHitData;
  61725. }
  61726. }
  61727. declare module "babylonjs/Physics/Plugins/index" {
  61728. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61729. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61730. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61731. }
  61732. declare module "babylonjs/Physics/index" {
  61733. export * from "babylonjs/Physics/IPhysicsEngine";
  61734. export * from "babylonjs/Physics/physicsEngine";
  61735. export * from "babylonjs/Physics/physicsEngineComponent";
  61736. export * from "babylonjs/Physics/physicsHelper";
  61737. export * from "babylonjs/Physics/physicsImpostor";
  61738. export * from "babylonjs/Physics/physicsJoint";
  61739. export * from "babylonjs/Physics/Plugins/index";
  61740. }
  61741. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61742. /** @hidden */
  61743. export var blackAndWhitePixelShader: {
  61744. name: string;
  61745. shader: string;
  61746. };
  61747. }
  61748. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61749. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61750. import { Camera } from "babylonjs/Cameras/camera";
  61751. import { Engine } from "babylonjs/Engines/engine";
  61752. import "babylonjs/Shaders/blackAndWhite.fragment";
  61753. /**
  61754. * Post process used to render in black and white
  61755. */
  61756. export class BlackAndWhitePostProcess extends PostProcess {
  61757. /**
  61758. * Linear about to convert he result to black and white (default: 1)
  61759. */
  61760. degree: number;
  61761. /**
  61762. * Creates a black and white post process
  61763. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61764. * @param name The name of the effect.
  61765. * @param options The required width/height ratio to downsize to before computing the render pass.
  61766. * @param camera The camera to apply the render pass to.
  61767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61768. * @param engine The engine which the post process will be applied. (default: current engine)
  61769. * @param reusable If the post process can be reused on the same frame. (default: false)
  61770. */
  61771. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61772. }
  61773. }
  61774. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61775. import { Nullable } from "babylonjs/types";
  61776. import { Camera } from "babylonjs/Cameras/camera";
  61777. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61778. import { Engine } from "babylonjs/Engines/engine";
  61779. /**
  61780. * This represents a set of one or more post processes in Babylon.
  61781. * A post process can be used to apply a shader to a texture after it is rendered.
  61782. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61783. */
  61784. export class PostProcessRenderEffect {
  61785. private _postProcesses;
  61786. private _getPostProcesses;
  61787. private _singleInstance;
  61788. private _cameras;
  61789. private _indicesForCamera;
  61790. /**
  61791. * Name of the effect
  61792. * @hidden
  61793. */
  61794. _name: string;
  61795. /**
  61796. * Instantiates a post process render effect.
  61797. * A post process can be used to apply a shader to a texture after it is rendered.
  61798. * @param engine The engine the effect is tied to
  61799. * @param name The name of the effect
  61800. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61801. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61802. */
  61803. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61804. /**
  61805. * Checks if all the post processes in the effect are supported.
  61806. */
  61807. readonly isSupported: boolean;
  61808. /**
  61809. * Updates the current state of the effect
  61810. * @hidden
  61811. */
  61812. _update(): void;
  61813. /**
  61814. * Attaches the effect on cameras
  61815. * @param cameras The camera to attach to.
  61816. * @hidden
  61817. */
  61818. _attachCameras(cameras: Camera): void;
  61819. /**
  61820. * Attaches the effect on cameras
  61821. * @param cameras The camera to attach to.
  61822. * @hidden
  61823. */
  61824. _attachCameras(cameras: Camera[]): void;
  61825. /**
  61826. * Detaches the effect on cameras
  61827. * @param cameras The camera to detatch from.
  61828. * @hidden
  61829. */
  61830. _detachCameras(cameras: Camera): void;
  61831. /**
  61832. * Detatches the effect on cameras
  61833. * @param cameras The camera to detatch from.
  61834. * @hidden
  61835. */
  61836. _detachCameras(cameras: Camera[]): void;
  61837. /**
  61838. * Enables the effect on given cameras
  61839. * @param cameras The camera to enable.
  61840. * @hidden
  61841. */
  61842. _enable(cameras: Camera): void;
  61843. /**
  61844. * Enables the effect on given cameras
  61845. * @param cameras The camera to enable.
  61846. * @hidden
  61847. */
  61848. _enable(cameras: Nullable<Camera[]>): void;
  61849. /**
  61850. * Disables the effect on the given cameras
  61851. * @param cameras The camera to disable.
  61852. * @hidden
  61853. */
  61854. _disable(cameras: Camera): void;
  61855. /**
  61856. * Disables the effect on the given cameras
  61857. * @param cameras The camera to disable.
  61858. * @hidden
  61859. */
  61860. _disable(cameras: Nullable<Camera[]>): void;
  61861. /**
  61862. * Gets a list of the post processes contained in the effect.
  61863. * @param camera The camera to get the post processes on.
  61864. * @returns The list of the post processes in the effect.
  61865. */
  61866. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61867. }
  61868. }
  61869. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61870. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61871. /** @hidden */
  61872. export var extractHighlightsPixelShader: {
  61873. name: string;
  61874. shader: string;
  61875. };
  61876. }
  61877. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61878. import { Nullable } from "babylonjs/types";
  61879. import { Camera } from "babylonjs/Cameras/camera";
  61880. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61881. import { Engine } from "babylonjs/Engines/engine";
  61882. import "babylonjs/Shaders/extractHighlights.fragment";
  61883. /**
  61884. * 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.
  61885. */
  61886. export class ExtractHighlightsPostProcess extends PostProcess {
  61887. /**
  61888. * The luminance threshold, pixels below this value will be set to black.
  61889. */
  61890. threshold: number;
  61891. /** @hidden */
  61892. _exposure: number;
  61893. /**
  61894. * Post process which has the input texture to be used when performing highlight extraction
  61895. * @hidden
  61896. */
  61897. _inputPostProcess: Nullable<PostProcess>;
  61898. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61899. }
  61900. }
  61901. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61902. /** @hidden */
  61903. export var bloomMergePixelShader: {
  61904. name: string;
  61905. shader: string;
  61906. };
  61907. }
  61908. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61910. import { Nullable } from "babylonjs/types";
  61911. import { Engine } from "babylonjs/Engines/engine";
  61912. import { Camera } from "babylonjs/Cameras/camera";
  61913. import "babylonjs/Shaders/bloomMerge.fragment";
  61914. /**
  61915. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61916. */
  61917. export class BloomMergePostProcess extends PostProcess {
  61918. /** Weight of the bloom to be added to the original input. */
  61919. weight: number;
  61920. /**
  61921. * Creates a new instance of @see BloomMergePostProcess
  61922. * @param name The name of the effect.
  61923. * @param originalFromInput Post process which's input will be used for the merge.
  61924. * @param blurred Blurred highlights post process which's output will be used.
  61925. * @param weight Weight of the bloom to be added to the original input.
  61926. * @param options The required width/height ratio to downsize to before computing the render pass.
  61927. * @param camera The camera to apply the render pass to.
  61928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61929. * @param engine The engine which the post process will be applied. (default: current engine)
  61930. * @param reusable If the post process can be reused on the same frame. (default: false)
  61931. * @param textureType Type of textures used when performing the post process. (default: 0)
  61932. * @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)
  61933. */
  61934. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61935. /** Weight of the bloom to be added to the original input. */
  61936. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61937. }
  61938. }
  61939. declare module "babylonjs/PostProcesses/bloomEffect" {
  61940. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61941. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61942. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61943. import { Camera } from "babylonjs/Cameras/camera";
  61944. import { Scene } from "babylonjs/scene";
  61945. /**
  61946. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61947. */
  61948. export class BloomEffect extends PostProcessRenderEffect {
  61949. private bloomScale;
  61950. /**
  61951. * @hidden Internal
  61952. */
  61953. _effects: Array<PostProcess>;
  61954. /**
  61955. * @hidden Internal
  61956. */
  61957. _downscale: ExtractHighlightsPostProcess;
  61958. private _blurX;
  61959. private _blurY;
  61960. private _merge;
  61961. /**
  61962. * The luminance threshold to find bright areas of the image to bloom.
  61963. */
  61964. threshold: number;
  61965. /**
  61966. * The strength of the bloom.
  61967. */
  61968. weight: number;
  61969. /**
  61970. * Specifies the size of the bloom blur kernel, relative to the final output size
  61971. */
  61972. kernel: number;
  61973. /**
  61974. * Creates a new instance of @see BloomEffect
  61975. * @param scene The scene the effect belongs to.
  61976. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61977. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61978. * @param bloomWeight The the strength of bloom.
  61979. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61980. * @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)
  61981. */
  61982. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61983. /**
  61984. * Disposes each of the internal effects for a given camera.
  61985. * @param camera The camera to dispose the effect on.
  61986. */
  61987. disposeEffects(camera: Camera): void;
  61988. /**
  61989. * @hidden Internal
  61990. */
  61991. _updateEffects(): void;
  61992. /**
  61993. * Internal
  61994. * @returns if all the contained post processes are ready.
  61995. * @hidden
  61996. */
  61997. _isReady(): boolean;
  61998. }
  61999. }
  62000. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62001. /** @hidden */
  62002. export var chromaticAberrationPixelShader: {
  62003. name: string;
  62004. shader: string;
  62005. };
  62006. }
  62007. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62008. import { Vector2 } from "babylonjs/Maths/math.vector";
  62009. import { Nullable } from "babylonjs/types";
  62010. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62011. import { Camera } from "babylonjs/Cameras/camera";
  62012. import { Engine } from "babylonjs/Engines/engine";
  62013. import "babylonjs/Shaders/chromaticAberration.fragment";
  62014. /**
  62015. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62016. */
  62017. export class ChromaticAberrationPostProcess extends PostProcess {
  62018. /**
  62019. * The amount of seperation of rgb channels (default: 30)
  62020. */
  62021. aberrationAmount: number;
  62022. /**
  62023. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62024. */
  62025. radialIntensity: number;
  62026. /**
  62027. * 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))
  62028. */
  62029. direction: Vector2;
  62030. /**
  62031. * 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))
  62032. */
  62033. centerPosition: Vector2;
  62034. /**
  62035. * Creates a new instance ChromaticAberrationPostProcess
  62036. * @param name The name of the effect.
  62037. * @param screenWidth The width of the screen to apply the effect on.
  62038. * @param screenHeight The height of the screen to apply the effect on.
  62039. * @param options The required width/height ratio to downsize to before computing the render pass.
  62040. * @param camera The camera to apply the render pass to.
  62041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62042. * @param engine The engine which the post process will be applied. (default: current engine)
  62043. * @param reusable If the post process can be reused on the same frame. (default: false)
  62044. * @param textureType Type of textures used when performing the post process. (default: 0)
  62045. * @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)
  62046. */
  62047. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62048. }
  62049. }
  62050. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62051. /** @hidden */
  62052. export var circleOfConfusionPixelShader: {
  62053. name: string;
  62054. shader: string;
  62055. };
  62056. }
  62057. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62058. import { Nullable } from "babylonjs/types";
  62059. import { Engine } from "babylonjs/Engines/engine";
  62060. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62061. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62062. import { Camera } from "babylonjs/Cameras/camera";
  62063. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62064. /**
  62065. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62066. */
  62067. export class CircleOfConfusionPostProcess extends PostProcess {
  62068. /**
  62069. * 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.
  62070. */
  62071. lensSize: number;
  62072. /**
  62073. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62074. */
  62075. fStop: number;
  62076. /**
  62077. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62078. */
  62079. focusDistance: number;
  62080. /**
  62081. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62082. */
  62083. focalLength: number;
  62084. private _depthTexture;
  62085. /**
  62086. * Creates a new instance CircleOfConfusionPostProcess
  62087. * @param name The name of the effect.
  62088. * @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.
  62089. * @param options The required width/height ratio to downsize to before computing the render pass.
  62090. * @param camera The camera to apply the render pass to.
  62091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62092. * @param engine The engine which the post process will be applied. (default: current engine)
  62093. * @param reusable If the post process can be reused on the same frame. (default: false)
  62094. * @param textureType Type of textures used when performing the post process. (default: 0)
  62095. * @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)
  62096. */
  62097. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62098. /**
  62099. * 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.
  62100. */
  62101. depthTexture: RenderTargetTexture;
  62102. }
  62103. }
  62104. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62105. /** @hidden */
  62106. export var colorCorrectionPixelShader: {
  62107. name: string;
  62108. shader: string;
  62109. };
  62110. }
  62111. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62112. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62113. import { Engine } from "babylonjs/Engines/engine";
  62114. import { Camera } from "babylonjs/Cameras/camera";
  62115. import "babylonjs/Shaders/colorCorrection.fragment";
  62116. /**
  62117. *
  62118. * This post-process allows the modification of rendered colors by using
  62119. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62120. *
  62121. * The object needs to be provided an url to a texture containing the color
  62122. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62123. * Use an image editing software to tweak the LUT to match your needs.
  62124. *
  62125. * For an example of a color LUT, see here:
  62126. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62127. * For explanations on color grading, see here:
  62128. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62129. *
  62130. */
  62131. export class ColorCorrectionPostProcess extends PostProcess {
  62132. private _colorTableTexture;
  62133. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62134. }
  62135. }
  62136. declare module "babylonjs/Shaders/convolution.fragment" {
  62137. /** @hidden */
  62138. export var convolutionPixelShader: {
  62139. name: string;
  62140. shader: string;
  62141. };
  62142. }
  62143. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62145. import { Nullable } from "babylonjs/types";
  62146. import { Camera } from "babylonjs/Cameras/camera";
  62147. import { Engine } from "babylonjs/Engines/engine";
  62148. import "babylonjs/Shaders/convolution.fragment";
  62149. /**
  62150. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62151. * input texture to perform effects such as edge detection or sharpening
  62152. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62153. */
  62154. export class ConvolutionPostProcess extends PostProcess {
  62155. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62156. kernel: number[];
  62157. /**
  62158. * Creates a new instance ConvolutionPostProcess
  62159. * @param name The name of the effect.
  62160. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62161. * @param options The required width/height ratio to downsize to before computing the render pass.
  62162. * @param camera The camera to apply the render pass to.
  62163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62164. * @param engine The engine which the post process will be applied. (default: current engine)
  62165. * @param reusable If the post process can be reused on the same frame. (default: false)
  62166. * @param textureType Type of textures used when performing the post process. (default: 0)
  62167. */
  62168. constructor(name: string,
  62169. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62170. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62171. /**
  62172. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62173. */
  62174. static EdgeDetect0Kernel: number[];
  62175. /**
  62176. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62177. */
  62178. static EdgeDetect1Kernel: number[];
  62179. /**
  62180. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62181. */
  62182. static EdgeDetect2Kernel: number[];
  62183. /**
  62184. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62185. */
  62186. static SharpenKernel: number[];
  62187. /**
  62188. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62189. */
  62190. static EmbossKernel: number[];
  62191. /**
  62192. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62193. */
  62194. static GaussianKernel: number[];
  62195. }
  62196. }
  62197. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62198. import { Nullable } from "babylonjs/types";
  62199. import { Vector2 } from "babylonjs/Maths/math.vector";
  62200. import { Camera } from "babylonjs/Cameras/camera";
  62201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62202. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62203. import { Engine } from "babylonjs/Engines/engine";
  62204. import { Scene } from "babylonjs/scene";
  62205. /**
  62206. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62207. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62208. * based on samples that have a large difference in distance than the center pixel.
  62209. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62210. */
  62211. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62212. direction: Vector2;
  62213. /**
  62214. * Creates a new instance CircleOfConfusionPostProcess
  62215. * @param name The name of the effect.
  62216. * @param scene The scene the effect belongs to.
  62217. * @param direction The direction the blur should be applied.
  62218. * @param kernel The size of the kernel used to blur.
  62219. * @param options The required width/height ratio to downsize to before computing the render pass.
  62220. * @param camera The camera to apply the render pass to.
  62221. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62222. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62224. * @param engine The engine which the post process will be applied. (default: current engine)
  62225. * @param reusable If the post process can be reused on the same frame. (default: false)
  62226. * @param textureType Type of textures used when performing the post process. (default: 0)
  62227. * @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)
  62228. */
  62229. 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);
  62230. }
  62231. }
  62232. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62233. /** @hidden */
  62234. export var depthOfFieldMergePixelShader: {
  62235. name: string;
  62236. shader: string;
  62237. };
  62238. }
  62239. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62240. import { Nullable } from "babylonjs/types";
  62241. import { Camera } from "babylonjs/Cameras/camera";
  62242. import { Effect } from "babylonjs/Materials/effect";
  62243. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62244. import { Engine } from "babylonjs/Engines/engine";
  62245. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62246. /**
  62247. * Options to be set when merging outputs from the default pipeline.
  62248. */
  62249. export class DepthOfFieldMergePostProcessOptions {
  62250. /**
  62251. * The original image to merge on top of
  62252. */
  62253. originalFromInput: PostProcess;
  62254. /**
  62255. * Parameters to perform the merge of the depth of field effect
  62256. */
  62257. depthOfField?: {
  62258. circleOfConfusion: PostProcess;
  62259. blurSteps: Array<PostProcess>;
  62260. };
  62261. /**
  62262. * Parameters to perform the merge of bloom effect
  62263. */
  62264. bloom?: {
  62265. blurred: PostProcess;
  62266. weight: number;
  62267. };
  62268. }
  62269. /**
  62270. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62271. */
  62272. export class DepthOfFieldMergePostProcess extends PostProcess {
  62273. private blurSteps;
  62274. /**
  62275. * Creates a new instance of DepthOfFieldMergePostProcess
  62276. * @param name The name of the effect.
  62277. * @param originalFromInput Post process which's input will be used for the merge.
  62278. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62279. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62280. * @param options The required width/height ratio to downsize to before computing the render pass.
  62281. * @param camera The camera to apply the render pass to.
  62282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62283. * @param engine The engine which the post process will be applied. (default: current engine)
  62284. * @param reusable If the post process can be reused on the same frame. (default: false)
  62285. * @param textureType Type of textures used when performing the post process. (default: 0)
  62286. * @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)
  62287. */
  62288. 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);
  62289. /**
  62290. * Updates the effect with the current post process compile time values and recompiles the shader.
  62291. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62292. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62293. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62294. * @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
  62295. * @param onCompiled Called when the shader has been compiled.
  62296. * @param onError Called if there is an error when compiling a shader.
  62297. */
  62298. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62299. }
  62300. }
  62301. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62302. import { Nullable } from "babylonjs/types";
  62303. import { Camera } from "babylonjs/Cameras/camera";
  62304. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62305. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62306. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62307. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62308. import { Scene } from "babylonjs/scene";
  62309. /**
  62310. * Specifies the level of max blur that should be applied when using the depth of field effect
  62311. */
  62312. export enum DepthOfFieldEffectBlurLevel {
  62313. /**
  62314. * Subtle blur
  62315. */
  62316. Low = 0,
  62317. /**
  62318. * Medium blur
  62319. */
  62320. Medium = 1,
  62321. /**
  62322. * Large blur
  62323. */
  62324. High = 2
  62325. }
  62326. /**
  62327. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62328. */
  62329. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62330. private _circleOfConfusion;
  62331. /**
  62332. * @hidden Internal, blurs from high to low
  62333. */
  62334. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62335. private _depthOfFieldBlurY;
  62336. private _dofMerge;
  62337. /**
  62338. * @hidden Internal post processes in depth of field effect
  62339. */
  62340. _effects: Array<PostProcess>;
  62341. /**
  62342. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62343. */
  62344. focalLength: number;
  62345. /**
  62346. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62347. */
  62348. fStop: number;
  62349. /**
  62350. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62351. */
  62352. focusDistance: number;
  62353. /**
  62354. * 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.
  62355. */
  62356. lensSize: number;
  62357. /**
  62358. * Creates a new instance DepthOfFieldEffect
  62359. * @param scene The scene the effect belongs to.
  62360. * @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.
  62361. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62362. * @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)
  62363. */
  62364. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62365. /**
  62366. * Get the current class name of the current effet
  62367. * @returns "DepthOfFieldEffect"
  62368. */
  62369. getClassName(): string;
  62370. /**
  62371. * 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.
  62372. */
  62373. depthTexture: RenderTargetTexture;
  62374. /**
  62375. * Disposes each of the internal effects for a given camera.
  62376. * @param camera The camera to dispose the effect on.
  62377. */
  62378. disposeEffects(camera: Camera): void;
  62379. /**
  62380. * @hidden Internal
  62381. */
  62382. _updateEffects(): void;
  62383. /**
  62384. * Internal
  62385. * @returns if all the contained post processes are ready.
  62386. * @hidden
  62387. */
  62388. _isReady(): boolean;
  62389. }
  62390. }
  62391. declare module "babylonjs/Shaders/displayPass.fragment" {
  62392. /** @hidden */
  62393. export var displayPassPixelShader: {
  62394. name: string;
  62395. shader: string;
  62396. };
  62397. }
  62398. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62399. import { Nullable } from "babylonjs/types";
  62400. import { Camera } from "babylonjs/Cameras/camera";
  62401. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62402. import { Engine } from "babylonjs/Engines/engine";
  62403. import "babylonjs/Shaders/displayPass.fragment";
  62404. /**
  62405. * DisplayPassPostProcess which produces an output the same as it's input
  62406. */
  62407. export class DisplayPassPostProcess extends PostProcess {
  62408. /**
  62409. * Creates the DisplayPassPostProcess
  62410. * @param name The name of the effect.
  62411. * @param options The required width/height ratio to downsize to before computing the render pass.
  62412. * @param camera The camera to apply the render pass to.
  62413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62414. * @param engine The engine which the post process will be applied. (default: current engine)
  62415. * @param reusable If the post process can be reused on the same frame. (default: false)
  62416. */
  62417. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62418. }
  62419. }
  62420. declare module "babylonjs/Shaders/filter.fragment" {
  62421. /** @hidden */
  62422. export var filterPixelShader: {
  62423. name: string;
  62424. shader: string;
  62425. };
  62426. }
  62427. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62428. import { Nullable } from "babylonjs/types";
  62429. import { Matrix } from "babylonjs/Maths/math.vector";
  62430. import { Camera } from "babylonjs/Cameras/camera";
  62431. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62432. import { Engine } from "babylonjs/Engines/engine";
  62433. import "babylonjs/Shaders/filter.fragment";
  62434. /**
  62435. * Applies a kernel filter to the image
  62436. */
  62437. export class FilterPostProcess extends PostProcess {
  62438. /** The matrix to be applied to the image */
  62439. kernelMatrix: Matrix;
  62440. /**
  62441. *
  62442. * @param name The name of the effect.
  62443. * @param kernelMatrix The matrix to be applied to the image
  62444. * @param options The required width/height ratio to downsize to before computing the render pass.
  62445. * @param camera The camera to apply the render pass to.
  62446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62447. * @param engine The engine which the post process will be applied. (default: current engine)
  62448. * @param reusable If the post process can be reused on the same frame. (default: false)
  62449. */
  62450. constructor(name: string,
  62451. /** The matrix to be applied to the image */
  62452. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62453. }
  62454. }
  62455. declare module "babylonjs/Shaders/fxaa.fragment" {
  62456. /** @hidden */
  62457. export var fxaaPixelShader: {
  62458. name: string;
  62459. shader: string;
  62460. };
  62461. }
  62462. declare module "babylonjs/Shaders/fxaa.vertex" {
  62463. /** @hidden */
  62464. export var fxaaVertexShader: {
  62465. name: string;
  62466. shader: string;
  62467. };
  62468. }
  62469. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62470. import { Nullable } from "babylonjs/types";
  62471. import { Camera } from "babylonjs/Cameras/camera";
  62472. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62473. import { Engine } from "babylonjs/Engines/engine";
  62474. import "babylonjs/Shaders/fxaa.fragment";
  62475. import "babylonjs/Shaders/fxaa.vertex";
  62476. /**
  62477. * Fxaa post process
  62478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62479. */
  62480. export class FxaaPostProcess extends PostProcess {
  62481. /** @hidden */
  62482. texelWidth: number;
  62483. /** @hidden */
  62484. texelHeight: number;
  62485. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62486. private _getDefines;
  62487. }
  62488. }
  62489. declare module "babylonjs/Shaders/grain.fragment" {
  62490. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62491. /** @hidden */
  62492. export var grainPixelShader: {
  62493. name: string;
  62494. shader: string;
  62495. };
  62496. }
  62497. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62498. import { Nullable } from "babylonjs/types";
  62499. import { Camera } from "babylonjs/Cameras/camera";
  62500. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62501. import { Engine } from "babylonjs/Engines/engine";
  62502. import "babylonjs/Shaders/grain.fragment";
  62503. /**
  62504. * The GrainPostProcess adds noise to the image at mid luminance levels
  62505. */
  62506. export class GrainPostProcess extends PostProcess {
  62507. /**
  62508. * The intensity of the grain added (default: 30)
  62509. */
  62510. intensity: number;
  62511. /**
  62512. * If the grain should be randomized on every frame
  62513. */
  62514. animated: boolean;
  62515. /**
  62516. * Creates a new instance of @see GrainPostProcess
  62517. * @param name The name of the effect.
  62518. * @param options The required width/height ratio to downsize to before computing the render pass.
  62519. * @param camera The camera to apply the render pass to.
  62520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62521. * @param engine The engine which the post process will be applied. (default: current engine)
  62522. * @param reusable If the post process can be reused on the same frame. (default: false)
  62523. * @param textureType Type of textures used when performing the post process. (default: 0)
  62524. * @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)
  62525. */
  62526. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62527. }
  62528. }
  62529. declare module "babylonjs/Shaders/highlights.fragment" {
  62530. /** @hidden */
  62531. export var highlightsPixelShader: {
  62532. name: string;
  62533. shader: string;
  62534. };
  62535. }
  62536. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62537. import { Nullable } from "babylonjs/types";
  62538. import { Camera } from "babylonjs/Cameras/camera";
  62539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62540. import { Engine } from "babylonjs/Engines/engine";
  62541. import "babylonjs/Shaders/highlights.fragment";
  62542. /**
  62543. * Extracts highlights from the image
  62544. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62545. */
  62546. export class HighlightsPostProcess extends PostProcess {
  62547. /**
  62548. * Extracts highlights from the image
  62549. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62550. * @param name The name of the effect.
  62551. * @param options The required width/height ratio to downsize to before computing the render pass.
  62552. * @param camera The camera to apply the render pass to.
  62553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62554. * @param engine The engine which the post process will be applied. (default: current engine)
  62555. * @param reusable If the post process can be reused on the same frame. (default: false)
  62556. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62557. */
  62558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62559. }
  62560. }
  62561. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62562. /** @hidden */
  62563. export var mrtFragmentDeclaration: {
  62564. name: string;
  62565. shader: string;
  62566. };
  62567. }
  62568. declare module "babylonjs/Shaders/geometry.fragment" {
  62569. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62570. /** @hidden */
  62571. export var geometryPixelShader: {
  62572. name: string;
  62573. shader: string;
  62574. };
  62575. }
  62576. declare module "babylonjs/Shaders/geometry.vertex" {
  62577. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62580. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62581. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62582. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62583. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62584. /** @hidden */
  62585. export var geometryVertexShader: {
  62586. name: string;
  62587. shader: string;
  62588. };
  62589. }
  62590. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62591. import { Matrix } from "babylonjs/Maths/math.vector";
  62592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62593. import { Mesh } from "babylonjs/Meshes/mesh";
  62594. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62595. import { Effect } from "babylonjs/Materials/effect";
  62596. import { Scene } from "babylonjs/scene";
  62597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62598. import "babylonjs/Shaders/geometry.fragment";
  62599. import "babylonjs/Shaders/geometry.vertex";
  62600. /** @hidden */
  62601. interface ISavedTransformationMatrix {
  62602. world: Matrix;
  62603. viewProjection: Matrix;
  62604. }
  62605. /**
  62606. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62607. */
  62608. export class GeometryBufferRenderer {
  62609. /**
  62610. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62611. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62612. */
  62613. static readonly POSITION_TEXTURE_TYPE: number;
  62614. /**
  62615. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62616. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62617. */
  62618. static readonly VELOCITY_TEXTURE_TYPE: number;
  62619. /**
  62620. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62621. * in order to compute objects velocities when enableVelocity is set to "true"
  62622. * @hidden
  62623. */
  62624. _previousTransformationMatrices: {
  62625. [index: number]: ISavedTransformationMatrix;
  62626. };
  62627. /**
  62628. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62629. * in order to compute objects velocities when enableVelocity is set to "true"
  62630. * @hidden
  62631. */
  62632. _previousBonesTransformationMatrices: {
  62633. [index: number]: Float32Array;
  62634. };
  62635. /**
  62636. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62637. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62638. */
  62639. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62640. private _scene;
  62641. private _multiRenderTarget;
  62642. private _ratio;
  62643. private _enablePosition;
  62644. private _enableVelocity;
  62645. private _positionIndex;
  62646. private _velocityIndex;
  62647. protected _effect: Effect;
  62648. protected _cachedDefines: string;
  62649. /**
  62650. * Set the render list (meshes to be rendered) used in the G buffer.
  62651. */
  62652. renderList: Mesh[];
  62653. /**
  62654. * Gets wether or not G buffer are supported by the running hardware.
  62655. * This requires draw buffer supports
  62656. */
  62657. readonly isSupported: boolean;
  62658. /**
  62659. * Returns the index of the given texture type in the G-Buffer textures array
  62660. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62661. * @returns the index of the given texture type in the G-Buffer textures array
  62662. */
  62663. getTextureIndex(textureType: number): number;
  62664. /**
  62665. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62666. */
  62667. /**
  62668. * Sets whether or not objects positions are enabled for the G buffer.
  62669. */
  62670. enablePosition: boolean;
  62671. /**
  62672. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62673. */
  62674. /**
  62675. * Sets wether or not objects velocities are enabled for the G buffer.
  62676. */
  62677. enableVelocity: boolean;
  62678. /**
  62679. * Gets the scene associated with the buffer.
  62680. */
  62681. readonly scene: Scene;
  62682. /**
  62683. * Gets the ratio used by the buffer during its creation.
  62684. * How big is the buffer related to the main canvas.
  62685. */
  62686. readonly ratio: number;
  62687. /** @hidden */
  62688. static _SceneComponentInitialization: (scene: Scene) => void;
  62689. /**
  62690. * Creates a new G Buffer for the scene
  62691. * @param scene The scene the buffer belongs to
  62692. * @param ratio How big is the buffer related to the main canvas.
  62693. */
  62694. constructor(scene: Scene, ratio?: number);
  62695. /**
  62696. * Checks wether everything is ready to render a submesh to the G buffer.
  62697. * @param subMesh the submesh to check readiness for
  62698. * @param useInstances is the mesh drawn using instance or not
  62699. * @returns true if ready otherwise false
  62700. */
  62701. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62702. /**
  62703. * Gets the current underlying G Buffer.
  62704. * @returns the buffer
  62705. */
  62706. getGBuffer(): MultiRenderTarget;
  62707. /**
  62708. * Gets the number of samples used to render the buffer (anti aliasing).
  62709. */
  62710. /**
  62711. * Sets the number of samples used to render the buffer (anti aliasing).
  62712. */
  62713. samples: number;
  62714. /**
  62715. * Disposes the renderer and frees up associated resources.
  62716. */
  62717. dispose(): void;
  62718. protected _createRenderTargets(): void;
  62719. private _copyBonesTransformationMatrices;
  62720. }
  62721. }
  62722. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62723. import { Nullable } from "babylonjs/types";
  62724. import { Scene } from "babylonjs/scene";
  62725. import { ISceneComponent } from "babylonjs/sceneComponent";
  62726. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62727. module "babylonjs/scene" {
  62728. interface Scene {
  62729. /** @hidden (Backing field) */
  62730. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62731. /**
  62732. * Gets or Sets the current geometry buffer associated to the scene.
  62733. */
  62734. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62735. /**
  62736. * Enables a GeometryBufferRender and associates it with the scene
  62737. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62738. * @returns the GeometryBufferRenderer
  62739. */
  62740. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62741. /**
  62742. * Disables the GeometryBufferRender associated with the scene
  62743. */
  62744. disableGeometryBufferRenderer(): void;
  62745. }
  62746. }
  62747. /**
  62748. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62749. * in several rendering techniques.
  62750. */
  62751. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62752. /**
  62753. * The component name helpful to identify the component in the list of scene components.
  62754. */
  62755. readonly name: string;
  62756. /**
  62757. * The scene the component belongs to.
  62758. */
  62759. scene: Scene;
  62760. /**
  62761. * Creates a new instance of the component for the given scene
  62762. * @param scene Defines the scene to register the component in
  62763. */
  62764. constructor(scene: Scene);
  62765. /**
  62766. * Registers the component in a given scene
  62767. */
  62768. register(): void;
  62769. /**
  62770. * Rebuilds the elements related to this component in case of
  62771. * context lost for instance.
  62772. */
  62773. rebuild(): void;
  62774. /**
  62775. * Disposes the component and the associated ressources
  62776. */
  62777. dispose(): void;
  62778. private _gatherRenderTargets;
  62779. }
  62780. }
  62781. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62782. /** @hidden */
  62783. export var motionBlurPixelShader: {
  62784. name: string;
  62785. shader: string;
  62786. };
  62787. }
  62788. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62789. import { Nullable } from "babylonjs/types";
  62790. import { Camera } from "babylonjs/Cameras/camera";
  62791. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62792. import { Scene } from "babylonjs/scene";
  62793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62794. import "babylonjs/Animations/animatable";
  62795. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62796. import "babylonjs/Shaders/motionBlur.fragment";
  62797. import { Engine } from "babylonjs/Engines/engine";
  62798. /**
  62799. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62800. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62801. * As an example, all you have to do is to create the post-process:
  62802. * var mb = new BABYLON.MotionBlurPostProcess(
  62803. * 'mb', // The name of the effect.
  62804. * scene, // The scene containing the objects to blur according to their velocity.
  62805. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62806. * camera // The camera to apply the render pass to.
  62807. * );
  62808. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62809. */
  62810. export class MotionBlurPostProcess extends PostProcess {
  62811. /**
  62812. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62813. */
  62814. motionStrength: number;
  62815. /**
  62816. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62817. */
  62818. /**
  62819. * Sets the number of iterations to be used for motion blur quality
  62820. */
  62821. motionBlurSamples: number;
  62822. private _motionBlurSamples;
  62823. private _geometryBufferRenderer;
  62824. /**
  62825. * Creates a new instance MotionBlurPostProcess
  62826. * @param name The name of the effect.
  62827. * @param scene The scene containing the objects to blur according to their velocity.
  62828. * @param options The required width/height ratio to downsize to before computing the render pass.
  62829. * @param camera The camera to apply the render pass to.
  62830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62831. * @param engine The engine which the post process will be applied. (default: current engine)
  62832. * @param reusable If the post process can be reused on the same frame. (default: false)
  62833. * @param textureType Type of textures used when performing the post process. (default: 0)
  62834. * @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)
  62835. */
  62836. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62837. /**
  62838. * Excludes the given skinned mesh from computing bones velocities.
  62839. * 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.
  62840. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62841. */
  62842. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62843. /**
  62844. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62845. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62846. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62847. */
  62848. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62849. /**
  62850. * Disposes the post process.
  62851. * @param camera The camera to dispose the post process on.
  62852. */
  62853. dispose(camera?: Camera): void;
  62854. }
  62855. }
  62856. declare module "babylonjs/Shaders/refraction.fragment" {
  62857. /** @hidden */
  62858. export var refractionPixelShader: {
  62859. name: string;
  62860. shader: string;
  62861. };
  62862. }
  62863. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62864. import { Color3 } from "babylonjs/Maths/math.color";
  62865. import { Camera } from "babylonjs/Cameras/camera";
  62866. import { Texture } from "babylonjs/Materials/Textures/texture";
  62867. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62868. import { Engine } from "babylonjs/Engines/engine";
  62869. import "babylonjs/Shaders/refraction.fragment";
  62870. /**
  62871. * Post process which applies a refractin texture
  62872. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62873. */
  62874. export class RefractionPostProcess extends PostProcess {
  62875. /** the base color of the refraction (used to taint the rendering) */
  62876. color: Color3;
  62877. /** simulated refraction depth */
  62878. depth: number;
  62879. /** the coefficient of the base color (0 to remove base color tainting) */
  62880. colorLevel: number;
  62881. private _refTexture;
  62882. private _ownRefractionTexture;
  62883. /**
  62884. * Gets or sets the refraction texture
  62885. * Please note that you are responsible for disposing the texture if you set it manually
  62886. */
  62887. refractionTexture: Texture;
  62888. /**
  62889. * Initializes the RefractionPostProcess
  62890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62891. * @param name The name of the effect.
  62892. * @param refractionTextureUrl Url of the refraction texture to use
  62893. * @param color the base color of the refraction (used to taint the rendering)
  62894. * @param depth simulated refraction depth
  62895. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62896. * @param camera The camera to apply the render pass to.
  62897. * @param options The required width/height ratio to downsize to before computing the render pass.
  62898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62899. * @param engine The engine which the post process will be applied. (default: current engine)
  62900. * @param reusable If the post process can be reused on the same frame. (default: false)
  62901. */
  62902. constructor(name: string, refractionTextureUrl: string,
  62903. /** the base color of the refraction (used to taint the rendering) */
  62904. color: Color3,
  62905. /** simulated refraction depth */
  62906. depth: number,
  62907. /** the coefficient of the base color (0 to remove base color tainting) */
  62908. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62909. /**
  62910. * Disposes of the post process
  62911. * @param camera Camera to dispose post process on
  62912. */
  62913. dispose(camera: Camera): void;
  62914. }
  62915. }
  62916. declare module "babylonjs/Shaders/sharpen.fragment" {
  62917. /** @hidden */
  62918. export var sharpenPixelShader: {
  62919. name: string;
  62920. shader: string;
  62921. };
  62922. }
  62923. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62924. import { Nullable } from "babylonjs/types";
  62925. import { Camera } from "babylonjs/Cameras/camera";
  62926. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62927. import "babylonjs/Shaders/sharpen.fragment";
  62928. import { Engine } from "babylonjs/Engines/engine";
  62929. /**
  62930. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62931. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62932. */
  62933. export class SharpenPostProcess extends PostProcess {
  62934. /**
  62935. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62936. */
  62937. colorAmount: number;
  62938. /**
  62939. * How much sharpness should be applied (default: 0.3)
  62940. */
  62941. edgeAmount: number;
  62942. /**
  62943. * Creates a new instance ConvolutionPostProcess
  62944. * @param name The name of the effect.
  62945. * @param options The required width/height ratio to downsize to before computing the render pass.
  62946. * @param camera The camera to apply the render pass to.
  62947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62948. * @param engine The engine which the post process will be applied. (default: current engine)
  62949. * @param reusable If the post process can be reused on the same frame. (default: false)
  62950. * @param textureType Type of textures used when performing the post process. (default: 0)
  62951. * @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)
  62952. */
  62953. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62954. }
  62955. }
  62956. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62957. import { Nullable } from "babylonjs/types";
  62958. import { Camera } from "babylonjs/Cameras/camera";
  62959. import { Engine } from "babylonjs/Engines/engine";
  62960. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62961. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62962. /**
  62963. * PostProcessRenderPipeline
  62964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62965. */
  62966. export class PostProcessRenderPipeline {
  62967. private engine;
  62968. private _renderEffects;
  62969. private _renderEffectsForIsolatedPass;
  62970. /**
  62971. * List of inspectable custom properties (used by the Inspector)
  62972. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62973. */
  62974. inspectableCustomProperties: IInspectable[];
  62975. /**
  62976. * @hidden
  62977. */
  62978. protected _cameras: Camera[];
  62979. /** @hidden */
  62980. _name: string;
  62981. /**
  62982. * Gets pipeline name
  62983. */
  62984. readonly name: string;
  62985. /**
  62986. * Initializes a PostProcessRenderPipeline
  62987. * @param engine engine to add the pipeline to
  62988. * @param name name of the pipeline
  62989. */
  62990. constructor(engine: Engine, name: string);
  62991. /**
  62992. * Gets the class name
  62993. * @returns "PostProcessRenderPipeline"
  62994. */
  62995. getClassName(): string;
  62996. /**
  62997. * If all the render effects in the pipeline are supported
  62998. */
  62999. readonly isSupported: boolean;
  63000. /**
  63001. * Adds an effect to the pipeline
  63002. * @param renderEffect the effect to add
  63003. */
  63004. addEffect(renderEffect: PostProcessRenderEffect): void;
  63005. /** @hidden */
  63006. _rebuild(): void;
  63007. /** @hidden */
  63008. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63009. /** @hidden */
  63010. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63011. /** @hidden */
  63012. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63013. /** @hidden */
  63014. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63015. /** @hidden */
  63016. _attachCameras(cameras: Camera, unique: boolean): void;
  63017. /** @hidden */
  63018. _attachCameras(cameras: Camera[], unique: boolean): void;
  63019. /** @hidden */
  63020. _detachCameras(cameras: Camera): void;
  63021. /** @hidden */
  63022. _detachCameras(cameras: Nullable<Camera[]>): void;
  63023. /** @hidden */
  63024. _update(): void;
  63025. /** @hidden */
  63026. _reset(): void;
  63027. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63028. /**
  63029. * Disposes of the pipeline
  63030. */
  63031. dispose(): void;
  63032. }
  63033. }
  63034. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63035. import { Camera } from "babylonjs/Cameras/camera";
  63036. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63037. /**
  63038. * PostProcessRenderPipelineManager class
  63039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63040. */
  63041. export class PostProcessRenderPipelineManager {
  63042. private _renderPipelines;
  63043. /**
  63044. * Initializes a PostProcessRenderPipelineManager
  63045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63046. */
  63047. constructor();
  63048. /**
  63049. * Gets the list of supported render pipelines
  63050. */
  63051. readonly supportedPipelines: PostProcessRenderPipeline[];
  63052. /**
  63053. * Adds a pipeline to the manager
  63054. * @param renderPipeline The pipeline to add
  63055. */
  63056. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63057. /**
  63058. * Attaches a camera to the pipeline
  63059. * @param renderPipelineName The name of the pipeline to attach to
  63060. * @param cameras the camera to attach
  63061. * @param unique if the camera can be attached multiple times to the pipeline
  63062. */
  63063. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63064. /**
  63065. * Detaches a camera from the pipeline
  63066. * @param renderPipelineName The name of the pipeline to detach from
  63067. * @param cameras the camera to detach
  63068. */
  63069. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63070. /**
  63071. * Enables an effect by name on a pipeline
  63072. * @param renderPipelineName the name of the pipeline to enable the effect in
  63073. * @param renderEffectName the name of the effect to enable
  63074. * @param cameras the cameras that the effect should be enabled on
  63075. */
  63076. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63077. /**
  63078. * Disables an effect by name on a pipeline
  63079. * @param renderPipelineName the name of the pipeline to disable the effect in
  63080. * @param renderEffectName the name of the effect to disable
  63081. * @param cameras the cameras that the effect should be disabled on
  63082. */
  63083. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63084. /**
  63085. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63086. */
  63087. update(): void;
  63088. /** @hidden */
  63089. _rebuild(): void;
  63090. /**
  63091. * Disposes of the manager and pipelines
  63092. */
  63093. dispose(): void;
  63094. }
  63095. }
  63096. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63097. import { ISceneComponent } from "babylonjs/sceneComponent";
  63098. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63099. import { Scene } from "babylonjs/scene";
  63100. module "babylonjs/scene" {
  63101. interface Scene {
  63102. /** @hidden (Backing field) */
  63103. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63104. /**
  63105. * Gets the postprocess render pipeline manager
  63106. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63107. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63108. */
  63109. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63110. }
  63111. }
  63112. /**
  63113. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63114. */
  63115. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63116. /**
  63117. * The component name helpfull to identify the component in the list of scene components.
  63118. */
  63119. readonly name: string;
  63120. /**
  63121. * The scene the component belongs to.
  63122. */
  63123. scene: Scene;
  63124. /**
  63125. * Creates a new instance of the component for the given scene
  63126. * @param scene Defines the scene to register the component in
  63127. */
  63128. constructor(scene: Scene);
  63129. /**
  63130. * Registers the component in a given scene
  63131. */
  63132. register(): void;
  63133. /**
  63134. * Rebuilds the elements related to this component in case of
  63135. * context lost for instance.
  63136. */
  63137. rebuild(): void;
  63138. /**
  63139. * Disposes the component and the associated ressources
  63140. */
  63141. dispose(): void;
  63142. private _gatherRenderTargets;
  63143. }
  63144. }
  63145. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63146. import { Nullable } from "babylonjs/types";
  63147. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63148. import { Camera } from "babylonjs/Cameras/camera";
  63149. import { IDisposable } from "babylonjs/scene";
  63150. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63151. import { Scene } from "babylonjs/scene";
  63152. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63153. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63154. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63155. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63156. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63157. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63158. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63159. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63160. import { Animation } from "babylonjs/Animations/animation";
  63161. /**
  63162. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63163. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63164. */
  63165. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63166. private _scene;
  63167. private _camerasToBeAttached;
  63168. /**
  63169. * ID of the sharpen post process,
  63170. */
  63171. private readonly SharpenPostProcessId;
  63172. /**
  63173. * @ignore
  63174. * ID of the image processing post process;
  63175. */
  63176. readonly ImageProcessingPostProcessId: string;
  63177. /**
  63178. * @ignore
  63179. * ID of the Fast Approximate Anti-Aliasing post process;
  63180. */
  63181. readonly FxaaPostProcessId: string;
  63182. /**
  63183. * ID of the chromatic aberration post process,
  63184. */
  63185. private readonly ChromaticAberrationPostProcessId;
  63186. /**
  63187. * ID of the grain post process
  63188. */
  63189. private readonly GrainPostProcessId;
  63190. /**
  63191. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63192. */
  63193. sharpen: SharpenPostProcess;
  63194. private _sharpenEffect;
  63195. private bloom;
  63196. /**
  63197. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63198. */
  63199. depthOfField: DepthOfFieldEffect;
  63200. /**
  63201. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63202. */
  63203. fxaa: FxaaPostProcess;
  63204. /**
  63205. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63206. */
  63207. imageProcessing: ImageProcessingPostProcess;
  63208. /**
  63209. * Chromatic aberration post process which will shift rgb colors in the image
  63210. */
  63211. chromaticAberration: ChromaticAberrationPostProcess;
  63212. private _chromaticAberrationEffect;
  63213. /**
  63214. * Grain post process which add noise to the image
  63215. */
  63216. grain: GrainPostProcess;
  63217. private _grainEffect;
  63218. /**
  63219. * Glow post process which adds a glow to emissive areas of the image
  63220. */
  63221. private _glowLayer;
  63222. /**
  63223. * Animations which can be used to tweak settings over a period of time
  63224. */
  63225. animations: Animation[];
  63226. private _imageProcessingConfigurationObserver;
  63227. private _sharpenEnabled;
  63228. private _bloomEnabled;
  63229. private _depthOfFieldEnabled;
  63230. private _depthOfFieldBlurLevel;
  63231. private _fxaaEnabled;
  63232. private _imageProcessingEnabled;
  63233. private _defaultPipelineTextureType;
  63234. private _bloomScale;
  63235. private _chromaticAberrationEnabled;
  63236. private _grainEnabled;
  63237. private _buildAllowed;
  63238. /**
  63239. * Gets active scene
  63240. */
  63241. readonly scene: Scene;
  63242. /**
  63243. * Enable or disable the sharpen process from the pipeline
  63244. */
  63245. sharpenEnabled: boolean;
  63246. private _resizeObserver;
  63247. private _hardwareScaleLevel;
  63248. private _bloomKernel;
  63249. /**
  63250. * Specifies the size of the bloom blur kernel, relative to the final output size
  63251. */
  63252. bloomKernel: number;
  63253. /**
  63254. * Specifies the weight of the bloom in the final rendering
  63255. */
  63256. private _bloomWeight;
  63257. /**
  63258. * Specifies the luma threshold for the area that will be blurred by the bloom
  63259. */
  63260. private _bloomThreshold;
  63261. private _hdr;
  63262. /**
  63263. * The strength of the bloom.
  63264. */
  63265. bloomWeight: number;
  63266. /**
  63267. * The strength of the bloom.
  63268. */
  63269. bloomThreshold: number;
  63270. /**
  63271. * The scale of the bloom, lower value will provide better performance.
  63272. */
  63273. bloomScale: number;
  63274. /**
  63275. * Enable or disable the bloom from the pipeline
  63276. */
  63277. bloomEnabled: boolean;
  63278. private _rebuildBloom;
  63279. /**
  63280. * If the depth of field is enabled.
  63281. */
  63282. depthOfFieldEnabled: boolean;
  63283. /**
  63284. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63285. */
  63286. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63287. /**
  63288. * If the anti aliasing is enabled.
  63289. */
  63290. fxaaEnabled: boolean;
  63291. private _samples;
  63292. /**
  63293. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63294. */
  63295. samples: number;
  63296. /**
  63297. * If image processing is enabled.
  63298. */
  63299. imageProcessingEnabled: boolean;
  63300. /**
  63301. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63302. */
  63303. glowLayerEnabled: boolean;
  63304. /**
  63305. * Gets the glow layer (or null if not defined)
  63306. */
  63307. readonly glowLayer: Nullable<GlowLayer>;
  63308. /**
  63309. * Enable or disable the chromaticAberration process from the pipeline
  63310. */
  63311. chromaticAberrationEnabled: boolean;
  63312. /**
  63313. * Enable or disable the grain process from the pipeline
  63314. */
  63315. grainEnabled: boolean;
  63316. /**
  63317. * @constructor
  63318. * @param name - The rendering pipeline name (default: "")
  63319. * @param hdr - If high dynamic range textures should be used (default: true)
  63320. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63321. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63322. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63323. */
  63324. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63325. /**
  63326. * Get the class name
  63327. * @returns "DefaultRenderingPipeline"
  63328. */
  63329. getClassName(): string;
  63330. /**
  63331. * Force the compilation of the entire pipeline.
  63332. */
  63333. prepare(): void;
  63334. private _hasCleared;
  63335. private _prevPostProcess;
  63336. private _prevPrevPostProcess;
  63337. private _setAutoClearAndTextureSharing;
  63338. private _depthOfFieldSceneObserver;
  63339. private _buildPipeline;
  63340. private _disposePostProcesses;
  63341. /**
  63342. * Adds a camera to the pipeline
  63343. * @param camera the camera to be added
  63344. */
  63345. addCamera(camera: Camera): void;
  63346. /**
  63347. * Removes a camera from the pipeline
  63348. * @param camera the camera to remove
  63349. */
  63350. removeCamera(camera: Camera): void;
  63351. /**
  63352. * Dispose of the pipeline and stop all post processes
  63353. */
  63354. dispose(): void;
  63355. /**
  63356. * Serialize the rendering pipeline (Used when exporting)
  63357. * @returns the serialized object
  63358. */
  63359. serialize(): any;
  63360. /**
  63361. * Parse the serialized pipeline
  63362. * @param source Source pipeline.
  63363. * @param scene The scene to load the pipeline to.
  63364. * @param rootUrl The URL of the serialized pipeline.
  63365. * @returns An instantiated pipeline from the serialized object.
  63366. */
  63367. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63368. }
  63369. }
  63370. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63371. /** @hidden */
  63372. export var lensHighlightsPixelShader: {
  63373. name: string;
  63374. shader: string;
  63375. };
  63376. }
  63377. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63378. /** @hidden */
  63379. export var depthOfFieldPixelShader: {
  63380. name: string;
  63381. shader: string;
  63382. };
  63383. }
  63384. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63385. import { Camera } from "babylonjs/Cameras/camera";
  63386. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63387. import { Scene } from "babylonjs/scene";
  63388. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63389. import "babylonjs/Shaders/chromaticAberration.fragment";
  63390. import "babylonjs/Shaders/lensHighlights.fragment";
  63391. import "babylonjs/Shaders/depthOfField.fragment";
  63392. /**
  63393. * BABYLON.JS Chromatic Aberration GLSL Shader
  63394. * Author: Olivier Guyot
  63395. * Separates very slightly R, G and B colors on the edges of the screen
  63396. * Inspired by Francois Tarlier & Martins Upitis
  63397. */
  63398. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63399. /**
  63400. * @ignore
  63401. * The chromatic aberration PostProcess id in the pipeline
  63402. */
  63403. LensChromaticAberrationEffect: string;
  63404. /**
  63405. * @ignore
  63406. * The highlights enhancing PostProcess id in the pipeline
  63407. */
  63408. HighlightsEnhancingEffect: string;
  63409. /**
  63410. * @ignore
  63411. * The depth-of-field PostProcess id in the pipeline
  63412. */
  63413. LensDepthOfFieldEffect: string;
  63414. private _scene;
  63415. private _depthTexture;
  63416. private _grainTexture;
  63417. private _chromaticAberrationPostProcess;
  63418. private _highlightsPostProcess;
  63419. private _depthOfFieldPostProcess;
  63420. private _edgeBlur;
  63421. private _grainAmount;
  63422. private _chromaticAberration;
  63423. private _distortion;
  63424. private _highlightsGain;
  63425. private _highlightsThreshold;
  63426. private _dofDistance;
  63427. private _dofAperture;
  63428. private _dofDarken;
  63429. private _dofPentagon;
  63430. private _blurNoise;
  63431. /**
  63432. * @constructor
  63433. *
  63434. * Effect parameters are as follow:
  63435. * {
  63436. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63437. * edge_blur: number; // from 0 to x (1 for realism)
  63438. * distortion: number; // from 0 to x (1 for realism)
  63439. * grain_amount: number; // from 0 to 1
  63440. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63441. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63442. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63443. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63444. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63445. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63446. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63447. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63448. * }
  63449. * Note: if an effect parameter is unset, effect is disabled
  63450. *
  63451. * @param name The rendering pipeline name
  63452. * @param parameters - An object containing all parameters (see above)
  63453. * @param scene The scene linked to this pipeline
  63454. * @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)
  63455. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63456. */
  63457. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63458. /**
  63459. * Get the class name
  63460. * @returns "LensRenderingPipeline"
  63461. */
  63462. getClassName(): string;
  63463. /**
  63464. * Gets associated scene
  63465. */
  63466. readonly scene: Scene;
  63467. /**
  63468. * Gets or sets the edge blur
  63469. */
  63470. edgeBlur: number;
  63471. /**
  63472. * Gets or sets the grain amount
  63473. */
  63474. grainAmount: number;
  63475. /**
  63476. * Gets or sets the chromatic aberration amount
  63477. */
  63478. chromaticAberration: number;
  63479. /**
  63480. * Gets or sets the depth of field aperture
  63481. */
  63482. dofAperture: number;
  63483. /**
  63484. * Gets or sets the edge distortion
  63485. */
  63486. edgeDistortion: number;
  63487. /**
  63488. * Gets or sets the depth of field distortion
  63489. */
  63490. dofDistortion: number;
  63491. /**
  63492. * Gets or sets the darken out of focus amount
  63493. */
  63494. darkenOutOfFocus: number;
  63495. /**
  63496. * Gets or sets a boolean indicating if blur noise is enabled
  63497. */
  63498. blurNoise: boolean;
  63499. /**
  63500. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63501. */
  63502. pentagonBokeh: boolean;
  63503. /**
  63504. * Gets or sets the highlight grain amount
  63505. */
  63506. highlightsGain: number;
  63507. /**
  63508. * Gets or sets the highlight threshold
  63509. */
  63510. highlightsThreshold: number;
  63511. /**
  63512. * Sets the amount of blur at the edges
  63513. * @param amount blur amount
  63514. */
  63515. setEdgeBlur(amount: number): void;
  63516. /**
  63517. * Sets edge blur to 0
  63518. */
  63519. disableEdgeBlur(): void;
  63520. /**
  63521. * Sets the amout of grain
  63522. * @param amount Amount of grain
  63523. */
  63524. setGrainAmount(amount: number): void;
  63525. /**
  63526. * Set grain amount to 0
  63527. */
  63528. disableGrain(): void;
  63529. /**
  63530. * Sets the chromatic aberration amount
  63531. * @param amount amount of chromatic aberration
  63532. */
  63533. setChromaticAberration(amount: number): void;
  63534. /**
  63535. * Sets chromatic aberration amount to 0
  63536. */
  63537. disableChromaticAberration(): void;
  63538. /**
  63539. * Sets the EdgeDistortion amount
  63540. * @param amount amount of EdgeDistortion
  63541. */
  63542. setEdgeDistortion(amount: number): void;
  63543. /**
  63544. * Sets edge distortion to 0
  63545. */
  63546. disableEdgeDistortion(): void;
  63547. /**
  63548. * Sets the FocusDistance amount
  63549. * @param amount amount of FocusDistance
  63550. */
  63551. setFocusDistance(amount: number): void;
  63552. /**
  63553. * Disables depth of field
  63554. */
  63555. disableDepthOfField(): void;
  63556. /**
  63557. * Sets the Aperture amount
  63558. * @param amount amount of Aperture
  63559. */
  63560. setAperture(amount: number): void;
  63561. /**
  63562. * Sets the DarkenOutOfFocus amount
  63563. * @param amount amount of DarkenOutOfFocus
  63564. */
  63565. setDarkenOutOfFocus(amount: number): void;
  63566. private _pentagonBokehIsEnabled;
  63567. /**
  63568. * Creates a pentagon bokeh effect
  63569. */
  63570. enablePentagonBokeh(): void;
  63571. /**
  63572. * Disables the pentagon bokeh effect
  63573. */
  63574. disablePentagonBokeh(): void;
  63575. /**
  63576. * Enables noise blur
  63577. */
  63578. enableNoiseBlur(): void;
  63579. /**
  63580. * Disables noise blur
  63581. */
  63582. disableNoiseBlur(): void;
  63583. /**
  63584. * Sets the HighlightsGain amount
  63585. * @param amount amount of HighlightsGain
  63586. */
  63587. setHighlightsGain(amount: number): void;
  63588. /**
  63589. * Sets the HighlightsThreshold amount
  63590. * @param amount amount of HighlightsThreshold
  63591. */
  63592. setHighlightsThreshold(amount: number): void;
  63593. /**
  63594. * Disables highlights
  63595. */
  63596. disableHighlights(): void;
  63597. /**
  63598. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63599. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63600. */
  63601. dispose(disableDepthRender?: boolean): void;
  63602. private _createChromaticAberrationPostProcess;
  63603. private _createHighlightsPostProcess;
  63604. private _createDepthOfFieldPostProcess;
  63605. private _createGrainTexture;
  63606. }
  63607. }
  63608. declare module "babylonjs/Shaders/ssao2.fragment" {
  63609. /** @hidden */
  63610. export var ssao2PixelShader: {
  63611. name: string;
  63612. shader: string;
  63613. };
  63614. }
  63615. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63616. /** @hidden */
  63617. export var ssaoCombinePixelShader: {
  63618. name: string;
  63619. shader: string;
  63620. };
  63621. }
  63622. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63623. import { Camera } from "babylonjs/Cameras/camera";
  63624. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63625. import { Scene } from "babylonjs/scene";
  63626. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63627. import "babylonjs/Shaders/ssao2.fragment";
  63628. import "babylonjs/Shaders/ssaoCombine.fragment";
  63629. /**
  63630. * Render pipeline to produce ssao effect
  63631. */
  63632. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63633. /**
  63634. * @ignore
  63635. * The PassPostProcess id in the pipeline that contains the original scene color
  63636. */
  63637. SSAOOriginalSceneColorEffect: string;
  63638. /**
  63639. * @ignore
  63640. * The SSAO PostProcess id in the pipeline
  63641. */
  63642. SSAORenderEffect: string;
  63643. /**
  63644. * @ignore
  63645. * The horizontal blur PostProcess id in the pipeline
  63646. */
  63647. SSAOBlurHRenderEffect: string;
  63648. /**
  63649. * @ignore
  63650. * The vertical blur PostProcess id in the pipeline
  63651. */
  63652. SSAOBlurVRenderEffect: string;
  63653. /**
  63654. * @ignore
  63655. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63656. */
  63657. SSAOCombineRenderEffect: string;
  63658. /**
  63659. * The output strength of the SSAO post-process. Default value is 1.0.
  63660. */
  63661. totalStrength: number;
  63662. /**
  63663. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63664. */
  63665. maxZ: number;
  63666. /**
  63667. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63668. */
  63669. minZAspect: number;
  63670. private _samples;
  63671. /**
  63672. * Number of samples used for the SSAO calculations. Default value is 8
  63673. */
  63674. samples: number;
  63675. private _textureSamples;
  63676. /**
  63677. * Number of samples to use for antialiasing
  63678. */
  63679. textureSamples: number;
  63680. /**
  63681. * Ratio object used for SSAO ratio and blur ratio
  63682. */
  63683. private _ratio;
  63684. /**
  63685. * Dynamically generated sphere sampler.
  63686. */
  63687. private _sampleSphere;
  63688. /**
  63689. * Blur filter offsets
  63690. */
  63691. private _samplerOffsets;
  63692. private _expensiveBlur;
  63693. /**
  63694. * If bilateral blur should be used
  63695. */
  63696. expensiveBlur: boolean;
  63697. /**
  63698. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63699. */
  63700. radius: number;
  63701. /**
  63702. * The base color of the SSAO post-process
  63703. * The final result is "base + ssao" between [0, 1]
  63704. */
  63705. base: number;
  63706. /**
  63707. * Support test.
  63708. */
  63709. static readonly IsSupported: boolean;
  63710. private _scene;
  63711. private _depthTexture;
  63712. private _normalTexture;
  63713. private _randomTexture;
  63714. private _originalColorPostProcess;
  63715. private _ssaoPostProcess;
  63716. private _blurHPostProcess;
  63717. private _blurVPostProcess;
  63718. private _ssaoCombinePostProcess;
  63719. private _firstUpdate;
  63720. /**
  63721. * Gets active scene
  63722. */
  63723. readonly scene: Scene;
  63724. /**
  63725. * @constructor
  63726. * @param name The rendering pipeline name
  63727. * @param scene The scene linked to this pipeline
  63728. * @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 }
  63729. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63730. */
  63731. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63732. /**
  63733. * Get the class name
  63734. * @returns "SSAO2RenderingPipeline"
  63735. */
  63736. getClassName(): string;
  63737. /**
  63738. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63739. */
  63740. dispose(disableGeometryBufferRenderer?: boolean): void;
  63741. private _createBlurPostProcess;
  63742. /** @hidden */
  63743. _rebuild(): void;
  63744. private _bits;
  63745. private _radicalInverse_VdC;
  63746. private _hammersley;
  63747. private _hemisphereSample_uniform;
  63748. private _generateHemisphere;
  63749. private _createSSAOPostProcess;
  63750. private _createSSAOCombinePostProcess;
  63751. private _createRandomTexture;
  63752. /**
  63753. * Serialize the rendering pipeline (Used when exporting)
  63754. * @returns the serialized object
  63755. */
  63756. serialize(): any;
  63757. /**
  63758. * Parse the serialized pipeline
  63759. * @param source Source pipeline.
  63760. * @param scene The scene to load the pipeline to.
  63761. * @param rootUrl The URL of the serialized pipeline.
  63762. * @returns An instantiated pipeline from the serialized object.
  63763. */
  63764. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63765. }
  63766. }
  63767. declare module "babylonjs/Shaders/ssao.fragment" {
  63768. /** @hidden */
  63769. export var ssaoPixelShader: {
  63770. name: string;
  63771. shader: string;
  63772. };
  63773. }
  63774. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63775. import { Camera } from "babylonjs/Cameras/camera";
  63776. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63777. import { Scene } from "babylonjs/scene";
  63778. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63779. import "babylonjs/Shaders/ssao.fragment";
  63780. import "babylonjs/Shaders/ssaoCombine.fragment";
  63781. /**
  63782. * Render pipeline to produce ssao effect
  63783. */
  63784. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63785. /**
  63786. * @ignore
  63787. * The PassPostProcess id in the pipeline that contains the original scene color
  63788. */
  63789. SSAOOriginalSceneColorEffect: string;
  63790. /**
  63791. * @ignore
  63792. * The SSAO PostProcess id in the pipeline
  63793. */
  63794. SSAORenderEffect: string;
  63795. /**
  63796. * @ignore
  63797. * The horizontal blur PostProcess id in the pipeline
  63798. */
  63799. SSAOBlurHRenderEffect: string;
  63800. /**
  63801. * @ignore
  63802. * The vertical blur PostProcess id in the pipeline
  63803. */
  63804. SSAOBlurVRenderEffect: string;
  63805. /**
  63806. * @ignore
  63807. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63808. */
  63809. SSAOCombineRenderEffect: string;
  63810. /**
  63811. * The output strength of the SSAO post-process. Default value is 1.0.
  63812. */
  63813. totalStrength: number;
  63814. /**
  63815. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63816. */
  63817. radius: number;
  63818. /**
  63819. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63820. * Must not be equal to fallOff and superior to fallOff.
  63821. * Default value is 0.0075
  63822. */
  63823. area: number;
  63824. /**
  63825. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63826. * Must not be equal to area and inferior to area.
  63827. * Default value is 0.000001
  63828. */
  63829. fallOff: number;
  63830. /**
  63831. * The base color of the SSAO post-process
  63832. * The final result is "base + ssao" between [0, 1]
  63833. */
  63834. base: number;
  63835. private _scene;
  63836. private _depthTexture;
  63837. private _randomTexture;
  63838. private _originalColorPostProcess;
  63839. private _ssaoPostProcess;
  63840. private _blurHPostProcess;
  63841. private _blurVPostProcess;
  63842. private _ssaoCombinePostProcess;
  63843. private _firstUpdate;
  63844. /**
  63845. * Gets active scene
  63846. */
  63847. readonly scene: Scene;
  63848. /**
  63849. * @constructor
  63850. * @param name - The rendering pipeline name
  63851. * @param scene - The scene linked to this pipeline
  63852. * @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 }
  63853. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63854. */
  63855. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63856. /**
  63857. * Get the class name
  63858. * @returns "SSAORenderingPipeline"
  63859. */
  63860. getClassName(): string;
  63861. /**
  63862. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63863. */
  63864. dispose(disableDepthRender?: boolean): void;
  63865. private _createBlurPostProcess;
  63866. /** @hidden */
  63867. _rebuild(): void;
  63868. private _createSSAOPostProcess;
  63869. private _createSSAOCombinePostProcess;
  63870. private _createRandomTexture;
  63871. }
  63872. }
  63873. declare module "babylonjs/Shaders/standard.fragment" {
  63874. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63875. /** @hidden */
  63876. export var standardPixelShader: {
  63877. name: string;
  63878. shader: string;
  63879. };
  63880. }
  63881. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63882. import { Nullable } from "babylonjs/types";
  63883. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63884. import { Camera } from "babylonjs/Cameras/camera";
  63885. import { Texture } from "babylonjs/Materials/Textures/texture";
  63886. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63887. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63888. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63889. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63890. import { IDisposable } from "babylonjs/scene";
  63891. import { SpotLight } from "babylonjs/Lights/spotLight";
  63892. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63893. import { Scene } from "babylonjs/scene";
  63894. import { Animation } from "babylonjs/Animations/animation";
  63895. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63896. import "babylonjs/Shaders/standard.fragment";
  63897. /**
  63898. * Standard rendering pipeline
  63899. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63900. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63901. */
  63902. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63903. /**
  63904. * Public members
  63905. */
  63906. /**
  63907. * Post-process which contains the original scene color before the pipeline applies all the effects
  63908. */
  63909. originalPostProcess: Nullable<PostProcess>;
  63910. /**
  63911. * Post-process used to down scale an image x4
  63912. */
  63913. downSampleX4PostProcess: Nullable<PostProcess>;
  63914. /**
  63915. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63916. */
  63917. brightPassPostProcess: Nullable<PostProcess>;
  63918. /**
  63919. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63920. */
  63921. blurHPostProcesses: PostProcess[];
  63922. /**
  63923. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63924. */
  63925. blurVPostProcesses: PostProcess[];
  63926. /**
  63927. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63928. */
  63929. textureAdderPostProcess: Nullable<PostProcess>;
  63930. /**
  63931. * Post-process used to create volumetric lighting effect
  63932. */
  63933. volumetricLightPostProcess: Nullable<PostProcess>;
  63934. /**
  63935. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63936. */
  63937. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63938. /**
  63939. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63940. */
  63941. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63942. /**
  63943. * Post-process used to merge the volumetric light effect and the real scene color
  63944. */
  63945. volumetricLightMergePostProces: Nullable<PostProcess>;
  63946. /**
  63947. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63948. */
  63949. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63950. /**
  63951. * Base post-process used to calculate the average luminance of the final image for HDR
  63952. */
  63953. luminancePostProcess: Nullable<PostProcess>;
  63954. /**
  63955. * Post-processes used to create down sample post-processes in order to get
  63956. * the average luminance of the final image for HDR
  63957. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63958. */
  63959. luminanceDownSamplePostProcesses: PostProcess[];
  63960. /**
  63961. * Post-process used to create a HDR effect (light adaptation)
  63962. */
  63963. hdrPostProcess: Nullable<PostProcess>;
  63964. /**
  63965. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63966. */
  63967. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63968. /**
  63969. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63970. */
  63971. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63972. /**
  63973. * Post-process used to merge the final HDR post-process and the real scene color
  63974. */
  63975. hdrFinalPostProcess: Nullable<PostProcess>;
  63976. /**
  63977. * Post-process used to create a lens flare effect
  63978. */
  63979. lensFlarePostProcess: Nullable<PostProcess>;
  63980. /**
  63981. * Post-process that merges the result of the lens flare post-process and the real scene color
  63982. */
  63983. lensFlareComposePostProcess: Nullable<PostProcess>;
  63984. /**
  63985. * Post-process used to create a motion blur effect
  63986. */
  63987. motionBlurPostProcess: Nullable<PostProcess>;
  63988. /**
  63989. * Post-process used to create a depth of field effect
  63990. */
  63991. depthOfFieldPostProcess: Nullable<PostProcess>;
  63992. /**
  63993. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63994. */
  63995. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63996. /**
  63997. * Represents the brightness threshold in order to configure the illuminated surfaces
  63998. */
  63999. brightThreshold: number;
  64000. /**
  64001. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64002. */
  64003. blurWidth: number;
  64004. /**
  64005. * Sets if the blur for highlighted surfaces must be only horizontal
  64006. */
  64007. horizontalBlur: boolean;
  64008. /**
  64009. * Gets the overall exposure used by the pipeline
  64010. */
  64011. /**
  64012. * Sets the overall exposure used by the pipeline
  64013. */
  64014. exposure: number;
  64015. /**
  64016. * Texture used typically to simulate "dirty" on camera lens
  64017. */
  64018. lensTexture: Nullable<Texture>;
  64019. /**
  64020. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64021. */
  64022. volumetricLightCoefficient: number;
  64023. /**
  64024. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64025. */
  64026. volumetricLightPower: number;
  64027. /**
  64028. * Used the set the blur intensity to smooth the volumetric lights
  64029. */
  64030. volumetricLightBlurScale: number;
  64031. /**
  64032. * Light (spot or directional) used to generate the volumetric lights rays
  64033. * The source light must have a shadow generate so the pipeline can get its
  64034. * depth map
  64035. */
  64036. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64037. /**
  64038. * For eye adaptation, represents the minimum luminance the eye can see
  64039. */
  64040. hdrMinimumLuminance: number;
  64041. /**
  64042. * For eye adaptation, represents the decrease luminance speed
  64043. */
  64044. hdrDecreaseRate: number;
  64045. /**
  64046. * For eye adaptation, represents the increase luminance speed
  64047. */
  64048. hdrIncreaseRate: number;
  64049. /**
  64050. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64051. */
  64052. /**
  64053. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64054. */
  64055. hdrAutoExposure: boolean;
  64056. /**
  64057. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64058. */
  64059. lensColorTexture: Nullable<Texture>;
  64060. /**
  64061. * The overall strengh for the lens flare effect
  64062. */
  64063. lensFlareStrength: number;
  64064. /**
  64065. * Dispersion coefficient for lens flare ghosts
  64066. */
  64067. lensFlareGhostDispersal: number;
  64068. /**
  64069. * Main lens flare halo width
  64070. */
  64071. lensFlareHaloWidth: number;
  64072. /**
  64073. * Based on the lens distortion effect, defines how much the lens flare result
  64074. * is distorted
  64075. */
  64076. lensFlareDistortionStrength: number;
  64077. /**
  64078. * Configures the blur intensity used for for lens flare (halo)
  64079. */
  64080. lensFlareBlurWidth: number;
  64081. /**
  64082. * Lens star texture must be used to simulate rays on the flares and is available
  64083. * in the documentation
  64084. */
  64085. lensStarTexture: Nullable<Texture>;
  64086. /**
  64087. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64088. * flare effect by taking account of the dirt texture
  64089. */
  64090. lensFlareDirtTexture: Nullable<Texture>;
  64091. /**
  64092. * Represents the focal length for the depth of field effect
  64093. */
  64094. depthOfFieldDistance: number;
  64095. /**
  64096. * Represents the blur intensity for the blurred part of the depth of field effect
  64097. */
  64098. depthOfFieldBlurWidth: number;
  64099. /**
  64100. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64101. */
  64102. /**
  64103. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64104. */
  64105. motionStrength: number;
  64106. /**
  64107. * Gets wether or not the motion blur post-process is object based or screen based.
  64108. */
  64109. /**
  64110. * Sets wether or not the motion blur post-process should be object based or screen based
  64111. */
  64112. objectBasedMotionBlur: boolean;
  64113. /**
  64114. * List of animations for the pipeline (IAnimatable implementation)
  64115. */
  64116. animations: Animation[];
  64117. /**
  64118. * Private members
  64119. */
  64120. private _scene;
  64121. private _currentDepthOfFieldSource;
  64122. private _basePostProcess;
  64123. private _fixedExposure;
  64124. private _currentExposure;
  64125. private _hdrAutoExposure;
  64126. private _hdrCurrentLuminance;
  64127. private _motionStrength;
  64128. private _isObjectBasedMotionBlur;
  64129. private _floatTextureType;
  64130. private _camerasToBeAttached;
  64131. private _ratio;
  64132. private _bloomEnabled;
  64133. private _depthOfFieldEnabled;
  64134. private _vlsEnabled;
  64135. private _lensFlareEnabled;
  64136. private _hdrEnabled;
  64137. private _motionBlurEnabled;
  64138. private _fxaaEnabled;
  64139. private _motionBlurSamples;
  64140. private _volumetricLightStepsCount;
  64141. private _samples;
  64142. /**
  64143. * @ignore
  64144. * Specifies if the bloom pipeline is enabled
  64145. */
  64146. BloomEnabled: boolean;
  64147. /**
  64148. * @ignore
  64149. * Specifies if the depth of field pipeline is enabed
  64150. */
  64151. DepthOfFieldEnabled: boolean;
  64152. /**
  64153. * @ignore
  64154. * Specifies if the lens flare pipeline is enabed
  64155. */
  64156. LensFlareEnabled: boolean;
  64157. /**
  64158. * @ignore
  64159. * Specifies if the HDR pipeline is enabled
  64160. */
  64161. HDREnabled: boolean;
  64162. /**
  64163. * @ignore
  64164. * Specifies if the volumetric lights scattering effect is enabled
  64165. */
  64166. VLSEnabled: boolean;
  64167. /**
  64168. * @ignore
  64169. * Specifies if the motion blur effect is enabled
  64170. */
  64171. MotionBlurEnabled: boolean;
  64172. /**
  64173. * Specifies if anti-aliasing is enabled
  64174. */
  64175. fxaaEnabled: boolean;
  64176. /**
  64177. * Specifies the number of steps used to calculate the volumetric lights
  64178. * Typically in interval [50, 200]
  64179. */
  64180. volumetricLightStepsCount: number;
  64181. /**
  64182. * Specifies the number of samples used for the motion blur effect
  64183. * Typically in interval [16, 64]
  64184. */
  64185. motionBlurSamples: number;
  64186. /**
  64187. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64188. */
  64189. samples: number;
  64190. /**
  64191. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64192. * @constructor
  64193. * @param name The rendering pipeline name
  64194. * @param scene The scene linked to this pipeline
  64195. * @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)
  64196. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64197. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64198. */
  64199. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64200. private _buildPipeline;
  64201. private _createDownSampleX4PostProcess;
  64202. private _createBrightPassPostProcess;
  64203. private _createBlurPostProcesses;
  64204. private _createTextureAdderPostProcess;
  64205. private _createVolumetricLightPostProcess;
  64206. private _createLuminancePostProcesses;
  64207. private _createHdrPostProcess;
  64208. private _createLensFlarePostProcess;
  64209. private _createDepthOfFieldPostProcess;
  64210. private _createMotionBlurPostProcess;
  64211. private _getDepthTexture;
  64212. private _disposePostProcesses;
  64213. /**
  64214. * Dispose of the pipeline and stop all post processes
  64215. */
  64216. dispose(): void;
  64217. /**
  64218. * Serialize the rendering pipeline (Used when exporting)
  64219. * @returns the serialized object
  64220. */
  64221. serialize(): any;
  64222. /**
  64223. * Parse the serialized pipeline
  64224. * @param source Source pipeline.
  64225. * @param scene The scene to load the pipeline to.
  64226. * @param rootUrl The URL of the serialized pipeline.
  64227. * @returns An instantiated pipeline from the serialized object.
  64228. */
  64229. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64230. /**
  64231. * Luminance steps
  64232. */
  64233. static LuminanceSteps: number;
  64234. }
  64235. }
  64236. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64237. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64238. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64239. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64240. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64241. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64242. }
  64243. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64244. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64245. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64246. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64247. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64248. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64249. }
  64250. declare module "babylonjs/Shaders/tonemap.fragment" {
  64251. /** @hidden */
  64252. export var tonemapPixelShader: {
  64253. name: string;
  64254. shader: string;
  64255. };
  64256. }
  64257. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64258. import { Camera } from "babylonjs/Cameras/camera";
  64259. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64260. import "babylonjs/Shaders/tonemap.fragment";
  64261. import { Engine } from "babylonjs/Engines/engine";
  64262. /** Defines operator used for tonemapping */
  64263. export enum TonemappingOperator {
  64264. /** Hable */
  64265. Hable = 0,
  64266. /** Reinhard */
  64267. Reinhard = 1,
  64268. /** HejiDawson */
  64269. HejiDawson = 2,
  64270. /** Photographic */
  64271. Photographic = 3
  64272. }
  64273. /**
  64274. * Defines a post process to apply tone mapping
  64275. */
  64276. export class TonemapPostProcess extends PostProcess {
  64277. private _operator;
  64278. /** Defines the required exposure adjustement */
  64279. exposureAdjustment: number;
  64280. /**
  64281. * Creates a new TonemapPostProcess
  64282. * @param name defines the name of the postprocess
  64283. * @param _operator defines the operator to use
  64284. * @param exposureAdjustment defines the required exposure adjustement
  64285. * @param camera defines the camera to use (can be null)
  64286. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64287. * @param engine defines the hosting engine (can be ignore if camera is set)
  64288. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64289. */
  64290. constructor(name: string, _operator: TonemappingOperator,
  64291. /** Defines the required exposure adjustement */
  64292. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64293. }
  64294. }
  64295. declare module "babylonjs/Shaders/depth.vertex" {
  64296. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64297. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64298. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64299. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64301. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64302. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64303. /** @hidden */
  64304. export var depthVertexShader: {
  64305. name: string;
  64306. shader: string;
  64307. };
  64308. }
  64309. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64310. /** @hidden */
  64311. export var volumetricLightScatteringPixelShader: {
  64312. name: string;
  64313. shader: string;
  64314. };
  64315. }
  64316. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64317. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64319. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64320. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64321. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64322. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64323. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64324. /** @hidden */
  64325. export var volumetricLightScatteringPassVertexShader: {
  64326. name: string;
  64327. shader: string;
  64328. };
  64329. }
  64330. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64331. /** @hidden */
  64332. export var volumetricLightScatteringPassPixelShader: {
  64333. name: string;
  64334. shader: string;
  64335. };
  64336. }
  64337. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64338. import { Vector3 } from "babylonjs/Maths/math.vector";
  64339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64340. import { Mesh } from "babylonjs/Meshes/mesh";
  64341. import { Camera } from "babylonjs/Cameras/camera";
  64342. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64343. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64344. import { Scene } from "babylonjs/scene";
  64345. import "babylonjs/Meshes/Builders/planeBuilder";
  64346. import "babylonjs/Shaders/depth.vertex";
  64347. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64348. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64349. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64350. import { Engine } from "babylonjs/Engines/engine";
  64351. /**
  64352. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64353. */
  64354. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64355. private _volumetricLightScatteringPass;
  64356. private _volumetricLightScatteringRTT;
  64357. private _viewPort;
  64358. private _screenCoordinates;
  64359. private _cachedDefines;
  64360. /**
  64361. * If not undefined, the mesh position is computed from the attached node position
  64362. */
  64363. attachedNode: {
  64364. position: Vector3;
  64365. };
  64366. /**
  64367. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64368. */
  64369. customMeshPosition: Vector3;
  64370. /**
  64371. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64372. */
  64373. useCustomMeshPosition: boolean;
  64374. /**
  64375. * If the post-process should inverse the light scattering direction
  64376. */
  64377. invert: boolean;
  64378. /**
  64379. * The internal mesh used by the post-process
  64380. */
  64381. mesh: Mesh;
  64382. /**
  64383. * @hidden
  64384. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64385. */
  64386. useDiffuseColor: boolean;
  64387. /**
  64388. * Array containing the excluded meshes not rendered in the internal pass
  64389. */
  64390. excludedMeshes: AbstractMesh[];
  64391. /**
  64392. * Controls the overall intensity of the post-process
  64393. */
  64394. exposure: number;
  64395. /**
  64396. * Dissipates each sample's contribution in range [0, 1]
  64397. */
  64398. decay: number;
  64399. /**
  64400. * Controls the overall intensity of each sample
  64401. */
  64402. weight: number;
  64403. /**
  64404. * Controls the density of each sample
  64405. */
  64406. density: number;
  64407. /**
  64408. * @constructor
  64409. * @param name The post-process name
  64410. * @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)
  64411. * @param camera The camera that the post-process will be attached to
  64412. * @param mesh The mesh used to create the light scattering
  64413. * @param samples The post-process quality, default 100
  64414. * @param samplingModeThe post-process filtering mode
  64415. * @param engine The babylon engine
  64416. * @param reusable If the post-process is reusable
  64417. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64418. */
  64419. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64420. /**
  64421. * Returns the string "VolumetricLightScatteringPostProcess"
  64422. * @returns "VolumetricLightScatteringPostProcess"
  64423. */
  64424. getClassName(): string;
  64425. private _isReady;
  64426. /**
  64427. * Sets the new light position for light scattering effect
  64428. * @param position The new custom light position
  64429. */
  64430. setCustomMeshPosition(position: Vector3): void;
  64431. /**
  64432. * Returns the light position for light scattering effect
  64433. * @return Vector3 The custom light position
  64434. */
  64435. getCustomMeshPosition(): Vector3;
  64436. /**
  64437. * Disposes the internal assets and detaches the post-process from the camera
  64438. */
  64439. dispose(camera: Camera): void;
  64440. /**
  64441. * Returns the render target texture used by the post-process
  64442. * @return the render target texture used by the post-process
  64443. */
  64444. getPass(): RenderTargetTexture;
  64445. private _meshExcluded;
  64446. private _createPass;
  64447. private _updateMeshScreenCoordinates;
  64448. /**
  64449. * Creates a default mesh for the Volumeric Light Scattering post-process
  64450. * @param name The mesh name
  64451. * @param scene The scene where to create the mesh
  64452. * @return the default mesh
  64453. */
  64454. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64455. }
  64456. }
  64457. declare module "babylonjs/PostProcesses/index" {
  64458. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64459. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64460. export * from "babylonjs/PostProcesses/bloomEffect";
  64461. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64462. export * from "babylonjs/PostProcesses/blurPostProcess";
  64463. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64464. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64465. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64466. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64467. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64468. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64469. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64470. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64471. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64472. export * from "babylonjs/PostProcesses/filterPostProcess";
  64473. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64474. export * from "babylonjs/PostProcesses/grainPostProcess";
  64475. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64476. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64477. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64478. export * from "babylonjs/PostProcesses/passPostProcess";
  64479. export * from "babylonjs/PostProcesses/postProcess";
  64480. export * from "babylonjs/PostProcesses/postProcessManager";
  64481. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64482. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64483. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64484. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64485. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64486. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64487. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64488. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64489. }
  64490. declare module "babylonjs/Probes/index" {
  64491. export * from "babylonjs/Probes/reflectionProbe";
  64492. }
  64493. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64494. import { Scene } from "babylonjs/scene";
  64495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64496. import { SmartArray } from "babylonjs/Misc/smartArray";
  64497. import { ISceneComponent } from "babylonjs/sceneComponent";
  64498. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64499. import "babylonjs/Meshes/Builders/boxBuilder";
  64500. import "babylonjs/Shaders/color.fragment";
  64501. import "babylonjs/Shaders/color.vertex";
  64502. import { Color3 } from "babylonjs/Maths/math.color";
  64503. module "babylonjs/scene" {
  64504. interface Scene {
  64505. /** @hidden (Backing field) */
  64506. _boundingBoxRenderer: BoundingBoxRenderer;
  64507. /** @hidden (Backing field) */
  64508. _forceShowBoundingBoxes: boolean;
  64509. /**
  64510. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64511. */
  64512. forceShowBoundingBoxes: boolean;
  64513. /**
  64514. * Gets the bounding box renderer associated with the scene
  64515. * @returns a BoundingBoxRenderer
  64516. */
  64517. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64518. }
  64519. }
  64520. module "babylonjs/Meshes/abstractMesh" {
  64521. interface AbstractMesh {
  64522. /** @hidden (Backing field) */
  64523. _showBoundingBox: boolean;
  64524. /**
  64525. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64526. */
  64527. showBoundingBox: boolean;
  64528. }
  64529. }
  64530. /**
  64531. * Component responsible of rendering the bounding box of the meshes in a scene.
  64532. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64533. */
  64534. export class BoundingBoxRenderer implements ISceneComponent {
  64535. /**
  64536. * The component name helpfull to identify the component in the list of scene components.
  64537. */
  64538. readonly name: string;
  64539. /**
  64540. * The scene the component belongs to.
  64541. */
  64542. scene: Scene;
  64543. /**
  64544. * Color of the bounding box lines placed in front of an object
  64545. */
  64546. frontColor: Color3;
  64547. /**
  64548. * Color of the bounding box lines placed behind an object
  64549. */
  64550. backColor: Color3;
  64551. /**
  64552. * Defines if the renderer should show the back lines or not
  64553. */
  64554. showBackLines: boolean;
  64555. /**
  64556. * @hidden
  64557. */
  64558. renderList: SmartArray<BoundingBox>;
  64559. private _colorShader;
  64560. private _vertexBuffers;
  64561. private _indexBuffer;
  64562. private _fillIndexBuffer;
  64563. private _fillIndexData;
  64564. /**
  64565. * Instantiates a new bounding box renderer in a scene.
  64566. * @param scene the scene the renderer renders in
  64567. */
  64568. constructor(scene: Scene);
  64569. /**
  64570. * Registers the component in a given scene
  64571. */
  64572. register(): void;
  64573. private _evaluateSubMesh;
  64574. private _activeMesh;
  64575. private _prepareRessources;
  64576. private _createIndexBuffer;
  64577. /**
  64578. * Rebuilds the elements related to this component in case of
  64579. * context lost for instance.
  64580. */
  64581. rebuild(): void;
  64582. /**
  64583. * @hidden
  64584. */
  64585. reset(): void;
  64586. /**
  64587. * Render the bounding boxes of a specific rendering group
  64588. * @param renderingGroupId defines the rendering group to render
  64589. */
  64590. render(renderingGroupId: number): void;
  64591. /**
  64592. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64593. * @param mesh Define the mesh to render the occlusion bounding box for
  64594. */
  64595. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64596. /**
  64597. * Dispose and release the resources attached to this renderer.
  64598. */
  64599. dispose(): void;
  64600. }
  64601. }
  64602. declare module "babylonjs/Shaders/depth.fragment" {
  64603. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64604. /** @hidden */
  64605. export var depthPixelShader: {
  64606. name: string;
  64607. shader: string;
  64608. };
  64609. }
  64610. declare module "babylonjs/Rendering/depthRenderer" {
  64611. import { Nullable } from "babylonjs/types";
  64612. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64613. import { Scene } from "babylonjs/scene";
  64614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64615. import { Camera } from "babylonjs/Cameras/camera";
  64616. import "babylonjs/Shaders/depth.fragment";
  64617. import "babylonjs/Shaders/depth.vertex";
  64618. /**
  64619. * This represents a depth renderer in Babylon.
  64620. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64621. */
  64622. export class DepthRenderer {
  64623. private _scene;
  64624. private _depthMap;
  64625. private _effect;
  64626. private readonly _storeNonLinearDepth;
  64627. private readonly _clearColor;
  64628. /** Get if the depth renderer is using packed depth or not */
  64629. readonly isPacked: boolean;
  64630. private _cachedDefines;
  64631. private _camera;
  64632. /**
  64633. * Specifiess that the depth renderer will only be used within
  64634. * the camera it is created for.
  64635. * This can help forcing its rendering during the camera processing.
  64636. */
  64637. useOnlyInActiveCamera: boolean;
  64638. /** @hidden */
  64639. static _SceneComponentInitialization: (scene: Scene) => void;
  64640. /**
  64641. * Instantiates a depth renderer
  64642. * @param scene The scene the renderer belongs to
  64643. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64644. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64645. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64646. */
  64647. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64648. /**
  64649. * Creates the depth rendering effect and checks if the effect is ready.
  64650. * @param subMesh The submesh to be used to render the depth map of
  64651. * @param useInstances If multiple world instances should be used
  64652. * @returns if the depth renderer is ready to render the depth map
  64653. */
  64654. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64655. /**
  64656. * Gets the texture which the depth map will be written to.
  64657. * @returns The depth map texture
  64658. */
  64659. getDepthMap(): RenderTargetTexture;
  64660. /**
  64661. * Disposes of the depth renderer.
  64662. */
  64663. dispose(): void;
  64664. }
  64665. }
  64666. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64667. import { Nullable } from "babylonjs/types";
  64668. import { Scene } from "babylonjs/scene";
  64669. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64670. import { Camera } from "babylonjs/Cameras/camera";
  64671. import { ISceneComponent } from "babylonjs/sceneComponent";
  64672. module "babylonjs/scene" {
  64673. interface Scene {
  64674. /** @hidden (Backing field) */
  64675. _depthRenderer: {
  64676. [id: string]: DepthRenderer;
  64677. };
  64678. /**
  64679. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64680. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64681. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64682. * @returns the created depth renderer
  64683. */
  64684. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64685. /**
  64686. * Disables a depth renderer for a given camera
  64687. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64688. */
  64689. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64690. }
  64691. }
  64692. /**
  64693. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64694. * in several rendering techniques.
  64695. */
  64696. export class DepthRendererSceneComponent implements ISceneComponent {
  64697. /**
  64698. * The component name helpfull to identify the component in the list of scene components.
  64699. */
  64700. readonly name: string;
  64701. /**
  64702. * The scene the component belongs to.
  64703. */
  64704. scene: Scene;
  64705. /**
  64706. * Creates a new instance of the component for the given scene
  64707. * @param scene Defines the scene to register the component in
  64708. */
  64709. constructor(scene: Scene);
  64710. /**
  64711. * Registers the component in a given scene
  64712. */
  64713. register(): void;
  64714. /**
  64715. * Rebuilds the elements related to this component in case of
  64716. * context lost for instance.
  64717. */
  64718. rebuild(): void;
  64719. /**
  64720. * Disposes the component and the associated ressources
  64721. */
  64722. dispose(): void;
  64723. private _gatherRenderTargets;
  64724. private _gatherActiveCameraRenderTargets;
  64725. }
  64726. }
  64727. declare module "babylonjs/Shaders/outline.fragment" {
  64728. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64729. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64730. /** @hidden */
  64731. export var outlinePixelShader: {
  64732. name: string;
  64733. shader: string;
  64734. };
  64735. }
  64736. declare module "babylonjs/Shaders/outline.vertex" {
  64737. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64738. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64739. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64740. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64741. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64743. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64744. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64745. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64746. /** @hidden */
  64747. export var outlineVertexShader: {
  64748. name: string;
  64749. shader: string;
  64750. };
  64751. }
  64752. declare module "babylonjs/Rendering/outlineRenderer" {
  64753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64754. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64755. import { Scene } from "babylonjs/scene";
  64756. import { ISceneComponent } from "babylonjs/sceneComponent";
  64757. import "babylonjs/Shaders/outline.fragment";
  64758. import "babylonjs/Shaders/outline.vertex";
  64759. module "babylonjs/scene" {
  64760. interface Scene {
  64761. /** @hidden */
  64762. _outlineRenderer: OutlineRenderer;
  64763. /**
  64764. * Gets the outline renderer associated with the scene
  64765. * @returns a OutlineRenderer
  64766. */
  64767. getOutlineRenderer(): OutlineRenderer;
  64768. }
  64769. }
  64770. module "babylonjs/Meshes/abstractMesh" {
  64771. interface AbstractMesh {
  64772. /** @hidden (Backing field) */
  64773. _renderOutline: boolean;
  64774. /**
  64775. * Gets or sets a boolean indicating if the outline must be rendered as well
  64776. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64777. */
  64778. renderOutline: boolean;
  64779. /** @hidden (Backing field) */
  64780. _renderOverlay: boolean;
  64781. /**
  64782. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64783. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64784. */
  64785. renderOverlay: boolean;
  64786. }
  64787. }
  64788. /**
  64789. * This class is responsible to draw bothe outline/overlay of meshes.
  64790. * It should not be used directly but through the available method on mesh.
  64791. */
  64792. export class OutlineRenderer implements ISceneComponent {
  64793. /**
  64794. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64795. */
  64796. private static _StencilReference;
  64797. /**
  64798. * The name of the component. Each component must have a unique name.
  64799. */
  64800. name: string;
  64801. /**
  64802. * The scene the component belongs to.
  64803. */
  64804. scene: Scene;
  64805. /**
  64806. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64807. */
  64808. zOffset: number;
  64809. private _engine;
  64810. private _effect;
  64811. private _cachedDefines;
  64812. private _savedDepthWrite;
  64813. /**
  64814. * Instantiates a new outline renderer. (There could be only one per scene).
  64815. * @param scene Defines the scene it belongs to
  64816. */
  64817. constructor(scene: Scene);
  64818. /**
  64819. * Register the component to one instance of a scene.
  64820. */
  64821. register(): void;
  64822. /**
  64823. * Rebuilds the elements related to this component in case of
  64824. * context lost for instance.
  64825. */
  64826. rebuild(): void;
  64827. /**
  64828. * Disposes the component and the associated ressources.
  64829. */
  64830. dispose(): void;
  64831. /**
  64832. * Renders the outline in the canvas.
  64833. * @param subMesh Defines the sumesh to render
  64834. * @param batch Defines the batch of meshes in case of instances
  64835. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64836. */
  64837. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64838. /**
  64839. * Returns whether or not the outline renderer is ready for a given submesh.
  64840. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64841. * @param subMesh Defines the submesh to check readyness for
  64842. * @param useInstances Defines wheter wee are trying to render instances or not
  64843. * @returns true if ready otherwise false
  64844. */
  64845. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64846. private _beforeRenderingMesh;
  64847. private _afterRenderingMesh;
  64848. }
  64849. }
  64850. declare module "babylonjs/Rendering/index" {
  64851. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64852. export * from "babylonjs/Rendering/depthRenderer";
  64853. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64854. export * from "babylonjs/Rendering/edgesRenderer";
  64855. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64856. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64857. export * from "babylonjs/Rendering/outlineRenderer";
  64858. export * from "babylonjs/Rendering/renderingGroup";
  64859. export * from "babylonjs/Rendering/renderingManager";
  64860. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64861. }
  64862. declare module "babylonjs/Sprites/spritePackedManager" {
  64863. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64864. import { Scene } from "babylonjs/scene";
  64865. /**
  64866. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64867. * @see http://doc.babylonjs.com/babylon101/sprites
  64868. */
  64869. export class SpritePackedManager extends SpriteManager {
  64870. /** defines the packed manager's name */
  64871. name: string;
  64872. /**
  64873. * Creates a new sprite manager from a packed sprite sheet
  64874. * @param name defines the manager's name
  64875. * @param imgUrl defines the sprite sheet url
  64876. * @param capacity defines the maximum allowed number of sprites
  64877. * @param scene defines the hosting scene
  64878. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64879. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64880. * @param samplingMode defines the smapling mode to use with spritesheet
  64881. * @param fromPacked set to true; do not alter
  64882. */
  64883. constructor(
  64884. /** defines the packed manager's name */
  64885. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64886. }
  64887. }
  64888. declare module "babylonjs/Sprites/index" {
  64889. export * from "babylonjs/Sprites/sprite";
  64890. export * from "babylonjs/Sprites/spriteManager";
  64891. export * from "babylonjs/Sprites/spritePackedManager";
  64892. export * from "babylonjs/Sprites/spriteSceneComponent";
  64893. }
  64894. declare module "babylonjs/States/index" {
  64895. export * from "babylonjs/States/alphaCullingState";
  64896. export * from "babylonjs/States/depthCullingState";
  64897. export * from "babylonjs/States/stencilState";
  64898. }
  64899. declare module "babylonjs/Misc/assetsManager" {
  64900. import { Scene } from "babylonjs/scene";
  64901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64902. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64903. import { Skeleton } from "babylonjs/Bones/skeleton";
  64904. import { Observable } from "babylonjs/Misc/observable";
  64905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64906. import { Texture } from "babylonjs/Materials/Textures/texture";
  64907. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64908. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64909. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64910. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64911. /**
  64912. * Defines the list of states available for a task inside a AssetsManager
  64913. */
  64914. export enum AssetTaskState {
  64915. /**
  64916. * Initialization
  64917. */
  64918. INIT = 0,
  64919. /**
  64920. * Running
  64921. */
  64922. RUNNING = 1,
  64923. /**
  64924. * Done
  64925. */
  64926. DONE = 2,
  64927. /**
  64928. * Error
  64929. */
  64930. ERROR = 3
  64931. }
  64932. /**
  64933. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64934. */
  64935. export abstract class AbstractAssetTask {
  64936. /**
  64937. * Task name
  64938. */ name: string;
  64939. /**
  64940. * Callback called when the task is successful
  64941. */
  64942. onSuccess: (task: any) => void;
  64943. /**
  64944. * Callback called when the task is not successful
  64945. */
  64946. onError: (task: any, message?: string, exception?: any) => void;
  64947. /**
  64948. * Creates a new AssetsManager
  64949. * @param name defines the name of the task
  64950. */
  64951. constructor(
  64952. /**
  64953. * Task name
  64954. */ name: string);
  64955. private _isCompleted;
  64956. private _taskState;
  64957. private _errorObject;
  64958. /**
  64959. * Get if the task is completed
  64960. */
  64961. readonly isCompleted: boolean;
  64962. /**
  64963. * Gets the current state of the task
  64964. */
  64965. readonly taskState: AssetTaskState;
  64966. /**
  64967. * Gets the current error object (if task is in error)
  64968. */
  64969. readonly errorObject: {
  64970. message?: string;
  64971. exception?: any;
  64972. };
  64973. /**
  64974. * Internal only
  64975. * @hidden
  64976. */
  64977. _setErrorObject(message?: string, exception?: any): void;
  64978. /**
  64979. * Execute the current task
  64980. * @param scene defines the scene where you want your assets to be loaded
  64981. * @param onSuccess is a callback called when the task is successfully executed
  64982. * @param onError is a callback called if an error occurs
  64983. */
  64984. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64985. /**
  64986. * Execute the current task
  64987. * @param scene defines the scene where you want your assets to be loaded
  64988. * @param onSuccess is a callback called when the task is successfully executed
  64989. * @param onError is a callback called if an error occurs
  64990. */
  64991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64992. /**
  64993. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64994. * This can be used with failed tasks that have the reason for failure fixed.
  64995. */
  64996. reset(): void;
  64997. private onErrorCallback;
  64998. private onDoneCallback;
  64999. }
  65000. /**
  65001. * Define the interface used by progress events raised during assets loading
  65002. */
  65003. export interface IAssetsProgressEvent {
  65004. /**
  65005. * Defines the number of remaining tasks to process
  65006. */
  65007. remainingCount: number;
  65008. /**
  65009. * Defines the total number of tasks
  65010. */
  65011. totalCount: number;
  65012. /**
  65013. * Defines the task that was just processed
  65014. */
  65015. task: AbstractAssetTask;
  65016. }
  65017. /**
  65018. * Class used to share progress information about assets loading
  65019. */
  65020. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65021. /**
  65022. * Defines the number of remaining tasks to process
  65023. */
  65024. remainingCount: number;
  65025. /**
  65026. * Defines the total number of tasks
  65027. */
  65028. totalCount: number;
  65029. /**
  65030. * Defines the task that was just processed
  65031. */
  65032. task: AbstractAssetTask;
  65033. /**
  65034. * Creates a AssetsProgressEvent
  65035. * @param remainingCount defines the number of remaining tasks to process
  65036. * @param totalCount defines the total number of tasks
  65037. * @param task defines the task that was just processed
  65038. */
  65039. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65040. }
  65041. /**
  65042. * Define a task used by AssetsManager to load meshes
  65043. */
  65044. export class MeshAssetTask extends AbstractAssetTask {
  65045. /**
  65046. * Defines the name of the task
  65047. */
  65048. name: string;
  65049. /**
  65050. * Defines the list of mesh's names you want to load
  65051. */
  65052. meshesNames: any;
  65053. /**
  65054. * Defines the root url to use as a base to load your meshes and associated resources
  65055. */
  65056. rootUrl: string;
  65057. /**
  65058. * Defines the filename of the scene to load from
  65059. */
  65060. sceneFilename: string;
  65061. /**
  65062. * Gets the list of loaded meshes
  65063. */
  65064. loadedMeshes: Array<AbstractMesh>;
  65065. /**
  65066. * Gets the list of loaded particle systems
  65067. */
  65068. loadedParticleSystems: Array<IParticleSystem>;
  65069. /**
  65070. * Gets the list of loaded skeletons
  65071. */
  65072. loadedSkeletons: Array<Skeleton>;
  65073. /**
  65074. * Gets the list of loaded animation groups
  65075. */
  65076. loadedAnimationGroups: Array<AnimationGroup>;
  65077. /**
  65078. * Callback called when the task is successful
  65079. */
  65080. onSuccess: (task: MeshAssetTask) => void;
  65081. /**
  65082. * Callback called when the task is successful
  65083. */
  65084. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65085. /**
  65086. * Creates a new MeshAssetTask
  65087. * @param name defines the name of the task
  65088. * @param meshesNames defines the list of mesh's names you want to load
  65089. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65090. * @param sceneFilename defines the filename of the scene to load from
  65091. */
  65092. constructor(
  65093. /**
  65094. * Defines the name of the task
  65095. */
  65096. name: string,
  65097. /**
  65098. * Defines the list of mesh's names you want to load
  65099. */
  65100. meshesNames: any,
  65101. /**
  65102. * Defines the root url to use as a base to load your meshes and associated resources
  65103. */
  65104. rootUrl: string,
  65105. /**
  65106. * Defines the filename of the scene to load from
  65107. */
  65108. sceneFilename: string);
  65109. /**
  65110. * Execute the current task
  65111. * @param scene defines the scene where you want your assets to be loaded
  65112. * @param onSuccess is a callback called when the task is successfully executed
  65113. * @param onError is a callback called if an error occurs
  65114. */
  65115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65116. }
  65117. /**
  65118. * Define a task used by AssetsManager to load text content
  65119. */
  65120. export class TextFileAssetTask extends AbstractAssetTask {
  65121. /**
  65122. * Defines the name of the task
  65123. */
  65124. name: string;
  65125. /**
  65126. * Defines the location of the file to load
  65127. */
  65128. url: string;
  65129. /**
  65130. * Gets the loaded text string
  65131. */
  65132. text: string;
  65133. /**
  65134. * Callback called when the task is successful
  65135. */
  65136. onSuccess: (task: TextFileAssetTask) => void;
  65137. /**
  65138. * Callback called when the task is successful
  65139. */
  65140. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65141. /**
  65142. * Creates a new TextFileAssetTask object
  65143. * @param name defines the name of the task
  65144. * @param url defines the location of the file to load
  65145. */
  65146. constructor(
  65147. /**
  65148. * Defines the name of the task
  65149. */
  65150. name: string,
  65151. /**
  65152. * Defines the location of the file to load
  65153. */
  65154. url: string);
  65155. /**
  65156. * Execute the current task
  65157. * @param scene defines the scene where you want your assets to be loaded
  65158. * @param onSuccess is a callback called when the task is successfully executed
  65159. * @param onError is a callback called if an error occurs
  65160. */
  65161. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65162. }
  65163. /**
  65164. * Define a task used by AssetsManager to load binary data
  65165. */
  65166. export class BinaryFileAssetTask extends AbstractAssetTask {
  65167. /**
  65168. * Defines the name of the task
  65169. */
  65170. name: string;
  65171. /**
  65172. * Defines the location of the file to load
  65173. */
  65174. url: string;
  65175. /**
  65176. * Gets the lodaded data (as an array buffer)
  65177. */
  65178. data: ArrayBuffer;
  65179. /**
  65180. * Callback called when the task is successful
  65181. */
  65182. onSuccess: (task: BinaryFileAssetTask) => void;
  65183. /**
  65184. * Callback called when the task is successful
  65185. */
  65186. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65187. /**
  65188. * Creates a new BinaryFileAssetTask object
  65189. * @param name defines the name of the new task
  65190. * @param url defines the location of the file to load
  65191. */
  65192. constructor(
  65193. /**
  65194. * Defines the name of the task
  65195. */
  65196. name: string,
  65197. /**
  65198. * Defines the location of the file to load
  65199. */
  65200. url: string);
  65201. /**
  65202. * Execute the current task
  65203. * @param scene defines the scene where you want your assets to be loaded
  65204. * @param onSuccess is a callback called when the task is successfully executed
  65205. * @param onError is a callback called if an error occurs
  65206. */
  65207. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65208. }
  65209. /**
  65210. * Define a task used by AssetsManager to load images
  65211. */
  65212. export class ImageAssetTask extends AbstractAssetTask {
  65213. /**
  65214. * Defines the name of the task
  65215. */
  65216. name: string;
  65217. /**
  65218. * Defines the location of the image to load
  65219. */
  65220. url: string;
  65221. /**
  65222. * Gets the loaded images
  65223. */
  65224. image: HTMLImageElement;
  65225. /**
  65226. * Callback called when the task is successful
  65227. */
  65228. onSuccess: (task: ImageAssetTask) => void;
  65229. /**
  65230. * Callback called when the task is successful
  65231. */
  65232. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65233. /**
  65234. * Creates a new ImageAssetTask
  65235. * @param name defines the name of the task
  65236. * @param url defines the location of the image to load
  65237. */
  65238. constructor(
  65239. /**
  65240. * Defines the name of the task
  65241. */
  65242. name: string,
  65243. /**
  65244. * Defines the location of the image to load
  65245. */
  65246. url: string);
  65247. /**
  65248. * Execute the current task
  65249. * @param scene defines the scene where you want your assets to be loaded
  65250. * @param onSuccess is a callback called when the task is successfully executed
  65251. * @param onError is a callback called if an error occurs
  65252. */
  65253. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65254. }
  65255. /**
  65256. * Defines the interface used by texture loading tasks
  65257. */
  65258. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65259. /**
  65260. * Gets the loaded texture
  65261. */
  65262. texture: TEX;
  65263. }
  65264. /**
  65265. * Define a task used by AssetsManager to load 2D textures
  65266. */
  65267. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65268. /**
  65269. * Defines the name of the task
  65270. */
  65271. name: string;
  65272. /**
  65273. * Defines the location of the file to load
  65274. */
  65275. url: string;
  65276. /**
  65277. * Defines if mipmap should not be generated (default is false)
  65278. */
  65279. noMipmap?: boolean | undefined;
  65280. /**
  65281. * Defines if texture must be inverted on Y axis (default is false)
  65282. */
  65283. invertY?: boolean | undefined;
  65284. /**
  65285. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65286. */
  65287. samplingMode: number;
  65288. /**
  65289. * Gets the loaded texture
  65290. */
  65291. texture: Texture;
  65292. /**
  65293. * Callback called when the task is successful
  65294. */
  65295. onSuccess: (task: TextureAssetTask) => void;
  65296. /**
  65297. * Callback called when the task is successful
  65298. */
  65299. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65300. /**
  65301. * Creates a new TextureAssetTask object
  65302. * @param name defines the name of the task
  65303. * @param url defines the location of the file to load
  65304. * @param noMipmap defines if mipmap should not be generated (default is false)
  65305. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65306. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65307. */
  65308. constructor(
  65309. /**
  65310. * Defines the name of the task
  65311. */
  65312. name: string,
  65313. /**
  65314. * Defines the location of the file to load
  65315. */
  65316. url: string,
  65317. /**
  65318. * Defines if mipmap should not be generated (default is false)
  65319. */
  65320. noMipmap?: boolean | undefined,
  65321. /**
  65322. * Defines if texture must be inverted on Y axis (default is false)
  65323. */
  65324. invertY?: boolean | undefined,
  65325. /**
  65326. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65327. */
  65328. samplingMode?: number);
  65329. /**
  65330. * Execute the current task
  65331. * @param scene defines the scene where you want your assets to be loaded
  65332. * @param onSuccess is a callback called when the task is successfully executed
  65333. * @param onError is a callback called if an error occurs
  65334. */
  65335. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65336. }
  65337. /**
  65338. * Define a task used by AssetsManager to load cube textures
  65339. */
  65340. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65341. /**
  65342. * Defines the name of the task
  65343. */
  65344. name: string;
  65345. /**
  65346. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65347. */
  65348. url: string;
  65349. /**
  65350. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65351. */
  65352. extensions?: string[] | undefined;
  65353. /**
  65354. * Defines if mipmaps should not be generated (default is false)
  65355. */
  65356. noMipmap?: boolean | undefined;
  65357. /**
  65358. * Defines the explicit list of files (undefined by default)
  65359. */
  65360. files?: string[] | undefined;
  65361. /**
  65362. * Gets the loaded texture
  65363. */
  65364. texture: CubeTexture;
  65365. /**
  65366. * Callback called when the task is successful
  65367. */
  65368. onSuccess: (task: CubeTextureAssetTask) => void;
  65369. /**
  65370. * Callback called when the task is successful
  65371. */
  65372. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65373. /**
  65374. * Creates a new CubeTextureAssetTask
  65375. * @param name defines the name of the task
  65376. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65377. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65378. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65379. * @param files defines the explicit list of files (undefined by default)
  65380. */
  65381. constructor(
  65382. /**
  65383. * Defines the name of the task
  65384. */
  65385. name: string,
  65386. /**
  65387. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65388. */
  65389. url: string,
  65390. /**
  65391. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65392. */
  65393. extensions?: string[] | undefined,
  65394. /**
  65395. * Defines if mipmaps should not be generated (default is false)
  65396. */
  65397. noMipmap?: boolean | undefined,
  65398. /**
  65399. * Defines the explicit list of files (undefined by default)
  65400. */
  65401. files?: string[] | undefined);
  65402. /**
  65403. * Execute the current task
  65404. * @param scene defines the scene where you want your assets to be loaded
  65405. * @param onSuccess is a callback called when the task is successfully executed
  65406. * @param onError is a callback called if an error occurs
  65407. */
  65408. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65409. }
  65410. /**
  65411. * Define a task used by AssetsManager to load HDR cube textures
  65412. */
  65413. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65414. /**
  65415. * Defines the name of the task
  65416. */
  65417. name: string;
  65418. /**
  65419. * Defines the location of the file to load
  65420. */
  65421. url: string;
  65422. /**
  65423. * Defines the desired size (the more it increases the longer the generation will be)
  65424. */
  65425. size: number;
  65426. /**
  65427. * Defines if mipmaps should not be generated (default is false)
  65428. */
  65429. noMipmap: boolean;
  65430. /**
  65431. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65432. */
  65433. generateHarmonics: boolean;
  65434. /**
  65435. * 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)
  65436. */
  65437. gammaSpace: boolean;
  65438. /**
  65439. * Internal Use Only
  65440. */
  65441. reserved: boolean;
  65442. /**
  65443. * Gets the loaded texture
  65444. */
  65445. texture: HDRCubeTexture;
  65446. /**
  65447. * Callback called when the task is successful
  65448. */
  65449. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65450. /**
  65451. * Callback called when the task is successful
  65452. */
  65453. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65454. /**
  65455. * Creates a new HDRCubeTextureAssetTask object
  65456. * @param name defines the name of the task
  65457. * @param url defines the location of the file to load
  65458. * @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.
  65459. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65460. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65461. * @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)
  65462. * @param reserved Internal use only
  65463. */
  65464. constructor(
  65465. /**
  65466. * Defines the name of the task
  65467. */
  65468. name: string,
  65469. /**
  65470. * Defines the location of the file to load
  65471. */
  65472. url: string,
  65473. /**
  65474. * Defines the desired size (the more it increases the longer the generation will be)
  65475. */
  65476. size: number,
  65477. /**
  65478. * Defines if mipmaps should not be generated (default is false)
  65479. */
  65480. noMipmap?: boolean,
  65481. /**
  65482. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65483. */
  65484. generateHarmonics?: boolean,
  65485. /**
  65486. * 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)
  65487. */
  65488. gammaSpace?: boolean,
  65489. /**
  65490. * Internal Use Only
  65491. */
  65492. reserved?: boolean);
  65493. /**
  65494. * Execute the current task
  65495. * @param scene defines the scene where you want your assets to be loaded
  65496. * @param onSuccess is a callback called when the task is successfully executed
  65497. * @param onError is a callback called if an error occurs
  65498. */
  65499. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65500. }
  65501. /**
  65502. * Define a task used by AssetsManager to load Equirectangular cube textures
  65503. */
  65504. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65505. /**
  65506. * Defines the name of the task
  65507. */
  65508. name: string;
  65509. /**
  65510. * Defines the location of the file to load
  65511. */
  65512. url: string;
  65513. /**
  65514. * Defines the desired size (the more it increases the longer the generation will be)
  65515. */
  65516. size: number;
  65517. /**
  65518. * Defines if mipmaps should not be generated (default is false)
  65519. */
  65520. noMipmap: boolean;
  65521. /**
  65522. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65523. * but the standard material would require them in Gamma space) (default is true)
  65524. */
  65525. gammaSpace: boolean;
  65526. /**
  65527. * Gets the loaded texture
  65528. */
  65529. texture: EquiRectangularCubeTexture;
  65530. /**
  65531. * Callback called when the task is successful
  65532. */
  65533. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65534. /**
  65535. * Callback called when the task is successful
  65536. */
  65537. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65538. /**
  65539. * Creates a new EquiRectangularCubeTextureAssetTask object
  65540. * @param name defines the name of the task
  65541. * @param url defines the location of the file to load
  65542. * @param size defines the desired size (the more it increases the longer the generation will be)
  65543. * If the size is omitted this implies you are using a preprocessed cubemap.
  65544. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65545. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65546. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65547. * (default is true)
  65548. */
  65549. constructor(
  65550. /**
  65551. * Defines the name of the task
  65552. */
  65553. name: string,
  65554. /**
  65555. * Defines the location of the file to load
  65556. */
  65557. url: string,
  65558. /**
  65559. * Defines the desired size (the more it increases the longer the generation will be)
  65560. */
  65561. size: number,
  65562. /**
  65563. * Defines if mipmaps should not be generated (default is false)
  65564. */
  65565. noMipmap?: boolean,
  65566. /**
  65567. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65568. * but the standard material would require them in Gamma space) (default is true)
  65569. */
  65570. gammaSpace?: boolean);
  65571. /**
  65572. * Execute the current task
  65573. * @param scene defines the scene where you want your assets to be loaded
  65574. * @param onSuccess is a callback called when the task is successfully executed
  65575. * @param onError is a callback called if an error occurs
  65576. */
  65577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65578. }
  65579. /**
  65580. * This class can be used to easily import assets into a scene
  65581. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65582. */
  65583. export class AssetsManager {
  65584. private _scene;
  65585. private _isLoading;
  65586. protected _tasks: AbstractAssetTask[];
  65587. protected _waitingTasksCount: number;
  65588. protected _totalTasksCount: number;
  65589. /**
  65590. * Callback called when all tasks are processed
  65591. */
  65592. onFinish: (tasks: AbstractAssetTask[]) => void;
  65593. /**
  65594. * Callback called when a task is successful
  65595. */
  65596. onTaskSuccess: (task: AbstractAssetTask) => void;
  65597. /**
  65598. * Callback called when a task had an error
  65599. */
  65600. onTaskError: (task: AbstractAssetTask) => void;
  65601. /**
  65602. * Callback called when a task is done (whatever the result is)
  65603. */
  65604. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65605. /**
  65606. * Observable called when all tasks are processed
  65607. */
  65608. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65609. /**
  65610. * Observable called when a task had an error
  65611. */
  65612. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65613. /**
  65614. * Observable called when all tasks were executed
  65615. */
  65616. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65617. /**
  65618. * Observable called when a task is done (whatever the result is)
  65619. */
  65620. onProgressObservable: Observable<IAssetsProgressEvent>;
  65621. /**
  65622. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65623. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65624. */
  65625. useDefaultLoadingScreen: boolean;
  65626. /**
  65627. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65628. * when all assets have been downloaded.
  65629. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65630. */
  65631. autoHideLoadingUI: boolean;
  65632. /**
  65633. * Creates a new AssetsManager
  65634. * @param scene defines the scene to work on
  65635. */
  65636. constructor(scene: Scene);
  65637. /**
  65638. * Add a MeshAssetTask to the list of active tasks
  65639. * @param taskName defines the name of the new task
  65640. * @param meshesNames defines the name of meshes to load
  65641. * @param rootUrl defines the root url to use to locate files
  65642. * @param sceneFilename defines the filename of the scene file
  65643. * @returns a new MeshAssetTask object
  65644. */
  65645. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65646. /**
  65647. * Add a TextFileAssetTask to the list of active tasks
  65648. * @param taskName defines the name of the new task
  65649. * @param url defines the url of the file to load
  65650. * @returns a new TextFileAssetTask object
  65651. */
  65652. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65653. /**
  65654. * Add a BinaryFileAssetTask to the list of active tasks
  65655. * @param taskName defines the name of the new task
  65656. * @param url defines the url of the file to load
  65657. * @returns a new BinaryFileAssetTask object
  65658. */
  65659. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65660. /**
  65661. * Add a ImageAssetTask to the list of active tasks
  65662. * @param taskName defines the name of the new task
  65663. * @param url defines the url of the file to load
  65664. * @returns a new ImageAssetTask object
  65665. */
  65666. addImageTask(taskName: string, url: string): ImageAssetTask;
  65667. /**
  65668. * Add a TextureAssetTask to the list of active tasks
  65669. * @param taskName defines the name of the new task
  65670. * @param url defines the url of the file to load
  65671. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65672. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65673. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65674. * @returns a new TextureAssetTask object
  65675. */
  65676. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65677. /**
  65678. * Add a CubeTextureAssetTask to the list of active tasks
  65679. * @param taskName defines the name of the new task
  65680. * @param url defines the url of the file to load
  65681. * @param extensions defines the extension to use to load the cube map (can be null)
  65682. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65683. * @param files defines the list of files to load (can be null)
  65684. * @returns a new CubeTextureAssetTask object
  65685. */
  65686. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65687. /**
  65688. *
  65689. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65690. * @param taskName defines the name of the new task
  65691. * @param url defines the url of the file to load
  65692. * @param size defines the size you want for the cubemap (can be null)
  65693. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65694. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65695. * @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)
  65696. * @param reserved Internal use only
  65697. * @returns a new HDRCubeTextureAssetTask object
  65698. */
  65699. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65700. /**
  65701. *
  65702. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65703. * @param taskName defines the name of the new task
  65704. * @param url defines the url of the file to load
  65705. * @param size defines the size you want for the cubemap (can be null)
  65706. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65707. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65708. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65709. * @returns a new EquiRectangularCubeTextureAssetTask object
  65710. */
  65711. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65712. /**
  65713. * Remove a task from the assets manager.
  65714. * @param task the task to remove
  65715. */
  65716. removeTask(task: AbstractAssetTask): void;
  65717. private _decreaseWaitingTasksCount;
  65718. private _runTask;
  65719. /**
  65720. * Reset the AssetsManager and remove all tasks
  65721. * @return the current instance of the AssetsManager
  65722. */
  65723. reset(): AssetsManager;
  65724. /**
  65725. * Start the loading process
  65726. * @return the current instance of the AssetsManager
  65727. */
  65728. load(): AssetsManager;
  65729. /**
  65730. * Start the loading process as an async operation
  65731. * @return a promise returning the list of failed tasks
  65732. */
  65733. loadAsync(): Promise<void>;
  65734. }
  65735. }
  65736. declare module "babylonjs/Misc/deferred" {
  65737. /**
  65738. * Wrapper class for promise with external resolve and reject.
  65739. */
  65740. export class Deferred<T> {
  65741. /**
  65742. * The promise associated with this deferred object.
  65743. */
  65744. readonly promise: Promise<T>;
  65745. private _resolve;
  65746. private _reject;
  65747. /**
  65748. * The resolve method of the promise associated with this deferred object.
  65749. */
  65750. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65751. /**
  65752. * The reject method of the promise associated with this deferred object.
  65753. */
  65754. readonly reject: (reason?: any) => void;
  65755. /**
  65756. * Constructor for this deferred object.
  65757. */
  65758. constructor();
  65759. }
  65760. }
  65761. declare module "babylonjs/Misc/meshExploder" {
  65762. import { Mesh } from "babylonjs/Meshes/mesh";
  65763. /**
  65764. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65765. */
  65766. export class MeshExploder {
  65767. private _centerMesh;
  65768. private _meshes;
  65769. private _meshesOrigins;
  65770. private _toCenterVectors;
  65771. private _scaledDirection;
  65772. private _newPosition;
  65773. private _centerPosition;
  65774. /**
  65775. * Explodes meshes from a center mesh.
  65776. * @param meshes The meshes to explode.
  65777. * @param centerMesh The mesh to be center of explosion.
  65778. */
  65779. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65780. private _setCenterMesh;
  65781. /**
  65782. * Get class name
  65783. * @returns "MeshExploder"
  65784. */
  65785. getClassName(): string;
  65786. /**
  65787. * "Exploded meshes"
  65788. * @returns Array of meshes with the centerMesh at index 0.
  65789. */
  65790. getMeshes(): Array<Mesh>;
  65791. /**
  65792. * Explodes meshes giving a specific direction
  65793. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65794. */
  65795. explode(direction?: number): void;
  65796. }
  65797. }
  65798. declare module "babylonjs/Misc/filesInput" {
  65799. import { Engine } from "babylonjs/Engines/engine";
  65800. import { Scene } from "babylonjs/scene";
  65801. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65802. /**
  65803. * Class used to help managing file picking and drag'n'drop
  65804. */
  65805. export class FilesInput {
  65806. /**
  65807. * List of files ready to be loaded
  65808. */
  65809. static readonly FilesToLoad: {
  65810. [key: string]: File;
  65811. };
  65812. /**
  65813. * Callback called when a file is processed
  65814. */
  65815. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65816. private _engine;
  65817. private _currentScene;
  65818. private _sceneLoadedCallback;
  65819. private _progressCallback;
  65820. private _additionalRenderLoopLogicCallback;
  65821. private _textureLoadingCallback;
  65822. private _startingProcessingFilesCallback;
  65823. private _onReloadCallback;
  65824. private _errorCallback;
  65825. private _elementToMonitor;
  65826. private _sceneFileToLoad;
  65827. private _filesToLoad;
  65828. /**
  65829. * Creates a new FilesInput
  65830. * @param engine defines the rendering engine
  65831. * @param scene defines the hosting scene
  65832. * @param sceneLoadedCallback callback called when scene is loaded
  65833. * @param progressCallback callback called to track progress
  65834. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65835. * @param textureLoadingCallback callback called when a texture is loading
  65836. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65837. * @param onReloadCallback callback called when a reload is requested
  65838. * @param errorCallback callback call if an error occurs
  65839. */
  65840. 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);
  65841. private _dragEnterHandler;
  65842. private _dragOverHandler;
  65843. private _dropHandler;
  65844. /**
  65845. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65846. * @param elementToMonitor defines the DOM element to track
  65847. */
  65848. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65849. /**
  65850. * Release all associated resources
  65851. */
  65852. dispose(): void;
  65853. private renderFunction;
  65854. private drag;
  65855. private drop;
  65856. private _traverseFolder;
  65857. private _processFiles;
  65858. /**
  65859. * Load files from a drop event
  65860. * @param event defines the drop event to use as source
  65861. */
  65862. loadFiles(event: any): void;
  65863. private _processReload;
  65864. /**
  65865. * Reload the current scene from the loaded files
  65866. */
  65867. reload(): void;
  65868. }
  65869. }
  65870. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65871. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65872. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65873. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65874. }
  65875. declare module "babylonjs/Misc/sceneOptimizer" {
  65876. import { Scene, IDisposable } from "babylonjs/scene";
  65877. import { Observable } from "babylonjs/Misc/observable";
  65878. /**
  65879. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65880. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65881. */
  65882. export class SceneOptimization {
  65883. /**
  65884. * Defines the priority of this optimization (0 by default which means first in the list)
  65885. */
  65886. priority: number;
  65887. /**
  65888. * Gets a string describing the action executed by the current optimization
  65889. * @returns description string
  65890. */
  65891. getDescription(): string;
  65892. /**
  65893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65894. * @param scene defines the current scene where to apply this optimization
  65895. * @param optimizer defines the current optimizer
  65896. * @returns true if everything that can be done was applied
  65897. */
  65898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65899. /**
  65900. * Creates the SceneOptimization object
  65901. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65902. * @param desc defines the description associated with the optimization
  65903. */
  65904. constructor(
  65905. /**
  65906. * Defines the priority of this optimization (0 by default which means first in the list)
  65907. */
  65908. priority?: number);
  65909. }
  65910. /**
  65911. * Defines an optimization used to reduce the size of render target textures
  65912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65913. */
  65914. export class TextureOptimization extends SceneOptimization {
  65915. /**
  65916. * Defines the priority of this optimization (0 by default which means first in the list)
  65917. */
  65918. priority: number;
  65919. /**
  65920. * 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
  65921. */
  65922. maximumSize: number;
  65923. /**
  65924. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65925. */
  65926. step: number;
  65927. /**
  65928. * Gets a string describing the action executed by the current optimization
  65929. * @returns description string
  65930. */
  65931. getDescription(): string;
  65932. /**
  65933. * Creates the TextureOptimization object
  65934. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65935. * @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
  65936. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65937. */
  65938. constructor(
  65939. /**
  65940. * Defines the priority of this optimization (0 by default which means first in the list)
  65941. */
  65942. priority?: number,
  65943. /**
  65944. * 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
  65945. */
  65946. maximumSize?: number,
  65947. /**
  65948. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65949. */
  65950. step?: number);
  65951. /**
  65952. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65953. * @param scene defines the current scene where to apply this optimization
  65954. * @param optimizer defines the current optimizer
  65955. * @returns true if everything that can be done was applied
  65956. */
  65957. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65958. }
  65959. /**
  65960. * Defines an optimization used to increase or decrease the rendering resolution
  65961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65962. */
  65963. export class HardwareScalingOptimization extends SceneOptimization {
  65964. /**
  65965. * Defines the priority of this optimization (0 by default which means first in the list)
  65966. */
  65967. priority: number;
  65968. /**
  65969. * Defines the maximum scale to use (2 by default)
  65970. */
  65971. maximumScale: number;
  65972. /**
  65973. * Defines the step to use between two passes (0.5 by default)
  65974. */
  65975. step: number;
  65976. private _currentScale;
  65977. private _directionOffset;
  65978. /**
  65979. * Gets a string describing the action executed by the current optimization
  65980. * @return description string
  65981. */
  65982. getDescription(): string;
  65983. /**
  65984. * Creates the HardwareScalingOptimization object
  65985. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65986. * @param maximumScale defines the maximum scale to use (2 by default)
  65987. * @param step defines the step to use between two passes (0.5 by default)
  65988. */
  65989. constructor(
  65990. /**
  65991. * Defines the priority of this optimization (0 by default which means first in the list)
  65992. */
  65993. priority?: number,
  65994. /**
  65995. * Defines the maximum scale to use (2 by default)
  65996. */
  65997. maximumScale?: number,
  65998. /**
  65999. * Defines the step to use between two passes (0.5 by default)
  66000. */
  66001. step?: number);
  66002. /**
  66003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66004. * @param scene defines the current scene where to apply this optimization
  66005. * @param optimizer defines the current optimizer
  66006. * @returns true if everything that can be done was applied
  66007. */
  66008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66009. }
  66010. /**
  66011. * Defines an optimization used to remove shadows
  66012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66013. */
  66014. export class ShadowsOptimization extends SceneOptimization {
  66015. /**
  66016. * Gets a string describing the action executed by the current optimization
  66017. * @return description string
  66018. */
  66019. getDescription(): string;
  66020. /**
  66021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66022. * @param scene defines the current scene where to apply this optimization
  66023. * @param optimizer defines the current optimizer
  66024. * @returns true if everything that can be done was applied
  66025. */
  66026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66027. }
  66028. /**
  66029. * Defines an optimization used to turn post-processes off
  66030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66031. */
  66032. export class PostProcessesOptimization extends SceneOptimization {
  66033. /**
  66034. * Gets a string describing the action executed by the current optimization
  66035. * @return description string
  66036. */
  66037. getDescription(): string;
  66038. /**
  66039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66040. * @param scene defines the current scene where to apply this optimization
  66041. * @param optimizer defines the current optimizer
  66042. * @returns true if everything that can be done was applied
  66043. */
  66044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66045. }
  66046. /**
  66047. * Defines an optimization used to turn lens flares off
  66048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66049. */
  66050. export class LensFlaresOptimization extends SceneOptimization {
  66051. /**
  66052. * Gets a string describing the action executed by the current optimization
  66053. * @return description string
  66054. */
  66055. getDescription(): string;
  66056. /**
  66057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66058. * @param scene defines the current scene where to apply this optimization
  66059. * @param optimizer defines the current optimizer
  66060. * @returns true if everything that can be done was applied
  66061. */
  66062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66063. }
  66064. /**
  66065. * Defines an optimization based on user defined callback.
  66066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66067. */
  66068. export class CustomOptimization extends SceneOptimization {
  66069. /**
  66070. * Callback called to apply the custom optimization.
  66071. */
  66072. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66073. /**
  66074. * Callback called to get custom description
  66075. */
  66076. onGetDescription: () => string;
  66077. /**
  66078. * Gets a string describing the action executed by the current optimization
  66079. * @returns description string
  66080. */
  66081. getDescription(): string;
  66082. /**
  66083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66084. * @param scene defines the current scene where to apply this optimization
  66085. * @param optimizer defines the current optimizer
  66086. * @returns true if everything that can be done was applied
  66087. */
  66088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66089. }
  66090. /**
  66091. * Defines an optimization used to turn particles off
  66092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66093. */
  66094. export class ParticlesOptimization extends SceneOptimization {
  66095. /**
  66096. * Gets a string describing the action executed by the current optimization
  66097. * @return description string
  66098. */
  66099. getDescription(): string;
  66100. /**
  66101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66102. * @param scene defines the current scene where to apply this optimization
  66103. * @param optimizer defines the current optimizer
  66104. * @returns true if everything that can be done was applied
  66105. */
  66106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66107. }
  66108. /**
  66109. * Defines an optimization used to turn render targets off
  66110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66111. */
  66112. export class RenderTargetsOptimization extends SceneOptimization {
  66113. /**
  66114. * Gets a string describing the action executed by the current optimization
  66115. * @return description string
  66116. */
  66117. getDescription(): string;
  66118. /**
  66119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66120. * @param scene defines the current scene where to apply this optimization
  66121. * @param optimizer defines the current optimizer
  66122. * @returns true if everything that can be done was applied
  66123. */
  66124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66125. }
  66126. /**
  66127. * Defines an optimization used to merge meshes with compatible materials
  66128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66129. */
  66130. export class MergeMeshesOptimization extends SceneOptimization {
  66131. private static _UpdateSelectionTree;
  66132. /**
  66133. * Gets or sets a boolean which defines if optimization octree has to be updated
  66134. */
  66135. /**
  66136. * Gets or sets a boolean which defines if optimization octree has to be updated
  66137. */
  66138. static UpdateSelectionTree: boolean;
  66139. /**
  66140. * Gets a string describing the action executed by the current optimization
  66141. * @return description string
  66142. */
  66143. getDescription(): string;
  66144. private _canBeMerged;
  66145. /**
  66146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66147. * @param scene defines the current scene where to apply this optimization
  66148. * @param optimizer defines the current optimizer
  66149. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66150. * @returns true if everything that can be done was applied
  66151. */
  66152. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66153. }
  66154. /**
  66155. * Defines a list of options used by SceneOptimizer
  66156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66157. */
  66158. export class SceneOptimizerOptions {
  66159. /**
  66160. * Defines the target frame rate to reach (60 by default)
  66161. */
  66162. targetFrameRate: number;
  66163. /**
  66164. * Defines the interval between two checkes (2000ms by default)
  66165. */
  66166. trackerDuration: number;
  66167. /**
  66168. * Gets the list of optimizations to apply
  66169. */
  66170. optimizations: SceneOptimization[];
  66171. /**
  66172. * Creates a new list of options used by SceneOptimizer
  66173. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66174. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66175. */
  66176. constructor(
  66177. /**
  66178. * Defines the target frame rate to reach (60 by default)
  66179. */
  66180. targetFrameRate?: number,
  66181. /**
  66182. * Defines the interval between two checkes (2000ms by default)
  66183. */
  66184. trackerDuration?: number);
  66185. /**
  66186. * Add a new optimization
  66187. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66188. * @returns the current SceneOptimizerOptions
  66189. */
  66190. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66191. /**
  66192. * Add a new custom optimization
  66193. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66194. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66195. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66196. * @returns the current SceneOptimizerOptions
  66197. */
  66198. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66199. /**
  66200. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66201. * @param targetFrameRate defines the target frame rate (60 by default)
  66202. * @returns a SceneOptimizerOptions object
  66203. */
  66204. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66205. /**
  66206. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66207. * @param targetFrameRate defines the target frame rate (60 by default)
  66208. * @returns a SceneOptimizerOptions object
  66209. */
  66210. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66211. /**
  66212. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66213. * @param targetFrameRate defines the target frame rate (60 by default)
  66214. * @returns a SceneOptimizerOptions object
  66215. */
  66216. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66217. }
  66218. /**
  66219. * Class used to run optimizations in order to reach a target frame rate
  66220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66221. */
  66222. export class SceneOptimizer implements IDisposable {
  66223. private _isRunning;
  66224. private _options;
  66225. private _scene;
  66226. private _currentPriorityLevel;
  66227. private _targetFrameRate;
  66228. private _trackerDuration;
  66229. private _currentFrameRate;
  66230. private _sceneDisposeObserver;
  66231. private _improvementMode;
  66232. /**
  66233. * Defines an observable called when the optimizer reaches the target frame rate
  66234. */
  66235. onSuccessObservable: Observable<SceneOptimizer>;
  66236. /**
  66237. * Defines an observable called when the optimizer enables an optimization
  66238. */
  66239. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66240. /**
  66241. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66242. */
  66243. onFailureObservable: Observable<SceneOptimizer>;
  66244. /**
  66245. * Gets a boolean indicating if the optimizer is in improvement mode
  66246. */
  66247. readonly isInImprovementMode: boolean;
  66248. /**
  66249. * Gets the current priority level (0 at start)
  66250. */
  66251. readonly currentPriorityLevel: number;
  66252. /**
  66253. * Gets the current frame rate checked by the SceneOptimizer
  66254. */
  66255. readonly currentFrameRate: number;
  66256. /**
  66257. * Gets or sets the current target frame rate (60 by default)
  66258. */
  66259. /**
  66260. * Gets or sets the current target frame rate (60 by default)
  66261. */
  66262. targetFrameRate: number;
  66263. /**
  66264. * Gets or sets the current interval between two checks (every 2000ms by default)
  66265. */
  66266. /**
  66267. * Gets or sets the current interval between two checks (every 2000ms by default)
  66268. */
  66269. trackerDuration: number;
  66270. /**
  66271. * Gets the list of active optimizations
  66272. */
  66273. readonly optimizations: SceneOptimization[];
  66274. /**
  66275. * Creates a new SceneOptimizer
  66276. * @param scene defines the scene to work on
  66277. * @param options defines the options to use with the SceneOptimizer
  66278. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66279. * @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)
  66280. */
  66281. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66282. /**
  66283. * Stops the current optimizer
  66284. */
  66285. stop(): void;
  66286. /**
  66287. * Reset the optimizer to initial step (current priority level = 0)
  66288. */
  66289. reset(): void;
  66290. /**
  66291. * Start the optimizer. By default it will try to reach a specific framerate
  66292. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66293. */
  66294. start(): void;
  66295. private _checkCurrentState;
  66296. /**
  66297. * Release all resources
  66298. */
  66299. dispose(): void;
  66300. /**
  66301. * Helper function to create a SceneOptimizer with one single line of code
  66302. * @param scene defines the scene to work on
  66303. * @param options defines the options to use with the SceneOptimizer
  66304. * @param onSuccess defines a callback to call on success
  66305. * @param onFailure defines a callback to call on failure
  66306. * @returns the new SceneOptimizer object
  66307. */
  66308. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66309. }
  66310. }
  66311. declare module "babylonjs/Misc/sceneSerializer" {
  66312. import { Scene } from "babylonjs/scene";
  66313. /**
  66314. * Class used to serialize a scene into a string
  66315. */
  66316. export class SceneSerializer {
  66317. /**
  66318. * Clear cache used by a previous serialization
  66319. */
  66320. static ClearCache(): void;
  66321. /**
  66322. * Serialize a scene into a JSON compatible object
  66323. * @param scene defines the scene to serialize
  66324. * @returns a JSON compatible object
  66325. */
  66326. static Serialize(scene: Scene): any;
  66327. /**
  66328. * Serialize a mesh into a JSON compatible object
  66329. * @param toSerialize defines the mesh to serialize
  66330. * @param withParents defines if parents must be serialized as well
  66331. * @param withChildren defines if children must be serialized as well
  66332. * @returns a JSON compatible object
  66333. */
  66334. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66335. }
  66336. }
  66337. declare module "babylonjs/Misc/textureTools" {
  66338. import { Texture } from "babylonjs/Materials/Textures/texture";
  66339. /**
  66340. * Class used to host texture specific utilities
  66341. */
  66342. export class TextureTools {
  66343. /**
  66344. * Uses the GPU to create a copy texture rescaled at a given size
  66345. * @param texture Texture to copy from
  66346. * @param width defines the desired width
  66347. * @param height defines the desired height
  66348. * @param useBilinearMode defines if bilinear mode has to be used
  66349. * @return the generated texture
  66350. */
  66351. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66352. }
  66353. }
  66354. declare module "babylonjs/Misc/videoRecorder" {
  66355. import { Nullable } from "babylonjs/types";
  66356. import { Engine } from "babylonjs/Engines/engine";
  66357. /**
  66358. * This represents the different options available for the video capture.
  66359. */
  66360. export interface VideoRecorderOptions {
  66361. /** Defines the mime type of the video. */
  66362. mimeType: string;
  66363. /** Defines the FPS the video should be recorded at. */
  66364. fps: number;
  66365. /** Defines the chunk size for the recording data. */
  66366. recordChunckSize: number;
  66367. /** The audio tracks to attach to the recording. */
  66368. audioTracks?: MediaStreamTrack[];
  66369. }
  66370. /**
  66371. * This can help with recording videos from BabylonJS.
  66372. * This is based on the available WebRTC functionalities of the browser.
  66373. *
  66374. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66375. */
  66376. export class VideoRecorder {
  66377. private static readonly _defaultOptions;
  66378. /**
  66379. * Returns whether or not the VideoRecorder is available in your browser.
  66380. * @param engine Defines the Babylon Engine.
  66381. * @returns true if supported otherwise false.
  66382. */
  66383. static IsSupported(engine: Engine): boolean;
  66384. private readonly _options;
  66385. private _canvas;
  66386. private _mediaRecorder;
  66387. private _recordedChunks;
  66388. private _fileName;
  66389. private _resolve;
  66390. private _reject;
  66391. /**
  66392. * True when a recording is already in progress.
  66393. */
  66394. readonly isRecording: boolean;
  66395. /**
  66396. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66397. * @param engine Defines the BabylonJS Engine you wish to record.
  66398. * @param options Defines options that can be used to customize the capture.
  66399. */
  66400. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66401. /**
  66402. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66403. */
  66404. stopRecording(): void;
  66405. /**
  66406. * Starts recording the canvas for a max duration specified in parameters.
  66407. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66408. * If null no automatic download will start and you can rely on the promise to get the data back.
  66409. * @param maxDuration Defines the maximum recording time in seconds.
  66410. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66411. * @return A promise callback at the end of the recording with the video data in Blob.
  66412. */
  66413. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66414. /**
  66415. * Releases internal resources used during the recording.
  66416. */
  66417. dispose(): void;
  66418. private _handleDataAvailable;
  66419. private _handleError;
  66420. private _handleStop;
  66421. }
  66422. }
  66423. declare module "babylonjs/Misc/screenshotTools" {
  66424. import { Camera } from "babylonjs/Cameras/camera";
  66425. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66426. import { Engine } from "babylonjs/Engines/engine";
  66427. /**
  66428. * Class containing a set of static utilities functions for screenshots
  66429. */
  66430. export class ScreenshotTools {
  66431. /**
  66432. * Captures a screenshot of the current rendering
  66433. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66434. * @param engine defines the rendering engine
  66435. * @param camera defines the source camera
  66436. * @param size This parameter can be set to a single number or to an object with the
  66437. * following (optional) properties: precision, width, height. If a single number is passed,
  66438. * it will be used for both width and height. If an object is passed, the screenshot size
  66439. * will be derived from the parameters. The precision property is a multiplier allowing
  66440. * rendering at a higher or lower resolution
  66441. * @param successCallback defines the callback receives a single parameter which contains the
  66442. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66443. * src parameter of an <img> to display it
  66444. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66445. * Check your browser for supported MIME types
  66446. */
  66447. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66448. /**
  66449. * Captures a screenshot of the current rendering
  66450. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66451. * @param engine defines the rendering engine
  66452. * @param camera defines the source camera
  66453. * @param size This parameter can be set to a single number or to an object with the
  66454. * following (optional) properties: precision, width, height. If a single number is passed,
  66455. * it will be used for both width and height. If an object is passed, the screenshot size
  66456. * will be derived from the parameters. The precision property is a multiplier allowing
  66457. * rendering at a higher or lower resolution
  66458. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66459. * Check your browser for supported MIME types
  66460. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66461. * to the src parameter of an <img> to display it
  66462. */
  66463. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66464. /**
  66465. * Generates an image screenshot from the specified camera.
  66466. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66467. * @param engine The engine to use for rendering
  66468. * @param camera The camera to use for rendering
  66469. * @param size This parameter can be set to a single number or to an object with the
  66470. * following (optional) properties: precision, width, height. If a single number is passed,
  66471. * it will be used for both width and height. If an object is passed, the screenshot size
  66472. * will be derived from the parameters. The precision property is a multiplier allowing
  66473. * rendering at a higher or lower resolution
  66474. * @param successCallback The callback receives a single parameter which contains the
  66475. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66476. * src parameter of an <img> to display it
  66477. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66478. * Check your browser for supported MIME types
  66479. * @param samples Texture samples (default: 1)
  66480. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66481. * @param fileName A name for for the downloaded file.
  66482. */
  66483. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66484. /**
  66485. * Generates an image screenshot from the specified camera.
  66486. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66487. * @param engine The engine to use for rendering
  66488. * @param camera The camera to use for rendering
  66489. * @param size This parameter can be set to a single number or to an object with the
  66490. * following (optional) properties: precision, width, height. If a single number is passed,
  66491. * it will be used for both width and height. If an object is passed, the screenshot size
  66492. * will be derived from the parameters. The precision property is a multiplier allowing
  66493. * rendering at a higher or lower resolution
  66494. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66495. * Check your browser for supported MIME types
  66496. * @param samples Texture samples (default: 1)
  66497. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66498. * @param fileName A name for for the downloaded file.
  66499. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66500. * to the src parameter of an <img> to display it
  66501. */
  66502. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66503. /**
  66504. * Gets height and width for screenshot size
  66505. * @private
  66506. */
  66507. private static _getScreenshotSize;
  66508. }
  66509. }
  66510. declare module "babylonjs/Misc/index" {
  66511. export * from "babylonjs/Misc/andOrNotEvaluator";
  66512. export * from "babylonjs/Misc/assetsManager";
  66513. export * from "babylonjs/Misc/dds";
  66514. export * from "babylonjs/Misc/decorators";
  66515. export * from "babylonjs/Misc/deferred";
  66516. export * from "babylonjs/Misc/environmentTextureTools";
  66517. export * from "babylonjs/Misc/meshExploder";
  66518. export * from "babylonjs/Misc/filesInput";
  66519. export * from "babylonjs/Misc/HighDynamicRange/index";
  66520. export * from "babylonjs/Misc/khronosTextureContainer";
  66521. export * from "babylonjs/Misc/observable";
  66522. export * from "babylonjs/Misc/performanceMonitor";
  66523. export * from "babylonjs/Misc/promise";
  66524. export * from "babylonjs/Misc/sceneOptimizer";
  66525. export * from "babylonjs/Misc/sceneSerializer";
  66526. export * from "babylonjs/Misc/smartArray";
  66527. export * from "babylonjs/Misc/stringDictionary";
  66528. export * from "babylonjs/Misc/tags";
  66529. export * from "babylonjs/Misc/textureTools";
  66530. export * from "babylonjs/Misc/tga";
  66531. export * from "babylonjs/Misc/tools";
  66532. export * from "babylonjs/Misc/videoRecorder";
  66533. export * from "babylonjs/Misc/virtualJoystick";
  66534. export * from "babylonjs/Misc/workerPool";
  66535. export * from "babylonjs/Misc/logger";
  66536. export * from "babylonjs/Misc/typeStore";
  66537. export * from "babylonjs/Misc/filesInputStore";
  66538. export * from "babylonjs/Misc/deepCopier";
  66539. export * from "babylonjs/Misc/pivotTools";
  66540. export * from "babylonjs/Misc/precisionDate";
  66541. export * from "babylonjs/Misc/screenshotTools";
  66542. export * from "babylonjs/Misc/typeStore";
  66543. export * from "babylonjs/Misc/webRequest";
  66544. export * from "babylonjs/Misc/iInspectable";
  66545. export * from "babylonjs/Misc/brdfTextureTools";
  66546. export * from "babylonjs/Misc/rgbdTextureTools";
  66547. export * from "babylonjs/Misc/gradients";
  66548. export * from "babylonjs/Misc/perfCounter";
  66549. export * from "babylonjs/Misc/fileRequest";
  66550. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66551. export * from "babylonjs/Misc/retryStrategy";
  66552. export * from "babylonjs/Misc/loadFileError";
  66553. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66554. }
  66555. declare module "babylonjs/index" {
  66556. export * from "babylonjs/abstractScene";
  66557. export * from "babylonjs/Actions/index";
  66558. export * from "babylonjs/Animations/index";
  66559. export * from "babylonjs/assetContainer";
  66560. export * from "babylonjs/Audio/index";
  66561. export * from "babylonjs/Behaviors/index";
  66562. export * from "babylonjs/Bones/index";
  66563. export * from "babylonjs/Cameras/index";
  66564. export * from "babylonjs/Collisions/index";
  66565. export * from "babylonjs/Culling/index";
  66566. export * from "babylonjs/Debug/index";
  66567. export * from "babylonjs/Engines/index";
  66568. export * from "babylonjs/Events/index";
  66569. export * from "babylonjs/Gamepads/index";
  66570. export * from "babylonjs/Gizmos/index";
  66571. export * from "babylonjs/Helpers/index";
  66572. export * from "babylonjs/Instrumentation/index";
  66573. export * from "babylonjs/Layers/index";
  66574. export * from "babylonjs/LensFlares/index";
  66575. export * from "babylonjs/Lights/index";
  66576. export * from "babylonjs/Loading/index";
  66577. export * from "babylonjs/Materials/index";
  66578. export * from "babylonjs/Maths/index";
  66579. export * from "babylonjs/Meshes/index";
  66580. export * from "babylonjs/Morph/index";
  66581. export * from "babylonjs/Navigation/index";
  66582. export * from "babylonjs/node";
  66583. export * from "babylonjs/Offline/index";
  66584. export * from "babylonjs/Particles/index";
  66585. export * from "babylonjs/Physics/index";
  66586. export * from "babylonjs/PostProcesses/index";
  66587. export * from "babylonjs/Probes/index";
  66588. export * from "babylonjs/Rendering/index";
  66589. export * from "babylonjs/scene";
  66590. export * from "babylonjs/sceneComponent";
  66591. export * from "babylonjs/Sprites/index";
  66592. export * from "babylonjs/States/index";
  66593. export * from "babylonjs/Misc/index";
  66594. export * from "babylonjs/types";
  66595. }
  66596. declare module "babylonjs/Animations/pathCursor" {
  66597. import { Vector3 } from "babylonjs/Maths/math.vector";
  66598. import { Path2 } from "babylonjs/Maths/math.path";
  66599. /**
  66600. * A cursor which tracks a point on a path
  66601. */
  66602. export class PathCursor {
  66603. private path;
  66604. /**
  66605. * Stores path cursor callbacks for when an onchange event is triggered
  66606. */
  66607. private _onchange;
  66608. /**
  66609. * The value of the path cursor
  66610. */
  66611. value: number;
  66612. /**
  66613. * The animation array of the path cursor
  66614. */
  66615. animations: Animation[];
  66616. /**
  66617. * Initializes the path cursor
  66618. * @param path The path to track
  66619. */
  66620. constructor(path: Path2);
  66621. /**
  66622. * Gets the cursor point on the path
  66623. * @returns A point on the path cursor at the cursor location
  66624. */
  66625. getPoint(): Vector3;
  66626. /**
  66627. * Moves the cursor ahead by the step amount
  66628. * @param step The amount to move the cursor forward
  66629. * @returns This path cursor
  66630. */
  66631. moveAhead(step?: number): PathCursor;
  66632. /**
  66633. * Moves the cursor behind by the step amount
  66634. * @param step The amount to move the cursor back
  66635. * @returns This path cursor
  66636. */
  66637. moveBack(step?: number): PathCursor;
  66638. /**
  66639. * Moves the cursor by the step amount
  66640. * If the step amount is greater than one, an exception is thrown
  66641. * @param step The amount to move the cursor
  66642. * @returns This path cursor
  66643. */
  66644. move(step: number): PathCursor;
  66645. /**
  66646. * Ensures that the value is limited between zero and one
  66647. * @returns This path cursor
  66648. */
  66649. private ensureLimits;
  66650. /**
  66651. * Runs onchange callbacks on change (used by the animation engine)
  66652. * @returns This path cursor
  66653. */
  66654. private raiseOnChange;
  66655. /**
  66656. * Executes a function on change
  66657. * @param f A path cursor onchange callback
  66658. * @returns This path cursor
  66659. */
  66660. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66661. }
  66662. }
  66663. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66664. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66665. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66666. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66667. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66668. }
  66669. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66670. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66671. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66672. }
  66673. declare module "babylonjs/Engines/Processors/index" {
  66674. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66675. export * from "babylonjs/Engines/Processors/Expressions/index";
  66676. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66677. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66678. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66679. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66680. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66681. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66682. }
  66683. declare module "babylonjs/Legacy/legacy" {
  66684. import * as Babylon from "babylonjs/index";
  66685. export * from "babylonjs/index";
  66686. }
  66687. declare module "babylonjs/Shaders/blur.fragment" {
  66688. /** @hidden */
  66689. export var blurPixelShader: {
  66690. name: string;
  66691. shader: string;
  66692. };
  66693. }
  66694. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66695. /** @hidden */
  66696. export var pointCloudVertexDeclaration: {
  66697. name: string;
  66698. shader: string;
  66699. };
  66700. }
  66701. declare module "babylonjs" {
  66702. export * from "babylonjs/Legacy/legacy";
  66703. }
  66704. declare module BABYLON {
  66705. /** Alias type for value that can be null */
  66706. export type Nullable<T> = T | null;
  66707. /**
  66708. * Alias type for number that are floats
  66709. * @ignorenaming
  66710. */
  66711. export type float = number;
  66712. /**
  66713. * Alias type for number that are doubles.
  66714. * @ignorenaming
  66715. */
  66716. export type double = number;
  66717. /**
  66718. * Alias type for number that are integer
  66719. * @ignorenaming
  66720. */
  66721. export type int = number;
  66722. /** Alias type for number array or Float32Array */
  66723. export type FloatArray = number[] | Float32Array;
  66724. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66725. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66726. /**
  66727. * Alias for types that can be used by a Buffer or VertexBuffer.
  66728. */
  66729. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66730. /**
  66731. * Alias type for primitive types
  66732. * @ignorenaming
  66733. */
  66734. type Primitive = undefined | null | boolean | string | number | Function;
  66735. /**
  66736. * Type modifier to make all the properties of an object Readonly
  66737. */
  66738. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66739. /**
  66740. * Type modifier to make all the properties of an object Readonly recursively
  66741. */
  66742. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66743. /**
  66744. * Type modifier to make object properties readonly.
  66745. */
  66746. export type DeepImmutableObject<T> = {
  66747. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66748. };
  66749. /** @hidden */
  66750. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66751. }
  66752. }
  66753. declare module BABYLON {
  66754. /**
  66755. * A class serves as a medium between the observable and its observers
  66756. */
  66757. export class EventState {
  66758. /**
  66759. * Create a new EventState
  66760. * @param mask defines the mask associated with this state
  66761. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66762. * @param target defines the original target of the state
  66763. * @param currentTarget defines the current target of the state
  66764. */
  66765. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66766. /**
  66767. * Initialize the current event state
  66768. * @param mask defines the mask associated with this state
  66769. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66770. * @param target defines the original target of the state
  66771. * @param currentTarget defines the current target of the state
  66772. * @returns the current event state
  66773. */
  66774. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66775. /**
  66776. * An Observer can set this property to true to prevent subsequent observers of being notified
  66777. */
  66778. skipNextObservers: boolean;
  66779. /**
  66780. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66781. */
  66782. mask: number;
  66783. /**
  66784. * The object that originally notified the event
  66785. */
  66786. target?: any;
  66787. /**
  66788. * The current object in the bubbling phase
  66789. */
  66790. currentTarget?: any;
  66791. /**
  66792. * This will be populated with the return value of the last function that was executed.
  66793. * If it is the first function in the callback chain it will be the event data.
  66794. */
  66795. lastReturnValue?: any;
  66796. }
  66797. /**
  66798. * Represent an Observer registered to a given Observable object.
  66799. */
  66800. export class Observer<T> {
  66801. /**
  66802. * Defines the callback to call when the observer is notified
  66803. */
  66804. callback: (eventData: T, eventState: EventState) => void;
  66805. /**
  66806. * Defines the mask of the observer (used to filter notifications)
  66807. */
  66808. mask: number;
  66809. /**
  66810. * Defines the current scope used to restore the JS context
  66811. */
  66812. scope: any;
  66813. /** @hidden */
  66814. _willBeUnregistered: boolean;
  66815. /**
  66816. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66817. */
  66818. unregisterOnNextCall: boolean;
  66819. /**
  66820. * Creates a new observer
  66821. * @param callback defines the callback to call when the observer is notified
  66822. * @param mask defines the mask of the observer (used to filter notifications)
  66823. * @param scope defines the current scope used to restore the JS context
  66824. */
  66825. constructor(
  66826. /**
  66827. * Defines the callback to call when the observer is notified
  66828. */
  66829. callback: (eventData: T, eventState: EventState) => void,
  66830. /**
  66831. * Defines the mask of the observer (used to filter notifications)
  66832. */
  66833. mask: number,
  66834. /**
  66835. * Defines the current scope used to restore the JS context
  66836. */
  66837. scope?: any);
  66838. }
  66839. /**
  66840. * Represent a list of observers registered to multiple Observables object.
  66841. */
  66842. export class MultiObserver<T> {
  66843. private _observers;
  66844. private _observables;
  66845. /**
  66846. * Release associated resources
  66847. */
  66848. dispose(): void;
  66849. /**
  66850. * Raise a callback when one of the observable will notify
  66851. * @param observables defines a list of observables to watch
  66852. * @param callback defines the callback to call on notification
  66853. * @param mask defines the mask used to filter notifications
  66854. * @param scope defines the current scope used to restore the JS context
  66855. * @returns the new MultiObserver
  66856. */
  66857. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66858. }
  66859. /**
  66860. * The Observable class is a simple implementation of the Observable pattern.
  66861. *
  66862. * 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.
  66863. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66864. * 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).
  66865. * 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.
  66866. */
  66867. export class Observable<T> {
  66868. private _observers;
  66869. private _eventState;
  66870. private _onObserverAdded;
  66871. /**
  66872. * Gets the list of observers
  66873. */
  66874. readonly observers: Array<Observer<T>>;
  66875. /**
  66876. * Creates a new observable
  66877. * @param onObserverAdded defines a callback to call when a new observer is added
  66878. */
  66879. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66880. /**
  66881. * Create a new Observer with the specified callback
  66882. * @param callback the callback that will be executed for that Observer
  66883. * @param mask the mask used to filter observers
  66884. * @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.
  66885. * @param scope optional scope for the callback to be called from
  66886. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66887. * @returns the new observer created for the callback
  66888. */
  66889. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66890. /**
  66891. * Create a new Observer with the specified callback and unregisters after the next notification
  66892. * @param callback the callback that will be executed for that Observer
  66893. * @returns the new observer created for the callback
  66894. */
  66895. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66896. /**
  66897. * Remove an Observer from the Observable object
  66898. * @param observer the instance of the Observer to remove
  66899. * @returns false if it doesn't belong to this Observable
  66900. */
  66901. remove(observer: Nullable<Observer<T>>): boolean;
  66902. /**
  66903. * Remove a callback from the Observable object
  66904. * @param callback the callback to remove
  66905. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66906. * @returns false if it doesn't belong to this Observable
  66907. */
  66908. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66909. private _deferUnregister;
  66910. private _remove;
  66911. /**
  66912. * Moves the observable to the top of the observer list making it get called first when notified
  66913. * @param observer the observer to move
  66914. */
  66915. makeObserverTopPriority(observer: Observer<T>): void;
  66916. /**
  66917. * Moves the observable to the bottom of the observer list making it get called last when notified
  66918. * @param observer the observer to move
  66919. */
  66920. makeObserverBottomPriority(observer: Observer<T>): void;
  66921. /**
  66922. * Notify all Observers by calling their respective callback with the given data
  66923. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66924. * @param eventData defines the data to send to all observers
  66925. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66926. * @param target defines the original target of the state
  66927. * @param currentTarget defines the current target of the state
  66928. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66929. */
  66930. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66931. /**
  66932. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66933. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66934. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66935. * and it is crucial that all callbacks will be executed.
  66936. * The order of the callbacks is kept, callbacks are not executed parallel.
  66937. *
  66938. * @param eventData The data to be sent to each callback
  66939. * @param mask is used to filter observers defaults to -1
  66940. * @param target defines the callback target (see EventState)
  66941. * @param currentTarget defines he current object in the bubbling phase
  66942. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66943. */
  66944. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66945. /**
  66946. * Notify a specific observer
  66947. * @param observer defines the observer to notify
  66948. * @param eventData defines the data to be sent to each callback
  66949. * @param mask is used to filter observers defaults to -1
  66950. */
  66951. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66952. /**
  66953. * Gets a boolean indicating if the observable has at least one observer
  66954. * @returns true is the Observable has at least one Observer registered
  66955. */
  66956. hasObservers(): boolean;
  66957. /**
  66958. * Clear the list of observers
  66959. */
  66960. clear(): void;
  66961. /**
  66962. * Clone the current observable
  66963. * @returns a new observable
  66964. */
  66965. clone(): Observable<T>;
  66966. /**
  66967. * Does this observable handles observer registered with a given mask
  66968. * @param mask defines the mask to be tested
  66969. * @return whether or not one observer registered with the given mask is handeled
  66970. **/
  66971. hasSpecificMask(mask?: number): boolean;
  66972. }
  66973. }
  66974. declare module BABYLON {
  66975. /**
  66976. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66977. * Babylon.js
  66978. */
  66979. export class DomManagement {
  66980. /**
  66981. * Checks if the window object exists
  66982. * @returns true if the window object exists
  66983. */
  66984. static IsWindowObjectExist(): boolean;
  66985. /**
  66986. * Checks if the navigator object exists
  66987. * @returns true if the navigator object exists
  66988. */
  66989. static IsNavigatorAvailable(): boolean;
  66990. /**
  66991. * Extracts text content from a DOM element hierarchy
  66992. * @param element defines the root element
  66993. * @returns a string
  66994. */
  66995. static GetDOMTextContent(element: HTMLElement): string;
  66996. }
  66997. }
  66998. declare module BABYLON {
  66999. /**
  67000. * Logger used througouht the application to allow configuration of
  67001. * the log level required for the messages.
  67002. */
  67003. export class Logger {
  67004. /**
  67005. * No log
  67006. */
  67007. static readonly NoneLogLevel: number;
  67008. /**
  67009. * Only message logs
  67010. */
  67011. static readonly MessageLogLevel: number;
  67012. /**
  67013. * Only warning logs
  67014. */
  67015. static readonly WarningLogLevel: number;
  67016. /**
  67017. * Only error logs
  67018. */
  67019. static readonly ErrorLogLevel: number;
  67020. /**
  67021. * All logs
  67022. */
  67023. static readonly AllLogLevel: number;
  67024. private static _LogCache;
  67025. /**
  67026. * Gets a value indicating the number of loading errors
  67027. * @ignorenaming
  67028. */
  67029. static errorsCount: number;
  67030. /**
  67031. * Callback called when a new log is added
  67032. */
  67033. static OnNewCacheEntry: (entry: string) => void;
  67034. private static _AddLogEntry;
  67035. private static _FormatMessage;
  67036. private static _LogDisabled;
  67037. private static _LogEnabled;
  67038. private static _WarnDisabled;
  67039. private static _WarnEnabled;
  67040. private static _ErrorDisabled;
  67041. private static _ErrorEnabled;
  67042. /**
  67043. * Log a message to the console
  67044. */
  67045. static Log: (message: string) => void;
  67046. /**
  67047. * Write a warning message to the console
  67048. */
  67049. static Warn: (message: string) => void;
  67050. /**
  67051. * Write an error message to the console
  67052. */
  67053. static Error: (message: string) => void;
  67054. /**
  67055. * Gets current log cache (list of logs)
  67056. */
  67057. static readonly LogCache: string;
  67058. /**
  67059. * Clears the log cache
  67060. */
  67061. static ClearLogCache(): void;
  67062. /**
  67063. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67064. */
  67065. static LogLevels: number;
  67066. }
  67067. }
  67068. declare module BABYLON {
  67069. /** @hidden */
  67070. export class _TypeStore {
  67071. /** @hidden */
  67072. static RegisteredTypes: {
  67073. [key: string]: Object;
  67074. };
  67075. /** @hidden */
  67076. static GetClass(fqdn: string): any;
  67077. }
  67078. }
  67079. declare module BABYLON {
  67080. /**
  67081. * Class containing a set of static utilities functions for deep copy.
  67082. */
  67083. export class DeepCopier {
  67084. /**
  67085. * Tries to copy an object by duplicating every property
  67086. * @param source defines the source object
  67087. * @param destination defines the target object
  67088. * @param doNotCopyList defines a list of properties to avoid
  67089. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67090. */
  67091. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67092. }
  67093. }
  67094. declare module BABYLON {
  67095. /**
  67096. * Class containing a set of static utilities functions for precision date
  67097. */
  67098. export class PrecisionDate {
  67099. /**
  67100. * Gets either window.performance.now() if supported or Date.now() else
  67101. */
  67102. static readonly Now: number;
  67103. }
  67104. }
  67105. declare module BABYLON {
  67106. /** @hidden */
  67107. export class _DevTools {
  67108. static WarnImport(name: string): string;
  67109. }
  67110. }
  67111. declare module BABYLON {
  67112. /**
  67113. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67114. */
  67115. export class WebRequest {
  67116. private _xhr;
  67117. /**
  67118. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67119. * i.e. when loading files, where the server/service expects an Authorization header
  67120. */
  67121. static CustomRequestHeaders: {
  67122. [key: string]: string;
  67123. };
  67124. /**
  67125. * Add callback functions in this array to update all the requests before they get sent to the network
  67126. */
  67127. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67128. private _injectCustomRequestHeaders;
  67129. /**
  67130. * Gets or sets a function to be called when loading progress changes
  67131. */
  67132. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67133. /**
  67134. * Returns client's state
  67135. */
  67136. readonly readyState: number;
  67137. /**
  67138. * Returns client's status
  67139. */
  67140. readonly status: number;
  67141. /**
  67142. * Returns client's status as a text
  67143. */
  67144. readonly statusText: string;
  67145. /**
  67146. * Returns client's response
  67147. */
  67148. readonly response: any;
  67149. /**
  67150. * Returns client's response url
  67151. */
  67152. readonly responseURL: string;
  67153. /**
  67154. * Returns client's response as text
  67155. */
  67156. readonly responseText: string;
  67157. /**
  67158. * Gets or sets the expected response type
  67159. */
  67160. responseType: XMLHttpRequestResponseType;
  67161. /** @hidden */
  67162. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67163. /** @hidden */
  67164. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67165. /**
  67166. * Cancels any network activity
  67167. */
  67168. abort(): void;
  67169. /**
  67170. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67171. * @param body defines an optional request body
  67172. */
  67173. send(body?: Document | BodyInit | null): void;
  67174. /**
  67175. * Sets the request method, request URL
  67176. * @param method defines the method to use (GET, POST, etc..)
  67177. * @param url defines the url to connect with
  67178. */
  67179. open(method: string, url: string): void;
  67180. }
  67181. }
  67182. declare module BABYLON {
  67183. /**
  67184. * File request interface
  67185. */
  67186. export interface IFileRequest {
  67187. /**
  67188. * Raised when the request is complete (success or error).
  67189. */
  67190. onCompleteObservable: Observable<IFileRequest>;
  67191. /**
  67192. * Aborts the request for a file.
  67193. */
  67194. abort: () => void;
  67195. }
  67196. }
  67197. declare module BABYLON {
  67198. /**
  67199. * Scalar computation library
  67200. */
  67201. export class Scalar {
  67202. /**
  67203. * Two pi constants convenient for computation.
  67204. */
  67205. static TwoPi: number;
  67206. /**
  67207. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67208. * @param a number
  67209. * @param b number
  67210. * @param epsilon (default = 1.401298E-45)
  67211. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67212. */
  67213. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  67214. /**
  67215. * Returns a string : the upper case translation of the number i to hexadecimal.
  67216. * @param i number
  67217. * @returns the upper case translation of the number i to hexadecimal.
  67218. */
  67219. static ToHex(i: number): string;
  67220. /**
  67221. * Returns -1 if value is negative and +1 is value is positive.
  67222. * @param value the value
  67223. * @returns the value itself if it's equal to zero.
  67224. */
  67225. static Sign(value: number): number;
  67226. /**
  67227. * Returns the value itself if it's between min and max.
  67228. * Returns min if the value is lower than min.
  67229. * Returns max if the value is greater than max.
  67230. * @param value the value to clmap
  67231. * @param min the min value to clamp to (default: 0)
  67232. * @param max the max value to clamp to (default: 1)
  67233. * @returns the clamped value
  67234. */
  67235. static Clamp(value: number, min?: number, max?: number): number;
  67236. /**
  67237. * the log2 of value.
  67238. * @param value the value to compute log2 of
  67239. * @returns the log2 of value.
  67240. */
  67241. static Log2(value: number): number;
  67242. /**
  67243. * Loops the value, so that it is never larger than length and never smaller than 0.
  67244. *
  67245. * This is similar to the modulo operator but it works with floating point numbers.
  67246. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67247. * With t = 5 and length = 2.5, the result would be 0.0.
  67248. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67249. * @param value the value
  67250. * @param length the length
  67251. * @returns the looped value
  67252. */
  67253. static Repeat(value: number, length: number): number;
  67254. /**
  67255. * Normalize the value between 0.0 and 1.0 using min and max values
  67256. * @param value value to normalize
  67257. * @param min max to normalize between
  67258. * @param max min to normalize between
  67259. * @returns the normalized value
  67260. */
  67261. static Normalize(value: number, min: number, max: number): number;
  67262. /**
  67263. * Denormalize the value from 0.0 and 1.0 using min and max values
  67264. * @param normalized value to denormalize
  67265. * @param min max to denormalize between
  67266. * @param max min to denormalize between
  67267. * @returns the denormalized value
  67268. */
  67269. static Denormalize(normalized: number, min: number, max: number): number;
  67270. /**
  67271. * Calculates the shortest difference between two given angles given in degrees.
  67272. * @param current current angle in degrees
  67273. * @param target target angle in degrees
  67274. * @returns the delta
  67275. */
  67276. static DeltaAngle(current: number, target: number): number;
  67277. /**
  67278. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67279. * @param tx value
  67280. * @param length length
  67281. * @returns The returned value will move back and forth between 0 and length
  67282. */
  67283. static PingPong(tx: number, length: number): number;
  67284. /**
  67285. * Interpolates between min and max with smoothing at the limits.
  67286. *
  67287. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67288. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67289. * @param from from
  67290. * @param to to
  67291. * @param tx value
  67292. * @returns the smooth stepped value
  67293. */
  67294. static SmoothStep(from: number, to: number, tx: number): number;
  67295. /**
  67296. * Moves a value current towards target.
  67297. *
  67298. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67299. * Negative values of maxDelta pushes the value away from target.
  67300. * @param current current value
  67301. * @param target target value
  67302. * @param maxDelta max distance to move
  67303. * @returns resulting value
  67304. */
  67305. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67306. /**
  67307. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67308. *
  67309. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67310. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67311. * @param current current value
  67312. * @param target target value
  67313. * @param maxDelta max distance to move
  67314. * @returns resulting angle
  67315. */
  67316. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67317. /**
  67318. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67319. * @param start start value
  67320. * @param end target value
  67321. * @param amount amount to lerp between
  67322. * @returns the lerped value
  67323. */
  67324. static Lerp(start: number, end: number, amount: number): number;
  67325. /**
  67326. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67327. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67328. * @param start start value
  67329. * @param end target value
  67330. * @param amount amount to lerp between
  67331. * @returns the lerped value
  67332. */
  67333. static LerpAngle(start: number, end: number, amount: number): number;
  67334. /**
  67335. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67336. * @param a start value
  67337. * @param b target value
  67338. * @param value value between a and b
  67339. * @returns the inverseLerp value
  67340. */
  67341. static InverseLerp(a: number, b: number, value: number): number;
  67342. /**
  67343. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67344. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67345. * @param value1 spline value
  67346. * @param tangent1 spline value
  67347. * @param value2 spline value
  67348. * @param tangent2 spline value
  67349. * @param amount input value
  67350. * @returns hermite result
  67351. */
  67352. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67353. /**
  67354. * Returns a random float number between and min and max values
  67355. * @param min min value of random
  67356. * @param max max value of random
  67357. * @returns random value
  67358. */
  67359. static RandomRange(min: number, max: number): number;
  67360. /**
  67361. * This function returns percentage of a number in a given range.
  67362. *
  67363. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67364. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67365. * @param number to convert to percentage
  67366. * @param min min range
  67367. * @param max max range
  67368. * @returns the percentage
  67369. */
  67370. static RangeToPercent(number: number, min: number, max: number): number;
  67371. /**
  67372. * This function returns number that corresponds to the percentage in a given range.
  67373. *
  67374. * PercentToRange(0.34,0,100) will return 34.
  67375. * @param percent to convert to number
  67376. * @param min min range
  67377. * @param max max range
  67378. * @returns the number
  67379. */
  67380. static PercentToRange(percent: number, min: number, max: number): number;
  67381. /**
  67382. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67383. * @param angle The angle to normalize in radian.
  67384. * @return The converted angle.
  67385. */
  67386. static NormalizeRadians(angle: number): number;
  67387. }
  67388. }
  67389. declare module BABYLON {
  67390. /**
  67391. * Constant used to convert a value to gamma space
  67392. * @ignorenaming
  67393. */
  67394. export const ToGammaSpace: number;
  67395. /**
  67396. * Constant used to convert a value to linear space
  67397. * @ignorenaming
  67398. */
  67399. export const ToLinearSpace = 2.2;
  67400. /**
  67401. * Constant used to define the minimal number value in Babylon.js
  67402. * @ignorenaming
  67403. */
  67404. let Epsilon: number;
  67405. }
  67406. declare module BABYLON {
  67407. /**
  67408. * Class used to represent a viewport on screen
  67409. */
  67410. export class Viewport {
  67411. /** viewport left coordinate */
  67412. x: number;
  67413. /** viewport top coordinate */
  67414. y: number;
  67415. /**viewport width */
  67416. width: number;
  67417. /** viewport height */
  67418. height: number;
  67419. /**
  67420. * Creates a Viewport object located at (x, y) and sized (width, height)
  67421. * @param x defines viewport left coordinate
  67422. * @param y defines viewport top coordinate
  67423. * @param width defines the viewport width
  67424. * @param height defines the viewport height
  67425. */
  67426. constructor(
  67427. /** viewport left coordinate */
  67428. x: number,
  67429. /** viewport top coordinate */
  67430. y: number,
  67431. /**viewport width */
  67432. width: number,
  67433. /** viewport height */
  67434. height: number);
  67435. /**
  67436. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67437. * @param renderWidth defines the rendering width
  67438. * @param renderHeight defines the rendering height
  67439. * @returns a new Viewport
  67440. */
  67441. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67442. /**
  67443. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67444. * @param renderWidth defines the rendering width
  67445. * @param renderHeight defines the rendering height
  67446. * @param ref defines the target viewport
  67447. * @returns the current viewport
  67448. */
  67449. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67450. /**
  67451. * Returns a new Viewport copied from the current one
  67452. * @returns a new Viewport
  67453. */
  67454. clone(): Viewport;
  67455. }
  67456. }
  67457. declare module BABYLON {
  67458. /**
  67459. * Class containing a set of static utilities functions for arrays.
  67460. */
  67461. export class ArrayTools {
  67462. /**
  67463. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67464. * @param size the number of element to construct and put in the array
  67465. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67466. * @returns a new array filled with new objects
  67467. */
  67468. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67469. }
  67470. }
  67471. declare module BABYLON {
  67472. /**
  67473. * @hidden
  67474. */
  67475. export interface IColor4Like {
  67476. r: float;
  67477. g: float;
  67478. b: float;
  67479. a: float;
  67480. }
  67481. /**
  67482. * @hidden
  67483. */
  67484. export interface IColor3Like {
  67485. r: float;
  67486. g: float;
  67487. b: float;
  67488. }
  67489. /**
  67490. * @hidden
  67491. */
  67492. export interface IVector4Like {
  67493. x: float;
  67494. y: float;
  67495. z: float;
  67496. w: float;
  67497. }
  67498. /**
  67499. * @hidden
  67500. */
  67501. export interface IVector3Like {
  67502. x: float;
  67503. y: float;
  67504. z: float;
  67505. }
  67506. /**
  67507. * @hidden
  67508. */
  67509. export interface IVector2Like {
  67510. x: float;
  67511. y: float;
  67512. }
  67513. /**
  67514. * @hidden
  67515. */
  67516. export interface IMatrixLike {
  67517. toArray(): DeepImmutable<Float32Array>;
  67518. updateFlag: int;
  67519. }
  67520. /**
  67521. * @hidden
  67522. */
  67523. export interface IViewportLike {
  67524. x: float;
  67525. y: float;
  67526. width: float;
  67527. height: float;
  67528. }
  67529. /**
  67530. * @hidden
  67531. */
  67532. export interface IPlaneLike {
  67533. normal: IVector3Like;
  67534. d: float;
  67535. normalize(): void;
  67536. }
  67537. }
  67538. declare module BABYLON {
  67539. /**
  67540. * Class representing a vector containing 2 coordinates
  67541. */
  67542. export class Vector2 {
  67543. /** defines the first coordinate */
  67544. x: number;
  67545. /** defines the second coordinate */
  67546. y: number;
  67547. /**
  67548. * Creates a new Vector2 from the given x and y coordinates
  67549. * @param x defines the first coordinate
  67550. * @param y defines the second coordinate
  67551. */
  67552. constructor(
  67553. /** defines the first coordinate */
  67554. x?: number,
  67555. /** defines the second coordinate */
  67556. y?: number);
  67557. /**
  67558. * Gets a string with the Vector2 coordinates
  67559. * @returns a string with the Vector2 coordinates
  67560. */
  67561. toString(): string;
  67562. /**
  67563. * Gets class name
  67564. * @returns the string "Vector2"
  67565. */
  67566. getClassName(): string;
  67567. /**
  67568. * Gets current vector hash code
  67569. * @returns the Vector2 hash code as a number
  67570. */
  67571. getHashCode(): number;
  67572. /**
  67573. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67574. * @param array defines the source array
  67575. * @param index defines the offset in source array
  67576. * @returns the current Vector2
  67577. */
  67578. toArray(array: FloatArray, index?: number): Vector2;
  67579. /**
  67580. * Copy the current vector to an array
  67581. * @returns a new array with 2 elements: the Vector2 coordinates.
  67582. */
  67583. asArray(): number[];
  67584. /**
  67585. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67586. * @param source defines the source Vector2
  67587. * @returns the current updated Vector2
  67588. */
  67589. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67590. /**
  67591. * Sets the Vector2 coordinates with the given floats
  67592. * @param x defines the first coordinate
  67593. * @param y defines the second coordinate
  67594. * @returns the current updated Vector2
  67595. */
  67596. copyFromFloats(x: number, y: number): Vector2;
  67597. /**
  67598. * Sets the Vector2 coordinates with the given floats
  67599. * @param x defines the first coordinate
  67600. * @param y defines the second coordinate
  67601. * @returns the current updated Vector2
  67602. */
  67603. set(x: number, y: number): Vector2;
  67604. /**
  67605. * Add another vector with the current one
  67606. * @param otherVector defines the other vector
  67607. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67608. */
  67609. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67610. /**
  67611. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67612. * @param otherVector defines the other vector
  67613. * @param result defines the target vector
  67614. * @returns the unmodified current Vector2
  67615. */
  67616. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67617. /**
  67618. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67619. * @param otherVector defines the other vector
  67620. * @returns the current updated Vector2
  67621. */
  67622. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67623. /**
  67624. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67625. * @param otherVector defines the other vector
  67626. * @returns a new Vector2
  67627. */
  67628. addVector3(otherVector: Vector3): Vector2;
  67629. /**
  67630. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67631. * @param otherVector defines the other vector
  67632. * @returns a new Vector2
  67633. */
  67634. subtract(otherVector: Vector2): Vector2;
  67635. /**
  67636. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67637. * @param otherVector defines the other vector
  67638. * @param result defines the target vector
  67639. * @returns the unmodified current Vector2
  67640. */
  67641. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67642. /**
  67643. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67644. * @param otherVector defines the other vector
  67645. * @returns the current updated Vector2
  67646. */
  67647. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67648. /**
  67649. * Multiplies in place the current Vector2 coordinates by the given ones
  67650. * @param otherVector defines the other vector
  67651. * @returns the current updated Vector2
  67652. */
  67653. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67654. /**
  67655. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67656. * @param otherVector defines the other vector
  67657. * @returns a new Vector2
  67658. */
  67659. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67660. /**
  67661. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67662. * @param otherVector defines the other vector
  67663. * @param result defines the target vector
  67664. * @returns the unmodified current Vector2
  67665. */
  67666. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67667. /**
  67668. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67669. * @param x defines the first coordinate
  67670. * @param y defines the second coordinate
  67671. * @returns a new Vector2
  67672. */
  67673. multiplyByFloats(x: number, y: number): Vector2;
  67674. /**
  67675. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67676. * @param otherVector defines the other vector
  67677. * @returns a new Vector2
  67678. */
  67679. divide(otherVector: Vector2): Vector2;
  67680. /**
  67681. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67682. * @param otherVector defines the other vector
  67683. * @param result defines the target vector
  67684. * @returns the unmodified current Vector2
  67685. */
  67686. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67687. /**
  67688. * Divides the current Vector2 coordinates by the given ones
  67689. * @param otherVector defines the other vector
  67690. * @returns the current updated Vector2
  67691. */
  67692. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67693. /**
  67694. * Gets a new Vector2 with current Vector2 negated coordinates
  67695. * @returns a new Vector2
  67696. */
  67697. negate(): Vector2;
  67698. /**
  67699. * Multiply the Vector2 coordinates by scale
  67700. * @param scale defines the scaling factor
  67701. * @returns the current updated Vector2
  67702. */
  67703. scaleInPlace(scale: number): Vector2;
  67704. /**
  67705. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67706. * @param scale defines the scaling factor
  67707. * @returns a new Vector2
  67708. */
  67709. scale(scale: number): Vector2;
  67710. /**
  67711. * Scale the current Vector2 values by a factor to a given Vector2
  67712. * @param scale defines the scale factor
  67713. * @param result defines the Vector2 object where to store the result
  67714. * @returns the unmodified current Vector2
  67715. */
  67716. scaleToRef(scale: number, result: Vector2): Vector2;
  67717. /**
  67718. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67719. * @param scale defines the scale factor
  67720. * @param result defines the Vector2 object where to store the result
  67721. * @returns the unmodified current Vector2
  67722. */
  67723. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67724. /**
  67725. * Gets a boolean if two vectors are equals
  67726. * @param otherVector defines the other vector
  67727. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67728. */
  67729. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67730. /**
  67731. * Gets a boolean if two vectors are equals (using an epsilon value)
  67732. * @param otherVector defines the other vector
  67733. * @param epsilon defines the minimal distance to consider equality
  67734. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67735. */
  67736. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67737. /**
  67738. * Gets a new Vector2 from current Vector2 floored values
  67739. * @returns a new Vector2
  67740. */
  67741. floor(): Vector2;
  67742. /**
  67743. * Gets a new Vector2 from current Vector2 floored values
  67744. * @returns a new Vector2
  67745. */
  67746. fract(): Vector2;
  67747. /**
  67748. * Gets the length of the vector
  67749. * @returns the vector length (float)
  67750. */
  67751. length(): number;
  67752. /**
  67753. * Gets the vector squared length
  67754. * @returns the vector squared length (float)
  67755. */
  67756. lengthSquared(): number;
  67757. /**
  67758. * Normalize the vector
  67759. * @returns the current updated Vector2
  67760. */
  67761. normalize(): Vector2;
  67762. /**
  67763. * Gets a new Vector2 copied from the Vector2
  67764. * @returns a new Vector2
  67765. */
  67766. clone(): Vector2;
  67767. /**
  67768. * Gets a new Vector2(0, 0)
  67769. * @returns a new Vector2
  67770. */
  67771. static Zero(): Vector2;
  67772. /**
  67773. * Gets a new Vector2(1, 1)
  67774. * @returns a new Vector2
  67775. */
  67776. static One(): Vector2;
  67777. /**
  67778. * Gets a new Vector2 set from the given index element of the given array
  67779. * @param array defines the data source
  67780. * @param offset defines the offset in the data source
  67781. * @returns a new Vector2
  67782. */
  67783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67784. /**
  67785. * Sets "result" from the given index element of the given array
  67786. * @param array defines the data source
  67787. * @param offset defines the offset in the data source
  67788. * @param result defines the target vector
  67789. */
  67790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67791. /**
  67792. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67793. * @param value1 defines 1st point of control
  67794. * @param value2 defines 2nd point of control
  67795. * @param value3 defines 3rd point of control
  67796. * @param value4 defines 4th point of control
  67797. * @param amount defines the interpolation factor
  67798. * @returns a new Vector2
  67799. */
  67800. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67801. /**
  67802. * 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".
  67803. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67804. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67805. * @param value defines the value to clamp
  67806. * @param min defines the lower limit
  67807. * @param max defines the upper limit
  67808. * @returns a new Vector2
  67809. */
  67810. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67811. /**
  67812. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67813. * @param value1 defines the 1st control point
  67814. * @param tangent1 defines the outgoing tangent
  67815. * @param value2 defines the 2nd control point
  67816. * @param tangent2 defines the incoming tangent
  67817. * @param amount defines the interpolation factor
  67818. * @returns a new Vector2
  67819. */
  67820. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67821. /**
  67822. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67823. * @param start defines the start vector
  67824. * @param end defines the end vector
  67825. * @param amount defines the interpolation factor
  67826. * @returns a new Vector2
  67827. */
  67828. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67829. /**
  67830. * Gets the dot product of the vector "left" and the vector "right"
  67831. * @param left defines first vector
  67832. * @param right defines second vector
  67833. * @returns the dot product (float)
  67834. */
  67835. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67836. /**
  67837. * Returns a new Vector2 equal to the normalized given vector
  67838. * @param vector defines the vector to normalize
  67839. * @returns a new Vector2
  67840. */
  67841. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67842. /**
  67843. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67844. * @param left defines 1st vector
  67845. * @param right defines 2nd vector
  67846. * @returns a new Vector2
  67847. */
  67848. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67849. /**
  67850. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67851. * @param left defines 1st vector
  67852. * @param right defines 2nd vector
  67853. * @returns a new Vector2
  67854. */
  67855. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67856. /**
  67857. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67858. * @param vector defines the vector to transform
  67859. * @param transformation defines the matrix to apply
  67860. * @returns a new Vector2
  67861. */
  67862. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67863. /**
  67864. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67865. * @param vector defines the vector to transform
  67866. * @param transformation defines the matrix to apply
  67867. * @param result defines the target vector
  67868. */
  67869. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67870. /**
  67871. * Determines if a given vector is included in a triangle
  67872. * @param p defines the vector to test
  67873. * @param p0 defines 1st triangle point
  67874. * @param p1 defines 2nd triangle point
  67875. * @param p2 defines 3rd triangle point
  67876. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67877. */
  67878. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67879. /**
  67880. * Gets the distance between the vectors "value1" and "value2"
  67881. * @param value1 defines first vector
  67882. * @param value2 defines second vector
  67883. * @returns the distance between vectors
  67884. */
  67885. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67886. /**
  67887. * Returns the squared distance between the vectors "value1" and "value2"
  67888. * @param value1 defines first vector
  67889. * @param value2 defines second vector
  67890. * @returns the squared distance between vectors
  67891. */
  67892. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67893. /**
  67894. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67895. * @param value1 defines first vector
  67896. * @param value2 defines second vector
  67897. * @returns a new Vector2
  67898. */
  67899. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67900. /**
  67901. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67902. * @param p defines the middle point
  67903. * @param segA defines one point of the segment
  67904. * @param segB defines the other point of the segment
  67905. * @returns the shortest distance
  67906. */
  67907. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67908. }
  67909. /**
  67910. * Classed used to store (x,y,z) vector representation
  67911. * A Vector3 is the main object used in 3D geometry
  67912. * It can represent etiher the coordinates of a point the space, either a direction
  67913. * Reminder: js uses a left handed forward facing system
  67914. */
  67915. export class Vector3 {
  67916. /**
  67917. * Defines the first coordinates (on X axis)
  67918. */
  67919. x: number;
  67920. /**
  67921. * Defines the second coordinates (on Y axis)
  67922. */
  67923. y: number;
  67924. /**
  67925. * Defines the third coordinates (on Z axis)
  67926. */
  67927. z: number;
  67928. private static _UpReadOnly;
  67929. private static _ZeroReadOnly;
  67930. /**
  67931. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67932. * @param x defines the first coordinates (on X axis)
  67933. * @param y defines the second coordinates (on Y axis)
  67934. * @param z defines the third coordinates (on Z axis)
  67935. */
  67936. constructor(
  67937. /**
  67938. * Defines the first coordinates (on X axis)
  67939. */
  67940. x?: number,
  67941. /**
  67942. * Defines the second coordinates (on Y axis)
  67943. */
  67944. y?: number,
  67945. /**
  67946. * Defines the third coordinates (on Z axis)
  67947. */
  67948. z?: number);
  67949. /**
  67950. * Creates a string representation of the Vector3
  67951. * @returns a string with the Vector3 coordinates.
  67952. */
  67953. toString(): string;
  67954. /**
  67955. * Gets the class name
  67956. * @returns the string "Vector3"
  67957. */
  67958. getClassName(): string;
  67959. /**
  67960. * Creates the Vector3 hash code
  67961. * @returns a number which tends to be unique between Vector3 instances
  67962. */
  67963. getHashCode(): number;
  67964. /**
  67965. * Creates an array containing three elements : the coordinates of the Vector3
  67966. * @returns a new array of numbers
  67967. */
  67968. asArray(): number[];
  67969. /**
  67970. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67971. * @param array defines the destination array
  67972. * @param index defines the offset in the destination array
  67973. * @returns the current Vector3
  67974. */
  67975. toArray(array: FloatArray, index?: number): Vector3;
  67976. /**
  67977. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67978. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67979. */
  67980. toQuaternion(): Quaternion;
  67981. /**
  67982. * Adds the given vector to the current Vector3
  67983. * @param otherVector defines the second operand
  67984. * @returns the current updated Vector3
  67985. */
  67986. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67987. /**
  67988. * Adds the given coordinates to the current Vector3
  67989. * @param x defines the x coordinate of the operand
  67990. * @param y defines the y coordinate of the operand
  67991. * @param z defines the z coordinate of the operand
  67992. * @returns the current updated Vector3
  67993. */
  67994. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67995. /**
  67996. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67997. * @param otherVector defines the second operand
  67998. * @returns the resulting Vector3
  67999. */
  68000. add(otherVector: DeepImmutable<Vector3>): Vector3;
  68001. /**
  68002. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68003. * @param otherVector defines the second operand
  68004. * @param result defines the Vector3 object where to store the result
  68005. * @returns the current Vector3
  68006. */
  68007. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68008. /**
  68009. * Subtract the given vector from the current Vector3
  68010. * @param otherVector defines the second operand
  68011. * @returns the current updated Vector3
  68012. */
  68013. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68014. /**
  68015. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68016. * @param otherVector defines the second operand
  68017. * @returns the resulting Vector3
  68018. */
  68019. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  68020. /**
  68021. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68022. * @param otherVector defines the second operand
  68023. * @param result defines the Vector3 object where to store the result
  68024. * @returns the current Vector3
  68025. */
  68026. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68027. /**
  68028. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68029. * @param x defines the x coordinate of the operand
  68030. * @param y defines the y coordinate of the operand
  68031. * @param z defines the z coordinate of the operand
  68032. * @returns the resulting Vector3
  68033. */
  68034. subtractFromFloats(x: number, y: number, z: number): Vector3;
  68035. /**
  68036. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68037. * @param x defines the x coordinate of the operand
  68038. * @param y defines the y coordinate of the operand
  68039. * @param z defines the z coordinate of the operand
  68040. * @param result defines the Vector3 object where to store the result
  68041. * @returns the current Vector3
  68042. */
  68043. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  68044. /**
  68045. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68046. * @returns a new Vector3
  68047. */
  68048. negate(): Vector3;
  68049. /**
  68050. * Multiplies the Vector3 coordinates by the float "scale"
  68051. * @param scale defines the multiplier factor
  68052. * @returns the current updated Vector3
  68053. */
  68054. scaleInPlace(scale: number): Vector3;
  68055. /**
  68056. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68057. * @param scale defines the multiplier factor
  68058. * @returns a new Vector3
  68059. */
  68060. scale(scale: number): Vector3;
  68061. /**
  68062. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68063. * @param scale defines the multiplier factor
  68064. * @param result defines the Vector3 object where to store the result
  68065. * @returns the current Vector3
  68066. */
  68067. scaleToRef(scale: number, result: Vector3): Vector3;
  68068. /**
  68069. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68070. * @param scale defines the scale factor
  68071. * @param result defines the Vector3 object where to store the result
  68072. * @returns the unmodified current Vector3
  68073. */
  68074. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  68075. /**
  68076. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68077. * @param otherVector defines the second operand
  68078. * @returns true if both vectors are equals
  68079. */
  68080. equals(otherVector: DeepImmutable<Vector3>): boolean;
  68081. /**
  68082. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68083. * @param otherVector defines the second operand
  68084. * @param epsilon defines the minimal distance to define values as equals
  68085. * @returns true if both vectors are distant less than epsilon
  68086. */
  68087. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  68088. /**
  68089. * Returns true if the current Vector3 coordinates equals the given floats
  68090. * @param x defines the x coordinate of the operand
  68091. * @param y defines the y coordinate of the operand
  68092. * @param z defines the z coordinate of the operand
  68093. * @returns true if both vectors are equals
  68094. */
  68095. equalsToFloats(x: number, y: number, z: number): boolean;
  68096. /**
  68097. * Multiplies the current Vector3 coordinates by the given ones
  68098. * @param otherVector defines the second operand
  68099. * @returns the current updated Vector3
  68100. */
  68101. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68102. /**
  68103. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68104. * @param otherVector defines the second operand
  68105. * @returns the new Vector3
  68106. */
  68107. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  68108. /**
  68109. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68110. * @param otherVector defines the second operand
  68111. * @param result defines the Vector3 object where to store the result
  68112. * @returns the current Vector3
  68113. */
  68114. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68115. /**
  68116. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68117. * @param x defines the x coordinate of the operand
  68118. * @param y defines the y coordinate of the operand
  68119. * @param z defines the z coordinate of the operand
  68120. * @returns the new Vector3
  68121. */
  68122. multiplyByFloats(x: number, y: number, z: number): Vector3;
  68123. /**
  68124. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68125. * @param otherVector defines the second operand
  68126. * @returns the new Vector3
  68127. */
  68128. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  68129. /**
  68130. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68131. * @param otherVector defines the second operand
  68132. * @param result defines the Vector3 object where to store the result
  68133. * @returns the current Vector3
  68134. */
  68135. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68136. /**
  68137. * Divides the current Vector3 coordinates by the given ones.
  68138. * @param otherVector defines the second operand
  68139. * @returns the current updated Vector3
  68140. */
  68141. divideInPlace(otherVector: Vector3): Vector3;
  68142. /**
  68143. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68144. * @param other defines the second operand
  68145. * @returns the current updated Vector3
  68146. */
  68147. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68148. /**
  68149. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68150. * @param other defines the second operand
  68151. * @returns the current updated Vector3
  68152. */
  68153. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68154. /**
  68155. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68156. * @param x defines the x coordinate of the operand
  68157. * @param y defines the y coordinate of the operand
  68158. * @param z defines the z coordinate of the operand
  68159. * @returns the current updated Vector3
  68160. */
  68161. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68162. /**
  68163. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68164. * @param x defines the x coordinate of the operand
  68165. * @param y defines the y coordinate of the operand
  68166. * @param z defines the z coordinate of the operand
  68167. * @returns the current updated Vector3
  68168. */
  68169. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68170. /**
  68171. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68172. * Check if is non uniform within a certain amount of decimal places to account for this
  68173. * @param epsilon the amount the values can differ
  68174. * @returns if the the vector is non uniform to a certain number of decimal places
  68175. */
  68176. isNonUniformWithinEpsilon(epsilon: number): boolean;
  68177. /**
  68178. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68179. */
  68180. readonly isNonUniform: boolean;
  68181. /**
  68182. * Gets a new Vector3 from current Vector3 floored values
  68183. * @returns a new Vector3
  68184. */
  68185. floor(): Vector3;
  68186. /**
  68187. * Gets a new Vector3 from current Vector3 floored values
  68188. * @returns a new Vector3
  68189. */
  68190. fract(): Vector3;
  68191. /**
  68192. * Gets the length of the Vector3
  68193. * @returns the length of the Vector3
  68194. */
  68195. length(): number;
  68196. /**
  68197. * Gets the squared length of the Vector3
  68198. * @returns squared length of the Vector3
  68199. */
  68200. lengthSquared(): number;
  68201. /**
  68202. * Normalize the current Vector3.
  68203. * Please note that this is an in place operation.
  68204. * @returns the current updated Vector3
  68205. */
  68206. normalize(): Vector3;
  68207. /**
  68208. * Reorders the x y z properties of the vector in place
  68209. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68210. * @returns the current updated vector
  68211. */
  68212. reorderInPlace(order: string): this;
  68213. /**
  68214. * Rotates the vector around 0,0,0 by a quaternion
  68215. * @param quaternion the rotation quaternion
  68216. * @param result vector to store the result
  68217. * @returns the resulting vector
  68218. */
  68219. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  68220. /**
  68221. * Rotates a vector around a given point
  68222. * @param quaternion the rotation quaternion
  68223. * @param point the point to rotate around
  68224. * @param result vector to store the result
  68225. * @returns the resulting vector
  68226. */
  68227. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  68228. /**
  68229. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  68230. * The cross product is then orthogonal to both current and "other"
  68231. * @param other defines the right operand
  68232. * @returns the cross product
  68233. */
  68234. cross(other: Vector3): Vector3;
  68235. /**
  68236. * Normalize the current Vector3 with the given input length.
  68237. * Please note that this is an in place operation.
  68238. * @param len the length of the vector
  68239. * @returns the current updated Vector3
  68240. */
  68241. normalizeFromLength(len: number): Vector3;
  68242. /**
  68243. * Normalize the current Vector3 to a new vector
  68244. * @returns the new Vector3
  68245. */
  68246. normalizeToNew(): Vector3;
  68247. /**
  68248. * Normalize the current Vector3 to the reference
  68249. * @param reference define the Vector3 to update
  68250. * @returns the updated Vector3
  68251. */
  68252. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  68253. /**
  68254. * Creates a new Vector3 copied from the current Vector3
  68255. * @returns the new Vector3
  68256. */
  68257. clone(): Vector3;
  68258. /**
  68259. * Copies the given vector coordinates to the current Vector3 ones
  68260. * @param source defines the source Vector3
  68261. * @returns the current updated Vector3
  68262. */
  68263. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  68264. /**
  68265. * Copies the given floats to the current Vector3 coordinates
  68266. * @param x defines the x coordinate of the operand
  68267. * @param y defines the y coordinate of the operand
  68268. * @param z defines the z coordinate of the operand
  68269. * @returns the current updated Vector3
  68270. */
  68271. copyFromFloats(x: number, y: number, z: number): Vector3;
  68272. /**
  68273. * Copies the given floats to the current Vector3 coordinates
  68274. * @param x defines the x coordinate of the operand
  68275. * @param y defines the y coordinate of the operand
  68276. * @param z defines the z coordinate of the operand
  68277. * @returns the current updated Vector3
  68278. */
  68279. set(x: number, y: number, z: number): Vector3;
  68280. /**
  68281. * Copies the given float to the current Vector3 coordinates
  68282. * @param v defines the x, y and z coordinates of the operand
  68283. * @returns the current updated Vector3
  68284. */
  68285. setAll(v: number): Vector3;
  68286. /**
  68287. * Get the clip factor between two vectors
  68288. * @param vector0 defines the first operand
  68289. * @param vector1 defines the second operand
  68290. * @param axis defines the axis to use
  68291. * @param size defines the size along the axis
  68292. * @returns the clip factor
  68293. */
  68294. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68295. /**
  68296. * Get angle between two vectors
  68297. * @param vector0 angle between vector0 and vector1
  68298. * @param vector1 angle between vector0 and vector1
  68299. * @param normal direction of the normal
  68300. * @return the angle between vector0 and vector1
  68301. */
  68302. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68303. /**
  68304. * Returns a new Vector3 set from the index "offset" of the given array
  68305. * @param array defines the source array
  68306. * @param offset defines the offset in the source array
  68307. * @returns the new Vector3
  68308. */
  68309. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68310. /**
  68311. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68312. * This function is deprecated. Use FromArray instead
  68313. * @param array defines the source array
  68314. * @param offset defines the offset in the source array
  68315. * @returns the new Vector3
  68316. */
  68317. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68318. /**
  68319. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68320. * @param array defines the source array
  68321. * @param offset defines the offset in the source array
  68322. * @param result defines the Vector3 where to store the result
  68323. */
  68324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68325. /**
  68326. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68327. * This function is deprecated. Use FromArrayToRef instead.
  68328. * @param array defines the source array
  68329. * @param offset defines the offset in the source array
  68330. * @param result defines the Vector3 where to store the result
  68331. */
  68332. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68333. /**
  68334. * Sets the given vector "result" with the given floats.
  68335. * @param x defines the x coordinate of the source
  68336. * @param y defines the y coordinate of the source
  68337. * @param z defines the z coordinate of the source
  68338. * @param result defines the Vector3 where to store the result
  68339. */
  68340. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68341. /**
  68342. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68343. * @returns a new empty Vector3
  68344. */
  68345. static Zero(): Vector3;
  68346. /**
  68347. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68348. * @returns a new unit Vector3
  68349. */
  68350. static One(): Vector3;
  68351. /**
  68352. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68353. * @returns a new up Vector3
  68354. */
  68355. static Up(): Vector3;
  68356. /**
  68357. * Gets a up Vector3 that must not be updated
  68358. */
  68359. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68360. /**
  68361. * Gets a zero Vector3 that must not be updated
  68362. */
  68363. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68364. /**
  68365. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68366. * @returns a new down Vector3
  68367. */
  68368. static Down(): Vector3;
  68369. /**
  68370. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68371. * @returns a new forward Vector3
  68372. */
  68373. static Forward(): Vector3;
  68374. /**
  68375. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68376. * @returns a new forward Vector3
  68377. */
  68378. static Backward(): Vector3;
  68379. /**
  68380. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68381. * @returns a new right Vector3
  68382. */
  68383. static Right(): Vector3;
  68384. /**
  68385. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68386. * @returns a new left Vector3
  68387. */
  68388. static Left(): Vector3;
  68389. /**
  68390. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68391. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68392. * @param vector defines the Vector3 to transform
  68393. * @param transformation defines the transformation matrix
  68394. * @returns the transformed Vector3
  68395. */
  68396. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68397. /**
  68398. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68399. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68400. * @param vector defines the Vector3 to transform
  68401. * @param transformation defines the transformation matrix
  68402. * @param result defines the Vector3 where to store the result
  68403. */
  68404. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68405. /**
  68406. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68407. * This method computes tranformed coordinates only, not transformed direction vectors
  68408. * @param x define the x coordinate of the source vector
  68409. * @param y define the y coordinate of the source vector
  68410. * @param z define the z coordinate of the source vector
  68411. * @param transformation defines the transformation matrix
  68412. * @param result defines the Vector3 where to store the result
  68413. */
  68414. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68415. /**
  68416. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68417. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68418. * @param vector defines the Vector3 to transform
  68419. * @param transformation defines the transformation matrix
  68420. * @returns the new Vector3
  68421. */
  68422. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68423. /**
  68424. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68425. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68426. * @param vector defines the Vector3 to transform
  68427. * @param transformation defines the transformation matrix
  68428. * @param result defines the Vector3 where to store the result
  68429. */
  68430. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68431. /**
  68432. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68433. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68434. * @param x define the x coordinate of the source vector
  68435. * @param y define the y coordinate of the source vector
  68436. * @param z define the z coordinate of the source vector
  68437. * @param transformation defines the transformation matrix
  68438. * @param result defines the Vector3 where to store the result
  68439. */
  68440. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68441. /**
  68442. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68443. * @param value1 defines the first control point
  68444. * @param value2 defines the second control point
  68445. * @param value3 defines the third control point
  68446. * @param value4 defines the fourth control point
  68447. * @param amount defines the amount on the spline to use
  68448. * @returns the new Vector3
  68449. */
  68450. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68451. /**
  68452. * 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"
  68453. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68454. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68455. * @param value defines the current value
  68456. * @param min defines the lower range value
  68457. * @param max defines the upper range value
  68458. * @returns the new Vector3
  68459. */
  68460. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68461. /**
  68462. * 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"
  68463. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68464. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68465. * @param value defines the current value
  68466. * @param min defines the lower range value
  68467. * @param max defines the upper range value
  68468. * @param result defines the Vector3 where to store the result
  68469. */
  68470. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68471. /**
  68472. * Checks if a given vector is inside a specific range
  68473. * @param v defines the vector to test
  68474. * @param min defines the minimum range
  68475. * @param max defines the maximum range
  68476. */
  68477. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68478. /**
  68479. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68480. * @param value1 defines the first control point
  68481. * @param tangent1 defines the first tangent vector
  68482. * @param value2 defines the second control point
  68483. * @param tangent2 defines the second tangent vector
  68484. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68485. * @returns the new Vector3
  68486. */
  68487. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68488. /**
  68489. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68490. * @param start defines the start value
  68491. * @param end defines the end value
  68492. * @param amount max defines amount between both (between 0 and 1)
  68493. * @returns the new Vector3
  68494. */
  68495. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68496. /**
  68497. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68498. * @param start defines the start value
  68499. * @param end defines the end value
  68500. * @param amount max defines amount between both (between 0 and 1)
  68501. * @param result defines the Vector3 where to store the result
  68502. */
  68503. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68504. /**
  68505. * Returns the dot product (float) between the vectors "left" and "right"
  68506. * @param left defines the left operand
  68507. * @param right defines the right operand
  68508. * @returns the dot product
  68509. */
  68510. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68511. /**
  68512. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68513. * The cross product is then orthogonal to both "left" and "right"
  68514. * @param left defines the left operand
  68515. * @param right defines the right operand
  68516. * @returns the cross product
  68517. */
  68518. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68519. /**
  68520. * Sets the given vector "result" with the cross product of "left" and "right"
  68521. * The cross product is then orthogonal to both "left" and "right"
  68522. * @param left defines the left operand
  68523. * @param right defines the right operand
  68524. * @param result defines the Vector3 where to store the result
  68525. */
  68526. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68527. /**
  68528. * Returns a new Vector3 as the normalization of the given vector
  68529. * @param vector defines the Vector3 to normalize
  68530. * @returns the new Vector3
  68531. */
  68532. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68533. /**
  68534. * Sets the given vector "result" with the normalization of the given first vector
  68535. * @param vector defines the Vector3 to normalize
  68536. * @param result defines the Vector3 where to store the result
  68537. */
  68538. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68539. /**
  68540. * Project a Vector3 onto screen space
  68541. * @param vector defines the Vector3 to project
  68542. * @param world defines the world matrix to use
  68543. * @param transform defines the transform (view x projection) matrix to use
  68544. * @param viewport defines the screen viewport to use
  68545. * @returns the new Vector3
  68546. */
  68547. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68548. /** @hidden */
  68549. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68550. /**
  68551. * Unproject from screen space to object space
  68552. * @param source defines the screen space Vector3 to use
  68553. * @param viewportWidth defines the current width of the viewport
  68554. * @param viewportHeight defines the current height of the viewport
  68555. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68556. * @param transform defines the transform (view x projection) matrix to use
  68557. * @returns the new Vector3
  68558. */
  68559. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68560. /**
  68561. * Unproject from screen space to object space
  68562. * @param source defines the screen space Vector3 to use
  68563. * @param viewportWidth defines the current width of the viewport
  68564. * @param viewportHeight defines the current height of the viewport
  68565. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68566. * @param view defines the view matrix to use
  68567. * @param projection defines the projection matrix to use
  68568. * @returns the new Vector3
  68569. */
  68570. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68571. /**
  68572. * Unproject from screen space to object space
  68573. * @param source defines the screen space Vector3 to use
  68574. * @param viewportWidth defines the current width of the viewport
  68575. * @param viewportHeight defines the current height of the viewport
  68576. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68577. * @param view defines the view matrix to use
  68578. * @param projection defines the projection matrix to use
  68579. * @param result defines the Vector3 where to store the result
  68580. */
  68581. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68582. /**
  68583. * Unproject from screen space to object space
  68584. * @param sourceX defines the screen space x coordinate to use
  68585. * @param sourceY defines the screen space y coordinate to use
  68586. * @param sourceZ defines the screen space z coordinate to use
  68587. * @param viewportWidth defines the current width of the viewport
  68588. * @param viewportHeight defines the current height of the viewport
  68589. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68590. * @param view defines the view matrix to use
  68591. * @param projection defines the projection matrix to use
  68592. * @param result defines the Vector3 where to store the result
  68593. */
  68594. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68595. /**
  68596. * Gets the minimal coordinate values between two Vector3
  68597. * @param left defines the first operand
  68598. * @param right defines the second operand
  68599. * @returns the new Vector3
  68600. */
  68601. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68602. /**
  68603. * Gets the maximal coordinate values between two Vector3
  68604. * @param left defines the first operand
  68605. * @param right defines the second operand
  68606. * @returns the new Vector3
  68607. */
  68608. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68609. /**
  68610. * Returns the distance between the vectors "value1" and "value2"
  68611. * @param value1 defines the first operand
  68612. * @param value2 defines the second operand
  68613. * @returns the distance
  68614. */
  68615. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68616. /**
  68617. * Returns the squared distance between the vectors "value1" and "value2"
  68618. * @param value1 defines the first operand
  68619. * @param value2 defines the second operand
  68620. * @returns the squared distance
  68621. */
  68622. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68623. /**
  68624. * Returns a new Vector3 located at the center between "value1" and "value2"
  68625. * @param value1 defines the first operand
  68626. * @param value2 defines the second operand
  68627. * @returns the new Vector3
  68628. */
  68629. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68630. /**
  68631. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68632. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68633. * to something in order to rotate it from its local system to the given target system
  68634. * Note: axis1, axis2 and axis3 are normalized during this operation
  68635. * @param axis1 defines the first axis
  68636. * @param axis2 defines the second axis
  68637. * @param axis3 defines the third axis
  68638. * @returns a new Vector3
  68639. */
  68640. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68641. /**
  68642. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68643. * @param axis1 defines the first axis
  68644. * @param axis2 defines the second axis
  68645. * @param axis3 defines the third axis
  68646. * @param ref defines the Vector3 where to store the result
  68647. */
  68648. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68649. }
  68650. /**
  68651. * Vector4 class created for EulerAngle class conversion to Quaternion
  68652. */
  68653. export class Vector4 {
  68654. /** x value of the vector */
  68655. x: number;
  68656. /** y value of the vector */
  68657. y: number;
  68658. /** z value of the vector */
  68659. z: number;
  68660. /** w value of the vector */
  68661. w: number;
  68662. /**
  68663. * Creates a Vector4 object from the given floats.
  68664. * @param x x value of the vector
  68665. * @param y y value of the vector
  68666. * @param z z value of the vector
  68667. * @param w w value of the vector
  68668. */
  68669. constructor(
  68670. /** x value of the vector */
  68671. x: number,
  68672. /** y value of the vector */
  68673. y: number,
  68674. /** z value of the vector */
  68675. z: number,
  68676. /** w value of the vector */
  68677. w: number);
  68678. /**
  68679. * Returns the string with the Vector4 coordinates.
  68680. * @returns a string containing all the vector values
  68681. */
  68682. toString(): string;
  68683. /**
  68684. * Returns the string "Vector4".
  68685. * @returns "Vector4"
  68686. */
  68687. getClassName(): string;
  68688. /**
  68689. * Returns the Vector4 hash code.
  68690. * @returns a unique hash code
  68691. */
  68692. getHashCode(): number;
  68693. /**
  68694. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68695. * @returns the resulting array
  68696. */
  68697. asArray(): number[];
  68698. /**
  68699. * Populates the given array from the given index with the Vector4 coordinates.
  68700. * @param array array to populate
  68701. * @param index index of the array to start at (default: 0)
  68702. * @returns the Vector4.
  68703. */
  68704. toArray(array: FloatArray, index?: number): Vector4;
  68705. /**
  68706. * Adds the given vector to the current Vector4.
  68707. * @param otherVector the vector to add
  68708. * @returns the updated Vector4.
  68709. */
  68710. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68711. /**
  68712. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68713. * @param otherVector the vector to add
  68714. * @returns the resulting vector
  68715. */
  68716. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68717. /**
  68718. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68719. * @param otherVector the vector to add
  68720. * @param result the vector to store the result
  68721. * @returns the current Vector4.
  68722. */
  68723. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68724. /**
  68725. * Subtract in place the given vector from the current Vector4.
  68726. * @param otherVector the vector to subtract
  68727. * @returns the updated Vector4.
  68728. */
  68729. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68730. /**
  68731. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68732. * @param otherVector the vector to add
  68733. * @returns the new vector with the result
  68734. */
  68735. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68736. /**
  68737. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68738. * @param otherVector the vector to subtract
  68739. * @param result the vector to store the result
  68740. * @returns the current Vector4.
  68741. */
  68742. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68743. /**
  68744. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68745. */
  68746. /**
  68747. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68748. * @param x value to subtract
  68749. * @param y value to subtract
  68750. * @param z value to subtract
  68751. * @param w value to subtract
  68752. * @returns new vector containing the result
  68753. */
  68754. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68755. /**
  68756. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68757. * @param x value to subtract
  68758. * @param y value to subtract
  68759. * @param z value to subtract
  68760. * @param w value to subtract
  68761. * @param result the vector to store the result in
  68762. * @returns the current Vector4.
  68763. */
  68764. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68765. /**
  68766. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68767. * @returns a new vector with the negated values
  68768. */
  68769. negate(): Vector4;
  68770. /**
  68771. * Multiplies the current Vector4 coordinates by scale (float).
  68772. * @param scale the number to scale with
  68773. * @returns the updated Vector4.
  68774. */
  68775. scaleInPlace(scale: number): Vector4;
  68776. /**
  68777. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68778. * @param scale the number to scale with
  68779. * @returns a new vector with the result
  68780. */
  68781. scale(scale: number): Vector4;
  68782. /**
  68783. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68784. * @param scale the number to scale with
  68785. * @param result a vector to store the result in
  68786. * @returns the current Vector4.
  68787. */
  68788. scaleToRef(scale: number, result: Vector4): Vector4;
  68789. /**
  68790. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68791. * @param scale defines the scale factor
  68792. * @param result defines the Vector4 object where to store the result
  68793. * @returns the unmodified current Vector4
  68794. */
  68795. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68796. /**
  68797. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68798. * @param otherVector the vector to compare against
  68799. * @returns true if they are equal
  68800. */
  68801. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68802. /**
  68803. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68804. * @param otherVector vector to compare against
  68805. * @param epsilon (Default: very small number)
  68806. * @returns true if they are equal
  68807. */
  68808. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68809. /**
  68810. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68811. * @param x x value to compare against
  68812. * @param y y value to compare against
  68813. * @param z z value to compare against
  68814. * @param w w value to compare against
  68815. * @returns true if equal
  68816. */
  68817. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68818. /**
  68819. * Multiplies in place the current Vector4 by the given one.
  68820. * @param otherVector vector to multiple with
  68821. * @returns the updated Vector4.
  68822. */
  68823. multiplyInPlace(otherVector: Vector4): Vector4;
  68824. /**
  68825. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68826. * @param otherVector vector to multiple with
  68827. * @returns resulting new vector
  68828. */
  68829. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68830. /**
  68831. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68832. * @param otherVector vector to multiple with
  68833. * @param result vector to store the result
  68834. * @returns the current Vector4.
  68835. */
  68836. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68837. /**
  68838. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68839. * @param x x value multiply with
  68840. * @param y y value multiply with
  68841. * @param z z value multiply with
  68842. * @param w w value multiply with
  68843. * @returns resulting new vector
  68844. */
  68845. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68846. /**
  68847. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68848. * @param otherVector vector to devide with
  68849. * @returns resulting new vector
  68850. */
  68851. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68852. /**
  68853. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68854. * @param otherVector vector to devide with
  68855. * @param result vector to store the result
  68856. * @returns the current Vector4.
  68857. */
  68858. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68859. /**
  68860. * Divides the current Vector3 coordinates by the given ones.
  68861. * @param otherVector vector to devide with
  68862. * @returns the updated Vector3.
  68863. */
  68864. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68865. /**
  68866. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68867. * @param other defines the second operand
  68868. * @returns the current updated Vector4
  68869. */
  68870. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68871. /**
  68872. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68873. * @param other defines the second operand
  68874. * @returns the current updated Vector4
  68875. */
  68876. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68877. /**
  68878. * Gets a new Vector4 from current Vector4 floored values
  68879. * @returns a new Vector4
  68880. */
  68881. floor(): Vector4;
  68882. /**
  68883. * Gets a new Vector4 from current Vector3 floored values
  68884. * @returns a new Vector4
  68885. */
  68886. fract(): Vector4;
  68887. /**
  68888. * Returns the Vector4 length (float).
  68889. * @returns the length
  68890. */
  68891. length(): number;
  68892. /**
  68893. * Returns the Vector4 squared length (float).
  68894. * @returns the length squared
  68895. */
  68896. lengthSquared(): number;
  68897. /**
  68898. * Normalizes in place the Vector4.
  68899. * @returns the updated Vector4.
  68900. */
  68901. normalize(): Vector4;
  68902. /**
  68903. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68904. * @returns this converted to a new vector3
  68905. */
  68906. toVector3(): Vector3;
  68907. /**
  68908. * Returns a new Vector4 copied from the current one.
  68909. * @returns the new cloned vector
  68910. */
  68911. clone(): Vector4;
  68912. /**
  68913. * Updates the current Vector4 with the given one coordinates.
  68914. * @param source the source vector to copy from
  68915. * @returns the updated Vector4.
  68916. */
  68917. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68918. /**
  68919. * Updates the current Vector4 coordinates with the given floats.
  68920. * @param x float to copy from
  68921. * @param y float to copy from
  68922. * @param z float to copy from
  68923. * @param w float to copy from
  68924. * @returns the updated Vector4.
  68925. */
  68926. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68927. /**
  68928. * Updates the current Vector4 coordinates with the given floats.
  68929. * @param x float to set from
  68930. * @param y float to set from
  68931. * @param z float to set from
  68932. * @param w float to set from
  68933. * @returns the updated Vector4.
  68934. */
  68935. set(x: number, y: number, z: number, w: number): Vector4;
  68936. /**
  68937. * Copies the given float to the current Vector3 coordinates
  68938. * @param v defines the x, y, z and w coordinates of the operand
  68939. * @returns the current updated Vector3
  68940. */
  68941. setAll(v: number): Vector4;
  68942. /**
  68943. * Returns a new Vector4 set from the starting index of the given array.
  68944. * @param array the array to pull values from
  68945. * @param offset the offset into the array to start at
  68946. * @returns the new vector
  68947. */
  68948. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68949. /**
  68950. * Updates the given vector "result" from the starting index of the given array.
  68951. * @param array the array to pull values from
  68952. * @param offset the offset into the array to start at
  68953. * @param result the vector to store the result in
  68954. */
  68955. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68956. /**
  68957. * Updates the given vector "result" from the starting index of the given Float32Array.
  68958. * @param array the array to pull values from
  68959. * @param offset the offset into the array to start at
  68960. * @param result the vector to store the result in
  68961. */
  68962. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68963. /**
  68964. * Updates the given vector "result" coordinates from the given floats.
  68965. * @param x float to set from
  68966. * @param y float to set from
  68967. * @param z float to set from
  68968. * @param w float to set from
  68969. * @param result the vector to the floats in
  68970. */
  68971. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68972. /**
  68973. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68974. * @returns the new vector
  68975. */
  68976. static Zero(): Vector4;
  68977. /**
  68978. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68979. * @returns the new vector
  68980. */
  68981. static One(): Vector4;
  68982. /**
  68983. * Returns a new normalized Vector4 from the given one.
  68984. * @param vector the vector to normalize
  68985. * @returns the vector
  68986. */
  68987. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68988. /**
  68989. * Updates the given vector "result" from the normalization of the given one.
  68990. * @param vector the vector to normalize
  68991. * @param result the vector to store the result in
  68992. */
  68993. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68994. /**
  68995. * Returns a vector with the minimum values from the left and right vectors
  68996. * @param left left vector to minimize
  68997. * @param right right vector to minimize
  68998. * @returns a new vector with the minimum of the left and right vector values
  68999. */
  69000. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69001. /**
  69002. * Returns a vector with the maximum values from the left and right vectors
  69003. * @param left left vector to maximize
  69004. * @param right right vector to maximize
  69005. * @returns a new vector with the maximum of the left and right vector values
  69006. */
  69007. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69008. /**
  69009. * Returns the distance (float) between the vectors "value1" and "value2".
  69010. * @param value1 value to calulate the distance between
  69011. * @param value2 value to calulate the distance between
  69012. * @return the distance between the two vectors
  69013. */
  69014. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69015. /**
  69016. * Returns the squared distance (float) between the vectors "value1" and "value2".
  69017. * @param value1 value to calulate the distance between
  69018. * @param value2 value to calulate the distance between
  69019. * @return the distance between the two vectors squared
  69020. */
  69021. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69022. /**
  69023. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  69024. * @param value1 value to calulate the center between
  69025. * @param value2 value to calulate the center between
  69026. * @return the center between the two vectors
  69027. */
  69028. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  69029. /**
  69030. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  69031. * This methods computes transformed normalized direction vectors only.
  69032. * @param vector the vector to transform
  69033. * @param transformation the transformation matrix to apply
  69034. * @returns the new vector
  69035. */
  69036. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  69037. /**
  69038. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  69039. * This methods computes transformed normalized direction vectors only.
  69040. * @param vector the vector to transform
  69041. * @param transformation the transformation matrix to apply
  69042. * @param result the vector to store the result in
  69043. */
  69044. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69045. /**
  69046. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  69047. * This methods computes transformed normalized direction vectors only.
  69048. * @param x value to transform
  69049. * @param y value to transform
  69050. * @param z value to transform
  69051. * @param w value to transform
  69052. * @param transformation the transformation matrix to apply
  69053. * @param result the vector to store the results in
  69054. */
  69055. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69056. /**
  69057. * Creates a new Vector4 from a Vector3
  69058. * @param source defines the source data
  69059. * @param w defines the 4th component (default is 0)
  69060. * @returns a new Vector4
  69061. */
  69062. static FromVector3(source: Vector3, w?: number): Vector4;
  69063. }
  69064. /**
  69065. * Class used to store quaternion data
  69066. * @see https://en.wikipedia.org/wiki/Quaternion
  69067. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  69068. */
  69069. export class Quaternion {
  69070. /** defines the first component (0 by default) */
  69071. x: number;
  69072. /** defines the second component (0 by default) */
  69073. y: number;
  69074. /** defines the third component (0 by default) */
  69075. z: number;
  69076. /** defines the fourth component (1.0 by default) */
  69077. w: number;
  69078. /**
  69079. * Creates a new Quaternion from the given floats
  69080. * @param x defines the first component (0 by default)
  69081. * @param y defines the second component (0 by default)
  69082. * @param z defines the third component (0 by default)
  69083. * @param w defines the fourth component (1.0 by default)
  69084. */
  69085. constructor(
  69086. /** defines the first component (0 by default) */
  69087. x?: number,
  69088. /** defines the second component (0 by default) */
  69089. y?: number,
  69090. /** defines the third component (0 by default) */
  69091. z?: number,
  69092. /** defines the fourth component (1.0 by default) */
  69093. w?: number);
  69094. /**
  69095. * Gets a string representation for the current quaternion
  69096. * @returns a string with the Quaternion coordinates
  69097. */
  69098. toString(): string;
  69099. /**
  69100. * Gets the class name of the quaternion
  69101. * @returns the string "Quaternion"
  69102. */
  69103. getClassName(): string;
  69104. /**
  69105. * Gets a hash code for this quaternion
  69106. * @returns the quaternion hash code
  69107. */
  69108. getHashCode(): number;
  69109. /**
  69110. * Copy the quaternion to an array
  69111. * @returns a new array populated with 4 elements from the quaternion coordinates
  69112. */
  69113. asArray(): number[];
  69114. /**
  69115. * Check if two quaternions are equals
  69116. * @param otherQuaternion defines the second operand
  69117. * @return true if the current quaternion and the given one coordinates are strictly equals
  69118. */
  69119. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  69120. /**
  69121. * Clone the current quaternion
  69122. * @returns a new quaternion copied from the current one
  69123. */
  69124. clone(): Quaternion;
  69125. /**
  69126. * Copy a quaternion to the current one
  69127. * @param other defines the other quaternion
  69128. * @returns the updated current quaternion
  69129. */
  69130. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  69131. /**
  69132. * Updates the current quaternion with the given float coordinates
  69133. * @param x defines the x coordinate
  69134. * @param y defines the y coordinate
  69135. * @param z defines the z coordinate
  69136. * @param w defines the w coordinate
  69137. * @returns the updated current quaternion
  69138. */
  69139. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  69140. /**
  69141. * Updates the current quaternion from the given float coordinates
  69142. * @param x defines the x coordinate
  69143. * @param y defines the y coordinate
  69144. * @param z defines the z coordinate
  69145. * @param w defines the w coordinate
  69146. * @returns the updated current quaternion
  69147. */
  69148. set(x: number, y: number, z: number, w: number): Quaternion;
  69149. /**
  69150. * Adds two quaternions
  69151. * @param other defines the second operand
  69152. * @returns a new quaternion as the addition result of the given one and the current quaternion
  69153. */
  69154. add(other: DeepImmutable<Quaternion>): Quaternion;
  69155. /**
  69156. * Add a quaternion to the current one
  69157. * @param other defines the quaternion to add
  69158. * @returns the current quaternion
  69159. */
  69160. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  69161. /**
  69162. * Subtract two quaternions
  69163. * @param other defines the second operand
  69164. * @returns a new quaternion as the subtraction result of the given one from the current one
  69165. */
  69166. subtract(other: Quaternion): Quaternion;
  69167. /**
  69168. * Multiplies the current quaternion by a scale factor
  69169. * @param value defines the scale factor
  69170. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  69171. */
  69172. scale(value: number): Quaternion;
  69173. /**
  69174. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  69175. * @param scale defines the scale factor
  69176. * @param result defines the Quaternion object where to store the result
  69177. * @returns the unmodified current quaternion
  69178. */
  69179. scaleToRef(scale: number, result: Quaternion): Quaternion;
  69180. /**
  69181. * Multiplies in place the current quaternion by a scale factor
  69182. * @param value defines the scale factor
  69183. * @returns the current modified quaternion
  69184. */
  69185. scaleInPlace(value: number): Quaternion;
  69186. /**
  69187. * Scale the current quaternion values by a factor and add the result to a given quaternion
  69188. * @param scale defines the scale factor
  69189. * @param result defines the Quaternion object where to store the result
  69190. * @returns the unmodified current quaternion
  69191. */
  69192. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  69193. /**
  69194. * Multiplies two quaternions
  69195. * @param q1 defines the second operand
  69196. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  69197. */
  69198. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  69199. /**
  69200. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  69201. * @param q1 defines the second operand
  69202. * @param result defines the target quaternion
  69203. * @returns the current quaternion
  69204. */
  69205. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  69206. /**
  69207. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  69208. * @param q1 defines the second operand
  69209. * @returns the currentupdated quaternion
  69210. */
  69211. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  69212. /**
  69213. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  69214. * @param ref defines the target quaternion
  69215. * @returns the current quaternion
  69216. */
  69217. conjugateToRef(ref: Quaternion): Quaternion;
  69218. /**
  69219. * Conjugates in place (1-q) the current quaternion
  69220. * @returns the current updated quaternion
  69221. */
  69222. conjugateInPlace(): Quaternion;
  69223. /**
  69224. * Conjugates in place (1-q) the current quaternion
  69225. * @returns a new quaternion
  69226. */
  69227. conjugate(): Quaternion;
  69228. /**
  69229. * Gets length of current quaternion
  69230. * @returns the quaternion length (float)
  69231. */
  69232. length(): number;
  69233. /**
  69234. * Normalize in place the current quaternion
  69235. * @returns the current updated quaternion
  69236. */
  69237. normalize(): Quaternion;
  69238. /**
  69239. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  69240. * @param order is a reserved parameter and is ignore for now
  69241. * @returns a new Vector3 containing the Euler angles
  69242. */
  69243. toEulerAngles(order?: string): Vector3;
  69244. /**
  69245. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  69246. * @param result defines the vector which will be filled with the Euler angles
  69247. * @param order is a reserved parameter and is ignore for now
  69248. * @returns the current unchanged quaternion
  69249. */
  69250. toEulerAnglesToRef(result: Vector3): Quaternion;
  69251. /**
  69252. * Updates the given rotation matrix with the current quaternion values
  69253. * @param result defines the target matrix
  69254. * @returns the current unchanged quaternion
  69255. */
  69256. toRotationMatrix(result: Matrix): Quaternion;
  69257. /**
  69258. * Updates the current quaternion from the given rotation matrix values
  69259. * @param matrix defines the source matrix
  69260. * @returns the current updated quaternion
  69261. */
  69262. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69263. /**
  69264. * Creates a new quaternion from a rotation matrix
  69265. * @param matrix defines the source matrix
  69266. * @returns a new quaternion created from the given rotation matrix values
  69267. */
  69268. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69269. /**
  69270. * Updates the given quaternion with the given rotation matrix values
  69271. * @param matrix defines the source matrix
  69272. * @param result defines the target quaternion
  69273. */
  69274. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69275. /**
  69276. * Returns the dot product (float) between the quaternions "left" and "right"
  69277. * @param left defines the left operand
  69278. * @param right defines the right operand
  69279. * @returns the dot product
  69280. */
  69281. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69282. /**
  69283. * Checks if the two quaternions are close to each other
  69284. * @param quat0 defines the first quaternion to check
  69285. * @param quat1 defines the second quaternion to check
  69286. * @returns true if the two quaternions are close to each other
  69287. */
  69288. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69289. /**
  69290. * Creates an empty quaternion
  69291. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69292. */
  69293. static Zero(): Quaternion;
  69294. /**
  69295. * Inverse a given quaternion
  69296. * @param q defines the source quaternion
  69297. * @returns a new quaternion as the inverted current quaternion
  69298. */
  69299. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69300. /**
  69301. * Inverse a given quaternion
  69302. * @param q defines the source quaternion
  69303. * @param result the quaternion the result will be stored in
  69304. * @returns the result quaternion
  69305. */
  69306. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69307. /**
  69308. * Creates an identity quaternion
  69309. * @returns the identity quaternion
  69310. */
  69311. static Identity(): Quaternion;
  69312. /**
  69313. * Gets a boolean indicating if the given quaternion is identity
  69314. * @param quaternion defines the quaternion to check
  69315. * @returns true if the quaternion is identity
  69316. */
  69317. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69318. /**
  69319. * Creates a quaternion from a rotation around an axis
  69320. * @param axis defines the axis to use
  69321. * @param angle defines the angle to use
  69322. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69323. */
  69324. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69325. /**
  69326. * Creates a rotation around an axis and stores it into the given quaternion
  69327. * @param axis defines the axis to use
  69328. * @param angle defines the angle to use
  69329. * @param result defines the target quaternion
  69330. * @returns the target quaternion
  69331. */
  69332. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69333. /**
  69334. * Creates a new quaternion from data stored into an array
  69335. * @param array defines the data source
  69336. * @param offset defines the offset in the source array where the data starts
  69337. * @returns a new quaternion
  69338. */
  69339. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69340. /**
  69341. * Create a quaternion from Euler rotation angles
  69342. * @param x Pitch
  69343. * @param y Yaw
  69344. * @param z Roll
  69345. * @returns the new Quaternion
  69346. */
  69347. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69348. /**
  69349. * Updates a quaternion from Euler rotation angles
  69350. * @param x Pitch
  69351. * @param y Yaw
  69352. * @param z Roll
  69353. * @param result the quaternion to store the result
  69354. * @returns the updated quaternion
  69355. */
  69356. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69357. /**
  69358. * Create a quaternion from Euler rotation vector
  69359. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69360. * @returns the new Quaternion
  69361. */
  69362. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69363. /**
  69364. * Updates a quaternion from Euler rotation vector
  69365. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69366. * @param result the quaternion to store the result
  69367. * @returns the updated quaternion
  69368. */
  69369. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69370. /**
  69371. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69372. * @param yaw defines the rotation around Y axis
  69373. * @param pitch defines the rotation around X axis
  69374. * @param roll defines the rotation around Z axis
  69375. * @returns the new quaternion
  69376. */
  69377. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69378. /**
  69379. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69380. * @param yaw defines the rotation around Y axis
  69381. * @param pitch defines the rotation around X axis
  69382. * @param roll defines the rotation around Z axis
  69383. * @param result defines the target quaternion
  69384. */
  69385. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69386. /**
  69387. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69388. * @param alpha defines the rotation around first axis
  69389. * @param beta defines the rotation around second axis
  69390. * @param gamma defines the rotation around third axis
  69391. * @returns the new quaternion
  69392. */
  69393. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69394. /**
  69395. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69396. * @param alpha defines the rotation around first axis
  69397. * @param beta defines the rotation around second axis
  69398. * @param gamma defines the rotation around third axis
  69399. * @param result defines the target quaternion
  69400. */
  69401. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69402. /**
  69403. * 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)
  69404. * @param axis1 defines the first axis
  69405. * @param axis2 defines the second axis
  69406. * @param axis3 defines the third axis
  69407. * @returns the new quaternion
  69408. */
  69409. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69410. /**
  69411. * 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
  69412. * @param axis1 defines the first axis
  69413. * @param axis2 defines the second axis
  69414. * @param axis3 defines the third axis
  69415. * @param ref defines the target quaternion
  69416. */
  69417. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69418. /**
  69419. * Interpolates between two quaternions
  69420. * @param left defines first quaternion
  69421. * @param right defines second quaternion
  69422. * @param amount defines the gradient to use
  69423. * @returns the new interpolated quaternion
  69424. */
  69425. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69426. /**
  69427. * Interpolates between two quaternions and stores it into a target quaternion
  69428. * @param left defines first quaternion
  69429. * @param right defines second quaternion
  69430. * @param amount defines the gradient to use
  69431. * @param result defines the target quaternion
  69432. */
  69433. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69434. /**
  69435. * Interpolate between two quaternions using Hermite interpolation
  69436. * @param value1 defines first quaternion
  69437. * @param tangent1 defines the incoming tangent
  69438. * @param value2 defines second quaternion
  69439. * @param tangent2 defines the outgoing tangent
  69440. * @param amount defines the target quaternion
  69441. * @returns the new interpolated quaternion
  69442. */
  69443. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69444. }
  69445. /**
  69446. * Class used to store matrix data (4x4)
  69447. */
  69448. export class Matrix {
  69449. private static _updateFlagSeed;
  69450. private static _identityReadOnly;
  69451. private _isIdentity;
  69452. private _isIdentityDirty;
  69453. private _isIdentity3x2;
  69454. private _isIdentity3x2Dirty;
  69455. /**
  69456. * Gets the update flag of the matrix which is an unique number for the matrix.
  69457. * It will be incremented every time the matrix data change.
  69458. * You can use it to speed the comparison between two versions of the same matrix.
  69459. */
  69460. updateFlag: number;
  69461. private readonly _m;
  69462. /**
  69463. * Gets the internal data of the matrix
  69464. */
  69465. readonly m: DeepImmutable<Float32Array>;
  69466. /** @hidden */
  69467. _markAsUpdated(): void;
  69468. /** @hidden */
  69469. private _updateIdentityStatus;
  69470. /**
  69471. * Creates an empty matrix (filled with zeros)
  69472. */
  69473. constructor();
  69474. /**
  69475. * Check if the current matrix is identity
  69476. * @returns true is the matrix is the identity matrix
  69477. */
  69478. isIdentity(): boolean;
  69479. /**
  69480. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69481. * @returns true is the matrix is the identity matrix
  69482. */
  69483. isIdentityAs3x2(): boolean;
  69484. /**
  69485. * Gets the determinant of the matrix
  69486. * @returns the matrix determinant
  69487. */
  69488. determinant(): number;
  69489. /**
  69490. * Returns the matrix as a Float32Array
  69491. * @returns the matrix underlying array
  69492. */
  69493. toArray(): DeepImmutable<Float32Array>;
  69494. /**
  69495. * Returns the matrix as a Float32Array
  69496. * @returns the matrix underlying array.
  69497. */
  69498. asArray(): DeepImmutable<Float32Array>;
  69499. /**
  69500. * Inverts the current matrix in place
  69501. * @returns the current inverted matrix
  69502. */
  69503. invert(): Matrix;
  69504. /**
  69505. * Sets all the matrix elements to zero
  69506. * @returns the current matrix
  69507. */
  69508. reset(): Matrix;
  69509. /**
  69510. * Adds the current matrix with a second one
  69511. * @param other defines the matrix to add
  69512. * @returns a new matrix as the addition of the current matrix and the given one
  69513. */
  69514. add(other: DeepImmutable<Matrix>): Matrix;
  69515. /**
  69516. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69517. * @param other defines the matrix to add
  69518. * @param result defines the target matrix
  69519. * @returns the current matrix
  69520. */
  69521. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69522. /**
  69523. * Adds in place the given matrix to the current matrix
  69524. * @param other defines the second operand
  69525. * @returns the current updated matrix
  69526. */
  69527. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69528. /**
  69529. * Sets the given matrix to the current inverted Matrix
  69530. * @param other defines the target matrix
  69531. * @returns the unmodified current matrix
  69532. */
  69533. invertToRef(other: Matrix): Matrix;
  69534. /**
  69535. * add a value at the specified position in the current Matrix
  69536. * @param index the index of the value within the matrix. between 0 and 15.
  69537. * @param value the value to be added
  69538. * @returns the current updated matrix
  69539. */
  69540. addAtIndex(index: number, value: number): Matrix;
  69541. /**
  69542. * mutiply the specified position in the current Matrix by a value
  69543. * @param index the index of the value within the matrix. between 0 and 15.
  69544. * @param value the value to be added
  69545. * @returns the current updated matrix
  69546. */
  69547. multiplyAtIndex(index: number, value: number): Matrix;
  69548. /**
  69549. * Inserts the translation vector (using 3 floats) in the current matrix
  69550. * @param x defines the 1st component of the translation
  69551. * @param y defines the 2nd component of the translation
  69552. * @param z defines the 3rd component of the translation
  69553. * @returns the current updated matrix
  69554. */
  69555. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69556. /**
  69557. * Adds the translation vector (using 3 floats) in the current matrix
  69558. * @param x defines the 1st component of the translation
  69559. * @param y defines the 2nd component of the translation
  69560. * @param z defines the 3rd component of the translation
  69561. * @returns the current updated matrix
  69562. */
  69563. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69564. /**
  69565. * Inserts the translation vector in the current matrix
  69566. * @param vector3 defines the translation to insert
  69567. * @returns the current updated matrix
  69568. */
  69569. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69570. /**
  69571. * Gets the translation value of the current matrix
  69572. * @returns a new Vector3 as the extracted translation from the matrix
  69573. */
  69574. getTranslation(): Vector3;
  69575. /**
  69576. * Fill a Vector3 with the extracted translation from the matrix
  69577. * @param result defines the Vector3 where to store the translation
  69578. * @returns the current matrix
  69579. */
  69580. getTranslationToRef(result: Vector3): Matrix;
  69581. /**
  69582. * Remove rotation and scaling part from the matrix
  69583. * @returns the updated matrix
  69584. */
  69585. removeRotationAndScaling(): Matrix;
  69586. /**
  69587. * Multiply two matrices
  69588. * @param other defines the second operand
  69589. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69590. */
  69591. multiply(other: DeepImmutable<Matrix>): Matrix;
  69592. /**
  69593. * Copy the current matrix from the given one
  69594. * @param other defines the source matrix
  69595. * @returns the current updated matrix
  69596. */
  69597. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69598. /**
  69599. * Populates the given array from the starting index with the current matrix values
  69600. * @param array defines the target array
  69601. * @param offset defines the offset in the target array where to start storing values
  69602. * @returns the current matrix
  69603. */
  69604. copyToArray(array: Float32Array, offset?: number): Matrix;
  69605. /**
  69606. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69607. * @param other defines the second operand
  69608. * @param result defines the matrix where to store the multiplication
  69609. * @returns the current matrix
  69610. */
  69611. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69612. /**
  69613. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69614. * @param other defines the second operand
  69615. * @param result defines the array where to store the multiplication
  69616. * @param offset defines the offset in the target array where to start storing values
  69617. * @returns the current matrix
  69618. */
  69619. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69620. /**
  69621. * Check equality between this matrix and a second one
  69622. * @param value defines the second matrix to compare
  69623. * @returns true is the current matrix and the given one values are strictly equal
  69624. */
  69625. equals(value: DeepImmutable<Matrix>): boolean;
  69626. /**
  69627. * Clone the current matrix
  69628. * @returns a new matrix from the current matrix
  69629. */
  69630. clone(): Matrix;
  69631. /**
  69632. * Returns the name of the current matrix class
  69633. * @returns the string "Matrix"
  69634. */
  69635. getClassName(): string;
  69636. /**
  69637. * Gets the hash code of the current matrix
  69638. * @returns the hash code
  69639. */
  69640. getHashCode(): number;
  69641. /**
  69642. * Decomposes the current Matrix into a translation, rotation and scaling components
  69643. * @param scale defines the scale vector3 given as a reference to update
  69644. * @param rotation defines the rotation quaternion given as a reference to update
  69645. * @param translation defines the translation vector3 given as a reference to update
  69646. * @returns true if operation was successful
  69647. */
  69648. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69649. /**
  69650. * Gets specific row of the matrix
  69651. * @param index defines the number of the row to get
  69652. * @returns the index-th row of the current matrix as a new Vector4
  69653. */
  69654. getRow(index: number): Nullable<Vector4>;
  69655. /**
  69656. * Sets the index-th row of the current matrix to the vector4 values
  69657. * @param index defines the number of the row to set
  69658. * @param row defines the target vector4
  69659. * @returns the updated current matrix
  69660. */
  69661. setRow(index: number, row: Vector4): Matrix;
  69662. /**
  69663. * Compute the transpose of the matrix
  69664. * @returns the new transposed matrix
  69665. */
  69666. transpose(): Matrix;
  69667. /**
  69668. * Compute the transpose of the matrix and store it in a given matrix
  69669. * @param result defines the target matrix
  69670. * @returns the current matrix
  69671. */
  69672. transposeToRef(result: Matrix): Matrix;
  69673. /**
  69674. * Sets the index-th row of the current matrix with the given 4 x float values
  69675. * @param index defines the row index
  69676. * @param x defines the x component to set
  69677. * @param y defines the y component to set
  69678. * @param z defines the z component to set
  69679. * @param w defines the w component to set
  69680. * @returns the updated current matrix
  69681. */
  69682. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69683. /**
  69684. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69685. * @param scale defines the scale factor
  69686. * @returns a new matrix
  69687. */
  69688. scale(scale: number): Matrix;
  69689. /**
  69690. * Scale the current matrix values by a factor to a given result matrix
  69691. * @param scale defines the scale factor
  69692. * @param result defines the matrix to store the result
  69693. * @returns the current matrix
  69694. */
  69695. scaleToRef(scale: number, result: Matrix): Matrix;
  69696. /**
  69697. * Scale the current matrix values by a factor and add the result to a given matrix
  69698. * @param scale defines the scale factor
  69699. * @param result defines the Matrix to store the result
  69700. * @returns the current matrix
  69701. */
  69702. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69703. /**
  69704. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69705. * @param ref matrix to store the result
  69706. */
  69707. toNormalMatrix(ref: Matrix): void;
  69708. /**
  69709. * Gets only rotation part of the current matrix
  69710. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69711. */
  69712. getRotationMatrix(): Matrix;
  69713. /**
  69714. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69715. * @param result defines the target matrix to store data to
  69716. * @returns the current matrix
  69717. */
  69718. getRotationMatrixToRef(result: Matrix): Matrix;
  69719. /**
  69720. * Toggles model matrix from being right handed to left handed in place and vice versa
  69721. */
  69722. toggleModelMatrixHandInPlace(): void;
  69723. /**
  69724. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69725. */
  69726. toggleProjectionMatrixHandInPlace(): void;
  69727. /**
  69728. * Creates a matrix from an array
  69729. * @param array defines the source array
  69730. * @param offset defines an offset in the source array
  69731. * @returns a new Matrix set from the starting index of the given array
  69732. */
  69733. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69734. /**
  69735. * Copy the content of an array into a given matrix
  69736. * @param array defines the source array
  69737. * @param offset defines an offset in the source array
  69738. * @param result defines the target matrix
  69739. */
  69740. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69741. /**
  69742. * Stores an array into a matrix after having multiplied each component by a given factor
  69743. * @param array defines the source array
  69744. * @param offset defines the offset in the source array
  69745. * @param scale defines the scaling factor
  69746. * @param result defines the target matrix
  69747. */
  69748. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69749. /**
  69750. * Gets an identity matrix that must not be updated
  69751. */
  69752. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69753. /**
  69754. * Stores a list of values (16) inside a given matrix
  69755. * @param initialM11 defines 1st value of 1st row
  69756. * @param initialM12 defines 2nd value of 1st row
  69757. * @param initialM13 defines 3rd value of 1st row
  69758. * @param initialM14 defines 4th value of 1st row
  69759. * @param initialM21 defines 1st value of 2nd row
  69760. * @param initialM22 defines 2nd value of 2nd row
  69761. * @param initialM23 defines 3rd value of 2nd row
  69762. * @param initialM24 defines 4th value of 2nd row
  69763. * @param initialM31 defines 1st value of 3rd row
  69764. * @param initialM32 defines 2nd value of 3rd row
  69765. * @param initialM33 defines 3rd value of 3rd row
  69766. * @param initialM34 defines 4th value of 3rd row
  69767. * @param initialM41 defines 1st value of 4th row
  69768. * @param initialM42 defines 2nd value of 4th row
  69769. * @param initialM43 defines 3rd value of 4th row
  69770. * @param initialM44 defines 4th value of 4th row
  69771. * @param result defines the target matrix
  69772. */
  69773. 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;
  69774. /**
  69775. * Creates new matrix from a list of values (16)
  69776. * @param initialM11 defines 1st value of 1st row
  69777. * @param initialM12 defines 2nd value of 1st row
  69778. * @param initialM13 defines 3rd value of 1st row
  69779. * @param initialM14 defines 4th value of 1st row
  69780. * @param initialM21 defines 1st value of 2nd row
  69781. * @param initialM22 defines 2nd value of 2nd row
  69782. * @param initialM23 defines 3rd value of 2nd row
  69783. * @param initialM24 defines 4th value of 2nd row
  69784. * @param initialM31 defines 1st value of 3rd row
  69785. * @param initialM32 defines 2nd value of 3rd row
  69786. * @param initialM33 defines 3rd value of 3rd row
  69787. * @param initialM34 defines 4th value of 3rd row
  69788. * @param initialM41 defines 1st value of 4th row
  69789. * @param initialM42 defines 2nd value of 4th row
  69790. * @param initialM43 defines 3rd value of 4th row
  69791. * @param initialM44 defines 4th value of 4th row
  69792. * @returns the new matrix
  69793. */
  69794. 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;
  69795. /**
  69796. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69797. * @param scale defines the scale vector3
  69798. * @param rotation defines the rotation quaternion
  69799. * @param translation defines the translation vector3
  69800. * @returns a new matrix
  69801. */
  69802. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69803. /**
  69804. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69805. * @param scale defines the scale vector3
  69806. * @param rotation defines the rotation quaternion
  69807. * @param translation defines the translation vector3
  69808. * @param result defines the target matrix
  69809. */
  69810. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69811. /**
  69812. * Creates a new identity matrix
  69813. * @returns a new identity matrix
  69814. */
  69815. static Identity(): Matrix;
  69816. /**
  69817. * Creates a new identity matrix and stores the result in a given matrix
  69818. * @param result defines the target matrix
  69819. */
  69820. static IdentityToRef(result: Matrix): void;
  69821. /**
  69822. * Creates a new zero matrix
  69823. * @returns a new zero matrix
  69824. */
  69825. static Zero(): Matrix;
  69826. /**
  69827. * Creates a new rotation matrix for "angle" radians around the X axis
  69828. * @param angle defines the angle (in radians) to use
  69829. * @return the new matrix
  69830. */
  69831. static RotationX(angle: number): Matrix;
  69832. /**
  69833. * Creates a new matrix as the invert of a given matrix
  69834. * @param source defines the source matrix
  69835. * @returns the new matrix
  69836. */
  69837. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69838. /**
  69839. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69840. * @param angle defines the angle (in radians) to use
  69841. * @param result defines the target matrix
  69842. */
  69843. static RotationXToRef(angle: number, result: Matrix): void;
  69844. /**
  69845. * Creates a new rotation matrix for "angle" radians around the Y axis
  69846. * @param angle defines the angle (in radians) to use
  69847. * @return the new matrix
  69848. */
  69849. static RotationY(angle: number): Matrix;
  69850. /**
  69851. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69852. * @param angle defines the angle (in radians) to use
  69853. * @param result defines the target matrix
  69854. */
  69855. static RotationYToRef(angle: number, result: Matrix): void;
  69856. /**
  69857. * Creates a new rotation matrix for "angle" radians around the Z axis
  69858. * @param angle defines the angle (in radians) to use
  69859. * @return the new matrix
  69860. */
  69861. static RotationZ(angle: number): Matrix;
  69862. /**
  69863. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69864. * @param angle defines the angle (in radians) to use
  69865. * @param result defines the target matrix
  69866. */
  69867. static RotationZToRef(angle: number, result: Matrix): void;
  69868. /**
  69869. * Creates a new rotation matrix for "angle" radians around the given axis
  69870. * @param axis defines the axis to use
  69871. * @param angle defines the angle (in radians) to use
  69872. * @return the new matrix
  69873. */
  69874. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69875. /**
  69876. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69877. * @param axis defines the axis to use
  69878. * @param angle defines the angle (in radians) to use
  69879. * @param result defines the target matrix
  69880. */
  69881. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69882. /**
  69883. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69884. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69885. * @param from defines the vector to align
  69886. * @param to defines the vector to align to
  69887. * @param result defines the target matrix
  69888. */
  69889. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69890. /**
  69891. * Creates a rotation matrix
  69892. * @param yaw defines the yaw angle in radians (Y axis)
  69893. * @param pitch defines the pitch angle in radians (X axis)
  69894. * @param roll defines the roll angle in radians (X axis)
  69895. * @returns the new rotation matrix
  69896. */
  69897. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69898. /**
  69899. * Creates a rotation matrix and stores it in a given matrix
  69900. * @param yaw defines the yaw angle in radians (Y axis)
  69901. * @param pitch defines the pitch angle in radians (X axis)
  69902. * @param roll defines the roll angle in radians (X axis)
  69903. * @param result defines the target matrix
  69904. */
  69905. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69906. /**
  69907. * Creates a scaling matrix
  69908. * @param x defines the scale factor on X axis
  69909. * @param y defines the scale factor on Y axis
  69910. * @param z defines the scale factor on Z axis
  69911. * @returns the new matrix
  69912. */
  69913. static Scaling(x: number, y: number, z: number): Matrix;
  69914. /**
  69915. * Creates a scaling matrix and stores it in a given matrix
  69916. * @param x defines the scale factor on X axis
  69917. * @param y defines the scale factor on Y axis
  69918. * @param z defines the scale factor on Z axis
  69919. * @param result defines the target matrix
  69920. */
  69921. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69922. /**
  69923. * Creates a translation matrix
  69924. * @param x defines the translation on X axis
  69925. * @param y defines the translation on Y axis
  69926. * @param z defines the translationon Z axis
  69927. * @returns the new matrix
  69928. */
  69929. static Translation(x: number, y: number, z: number): Matrix;
  69930. /**
  69931. * Creates a translation matrix and stores it in a given matrix
  69932. * @param x defines the translation on X axis
  69933. * @param y defines the translation on Y axis
  69934. * @param z defines the translationon Z axis
  69935. * @param result defines the target matrix
  69936. */
  69937. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69938. /**
  69939. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69940. * @param startValue defines the start value
  69941. * @param endValue defines the end value
  69942. * @param gradient defines the gradient factor
  69943. * @returns the new matrix
  69944. */
  69945. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69946. /**
  69947. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69948. * @param startValue defines the start value
  69949. * @param endValue defines the end value
  69950. * @param gradient defines the gradient factor
  69951. * @param result defines the Matrix object where to store data
  69952. */
  69953. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69954. /**
  69955. * Builds a new matrix whose values are computed by:
  69956. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69957. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69958. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69959. * @param startValue defines the first matrix
  69960. * @param endValue defines the second matrix
  69961. * @param gradient defines the gradient between the two matrices
  69962. * @returns the new matrix
  69963. */
  69964. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69965. /**
  69966. * Update a matrix to values which are computed by:
  69967. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69968. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69969. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69970. * @param startValue defines the first matrix
  69971. * @param endValue defines the second matrix
  69972. * @param gradient defines the gradient between the two matrices
  69973. * @param result defines the target matrix
  69974. */
  69975. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69976. /**
  69977. * 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"
  69978. * This function works in left handed mode
  69979. * @param eye defines the final position of the entity
  69980. * @param target defines where the entity should look at
  69981. * @param up defines the up vector for the entity
  69982. * @returns the new matrix
  69983. */
  69984. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69985. /**
  69986. * 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".
  69987. * This function works in left handed mode
  69988. * @param eye defines the final position of the entity
  69989. * @param target defines where the entity should look at
  69990. * @param up defines the up vector for the entity
  69991. * @param result defines the target matrix
  69992. */
  69993. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69994. /**
  69995. * 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"
  69996. * This function works in right handed mode
  69997. * @param eye defines the final position of the entity
  69998. * @param target defines where the entity should look at
  69999. * @param up defines the up vector for the entity
  70000. * @returns the new matrix
  70001. */
  70002. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70003. /**
  70004. * 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".
  70005. * This function works in right handed mode
  70006. * @param eye defines the final position of the entity
  70007. * @param target defines where the entity should look at
  70008. * @param up defines the up vector for the entity
  70009. * @param result defines the target matrix
  70010. */
  70011. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70012. /**
  70013. * Create a left-handed orthographic projection matrix
  70014. * @param width defines the viewport width
  70015. * @param height defines the viewport height
  70016. * @param znear defines the near clip plane
  70017. * @param zfar defines the far clip plane
  70018. * @returns a new matrix as a left-handed orthographic projection matrix
  70019. */
  70020. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70021. /**
  70022. * Store a left-handed orthographic projection to a given matrix
  70023. * @param width defines the viewport width
  70024. * @param height defines the viewport height
  70025. * @param znear defines the near clip plane
  70026. * @param zfar defines the far clip plane
  70027. * @param result defines the target matrix
  70028. */
  70029. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  70030. /**
  70031. * Create a left-handed orthographic projection matrix
  70032. * @param left defines the viewport left coordinate
  70033. * @param right defines the viewport right coordinate
  70034. * @param bottom defines the viewport bottom coordinate
  70035. * @param top defines the viewport top coordinate
  70036. * @param znear defines the near clip plane
  70037. * @param zfar defines the far clip plane
  70038. * @returns a new matrix as a left-handed orthographic projection matrix
  70039. */
  70040. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70041. /**
  70042. * Stores a left-handed orthographic projection into a given matrix
  70043. * @param left defines the viewport left coordinate
  70044. * @param right defines the viewport right coordinate
  70045. * @param bottom defines the viewport bottom coordinate
  70046. * @param top defines the viewport top coordinate
  70047. * @param znear defines the near clip plane
  70048. * @param zfar defines the far clip plane
  70049. * @param result defines the target matrix
  70050. */
  70051. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70052. /**
  70053. * Creates a right-handed orthographic projection matrix
  70054. * @param left defines the viewport left coordinate
  70055. * @param right defines the viewport right coordinate
  70056. * @param bottom defines the viewport bottom coordinate
  70057. * @param top defines the viewport top coordinate
  70058. * @param znear defines the near clip plane
  70059. * @param zfar defines the far clip plane
  70060. * @returns a new matrix as a right-handed orthographic projection matrix
  70061. */
  70062. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70063. /**
  70064. * Stores a right-handed orthographic projection into a given matrix
  70065. * @param left defines the viewport left coordinate
  70066. * @param right defines the viewport right coordinate
  70067. * @param bottom defines the viewport bottom coordinate
  70068. * @param top defines the viewport top coordinate
  70069. * @param znear defines the near clip plane
  70070. * @param zfar defines the far clip plane
  70071. * @param result defines the target matrix
  70072. */
  70073. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70074. /**
  70075. * Creates a left-handed perspective projection matrix
  70076. * @param width defines the viewport width
  70077. * @param height defines the viewport height
  70078. * @param znear defines the near clip plane
  70079. * @param zfar defines the far clip plane
  70080. * @returns a new matrix as a left-handed perspective projection matrix
  70081. */
  70082. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70083. /**
  70084. * Creates a left-handed perspective projection matrix
  70085. * @param fov defines the horizontal field of view
  70086. * @param aspect defines the aspect ratio
  70087. * @param znear defines the near clip plane
  70088. * @param zfar defines the far clip plane
  70089. * @returns a new matrix as a left-handed perspective projection matrix
  70090. */
  70091. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70092. /**
  70093. * Stores a left-handed perspective projection into a given matrix
  70094. * @param fov defines the horizontal field of view
  70095. * @param aspect defines the aspect ratio
  70096. * @param znear defines the near clip plane
  70097. * @param zfar defines the far clip plane
  70098. * @param result defines the target matrix
  70099. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70100. */
  70101. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70102. /**
  70103. * Creates a right-handed perspective projection matrix
  70104. * @param fov defines the horizontal field of view
  70105. * @param aspect defines the aspect ratio
  70106. * @param znear defines the near clip plane
  70107. * @param zfar defines the far clip plane
  70108. * @returns a new matrix as a right-handed perspective projection matrix
  70109. */
  70110. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70111. /**
  70112. * Stores a right-handed perspective projection into a given matrix
  70113. * @param fov defines the horizontal field of view
  70114. * @param aspect defines the aspect ratio
  70115. * @param znear defines the near clip plane
  70116. * @param zfar defines the far clip plane
  70117. * @param result defines the target matrix
  70118. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70119. */
  70120. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70121. /**
  70122. * Stores a perspective projection for WebVR info a given matrix
  70123. * @param fov defines the field of view
  70124. * @param znear defines the near clip plane
  70125. * @param zfar defines the far clip plane
  70126. * @param result defines the target matrix
  70127. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  70128. */
  70129. static PerspectiveFovWebVRToRef(fov: {
  70130. upDegrees: number;
  70131. downDegrees: number;
  70132. leftDegrees: number;
  70133. rightDegrees: number;
  70134. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  70135. /**
  70136. * Computes a complete transformation matrix
  70137. * @param viewport defines the viewport to use
  70138. * @param world defines the world matrix
  70139. * @param view defines the view matrix
  70140. * @param projection defines the projection matrix
  70141. * @param zmin defines the near clip plane
  70142. * @param zmax defines the far clip plane
  70143. * @returns the transformation matrix
  70144. */
  70145. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  70146. /**
  70147. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  70148. * @param matrix defines the matrix to use
  70149. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  70150. */
  70151. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  70152. /**
  70153. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  70154. * @param matrix defines the matrix to use
  70155. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  70156. */
  70157. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  70158. /**
  70159. * Compute the transpose of a given matrix
  70160. * @param matrix defines the matrix to transpose
  70161. * @returns the new matrix
  70162. */
  70163. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  70164. /**
  70165. * Compute the transpose of a matrix and store it in a target matrix
  70166. * @param matrix defines the matrix to transpose
  70167. * @param result defines the target matrix
  70168. */
  70169. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  70170. /**
  70171. * Computes a reflection matrix from a plane
  70172. * @param plane defines the reflection plane
  70173. * @returns a new matrix
  70174. */
  70175. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  70176. /**
  70177. * Computes a reflection matrix from a plane
  70178. * @param plane defines the reflection plane
  70179. * @param result defines the target matrix
  70180. */
  70181. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  70182. /**
  70183. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  70184. * @param xaxis defines the value of the 1st axis
  70185. * @param yaxis defines the value of the 2nd axis
  70186. * @param zaxis defines the value of the 3rd axis
  70187. * @param result defines the target matrix
  70188. */
  70189. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  70190. /**
  70191. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  70192. * @param quat defines the quaternion to use
  70193. * @param result defines the target matrix
  70194. */
  70195. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  70196. }
  70197. /**
  70198. * @hidden
  70199. */
  70200. export class TmpVectors {
  70201. static Vector2: Vector2[];
  70202. static Vector3: Vector3[];
  70203. static Vector4: Vector4[];
  70204. static Quaternion: Quaternion[];
  70205. static Matrix: Matrix[];
  70206. }
  70207. }
  70208. declare module BABYLON {
  70209. /**
  70210. * Class used to hold a RBG color
  70211. */
  70212. export class Color3 {
  70213. /**
  70214. * Defines the red component (between 0 and 1, default is 0)
  70215. */
  70216. r: number;
  70217. /**
  70218. * Defines the green component (between 0 and 1, default is 0)
  70219. */
  70220. g: number;
  70221. /**
  70222. * Defines the blue component (between 0 and 1, default is 0)
  70223. */
  70224. b: number;
  70225. /**
  70226. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70227. * @param r defines the red component (between 0 and 1, default is 0)
  70228. * @param g defines the green component (between 0 and 1, default is 0)
  70229. * @param b defines the blue component (between 0 and 1, default is 0)
  70230. */
  70231. constructor(
  70232. /**
  70233. * Defines the red component (between 0 and 1, default is 0)
  70234. */
  70235. r?: number,
  70236. /**
  70237. * Defines the green component (between 0 and 1, default is 0)
  70238. */
  70239. g?: number,
  70240. /**
  70241. * Defines the blue component (between 0 and 1, default is 0)
  70242. */
  70243. b?: number);
  70244. /**
  70245. * Creates a string with the Color3 current values
  70246. * @returns the string representation of the Color3 object
  70247. */
  70248. toString(): string;
  70249. /**
  70250. * Returns the string "Color3"
  70251. * @returns "Color3"
  70252. */
  70253. getClassName(): string;
  70254. /**
  70255. * Compute the Color3 hash code
  70256. * @returns an unique number that can be used to hash Color3 objects
  70257. */
  70258. getHashCode(): number;
  70259. /**
  70260. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70261. * @param array defines the array where to store the r,g,b components
  70262. * @param index defines an optional index in the target array to define where to start storing values
  70263. * @returns the current Color3 object
  70264. */
  70265. toArray(array: FloatArray, index?: number): Color3;
  70266. /**
  70267. * Returns a new Color4 object from the current Color3 and the given alpha
  70268. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70269. * @returns a new Color4 object
  70270. */
  70271. toColor4(alpha?: number): Color4;
  70272. /**
  70273. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70274. * @returns the new array
  70275. */
  70276. asArray(): number[];
  70277. /**
  70278. * Returns the luminance value
  70279. * @returns a float value
  70280. */
  70281. toLuminance(): number;
  70282. /**
  70283. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70284. * @param otherColor defines the second operand
  70285. * @returns the new Color3 object
  70286. */
  70287. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70288. /**
  70289. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70290. * @param otherColor defines the second operand
  70291. * @param result defines the Color3 object where to store the result
  70292. * @returns the current Color3
  70293. */
  70294. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70295. /**
  70296. * Determines equality between Color3 objects
  70297. * @param otherColor defines the second operand
  70298. * @returns true if the rgb values are equal to the given ones
  70299. */
  70300. equals(otherColor: DeepImmutable<Color3>): boolean;
  70301. /**
  70302. * Determines equality between the current Color3 object and a set of r,b,g values
  70303. * @param r defines the red component to check
  70304. * @param g defines the green component to check
  70305. * @param b defines the blue component to check
  70306. * @returns true if the rgb values are equal to the given ones
  70307. */
  70308. equalsFloats(r: number, g: number, b: number): boolean;
  70309. /**
  70310. * Multiplies in place each rgb value by scale
  70311. * @param scale defines the scaling factor
  70312. * @returns the updated Color3
  70313. */
  70314. scale(scale: number): Color3;
  70315. /**
  70316. * Multiplies the rgb values by scale and stores the result into "result"
  70317. * @param scale defines the scaling factor
  70318. * @param result defines the Color3 object where to store the result
  70319. * @returns the unmodified current Color3
  70320. */
  70321. scaleToRef(scale: number, result: Color3): Color3;
  70322. /**
  70323. * Scale the current Color3 values by a factor and add the result to a given Color3
  70324. * @param scale defines the scale factor
  70325. * @param result defines color to store the result into
  70326. * @returns the unmodified current Color3
  70327. */
  70328. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70329. /**
  70330. * Clamps the rgb values by the min and max values and stores the result into "result"
  70331. * @param min defines minimum clamping value (default is 0)
  70332. * @param max defines maximum clamping value (default is 1)
  70333. * @param result defines color to store the result into
  70334. * @returns the original Color3
  70335. */
  70336. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70337. /**
  70338. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70339. * @param otherColor defines the second operand
  70340. * @returns the new Color3
  70341. */
  70342. add(otherColor: DeepImmutable<Color3>): Color3;
  70343. /**
  70344. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70345. * @param otherColor defines the second operand
  70346. * @param result defines Color3 object to store the result into
  70347. * @returns the unmodified current Color3
  70348. */
  70349. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70350. /**
  70351. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70352. * @param otherColor defines the second operand
  70353. * @returns the new Color3
  70354. */
  70355. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70356. /**
  70357. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70358. * @param otherColor defines the second operand
  70359. * @param result defines Color3 object to store the result into
  70360. * @returns the unmodified current Color3
  70361. */
  70362. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70363. /**
  70364. * Copy the current object
  70365. * @returns a new Color3 copied the current one
  70366. */
  70367. clone(): Color3;
  70368. /**
  70369. * Copies the rgb values from the source in the current Color3
  70370. * @param source defines the source Color3 object
  70371. * @returns the updated Color3 object
  70372. */
  70373. copyFrom(source: DeepImmutable<Color3>): Color3;
  70374. /**
  70375. * Updates the Color3 rgb values from the given floats
  70376. * @param r defines the red component to read from
  70377. * @param g defines the green component to read from
  70378. * @param b defines the blue component to read from
  70379. * @returns the current Color3 object
  70380. */
  70381. copyFromFloats(r: number, g: number, b: number): Color3;
  70382. /**
  70383. * Updates the Color3 rgb values from the given floats
  70384. * @param r defines the red component to read from
  70385. * @param g defines the green component to read from
  70386. * @param b defines the blue component to read from
  70387. * @returns the current Color3 object
  70388. */
  70389. set(r: number, g: number, b: number): Color3;
  70390. /**
  70391. * Compute the Color3 hexadecimal code as a string
  70392. * @returns a string containing the hexadecimal representation of the Color3 object
  70393. */
  70394. toHexString(): string;
  70395. /**
  70396. * Computes a new Color3 converted from the current one to linear space
  70397. * @returns a new Color3 object
  70398. */
  70399. toLinearSpace(): Color3;
  70400. /**
  70401. * Converts current color in rgb space to HSV values
  70402. * @returns a new color3 representing the HSV values
  70403. */
  70404. toHSV(): Color3;
  70405. /**
  70406. * Converts current color in rgb space to HSV values
  70407. * @param result defines the Color3 where to store the HSV values
  70408. */
  70409. toHSVToRef(result: Color3): void;
  70410. /**
  70411. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70412. * @param convertedColor defines the Color3 object where to store the linear space version
  70413. * @returns the unmodified Color3
  70414. */
  70415. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70416. /**
  70417. * Computes a new Color3 converted from the current one to gamma space
  70418. * @returns a new Color3 object
  70419. */
  70420. toGammaSpace(): Color3;
  70421. /**
  70422. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70423. * @param convertedColor defines the Color3 object where to store the gamma space version
  70424. * @returns the unmodified Color3
  70425. */
  70426. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70427. private static _BlackReadOnly;
  70428. /**
  70429. * Convert Hue, saturation and value to a Color3 (RGB)
  70430. * @param hue defines the hue
  70431. * @param saturation defines the saturation
  70432. * @param value defines the value
  70433. * @param result defines the Color3 where to store the RGB values
  70434. */
  70435. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70436. /**
  70437. * Creates a new Color3 from the string containing valid hexadecimal values
  70438. * @param hex defines a string containing valid hexadecimal values
  70439. * @returns a new Color3 object
  70440. */
  70441. static FromHexString(hex: string): Color3;
  70442. /**
  70443. * Creates a new Color3 from the starting index of the given array
  70444. * @param array defines the source array
  70445. * @param offset defines an offset in the source array
  70446. * @returns a new Color3 object
  70447. */
  70448. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70449. /**
  70450. * Creates a new Color3 from integer values (< 256)
  70451. * @param r defines the red component to read from (value between 0 and 255)
  70452. * @param g defines the green component to read from (value between 0 and 255)
  70453. * @param b defines the blue component to read from (value between 0 and 255)
  70454. * @returns a new Color3 object
  70455. */
  70456. static FromInts(r: number, g: number, b: number): Color3;
  70457. /**
  70458. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70459. * @param start defines the start Color3 value
  70460. * @param end defines the end Color3 value
  70461. * @param amount defines the gradient value between start and end
  70462. * @returns a new Color3 object
  70463. */
  70464. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70465. /**
  70466. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70467. * @param left defines the start value
  70468. * @param right defines the end value
  70469. * @param amount defines the gradient factor
  70470. * @param result defines the Color3 object where to store the result
  70471. */
  70472. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70473. /**
  70474. * Returns a Color3 value containing a red color
  70475. * @returns a new Color3 object
  70476. */
  70477. static Red(): Color3;
  70478. /**
  70479. * Returns a Color3 value containing a green color
  70480. * @returns a new Color3 object
  70481. */
  70482. static Green(): Color3;
  70483. /**
  70484. * Returns a Color3 value containing a blue color
  70485. * @returns a new Color3 object
  70486. */
  70487. static Blue(): Color3;
  70488. /**
  70489. * Returns a Color3 value containing a black color
  70490. * @returns a new Color3 object
  70491. */
  70492. static Black(): Color3;
  70493. /**
  70494. * Gets a Color3 value containing a black color that must not be updated
  70495. */
  70496. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70497. /**
  70498. * Returns a Color3 value containing a white color
  70499. * @returns a new Color3 object
  70500. */
  70501. static White(): Color3;
  70502. /**
  70503. * Returns a Color3 value containing a purple color
  70504. * @returns a new Color3 object
  70505. */
  70506. static Purple(): Color3;
  70507. /**
  70508. * Returns a Color3 value containing a magenta color
  70509. * @returns a new Color3 object
  70510. */
  70511. static Magenta(): Color3;
  70512. /**
  70513. * Returns a Color3 value containing a yellow color
  70514. * @returns a new Color3 object
  70515. */
  70516. static Yellow(): Color3;
  70517. /**
  70518. * Returns a Color3 value containing a gray color
  70519. * @returns a new Color3 object
  70520. */
  70521. static Gray(): Color3;
  70522. /**
  70523. * Returns a Color3 value containing a teal color
  70524. * @returns a new Color3 object
  70525. */
  70526. static Teal(): Color3;
  70527. /**
  70528. * Returns a Color3 value containing a random color
  70529. * @returns a new Color3 object
  70530. */
  70531. static Random(): Color3;
  70532. }
  70533. /**
  70534. * Class used to hold a RBGA color
  70535. */
  70536. export class Color4 {
  70537. /**
  70538. * Defines the red component (between 0 and 1, default is 0)
  70539. */
  70540. r: number;
  70541. /**
  70542. * Defines the green component (between 0 and 1, default is 0)
  70543. */
  70544. g: number;
  70545. /**
  70546. * Defines the blue component (between 0 and 1, default is 0)
  70547. */
  70548. b: number;
  70549. /**
  70550. * Defines the alpha component (between 0 and 1, default is 1)
  70551. */
  70552. a: number;
  70553. /**
  70554. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70555. * @param r defines the red component (between 0 and 1, default is 0)
  70556. * @param g defines the green component (between 0 and 1, default is 0)
  70557. * @param b defines the blue component (between 0 and 1, default is 0)
  70558. * @param a defines the alpha component (between 0 and 1, default is 1)
  70559. */
  70560. constructor(
  70561. /**
  70562. * Defines the red component (between 0 and 1, default is 0)
  70563. */
  70564. r?: number,
  70565. /**
  70566. * Defines the green component (between 0 and 1, default is 0)
  70567. */
  70568. g?: number,
  70569. /**
  70570. * Defines the blue component (between 0 and 1, default is 0)
  70571. */
  70572. b?: number,
  70573. /**
  70574. * Defines the alpha component (between 0 and 1, default is 1)
  70575. */
  70576. a?: number);
  70577. /**
  70578. * Adds in place the given Color4 values to the current Color4 object
  70579. * @param right defines the second operand
  70580. * @returns the current updated Color4 object
  70581. */
  70582. addInPlace(right: DeepImmutable<Color4>): Color4;
  70583. /**
  70584. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70585. * @returns the new array
  70586. */
  70587. asArray(): number[];
  70588. /**
  70589. * Stores from the starting index in the given array the Color4 successive values
  70590. * @param array defines the array where to store the r,g,b components
  70591. * @param index defines an optional index in the target array to define where to start storing values
  70592. * @returns the current Color4 object
  70593. */
  70594. toArray(array: number[], index?: number): Color4;
  70595. /**
  70596. * Determines equality between Color4 objects
  70597. * @param otherColor defines the second operand
  70598. * @returns true if the rgba values are equal to the given ones
  70599. */
  70600. equals(otherColor: DeepImmutable<Color4>): boolean;
  70601. /**
  70602. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70603. * @param right defines the second operand
  70604. * @returns a new Color4 object
  70605. */
  70606. add(right: DeepImmutable<Color4>): Color4;
  70607. /**
  70608. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70609. * @param right defines the second operand
  70610. * @returns a new Color4 object
  70611. */
  70612. subtract(right: DeepImmutable<Color4>): Color4;
  70613. /**
  70614. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70615. * @param right defines the second operand
  70616. * @param result defines the Color4 object where to store the result
  70617. * @returns the current Color4 object
  70618. */
  70619. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70620. /**
  70621. * Creates a new Color4 with the current Color4 values multiplied by scale
  70622. * @param scale defines the scaling factor to apply
  70623. * @returns a new Color4 object
  70624. */
  70625. scale(scale: number): Color4;
  70626. /**
  70627. * Multiplies the current Color4 values by scale and stores the result in "result"
  70628. * @param scale defines the scaling factor to apply
  70629. * @param result defines the Color4 object where to store the result
  70630. * @returns the current unmodified Color4
  70631. */
  70632. scaleToRef(scale: number, result: Color4): Color4;
  70633. /**
  70634. * Scale the current Color4 values by a factor and add the result to a given Color4
  70635. * @param scale defines the scale factor
  70636. * @param result defines the Color4 object where to store the result
  70637. * @returns the unmodified current Color4
  70638. */
  70639. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70640. /**
  70641. * Clamps the rgb values by the min and max values and stores the result into "result"
  70642. * @param min defines minimum clamping value (default is 0)
  70643. * @param max defines maximum clamping value (default is 1)
  70644. * @param result defines color to store the result into.
  70645. * @returns the cuurent Color4
  70646. */
  70647. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70648. /**
  70649. * Multipy an Color4 value by another and return a new Color4 object
  70650. * @param color defines the Color4 value to multiply by
  70651. * @returns a new Color4 object
  70652. */
  70653. multiply(color: Color4): Color4;
  70654. /**
  70655. * Multipy a Color4 value by another and push the result in a reference value
  70656. * @param color defines the Color4 value to multiply by
  70657. * @param result defines the Color4 to fill the result in
  70658. * @returns the result Color4
  70659. */
  70660. multiplyToRef(color: Color4, result: Color4): Color4;
  70661. /**
  70662. * Creates a string with the Color4 current values
  70663. * @returns the string representation of the Color4 object
  70664. */
  70665. toString(): string;
  70666. /**
  70667. * Returns the string "Color4"
  70668. * @returns "Color4"
  70669. */
  70670. getClassName(): string;
  70671. /**
  70672. * Compute the Color4 hash code
  70673. * @returns an unique number that can be used to hash Color4 objects
  70674. */
  70675. getHashCode(): number;
  70676. /**
  70677. * Creates a new Color4 copied from the current one
  70678. * @returns a new Color4 object
  70679. */
  70680. clone(): Color4;
  70681. /**
  70682. * Copies the given Color4 values into the current one
  70683. * @param source defines the source Color4 object
  70684. * @returns the current updated Color4 object
  70685. */
  70686. copyFrom(source: Color4): Color4;
  70687. /**
  70688. * Copies the given float values into the current one
  70689. * @param r defines the red component to read from
  70690. * @param g defines the green component to read from
  70691. * @param b defines the blue component to read from
  70692. * @param a defines the alpha component to read from
  70693. * @returns the current updated Color4 object
  70694. */
  70695. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70696. /**
  70697. * Copies the given float values into the current one
  70698. * @param r defines the red component to read from
  70699. * @param g defines the green component to read from
  70700. * @param b defines the blue component to read from
  70701. * @param a defines the alpha component to read from
  70702. * @returns the current updated Color4 object
  70703. */
  70704. set(r: number, g: number, b: number, a: number): Color4;
  70705. /**
  70706. * Compute the Color4 hexadecimal code as a string
  70707. * @returns a string containing the hexadecimal representation of the Color4 object
  70708. */
  70709. toHexString(): string;
  70710. /**
  70711. * Computes a new Color4 converted from the current one to linear space
  70712. * @returns a new Color4 object
  70713. */
  70714. toLinearSpace(): Color4;
  70715. /**
  70716. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70717. * @param convertedColor defines the Color4 object where to store the linear space version
  70718. * @returns the unmodified Color4
  70719. */
  70720. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70721. /**
  70722. * Computes a new Color4 converted from the current one to gamma space
  70723. * @returns a new Color4 object
  70724. */
  70725. toGammaSpace(): Color4;
  70726. /**
  70727. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70728. * @param convertedColor defines the Color4 object where to store the gamma space version
  70729. * @returns the unmodified Color4
  70730. */
  70731. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70732. /**
  70733. * Creates a new Color4 from the string containing valid hexadecimal values
  70734. * @param hex defines a string containing valid hexadecimal values
  70735. * @returns a new Color4 object
  70736. */
  70737. static FromHexString(hex: string): Color4;
  70738. /**
  70739. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70740. * @param left defines the start value
  70741. * @param right defines the end value
  70742. * @param amount defines the gradient factor
  70743. * @returns a new Color4 object
  70744. */
  70745. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70746. /**
  70747. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70748. * @param left defines the start value
  70749. * @param right defines the end value
  70750. * @param amount defines the gradient factor
  70751. * @param result defines the Color4 object where to store data
  70752. */
  70753. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70754. /**
  70755. * Creates a new Color4 from a Color3 and an alpha value
  70756. * @param color3 defines the source Color3 to read from
  70757. * @param alpha defines the alpha component (1.0 by default)
  70758. * @returns a new Color4 object
  70759. */
  70760. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70761. /**
  70762. * Creates a new Color4 from the starting index element of the given array
  70763. * @param array defines the source array to read from
  70764. * @param offset defines the offset in the source array
  70765. * @returns a new Color4 object
  70766. */
  70767. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70768. /**
  70769. * Creates a new Color3 from integer values (< 256)
  70770. * @param r defines the red component to read from (value between 0 and 255)
  70771. * @param g defines the green component to read from (value between 0 and 255)
  70772. * @param b defines the blue component to read from (value between 0 and 255)
  70773. * @param a defines the alpha component to read from (value between 0 and 255)
  70774. * @returns a new Color3 object
  70775. */
  70776. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70777. /**
  70778. * Check the content of a given array and convert it to an array containing RGBA data
  70779. * If the original array was already containing count * 4 values then it is returned directly
  70780. * @param colors defines the array to check
  70781. * @param count defines the number of RGBA data to expect
  70782. * @returns an array containing count * 4 values (RGBA)
  70783. */
  70784. static CheckColors4(colors: number[], count: number): number[];
  70785. }
  70786. /**
  70787. * @hidden
  70788. */
  70789. export class TmpColors {
  70790. static Color3: Color3[];
  70791. static Color4: Color4[];
  70792. }
  70793. }
  70794. declare module BABYLON {
  70795. /**
  70796. * Class representing spherical harmonics coefficients to the 3rd degree
  70797. */
  70798. export class SphericalHarmonics {
  70799. /**
  70800. * Defines whether or not the harmonics have been prescaled for rendering.
  70801. */
  70802. preScaled: boolean;
  70803. /**
  70804. * The l0,0 coefficients of the spherical harmonics
  70805. */
  70806. l00: Vector3;
  70807. /**
  70808. * The l1,-1 coefficients of the spherical harmonics
  70809. */
  70810. l1_1: Vector3;
  70811. /**
  70812. * The l1,0 coefficients of the spherical harmonics
  70813. */
  70814. l10: Vector3;
  70815. /**
  70816. * The l1,1 coefficients of the spherical harmonics
  70817. */
  70818. l11: Vector3;
  70819. /**
  70820. * The l2,-2 coefficients of the spherical harmonics
  70821. */
  70822. l2_2: Vector3;
  70823. /**
  70824. * The l2,-1 coefficients of the spherical harmonics
  70825. */
  70826. l2_1: Vector3;
  70827. /**
  70828. * The l2,0 coefficients of the spherical harmonics
  70829. */
  70830. l20: Vector3;
  70831. /**
  70832. * The l2,1 coefficients of the spherical harmonics
  70833. */
  70834. l21: Vector3;
  70835. /**
  70836. * The l2,2 coefficients of the spherical harmonics
  70837. */
  70838. l22: Vector3;
  70839. /**
  70840. * Adds a light to the spherical harmonics
  70841. * @param direction the direction of the light
  70842. * @param color the color of the light
  70843. * @param deltaSolidAngle the delta solid angle of the light
  70844. */
  70845. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70846. /**
  70847. * Scales the spherical harmonics by the given amount
  70848. * @param scale the amount to scale
  70849. */
  70850. scaleInPlace(scale: number): void;
  70851. /**
  70852. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70853. *
  70854. * ```
  70855. * E_lm = A_l * L_lm
  70856. * ```
  70857. *
  70858. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70859. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70860. * the scaling factors are given in equation 9.
  70861. */
  70862. convertIncidentRadianceToIrradiance(): void;
  70863. /**
  70864. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70865. *
  70866. * ```
  70867. * L = (1/pi) * E * rho
  70868. * ```
  70869. *
  70870. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70871. */
  70872. convertIrradianceToLambertianRadiance(): void;
  70873. /**
  70874. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70875. * required operations at run time.
  70876. *
  70877. * This is simply done by scaling back the SH with Ylm constants parameter.
  70878. * The trigonometric part being applied by the shader at run time.
  70879. */
  70880. preScaleForRendering(): void;
  70881. /**
  70882. * Constructs a spherical harmonics from an array.
  70883. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70884. * @returns the spherical harmonics
  70885. */
  70886. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70887. /**
  70888. * Gets the spherical harmonics from polynomial
  70889. * @param polynomial the spherical polynomial
  70890. * @returns the spherical harmonics
  70891. */
  70892. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70893. }
  70894. /**
  70895. * Class representing spherical polynomial coefficients to the 3rd degree
  70896. */
  70897. export class SphericalPolynomial {
  70898. private _harmonics;
  70899. /**
  70900. * The spherical harmonics used to create the polynomials.
  70901. */
  70902. readonly preScaledHarmonics: SphericalHarmonics;
  70903. /**
  70904. * The x coefficients of the spherical polynomial
  70905. */
  70906. x: Vector3;
  70907. /**
  70908. * The y coefficients of the spherical polynomial
  70909. */
  70910. y: Vector3;
  70911. /**
  70912. * The z coefficients of the spherical polynomial
  70913. */
  70914. z: Vector3;
  70915. /**
  70916. * The xx coefficients of the spherical polynomial
  70917. */
  70918. xx: Vector3;
  70919. /**
  70920. * The yy coefficients of the spherical polynomial
  70921. */
  70922. yy: Vector3;
  70923. /**
  70924. * The zz coefficients of the spherical polynomial
  70925. */
  70926. zz: Vector3;
  70927. /**
  70928. * The xy coefficients of the spherical polynomial
  70929. */
  70930. xy: Vector3;
  70931. /**
  70932. * The yz coefficients of the spherical polynomial
  70933. */
  70934. yz: Vector3;
  70935. /**
  70936. * The zx coefficients of the spherical polynomial
  70937. */
  70938. zx: Vector3;
  70939. /**
  70940. * Adds an ambient color to the spherical polynomial
  70941. * @param color the color to add
  70942. */
  70943. addAmbient(color: Color3): void;
  70944. /**
  70945. * Scales the spherical polynomial by the given amount
  70946. * @param scale the amount to scale
  70947. */
  70948. scaleInPlace(scale: number): void;
  70949. /**
  70950. * Gets the spherical polynomial from harmonics
  70951. * @param harmonics the spherical harmonics
  70952. * @returns the spherical polynomial
  70953. */
  70954. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70955. /**
  70956. * Constructs a spherical polynomial from an array.
  70957. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70958. * @returns the spherical polynomial
  70959. */
  70960. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70961. }
  70962. }
  70963. declare module BABYLON {
  70964. /**
  70965. * Define options used to create a render target texture
  70966. */
  70967. export class RenderTargetCreationOptions {
  70968. /**
  70969. * Specifies is mipmaps must be generated
  70970. */
  70971. generateMipMaps?: boolean;
  70972. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70973. generateDepthBuffer?: boolean;
  70974. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70975. generateStencilBuffer?: boolean;
  70976. /** Defines texture type (int by default) */
  70977. type?: number;
  70978. /** Defines sampling mode (trilinear by default) */
  70979. samplingMode?: number;
  70980. /** Defines format (RGBA by default) */
  70981. format?: number;
  70982. }
  70983. }
  70984. declare module BABYLON {
  70985. /**
  70986. * @hidden
  70987. **/
  70988. export class _TimeToken {
  70989. _startTimeQuery: Nullable<WebGLQuery>;
  70990. _endTimeQuery: Nullable<WebGLQuery>;
  70991. _timeElapsedQuery: Nullable<WebGLQuery>;
  70992. _timeElapsedQueryEnded: boolean;
  70993. }
  70994. }
  70995. declare module BABYLON {
  70996. /** Defines the cross module used constants to avoid circular dependncies */
  70997. export class Constants {
  70998. /** Defines that alpha blending is disabled */
  70999. static readonly ALPHA_DISABLE: number;
  71000. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  71001. static readonly ALPHA_ADD: number;
  71002. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71003. static readonly ALPHA_COMBINE: number;
  71004. /** Defines that alpha blending to DEST - SRC * DEST */
  71005. static readonly ALPHA_SUBTRACT: number;
  71006. /** Defines that alpha blending to SRC * DEST */
  71007. static readonly ALPHA_MULTIPLY: number;
  71008. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  71009. static readonly ALPHA_MAXIMIZED: number;
  71010. /** Defines that alpha blending to SRC + DEST */
  71011. static readonly ALPHA_ONEONE: number;
  71012. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  71013. static readonly ALPHA_PREMULTIPLIED: number;
  71014. /**
  71015. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  71016. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71017. */
  71018. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71019. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  71020. static readonly ALPHA_INTERPOLATE: number;
  71021. /**
  71022. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  71023. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71024. */
  71025. static readonly ALPHA_SCREENMODE: number;
  71026. /**
  71027. * Defines that alpha blending to SRC + DST
  71028. * Alpha will be set to SRC ALPHA + DST ALPHA
  71029. */
  71030. static readonly ALPHA_ONEONE_ONEONE: number;
  71031. /**
  71032. * Defines that alpha blending to SRC * DST ALPHA + DST
  71033. * Alpha will be set to 0
  71034. */
  71035. static readonly ALPHA_ALPHATOCOLOR: number;
  71036. /**
  71037. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  71038. */
  71039. static readonly ALPHA_REVERSEONEMINUS: number;
  71040. /**
  71041. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  71042. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71043. */
  71044. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71045. /**
  71046. * Defines that alpha blending to SRC + DST
  71047. * Alpha will be set to SRC ALPHA
  71048. */
  71049. static readonly ALPHA_ONEONE_ONEZERO: number;
  71050. /** Defines that alpha blending equation a SUM */
  71051. static readonly ALPHA_EQUATION_ADD: number;
  71052. /** Defines that alpha blending equation a SUBSTRACTION */
  71053. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71054. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71055. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71056. /** Defines that alpha blending equation a MAX operation */
  71057. static readonly ALPHA_EQUATION_MAX: number;
  71058. /** Defines that alpha blending equation a MIN operation */
  71059. static readonly ALPHA_EQUATION_MIN: number;
  71060. /**
  71061. * Defines that alpha blending equation a DARKEN operation:
  71062. * It takes the min of the src and sums the alpha channels.
  71063. */
  71064. static readonly ALPHA_EQUATION_DARKEN: number;
  71065. /** Defines that the ressource is not delayed*/
  71066. static readonly DELAYLOADSTATE_NONE: number;
  71067. /** Defines that the ressource was successfully delay loaded */
  71068. static readonly DELAYLOADSTATE_LOADED: number;
  71069. /** Defines that the ressource is currently delay loading */
  71070. static readonly DELAYLOADSTATE_LOADING: number;
  71071. /** Defines that the ressource is delayed and has not started loading */
  71072. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71073. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71074. static readonly NEVER: number;
  71075. /** 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 */
  71076. static readonly ALWAYS: number;
  71077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71078. static readonly LESS: number;
  71079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71080. static readonly EQUAL: number;
  71081. /** 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 */
  71082. static readonly LEQUAL: number;
  71083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71084. static readonly GREATER: number;
  71085. /** 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 */
  71086. static readonly GEQUAL: number;
  71087. /** 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 */
  71088. static readonly NOTEQUAL: number;
  71089. /** Passed to stencilOperation to specify that stencil value must be kept */
  71090. static readonly KEEP: number;
  71091. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71092. static readonly REPLACE: number;
  71093. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71094. static readonly INCR: number;
  71095. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71096. static readonly DECR: number;
  71097. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71098. static readonly INVERT: number;
  71099. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71100. static readonly INCR_WRAP: number;
  71101. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71102. static readonly DECR_WRAP: number;
  71103. /** Texture is not repeating outside of 0..1 UVs */
  71104. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71105. /** Texture is repeating outside of 0..1 UVs */
  71106. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71107. /** Texture is repeating and mirrored */
  71108. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71109. /** ALPHA */
  71110. static readonly TEXTUREFORMAT_ALPHA: number;
  71111. /** LUMINANCE */
  71112. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71113. /** LUMINANCE_ALPHA */
  71114. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71115. /** RGB */
  71116. static readonly TEXTUREFORMAT_RGB: number;
  71117. /** RGBA */
  71118. static readonly TEXTUREFORMAT_RGBA: number;
  71119. /** RED */
  71120. static readonly TEXTUREFORMAT_RED: number;
  71121. /** RED (2nd reference) */
  71122. static readonly TEXTUREFORMAT_R: number;
  71123. /** RG */
  71124. static readonly TEXTUREFORMAT_RG: number;
  71125. /** RED_INTEGER */
  71126. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71127. /** RED_INTEGER (2nd reference) */
  71128. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71129. /** RG_INTEGER */
  71130. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71131. /** RGB_INTEGER */
  71132. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71133. /** RGBA_INTEGER */
  71134. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71135. /** UNSIGNED_BYTE */
  71136. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71137. /** UNSIGNED_BYTE (2nd reference) */
  71138. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71139. /** FLOAT */
  71140. static readonly TEXTURETYPE_FLOAT: number;
  71141. /** HALF_FLOAT */
  71142. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71143. /** BYTE */
  71144. static readonly TEXTURETYPE_BYTE: number;
  71145. /** SHORT */
  71146. static readonly TEXTURETYPE_SHORT: number;
  71147. /** UNSIGNED_SHORT */
  71148. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71149. /** INT */
  71150. static readonly TEXTURETYPE_INT: number;
  71151. /** UNSIGNED_INT */
  71152. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71153. /** UNSIGNED_SHORT_4_4_4_4 */
  71154. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71155. /** UNSIGNED_SHORT_5_5_5_1 */
  71156. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71157. /** UNSIGNED_SHORT_5_6_5 */
  71158. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71159. /** UNSIGNED_INT_2_10_10_10_REV */
  71160. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71161. /** UNSIGNED_INT_24_8 */
  71162. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71163. /** UNSIGNED_INT_10F_11F_11F_REV */
  71164. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71165. /** UNSIGNED_INT_5_9_9_9_REV */
  71166. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71167. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71168. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71169. /** nearest is mag = nearest and min = nearest and mip = linear */
  71170. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71171. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71172. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71173. /** Trilinear is mag = linear and min = linear and mip = linear */
  71174. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71175. /** nearest is mag = nearest and min = nearest and mip = linear */
  71176. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71177. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71178. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71179. /** Trilinear is mag = linear and min = linear and mip = linear */
  71180. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71181. /** mag = nearest and min = nearest and mip = nearest */
  71182. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71183. /** mag = nearest and min = linear and mip = nearest */
  71184. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71185. /** mag = nearest and min = linear and mip = linear */
  71186. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71187. /** mag = nearest and min = linear and mip = none */
  71188. static readonly TEXTURE_NEAREST_LINEAR: number;
  71189. /** mag = nearest and min = nearest and mip = none */
  71190. static readonly TEXTURE_NEAREST_NEAREST: number;
  71191. /** mag = linear and min = nearest and mip = nearest */
  71192. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71193. /** mag = linear and min = nearest and mip = linear */
  71194. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71195. /** mag = linear and min = linear and mip = none */
  71196. static readonly TEXTURE_LINEAR_LINEAR: number;
  71197. /** mag = linear and min = nearest and mip = none */
  71198. static readonly TEXTURE_LINEAR_NEAREST: number;
  71199. /** Explicit coordinates mode */
  71200. static readonly TEXTURE_EXPLICIT_MODE: number;
  71201. /** Spherical coordinates mode */
  71202. static readonly TEXTURE_SPHERICAL_MODE: number;
  71203. /** Planar coordinates mode */
  71204. static readonly TEXTURE_PLANAR_MODE: number;
  71205. /** Cubic coordinates mode */
  71206. static readonly TEXTURE_CUBIC_MODE: number;
  71207. /** Projection coordinates mode */
  71208. static readonly TEXTURE_PROJECTION_MODE: number;
  71209. /** Skybox coordinates mode */
  71210. static readonly TEXTURE_SKYBOX_MODE: number;
  71211. /** Inverse Cubic coordinates mode */
  71212. static readonly TEXTURE_INVCUBIC_MODE: number;
  71213. /** Equirectangular coordinates mode */
  71214. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71215. /** Equirectangular Fixed coordinates mode */
  71216. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71217. /** Equirectangular Fixed Mirrored coordinates mode */
  71218. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71219. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71220. static readonly SCALEMODE_FLOOR: number;
  71221. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71222. static readonly SCALEMODE_NEAREST: number;
  71223. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71224. static readonly SCALEMODE_CEILING: number;
  71225. /**
  71226. * The dirty texture flag value
  71227. */
  71228. static readonly MATERIAL_TextureDirtyFlag: number;
  71229. /**
  71230. * The dirty light flag value
  71231. */
  71232. static readonly MATERIAL_LightDirtyFlag: number;
  71233. /**
  71234. * The dirty fresnel flag value
  71235. */
  71236. static readonly MATERIAL_FresnelDirtyFlag: number;
  71237. /**
  71238. * The dirty attribute flag value
  71239. */
  71240. static readonly MATERIAL_AttributesDirtyFlag: number;
  71241. /**
  71242. * The dirty misc flag value
  71243. */
  71244. static readonly MATERIAL_MiscDirtyFlag: number;
  71245. /**
  71246. * The all dirty flag value
  71247. */
  71248. static readonly MATERIAL_AllDirtyFlag: number;
  71249. /**
  71250. * Returns the triangle fill mode
  71251. */
  71252. static readonly MATERIAL_TriangleFillMode: number;
  71253. /**
  71254. * Returns the wireframe mode
  71255. */
  71256. static readonly MATERIAL_WireFrameFillMode: number;
  71257. /**
  71258. * Returns the point fill mode
  71259. */
  71260. static readonly MATERIAL_PointFillMode: number;
  71261. /**
  71262. * Returns the point list draw mode
  71263. */
  71264. static readonly MATERIAL_PointListDrawMode: number;
  71265. /**
  71266. * Returns the line list draw mode
  71267. */
  71268. static readonly MATERIAL_LineListDrawMode: number;
  71269. /**
  71270. * Returns the line loop draw mode
  71271. */
  71272. static readonly MATERIAL_LineLoopDrawMode: number;
  71273. /**
  71274. * Returns the line strip draw mode
  71275. */
  71276. static readonly MATERIAL_LineStripDrawMode: number;
  71277. /**
  71278. * Returns the triangle strip draw mode
  71279. */
  71280. static readonly MATERIAL_TriangleStripDrawMode: number;
  71281. /**
  71282. * Returns the triangle fan draw mode
  71283. */
  71284. static readonly MATERIAL_TriangleFanDrawMode: number;
  71285. /**
  71286. * Stores the clock-wise side orientation
  71287. */
  71288. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71289. /**
  71290. * Stores the counter clock-wise side orientation
  71291. */
  71292. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71293. /**
  71294. * Nothing
  71295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71296. */
  71297. static readonly ACTION_NothingTrigger: number;
  71298. /**
  71299. * On pick
  71300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71301. */
  71302. static readonly ACTION_OnPickTrigger: number;
  71303. /**
  71304. * On left pick
  71305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71306. */
  71307. static readonly ACTION_OnLeftPickTrigger: number;
  71308. /**
  71309. * On right pick
  71310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71311. */
  71312. static readonly ACTION_OnRightPickTrigger: number;
  71313. /**
  71314. * On center pick
  71315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71316. */
  71317. static readonly ACTION_OnCenterPickTrigger: number;
  71318. /**
  71319. * On pick down
  71320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71321. */
  71322. static readonly ACTION_OnPickDownTrigger: number;
  71323. /**
  71324. * On double pick
  71325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71326. */
  71327. static readonly ACTION_OnDoublePickTrigger: number;
  71328. /**
  71329. * On pick up
  71330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71331. */
  71332. static readonly ACTION_OnPickUpTrigger: number;
  71333. /**
  71334. * On pick out.
  71335. * This trigger will only be raised if you also declared a OnPickDown
  71336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71337. */
  71338. static readonly ACTION_OnPickOutTrigger: number;
  71339. /**
  71340. * On long press
  71341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71342. */
  71343. static readonly ACTION_OnLongPressTrigger: number;
  71344. /**
  71345. * On pointer over
  71346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71347. */
  71348. static readonly ACTION_OnPointerOverTrigger: number;
  71349. /**
  71350. * On pointer out
  71351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71352. */
  71353. static readonly ACTION_OnPointerOutTrigger: number;
  71354. /**
  71355. * On every frame
  71356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71357. */
  71358. static readonly ACTION_OnEveryFrameTrigger: number;
  71359. /**
  71360. * On intersection enter
  71361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71362. */
  71363. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71364. /**
  71365. * On intersection exit
  71366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71367. */
  71368. static readonly ACTION_OnIntersectionExitTrigger: number;
  71369. /**
  71370. * On key down
  71371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71372. */
  71373. static readonly ACTION_OnKeyDownTrigger: number;
  71374. /**
  71375. * On key up
  71376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71377. */
  71378. static readonly ACTION_OnKeyUpTrigger: number;
  71379. /**
  71380. * Billboard mode will only apply to Y axis
  71381. */
  71382. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71383. /**
  71384. * Billboard mode will apply to all axes
  71385. */
  71386. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71387. /**
  71388. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71389. */
  71390. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71391. /**
  71392. * Gets or sets base Assets URL
  71393. */
  71394. static PARTICLES_BaseAssetsUrl: string;
  71395. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71396. * Test order :
  71397. * Is the bounding sphere outside the frustum ?
  71398. * If not, are the bounding box vertices outside the frustum ?
  71399. * It not, then the cullable object is in the frustum.
  71400. */
  71401. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71402. /** Culling strategy : Bounding Sphere Only.
  71403. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71404. * It's also less accurate than the standard because some not visible objects can still be selected.
  71405. * Test : is the bounding sphere outside the frustum ?
  71406. * If not, then the cullable object is in the frustum.
  71407. */
  71408. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71409. /** Culling strategy : Optimistic Inclusion.
  71410. * This in an inclusion test first, then the standard exclusion test.
  71411. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71412. * 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.
  71413. * Anyway, it's as accurate as the standard strategy.
  71414. * Test :
  71415. * Is the cullable object bounding sphere center in the frustum ?
  71416. * If not, apply the default culling strategy.
  71417. */
  71418. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71419. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71420. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71421. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71422. * 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.
  71423. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71424. * Test :
  71425. * Is the cullable object bounding sphere center in the frustum ?
  71426. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71427. */
  71428. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71429. /**
  71430. * No logging while loading
  71431. */
  71432. static readonly SCENELOADER_NO_LOGGING: number;
  71433. /**
  71434. * Minimal logging while loading
  71435. */
  71436. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71437. /**
  71438. * Summary logging while loading
  71439. */
  71440. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71441. /**
  71442. * Detailled logging while loading
  71443. */
  71444. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71445. }
  71446. }
  71447. declare module BABYLON {
  71448. /**
  71449. * This represents the required contract to create a new type of texture loader.
  71450. */
  71451. export interface IInternalTextureLoader {
  71452. /**
  71453. * Defines wether the loader supports cascade loading the different faces.
  71454. */
  71455. supportCascades: boolean;
  71456. /**
  71457. * This returns if the loader support the current file information.
  71458. * @param extension defines the file extension of the file being loaded
  71459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71460. * @param fallback defines the fallback internal texture if any
  71461. * @param isBase64 defines whether the texture is encoded as a base64
  71462. * @param isBuffer defines whether the texture data are stored as a buffer
  71463. * @returns true if the loader can load the specified file
  71464. */
  71465. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71466. /**
  71467. * Transform the url before loading if required.
  71468. * @param rootUrl the url of the texture
  71469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71470. * @returns the transformed texture
  71471. */
  71472. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71473. /**
  71474. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71475. * @param rootUrl the url of the texture
  71476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71477. * @returns the fallback texture
  71478. */
  71479. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71480. /**
  71481. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71482. * @param data contains the texture data
  71483. * @param texture defines the BabylonJS internal texture
  71484. * @param createPolynomials will be true if polynomials have been requested
  71485. * @param onLoad defines the callback to trigger once the texture is ready
  71486. * @param onError defines the callback to trigger in case of error
  71487. */
  71488. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71489. /**
  71490. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71491. * @param data contains the texture data
  71492. * @param texture defines the BabylonJS internal texture
  71493. * @param callback defines the method to call once ready to upload
  71494. */
  71495. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71496. }
  71497. }
  71498. declare module BABYLON {
  71499. /**
  71500. * Class used to store and describe the pipeline context associated with an effect
  71501. */
  71502. export interface IPipelineContext {
  71503. /**
  71504. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71505. */
  71506. isAsync: boolean;
  71507. /**
  71508. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71509. */
  71510. isReady: boolean;
  71511. /** @hidden */
  71512. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71513. }
  71514. }
  71515. declare module BABYLON {
  71516. /**
  71517. * Class used to store gfx data (like WebGLBuffer)
  71518. */
  71519. export class DataBuffer {
  71520. /**
  71521. * Gets or sets the number of objects referencing this buffer
  71522. */
  71523. references: number;
  71524. /** Gets or sets the size of the underlying buffer */
  71525. capacity: number;
  71526. /**
  71527. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71528. */
  71529. is32Bits: boolean;
  71530. /**
  71531. * Gets the underlying buffer
  71532. */
  71533. readonly underlyingResource: any;
  71534. }
  71535. }
  71536. declare module BABYLON {
  71537. /** @hidden */
  71538. export interface IShaderProcessor {
  71539. attributeProcessor?: (attribute: string) => string;
  71540. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71541. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71542. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71543. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71544. lineProcessor?: (line: string, isFragment: boolean) => string;
  71545. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71546. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71547. }
  71548. }
  71549. declare module BABYLON {
  71550. /** @hidden */
  71551. export interface ProcessingOptions {
  71552. defines: string[];
  71553. indexParameters: any;
  71554. isFragment: boolean;
  71555. shouldUseHighPrecisionShader: boolean;
  71556. supportsUniformBuffers: boolean;
  71557. shadersRepository: string;
  71558. includesShadersStore: {
  71559. [key: string]: string;
  71560. };
  71561. processor?: IShaderProcessor;
  71562. version: string;
  71563. platformName: string;
  71564. lookForClosingBracketForUniformBuffer?: boolean;
  71565. }
  71566. }
  71567. declare module BABYLON {
  71568. /**
  71569. * Helper to manipulate strings
  71570. */
  71571. export class StringTools {
  71572. /**
  71573. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71574. * @param str Source string
  71575. * @param suffix Suffix to search for in the source string
  71576. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71577. */
  71578. static EndsWith(str: string, suffix: string): boolean;
  71579. /**
  71580. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71581. * @param str Source string
  71582. * @param suffix Suffix to search for in the source string
  71583. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71584. */
  71585. static StartsWith(str: string, suffix: string): boolean;
  71586. }
  71587. }
  71588. declare module BABYLON {
  71589. /** @hidden */
  71590. export class ShaderCodeNode {
  71591. line: string;
  71592. children: ShaderCodeNode[];
  71593. additionalDefineKey?: string;
  71594. additionalDefineValue?: string;
  71595. isValid(preprocessors: {
  71596. [key: string]: string;
  71597. }): boolean;
  71598. process(preprocessors: {
  71599. [key: string]: string;
  71600. }, options: ProcessingOptions): string;
  71601. }
  71602. }
  71603. declare module BABYLON {
  71604. /** @hidden */
  71605. export class ShaderCodeCursor {
  71606. private _lines;
  71607. lineIndex: number;
  71608. readonly currentLine: string;
  71609. readonly canRead: boolean;
  71610. lines: string[];
  71611. }
  71612. }
  71613. declare module BABYLON {
  71614. /** @hidden */
  71615. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71616. process(preprocessors: {
  71617. [key: string]: string;
  71618. }, options: ProcessingOptions): string;
  71619. }
  71620. }
  71621. declare module BABYLON {
  71622. /** @hidden */
  71623. export class ShaderDefineExpression {
  71624. isTrue(preprocessors: {
  71625. [key: string]: string;
  71626. }): boolean;
  71627. }
  71628. }
  71629. declare module BABYLON {
  71630. /** @hidden */
  71631. export class ShaderCodeTestNode extends ShaderCodeNode {
  71632. testExpression: ShaderDefineExpression;
  71633. isValid(preprocessors: {
  71634. [key: string]: string;
  71635. }): boolean;
  71636. }
  71637. }
  71638. declare module BABYLON {
  71639. /** @hidden */
  71640. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71641. define: string;
  71642. not: boolean;
  71643. constructor(define: string, not?: boolean);
  71644. isTrue(preprocessors: {
  71645. [key: string]: string;
  71646. }): boolean;
  71647. }
  71648. }
  71649. declare module BABYLON {
  71650. /** @hidden */
  71651. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71652. leftOperand: ShaderDefineExpression;
  71653. rightOperand: ShaderDefineExpression;
  71654. isTrue(preprocessors: {
  71655. [key: string]: string;
  71656. }): boolean;
  71657. }
  71658. }
  71659. declare module BABYLON {
  71660. /** @hidden */
  71661. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71662. leftOperand: ShaderDefineExpression;
  71663. rightOperand: ShaderDefineExpression;
  71664. isTrue(preprocessors: {
  71665. [key: string]: string;
  71666. }): boolean;
  71667. }
  71668. }
  71669. declare module BABYLON {
  71670. /** @hidden */
  71671. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71672. define: string;
  71673. operand: string;
  71674. testValue: string;
  71675. constructor(define: string, operand: string, testValue: string);
  71676. isTrue(preprocessors: {
  71677. [key: string]: string;
  71678. }): boolean;
  71679. }
  71680. }
  71681. declare module BABYLON {
  71682. /**
  71683. * @ignore
  71684. * Application error to support additional information when loading a file
  71685. */
  71686. export class LoadFileError extends Error {
  71687. /** defines the optional web request */
  71688. request?: WebRequest | undefined;
  71689. private static _setPrototypeOf;
  71690. /**
  71691. * Creates a new LoadFileError
  71692. * @param message defines the message of the error
  71693. * @param request defines the optional web request
  71694. */
  71695. constructor(message: string,
  71696. /** defines the optional web request */
  71697. request?: WebRequest | undefined);
  71698. }
  71699. }
  71700. declare module BABYLON {
  71701. /**
  71702. * Class used to enable access to offline support
  71703. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71704. */
  71705. export interface IOfflineProvider {
  71706. /**
  71707. * Gets a boolean indicating if scene must be saved in the database
  71708. */
  71709. enableSceneOffline: boolean;
  71710. /**
  71711. * Gets a boolean indicating if textures must be saved in the database
  71712. */
  71713. enableTexturesOffline: boolean;
  71714. /**
  71715. * Open the offline support and make it available
  71716. * @param successCallback defines the callback to call on success
  71717. * @param errorCallback defines the callback to call on error
  71718. */
  71719. open(successCallback: () => void, errorCallback: () => void): void;
  71720. /**
  71721. * Loads an image from the offline support
  71722. * @param url defines the url to load from
  71723. * @param image defines the target DOM image
  71724. */
  71725. loadImage(url: string, image: HTMLImageElement): void;
  71726. /**
  71727. * Loads a file from offline support
  71728. * @param url defines the URL to load from
  71729. * @param sceneLoaded defines a callback to call on success
  71730. * @param progressCallBack defines a callback to call when progress changed
  71731. * @param errorCallback defines a callback to call on error
  71732. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71733. */
  71734. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71735. }
  71736. }
  71737. declare module BABYLON {
  71738. /**
  71739. * Class used to help managing file picking and drag'n'drop
  71740. * File Storage
  71741. */
  71742. export class FilesInputStore {
  71743. /**
  71744. * List of files ready to be loaded
  71745. */
  71746. static FilesToLoad: {
  71747. [key: string]: File;
  71748. };
  71749. }
  71750. }
  71751. declare module BABYLON {
  71752. /**
  71753. * Class used to define a retry strategy when error happens while loading assets
  71754. */
  71755. export class RetryStrategy {
  71756. /**
  71757. * Function used to defines an exponential back off strategy
  71758. * @param maxRetries defines the maximum number of retries (3 by default)
  71759. * @param baseInterval defines the interval between retries
  71760. * @returns the strategy function to use
  71761. */
  71762. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71763. }
  71764. }
  71765. declare module BABYLON {
  71766. /**
  71767. * @hidden
  71768. */
  71769. export class FileTools {
  71770. /**
  71771. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71772. */
  71773. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71774. /**
  71775. * Gets or sets the base URL to use to load assets
  71776. */
  71777. static BaseUrl: string;
  71778. /**
  71779. * Default behaviour for cors in the application.
  71780. * It can be a string if the expected behavior is identical in the entire app.
  71781. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71782. */
  71783. static CorsBehavior: string | ((url: string | string[]) => string);
  71784. /**
  71785. * Gets or sets a function used to pre-process url before using them to load assets
  71786. */
  71787. static PreprocessUrl: (url: string) => string;
  71788. /**
  71789. * Removes unwanted characters from an url
  71790. * @param url defines the url to clean
  71791. * @returns the cleaned url
  71792. */
  71793. private static _CleanUrl;
  71794. /**
  71795. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71796. * @param url define the url we are trying
  71797. * @param element define the dom element where to configure the cors policy
  71798. */
  71799. static SetCorsBehavior(url: string | string[], element: {
  71800. crossOrigin: string | null;
  71801. }): void;
  71802. /**
  71803. * Loads an image as an HTMLImageElement.
  71804. * @param input url string, ArrayBuffer, or Blob to load
  71805. * @param onLoad callback called when the image successfully loads
  71806. * @param onError callback called when the image fails to load
  71807. * @param offlineProvider offline provider for caching
  71808. * @returns the HTMLImageElement of the loaded image
  71809. */
  71810. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71811. /**
  71812. * Loads a file
  71813. * @param fileToLoad defines the file to load
  71814. * @param callback defines the callback to call when data is loaded
  71815. * @param progressCallBack defines the callback to call during loading process
  71816. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71817. * @returns a file request object
  71818. */
  71819. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71820. /**
  71821. * Loads a file
  71822. * @param url url string, ArrayBuffer, or Blob to load
  71823. * @param onSuccess callback called when the file successfully loads
  71824. * @param onProgress callback called while file is loading (if the server supports this mode)
  71825. * @param offlineProvider defines the offline provider for caching
  71826. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71827. * @param onError callback called when the file fails to load
  71828. * @returns a file request object
  71829. */
  71830. 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;
  71831. /**
  71832. * Checks if the loaded document was accessed via `file:`-Protocol.
  71833. * @returns boolean
  71834. */
  71835. static IsFileURL(): boolean;
  71836. }
  71837. }
  71838. declare module BABYLON {
  71839. /** @hidden */
  71840. export class ShaderProcessor {
  71841. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71842. private static _ProcessPrecision;
  71843. private static _ExtractOperation;
  71844. private static _BuildSubExpression;
  71845. private static _BuildExpression;
  71846. private static _MoveCursorWithinIf;
  71847. private static _MoveCursor;
  71848. private static _EvaluatePreProcessors;
  71849. private static _PreparePreProcessors;
  71850. private static _ProcessShaderConversion;
  71851. private static _ProcessIncludes;
  71852. }
  71853. }
  71854. declare module BABYLON {
  71855. /**
  71856. * Interface used to define common properties for effect fallbacks
  71857. */
  71858. export interface IEffectFallbacks {
  71859. /**
  71860. * Removes the defines that should be removed when falling back.
  71861. * @param currentDefines defines the current define statements for the shader.
  71862. * @param effect defines the current effect we try to compile
  71863. * @returns The resulting defines with defines of the current rank removed.
  71864. */
  71865. reduce(currentDefines: string, effect: Effect): string;
  71866. /**
  71867. * Removes the fallback from the bound mesh.
  71868. */
  71869. unBindMesh(): void;
  71870. /**
  71871. * Checks to see if more fallbacks are still availible.
  71872. */
  71873. hasMoreFallbacks: boolean;
  71874. }
  71875. }
  71876. declare module BABYLON {
  71877. /**
  71878. * Class used to evalaute queries containing `and` and `or` operators
  71879. */
  71880. export class AndOrNotEvaluator {
  71881. /**
  71882. * Evaluate a query
  71883. * @param query defines the query to evaluate
  71884. * @param evaluateCallback defines the callback used to filter result
  71885. * @returns true if the query matches
  71886. */
  71887. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71888. private static _HandleParenthesisContent;
  71889. private static _SimplifyNegation;
  71890. }
  71891. }
  71892. declare module BABYLON {
  71893. /**
  71894. * Class used to store custom tags
  71895. */
  71896. export class Tags {
  71897. /**
  71898. * Adds support for tags on the given object
  71899. * @param obj defines the object to use
  71900. */
  71901. static EnableFor(obj: any): void;
  71902. /**
  71903. * Removes tags support
  71904. * @param obj defines the object to use
  71905. */
  71906. static DisableFor(obj: any): void;
  71907. /**
  71908. * Gets a boolean indicating if the given object has tags
  71909. * @param obj defines the object to use
  71910. * @returns a boolean
  71911. */
  71912. static HasTags(obj: any): boolean;
  71913. /**
  71914. * Gets the tags available on a given object
  71915. * @param obj defines the object to use
  71916. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71917. * @returns the tags
  71918. */
  71919. static GetTags(obj: any, asString?: boolean): any;
  71920. /**
  71921. * Adds tags to an object
  71922. * @param obj defines the object to use
  71923. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71924. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71925. */
  71926. static AddTagsTo(obj: any, tagsString: string): void;
  71927. /**
  71928. * @hidden
  71929. */
  71930. static _AddTagTo(obj: any, tag: string): void;
  71931. /**
  71932. * Removes specific tags from a specific object
  71933. * @param obj defines the object to use
  71934. * @param tagsString defines the tags to remove
  71935. */
  71936. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71937. /**
  71938. * @hidden
  71939. */
  71940. static _RemoveTagFrom(obj: any, tag: string): void;
  71941. /**
  71942. * Defines if tags hosted on an object match a given query
  71943. * @param obj defines the object to use
  71944. * @param tagsQuery defines the tag query
  71945. * @returns a boolean
  71946. */
  71947. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71948. }
  71949. }
  71950. declare module BABYLON {
  71951. /**
  71952. * Defines potential orientation for back face culling
  71953. */
  71954. export enum Orientation {
  71955. /**
  71956. * Clockwise
  71957. */
  71958. CW = 0,
  71959. /** Counter clockwise */
  71960. CCW = 1
  71961. }
  71962. /** Class used to represent a Bezier curve */
  71963. export class BezierCurve {
  71964. /**
  71965. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71966. * @param t defines the time
  71967. * @param x1 defines the left coordinate on X axis
  71968. * @param y1 defines the left coordinate on Y axis
  71969. * @param x2 defines the right coordinate on X axis
  71970. * @param y2 defines the right coordinate on Y axis
  71971. * @returns the interpolated value
  71972. */
  71973. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71974. }
  71975. /**
  71976. * Defines angle representation
  71977. */
  71978. export class Angle {
  71979. private _radians;
  71980. /**
  71981. * Creates an Angle object of "radians" radians (float).
  71982. * @param radians the angle in radians
  71983. */
  71984. constructor(radians: number);
  71985. /**
  71986. * Get value in degrees
  71987. * @returns the Angle value in degrees (float)
  71988. */
  71989. degrees(): number;
  71990. /**
  71991. * Get value in radians
  71992. * @returns the Angle value in radians (float)
  71993. */
  71994. radians(): number;
  71995. /**
  71996. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71997. * @param a defines first vector
  71998. * @param b defines second vector
  71999. * @returns a new Angle
  72000. */
  72001. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72002. /**
  72003. * Gets a new Angle object from the given float in radians
  72004. * @param radians defines the angle value in radians
  72005. * @returns a new Angle
  72006. */
  72007. static FromRadians(radians: number): Angle;
  72008. /**
  72009. * Gets a new Angle object from the given float in degrees
  72010. * @param degrees defines the angle value in degrees
  72011. * @returns a new Angle
  72012. */
  72013. static FromDegrees(degrees: number): Angle;
  72014. }
  72015. /**
  72016. * This represents an arc in a 2d space.
  72017. */
  72018. export class Arc2 {
  72019. /** Defines the start point of the arc */
  72020. startPoint: Vector2;
  72021. /** Defines the mid point of the arc */
  72022. midPoint: Vector2;
  72023. /** Defines the end point of the arc */
  72024. endPoint: Vector2;
  72025. /**
  72026. * Defines the center point of the arc.
  72027. */
  72028. centerPoint: Vector2;
  72029. /**
  72030. * Defines the radius of the arc.
  72031. */
  72032. radius: number;
  72033. /**
  72034. * Defines the angle of the arc (from mid point to end point).
  72035. */
  72036. angle: Angle;
  72037. /**
  72038. * Defines the start angle of the arc (from start point to middle point).
  72039. */
  72040. startAngle: Angle;
  72041. /**
  72042. * Defines the orientation of the arc (clock wise/counter clock wise).
  72043. */
  72044. orientation: Orientation;
  72045. /**
  72046. * Creates an Arc object from the three given points : start, middle and end.
  72047. * @param startPoint Defines the start point of the arc
  72048. * @param midPoint Defines the midlle point of the arc
  72049. * @param endPoint Defines the end point of the arc
  72050. */
  72051. constructor(
  72052. /** Defines the start point of the arc */
  72053. startPoint: Vector2,
  72054. /** Defines the mid point of the arc */
  72055. midPoint: Vector2,
  72056. /** Defines the end point of the arc */
  72057. endPoint: Vector2);
  72058. }
  72059. /**
  72060. * Represents a 2D path made up of multiple 2D points
  72061. */
  72062. export class Path2 {
  72063. private _points;
  72064. private _length;
  72065. /**
  72066. * If the path start and end point are the same
  72067. */
  72068. closed: boolean;
  72069. /**
  72070. * Creates a Path2 object from the starting 2D coordinates x and y.
  72071. * @param x the starting points x value
  72072. * @param y the starting points y value
  72073. */
  72074. constructor(x: number, y: number);
  72075. /**
  72076. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72077. * @param x the added points x value
  72078. * @param y the added points y value
  72079. * @returns the updated Path2.
  72080. */
  72081. addLineTo(x: number, y: number): Path2;
  72082. /**
  72083. * 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.
  72084. * @param midX middle point x value
  72085. * @param midY middle point y value
  72086. * @param endX end point x value
  72087. * @param endY end point y value
  72088. * @param numberOfSegments (default: 36)
  72089. * @returns the updated Path2.
  72090. */
  72091. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72092. /**
  72093. * Closes the Path2.
  72094. * @returns the Path2.
  72095. */
  72096. close(): Path2;
  72097. /**
  72098. * Gets the sum of the distance between each sequential point in the path
  72099. * @returns the Path2 total length (float).
  72100. */
  72101. length(): number;
  72102. /**
  72103. * Gets the points which construct the path
  72104. * @returns the Path2 internal array of points.
  72105. */
  72106. getPoints(): Vector2[];
  72107. /**
  72108. * Retreives the point at the distance aways from the starting point
  72109. * @param normalizedLengthPosition the length along the path to retreive the point from
  72110. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72111. */
  72112. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72113. /**
  72114. * Creates a new path starting from an x and y position
  72115. * @param x starting x value
  72116. * @param y starting y value
  72117. * @returns a new Path2 starting at the coordinates (x, y).
  72118. */
  72119. static StartingAt(x: number, y: number): Path2;
  72120. }
  72121. /**
  72122. * Represents a 3D path made up of multiple 3D points
  72123. */
  72124. export class Path3D {
  72125. /**
  72126. * an array of Vector3, the curve axis of the Path3D
  72127. */
  72128. path: Vector3[];
  72129. private _curve;
  72130. private _distances;
  72131. private _tangents;
  72132. private _normals;
  72133. private _binormals;
  72134. private _raw;
  72135. /**
  72136. * new Path3D(path, normal, raw)
  72137. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72138. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72139. * @param path an array of Vector3, the curve axis of the Path3D
  72140. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72141. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72142. */
  72143. constructor(
  72144. /**
  72145. * an array of Vector3, the curve axis of the Path3D
  72146. */
  72147. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72148. /**
  72149. * Returns the Path3D array of successive Vector3 designing its curve.
  72150. * @returns the Path3D array of successive Vector3 designing its curve.
  72151. */
  72152. getCurve(): Vector3[];
  72153. /**
  72154. * Returns an array populated with tangent vectors on each Path3D curve point.
  72155. * @returns an array populated with tangent vectors on each Path3D curve point.
  72156. */
  72157. getTangents(): Vector3[];
  72158. /**
  72159. * Returns an array populated with normal vectors on each Path3D curve point.
  72160. * @returns an array populated with normal vectors on each Path3D curve point.
  72161. */
  72162. getNormals(): Vector3[];
  72163. /**
  72164. * Returns an array populated with binormal vectors on each Path3D curve point.
  72165. * @returns an array populated with binormal vectors on each Path3D curve point.
  72166. */
  72167. getBinormals(): Vector3[];
  72168. /**
  72169. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72170. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72171. */
  72172. getDistances(): number[];
  72173. /**
  72174. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72175. * @param path path which all values are copied into the curves points
  72176. * @param firstNormal which should be projected onto the curve
  72177. * @returns the same object updated.
  72178. */
  72179. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72180. private _compute;
  72181. private _getFirstNonNullVector;
  72182. private _getLastNonNullVector;
  72183. private _normalVector;
  72184. }
  72185. /**
  72186. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72187. * A Curve3 is designed from a series of successive Vector3.
  72188. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72189. */
  72190. export class Curve3 {
  72191. private _points;
  72192. private _length;
  72193. /**
  72194. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72195. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72196. * @param v1 (Vector3) the control point
  72197. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72198. * @param nbPoints (integer) the wanted number of points in the curve
  72199. * @returns the created Curve3
  72200. */
  72201. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72202. /**
  72203. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72204. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72205. * @param v1 (Vector3) the first control point
  72206. * @param v2 (Vector3) the second control point
  72207. * @param v3 (Vector3) the end point of the Cubic Bezier
  72208. * @param nbPoints (integer) the wanted number of points in the curve
  72209. * @returns the created Curve3
  72210. */
  72211. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72212. /**
  72213. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72214. * @param p1 (Vector3) the origin point of the Hermite Spline
  72215. * @param t1 (Vector3) the tangent vector at the origin point
  72216. * @param p2 (Vector3) the end point of the Hermite Spline
  72217. * @param t2 (Vector3) the tangent vector at the end point
  72218. * @param nbPoints (integer) the wanted number of points in the curve
  72219. * @returns the created Curve3
  72220. */
  72221. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72222. /**
  72223. * Returns a Curve3 object along a CatmullRom Spline curve :
  72224. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72225. * @param nbPoints (integer) the wanted number of points between each curve control points
  72226. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72227. * @returns the created Curve3
  72228. */
  72229. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72230. /**
  72231. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72232. * A Curve3 is designed from a series of successive Vector3.
  72233. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72234. * @param points points which make up the curve
  72235. */
  72236. constructor(points: Vector3[]);
  72237. /**
  72238. * @returns the Curve3 stored array of successive Vector3
  72239. */
  72240. getPoints(): Vector3[];
  72241. /**
  72242. * @returns the computed length (float) of the curve.
  72243. */
  72244. length(): number;
  72245. /**
  72246. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72247. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72248. * curveA and curveB keep unchanged.
  72249. * @param curve the curve to continue from this curve
  72250. * @returns the newly constructed curve
  72251. */
  72252. continue(curve: DeepImmutable<Curve3>): Curve3;
  72253. private _computeLength;
  72254. }
  72255. }
  72256. declare module BABYLON {
  72257. /**
  72258. * This represents the main contract an easing function should follow.
  72259. * Easing functions are used throughout the animation system.
  72260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72261. */
  72262. export interface IEasingFunction {
  72263. /**
  72264. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72265. * of the easing function.
  72266. * The link below provides some of the most common examples of easing functions.
  72267. * @see https://easings.net/
  72268. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72269. * @returns the corresponding value on the curve defined by the easing function
  72270. */
  72271. ease(gradient: number): number;
  72272. }
  72273. /**
  72274. * Base class used for every default easing function.
  72275. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72276. */
  72277. export class EasingFunction implements IEasingFunction {
  72278. /**
  72279. * Interpolation follows the mathematical formula associated with the easing function.
  72280. */
  72281. static readonly EASINGMODE_EASEIN: number;
  72282. /**
  72283. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72284. */
  72285. static readonly EASINGMODE_EASEOUT: number;
  72286. /**
  72287. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72288. */
  72289. static readonly EASINGMODE_EASEINOUT: number;
  72290. private _easingMode;
  72291. /**
  72292. * Sets the easing mode of the current function.
  72293. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72294. */
  72295. setEasingMode(easingMode: number): void;
  72296. /**
  72297. * Gets the current easing mode.
  72298. * @returns the easing mode
  72299. */
  72300. getEasingMode(): number;
  72301. /**
  72302. * @hidden
  72303. */
  72304. easeInCore(gradient: number): number;
  72305. /**
  72306. * Given an input gradient between 0 and 1, this returns the corresponding value
  72307. * of the easing function.
  72308. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72309. * @returns the corresponding value on the curve defined by the easing function
  72310. */
  72311. ease(gradient: number): number;
  72312. }
  72313. /**
  72314. * Easing function with a circle shape (see link below).
  72315. * @see https://easings.net/#easeInCirc
  72316. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72317. */
  72318. export class CircleEase extends EasingFunction implements IEasingFunction {
  72319. /** @hidden */
  72320. easeInCore(gradient: number): number;
  72321. }
  72322. /**
  72323. * Easing function with a ease back shape (see link below).
  72324. * @see https://easings.net/#easeInBack
  72325. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72326. */
  72327. export class BackEase extends EasingFunction implements IEasingFunction {
  72328. /** Defines the amplitude of the function */
  72329. amplitude: number;
  72330. /**
  72331. * Instantiates a back ease easing
  72332. * @see https://easings.net/#easeInBack
  72333. * @param amplitude Defines the amplitude of the function
  72334. */
  72335. constructor(
  72336. /** Defines the amplitude of the function */
  72337. amplitude?: number);
  72338. /** @hidden */
  72339. easeInCore(gradient: number): number;
  72340. }
  72341. /**
  72342. * Easing function with a bouncing shape (see link below).
  72343. * @see https://easings.net/#easeInBounce
  72344. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72345. */
  72346. export class BounceEase extends EasingFunction implements IEasingFunction {
  72347. /** Defines the number of bounces */
  72348. bounces: number;
  72349. /** Defines the amplitude of the bounce */
  72350. bounciness: number;
  72351. /**
  72352. * Instantiates a bounce easing
  72353. * @see https://easings.net/#easeInBounce
  72354. * @param bounces Defines the number of bounces
  72355. * @param bounciness Defines the amplitude of the bounce
  72356. */
  72357. constructor(
  72358. /** Defines the number of bounces */
  72359. bounces?: number,
  72360. /** Defines the amplitude of the bounce */
  72361. bounciness?: number);
  72362. /** @hidden */
  72363. easeInCore(gradient: number): number;
  72364. }
  72365. /**
  72366. * Easing function with a power of 3 shape (see link below).
  72367. * @see https://easings.net/#easeInCubic
  72368. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72369. */
  72370. export class CubicEase extends EasingFunction implements IEasingFunction {
  72371. /** @hidden */
  72372. easeInCore(gradient: number): number;
  72373. }
  72374. /**
  72375. * Easing function with an elastic shape (see link below).
  72376. * @see https://easings.net/#easeInElastic
  72377. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72378. */
  72379. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72380. /** Defines the number of oscillations*/
  72381. oscillations: number;
  72382. /** Defines the amplitude of the oscillations*/
  72383. springiness: number;
  72384. /**
  72385. * Instantiates an elastic easing function
  72386. * @see https://easings.net/#easeInElastic
  72387. * @param oscillations Defines the number of oscillations
  72388. * @param springiness Defines the amplitude of the oscillations
  72389. */
  72390. constructor(
  72391. /** Defines the number of oscillations*/
  72392. oscillations?: number,
  72393. /** Defines the amplitude of the oscillations*/
  72394. springiness?: number);
  72395. /** @hidden */
  72396. easeInCore(gradient: number): number;
  72397. }
  72398. /**
  72399. * Easing function with an exponential shape (see link below).
  72400. * @see https://easings.net/#easeInExpo
  72401. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72402. */
  72403. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72404. /** Defines the exponent of the function */
  72405. exponent: number;
  72406. /**
  72407. * Instantiates an exponential easing function
  72408. * @see https://easings.net/#easeInExpo
  72409. * @param exponent Defines the exponent of the function
  72410. */
  72411. constructor(
  72412. /** Defines the exponent of the function */
  72413. exponent?: number);
  72414. /** @hidden */
  72415. easeInCore(gradient: number): number;
  72416. }
  72417. /**
  72418. * Easing function with a power shape (see link below).
  72419. * @see https://easings.net/#easeInQuad
  72420. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72421. */
  72422. export class PowerEase extends EasingFunction implements IEasingFunction {
  72423. /** Defines the power of the function */
  72424. power: number;
  72425. /**
  72426. * Instantiates an power base easing function
  72427. * @see https://easings.net/#easeInQuad
  72428. * @param power Defines the power of the function
  72429. */
  72430. constructor(
  72431. /** Defines the power of the function */
  72432. power?: number);
  72433. /** @hidden */
  72434. easeInCore(gradient: number): number;
  72435. }
  72436. /**
  72437. * Easing function with a power of 2 shape (see link below).
  72438. * @see https://easings.net/#easeInQuad
  72439. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72440. */
  72441. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72442. /** @hidden */
  72443. easeInCore(gradient: number): number;
  72444. }
  72445. /**
  72446. * Easing function with a power of 4 shape (see link below).
  72447. * @see https://easings.net/#easeInQuart
  72448. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72449. */
  72450. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72451. /** @hidden */
  72452. easeInCore(gradient: number): number;
  72453. }
  72454. /**
  72455. * Easing function with a power of 5 shape (see link below).
  72456. * @see https://easings.net/#easeInQuint
  72457. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72458. */
  72459. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72460. /** @hidden */
  72461. easeInCore(gradient: number): number;
  72462. }
  72463. /**
  72464. * Easing function with a sin shape (see link below).
  72465. * @see https://easings.net/#easeInSine
  72466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72467. */
  72468. export class SineEase extends EasingFunction implements IEasingFunction {
  72469. /** @hidden */
  72470. easeInCore(gradient: number): number;
  72471. }
  72472. /**
  72473. * Easing function with a bezier shape (see link below).
  72474. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72475. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72476. */
  72477. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72478. /** Defines the x component of the start tangent in the bezier curve */
  72479. x1: number;
  72480. /** Defines the y component of the start tangent in the bezier curve */
  72481. y1: number;
  72482. /** Defines the x component of the end tangent in the bezier curve */
  72483. x2: number;
  72484. /** Defines the y component of the end tangent in the bezier curve */
  72485. y2: number;
  72486. /**
  72487. * Instantiates a bezier function
  72488. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72489. * @param x1 Defines the x component of the start tangent in the bezier curve
  72490. * @param y1 Defines the y component of the start tangent in the bezier curve
  72491. * @param x2 Defines the x component of the end tangent in the bezier curve
  72492. * @param y2 Defines the y component of the end tangent in the bezier curve
  72493. */
  72494. constructor(
  72495. /** Defines the x component of the start tangent in the bezier curve */
  72496. x1?: number,
  72497. /** Defines the y component of the start tangent in the bezier curve */
  72498. y1?: number,
  72499. /** Defines the x component of the end tangent in the bezier curve */
  72500. x2?: number,
  72501. /** Defines the y component of the end tangent in the bezier curve */
  72502. y2?: number);
  72503. /** @hidden */
  72504. easeInCore(gradient: number): number;
  72505. }
  72506. }
  72507. declare module BABYLON {
  72508. /**
  72509. * Defines an interface which represents an animation key frame
  72510. */
  72511. export interface IAnimationKey {
  72512. /**
  72513. * Frame of the key frame
  72514. */
  72515. frame: number;
  72516. /**
  72517. * Value at the specifies key frame
  72518. */
  72519. value: any;
  72520. /**
  72521. * The input tangent for the cubic hermite spline
  72522. */
  72523. inTangent?: any;
  72524. /**
  72525. * The output tangent for the cubic hermite spline
  72526. */
  72527. outTangent?: any;
  72528. /**
  72529. * The animation interpolation type
  72530. */
  72531. interpolation?: AnimationKeyInterpolation;
  72532. }
  72533. /**
  72534. * Enum for the animation key frame interpolation type
  72535. */
  72536. export enum AnimationKeyInterpolation {
  72537. /**
  72538. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72539. */
  72540. STEP = 1
  72541. }
  72542. }
  72543. declare module BABYLON {
  72544. /**
  72545. * Represents the range of an animation
  72546. */
  72547. export class AnimationRange {
  72548. /**The name of the animation range**/
  72549. name: string;
  72550. /**The starting frame of the animation */
  72551. from: number;
  72552. /**The ending frame of the animation*/
  72553. to: number;
  72554. /**
  72555. * Initializes the range of an animation
  72556. * @param name The name of the animation range
  72557. * @param from The starting frame of the animation
  72558. * @param to The ending frame of the animation
  72559. */
  72560. constructor(
  72561. /**The name of the animation range**/
  72562. name: string,
  72563. /**The starting frame of the animation */
  72564. from: number,
  72565. /**The ending frame of the animation*/
  72566. to: number);
  72567. /**
  72568. * Makes a copy of the animation range
  72569. * @returns A copy of the animation range
  72570. */
  72571. clone(): AnimationRange;
  72572. }
  72573. }
  72574. declare module BABYLON {
  72575. /**
  72576. * Composed of a frame, and an action function
  72577. */
  72578. export class AnimationEvent {
  72579. /** The frame for which the event is triggered **/
  72580. frame: number;
  72581. /** The event to perform when triggered **/
  72582. action: (currentFrame: number) => void;
  72583. /** Specifies if the event should be triggered only once**/
  72584. onlyOnce?: boolean | undefined;
  72585. /**
  72586. * Specifies if the animation event is done
  72587. */
  72588. isDone: boolean;
  72589. /**
  72590. * Initializes the animation event
  72591. * @param frame The frame for which the event is triggered
  72592. * @param action The event to perform when triggered
  72593. * @param onlyOnce Specifies if the event should be triggered only once
  72594. */
  72595. constructor(
  72596. /** The frame for which the event is triggered **/
  72597. frame: number,
  72598. /** The event to perform when triggered **/
  72599. action: (currentFrame: number) => void,
  72600. /** Specifies if the event should be triggered only once**/
  72601. onlyOnce?: boolean | undefined);
  72602. /** @hidden */
  72603. _clone(): AnimationEvent;
  72604. }
  72605. }
  72606. declare module BABYLON {
  72607. /**
  72608. * Interface used to define a behavior
  72609. */
  72610. export interface Behavior<T> {
  72611. /** gets or sets behavior's name */
  72612. name: string;
  72613. /**
  72614. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72615. */
  72616. init(): void;
  72617. /**
  72618. * Called when the behavior is attached to a target
  72619. * @param target defines the target where the behavior is attached to
  72620. */
  72621. attach(target: T): void;
  72622. /**
  72623. * Called when the behavior is detached from its target
  72624. */
  72625. detach(): void;
  72626. }
  72627. /**
  72628. * Interface implemented by classes supporting behaviors
  72629. */
  72630. export interface IBehaviorAware<T> {
  72631. /**
  72632. * Attach a behavior
  72633. * @param behavior defines the behavior to attach
  72634. * @returns the current host
  72635. */
  72636. addBehavior(behavior: Behavior<T>): T;
  72637. /**
  72638. * Remove a behavior from the current object
  72639. * @param behavior defines the behavior to detach
  72640. * @returns the current host
  72641. */
  72642. removeBehavior(behavior: Behavior<T>): T;
  72643. /**
  72644. * Gets a behavior using its name to search
  72645. * @param name defines the name to search
  72646. * @returns the behavior or null if not found
  72647. */
  72648. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72649. }
  72650. }
  72651. declare module BABYLON {
  72652. /**
  72653. * Defines an array and its length.
  72654. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72655. */
  72656. export interface ISmartArrayLike<T> {
  72657. /**
  72658. * The data of the array.
  72659. */
  72660. data: Array<T>;
  72661. /**
  72662. * The active length of the array.
  72663. */
  72664. length: number;
  72665. }
  72666. /**
  72667. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72668. */
  72669. export class SmartArray<T> implements ISmartArrayLike<T> {
  72670. /**
  72671. * The full set of data from the array.
  72672. */
  72673. data: Array<T>;
  72674. /**
  72675. * The active length of the array.
  72676. */
  72677. length: number;
  72678. protected _id: number;
  72679. /**
  72680. * Instantiates a Smart Array.
  72681. * @param capacity defines the default capacity of the array.
  72682. */
  72683. constructor(capacity: number);
  72684. /**
  72685. * Pushes a value at the end of the active data.
  72686. * @param value defines the object to push in the array.
  72687. */
  72688. push(value: T): void;
  72689. /**
  72690. * Iterates over the active data and apply the lambda to them.
  72691. * @param func defines the action to apply on each value.
  72692. */
  72693. forEach(func: (content: T) => void): void;
  72694. /**
  72695. * Sorts the full sets of data.
  72696. * @param compareFn defines the comparison function to apply.
  72697. */
  72698. sort(compareFn: (a: T, b: T) => number): void;
  72699. /**
  72700. * Resets the active data to an empty array.
  72701. */
  72702. reset(): void;
  72703. /**
  72704. * Releases all the data from the array as well as the array.
  72705. */
  72706. dispose(): void;
  72707. /**
  72708. * Concats the active data with a given array.
  72709. * @param array defines the data to concatenate with.
  72710. */
  72711. concat(array: any): void;
  72712. /**
  72713. * Returns the position of a value in the active data.
  72714. * @param value defines the value to find the index for
  72715. * @returns the index if found in the active data otherwise -1
  72716. */
  72717. indexOf(value: T): number;
  72718. /**
  72719. * Returns whether an element is part of the active data.
  72720. * @param value defines the value to look for
  72721. * @returns true if found in the active data otherwise false
  72722. */
  72723. contains(value: T): boolean;
  72724. private static _GlobalId;
  72725. }
  72726. /**
  72727. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72728. * The data in this array can only be present once
  72729. */
  72730. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72731. private _duplicateId;
  72732. /**
  72733. * Pushes a value at the end of the active data.
  72734. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72735. * @param value defines the object to push in the array.
  72736. */
  72737. push(value: T): void;
  72738. /**
  72739. * Pushes a value at the end of the active data.
  72740. * If the data is already present, it won t be added again
  72741. * @param value defines the object to push in the array.
  72742. * @returns true if added false if it was already present
  72743. */
  72744. pushNoDuplicate(value: T): boolean;
  72745. /**
  72746. * Resets the active data to an empty array.
  72747. */
  72748. reset(): void;
  72749. /**
  72750. * Concats the active data with a given array.
  72751. * This ensures no dupplicate will be present in the result.
  72752. * @param array defines the data to concatenate with.
  72753. */
  72754. concatWithNoDuplicate(array: any): void;
  72755. }
  72756. }
  72757. declare module BABYLON {
  72758. /**
  72759. * @ignore
  72760. * This is a list of all the different input types that are available in the application.
  72761. * Fo instance: ArcRotateCameraGamepadInput...
  72762. */
  72763. export var CameraInputTypes: {};
  72764. /**
  72765. * This is the contract to implement in order to create a new input class.
  72766. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72767. */
  72768. export interface ICameraInput<TCamera extends Camera> {
  72769. /**
  72770. * Defines the camera the input is attached to.
  72771. */
  72772. camera: Nullable<TCamera>;
  72773. /**
  72774. * Gets the class name of the current intput.
  72775. * @returns the class name
  72776. */
  72777. getClassName(): string;
  72778. /**
  72779. * Get the friendly name associated with the input class.
  72780. * @returns the input friendly name
  72781. */
  72782. getSimpleName(): string;
  72783. /**
  72784. * Attach the input controls to a specific dom element to get the input from.
  72785. * @param element Defines the element the controls should be listened from
  72786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72787. */
  72788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72789. /**
  72790. * Detach the current controls from the specified dom element.
  72791. * @param element Defines the element to stop listening the inputs from
  72792. */
  72793. detachControl(element: Nullable<HTMLElement>): void;
  72794. /**
  72795. * Update the current camera state depending on the inputs that have been used this frame.
  72796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72797. */
  72798. checkInputs?: () => void;
  72799. }
  72800. /**
  72801. * Represents a map of input types to input instance or input index to input instance.
  72802. */
  72803. export interface CameraInputsMap<TCamera extends Camera> {
  72804. /**
  72805. * Accessor to the input by input type.
  72806. */
  72807. [name: string]: ICameraInput<TCamera>;
  72808. /**
  72809. * Accessor to the input by input index.
  72810. */
  72811. [idx: number]: ICameraInput<TCamera>;
  72812. }
  72813. /**
  72814. * This represents the input manager used within a camera.
  72815. * It helps dealing with all the different kind of input attached to a camera.
  72816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72817. */
  72818. export class CameraInputsManager<TCamera extends Camera> {
  72819. /**
  72820. * Defines the list of inputs attahed to the camera.
  72821. */
  72822. attached: CameraInputsMap<TCamera>;
  72823. /**
  72824. * Defines the dom element the camera is collecting inputs from.
  72825. * This is null if the controls have not been attached.
  72826. */
  72827. attachedElement: Nullable<HTMLElement>;
  72828. /**
  72829. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72830. */
  72831. noPreventDefault: boolean;
  72832. /**
  72833. * Defined the camera the input manager belongs to.
  72834. */
  72835. camera: TCamera;
  72836. /**
  72837. * Update the current camera state depending on the inputs that have been used this frame.
  72838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72839. */
  72840. checkInputs: () => void;
  72841. /**
  72842. * Instantiate a new Camera Input Manager.
  72843. * @param camera Defines the camera the input manager blongs to
  72844. */
  72845. constructor(camera: TCamera);
  72846. /**
  72847. * Add an input method to a camera
  72848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72849. * @param input camera input method
  72850. */
  72851. add(input: ICameraInput<TCamera>): void;
  72852. /**
  72853. * Remove a specific input method from a camera
  72854. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72855. * @param inputToRemove camera input method
  72856. */
  72857. remove(inputToRemove: ICameraInput<TCamera>): void;
  72858. /**
  72859. * Remove a specific input type from a camera
  72860. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72861. * @param inputType the type of the input to remove
  72862. */
  72863. removeByType(inputType: string): void;
  72864. private _addCheckInputs;
  72865. /**
  72866. * Attach the input controls to the currently attached dom element to listen the events from.
  72867. * @param input Defines the input to attach
  72868. */
  72869. attachInput(input: ICameraInput<TCamera>): void;
  72870. /**
  72871. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72872. * @param element Defines the dom element to collect the events from
  72873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72874. */
  72875. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72876. /**
  72877. * Detach the current manager inputs controls from a specific dom element.
  72878. * @param element Defines the dom element to collect the events from
  72879. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72880. */
  72881. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72882. /**
  72883. * Rebuild the dynamic inputCheck function from the current list of
  72884. * defined inputs in the manager.
  72885. */
  72886. rebuildInputCheck(): void;
  72887. /**
  72888. * Remove all attached input methods from a camera
  72889. */
  72890. clear(): void;
  72891. /**
  72892. * Serialize the current input manager attached to a camera.
  72893. * This ensures than once parsed,
  72894. * the input associated to the camera will be identical to the current ones
  72895. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72896. */
  72897. serialize(serializedCamera: any): void;
  72898. /**
  72899. * Parses an input manager serialized JSON to restore the previous list of inputs
  72900. * and states associated to a camera.
  72901. * @param parsedCamera Defines the JSON to parse
  72902. */
  72903. parse(parsedCamera: any): void;
  72904. }
  72905. }
  72906. declare module BABYLON {
  72907. /**
  72908. * Class used to store data that will be store in GPU memory
  72909. */
  72910. export class Buffer {
  72911. private _engine;
  72912. private _buffer;
  72913. /** @hidden */
  72914. _data: Nullable<DataArray>;
  72915. private _updatable;
  72916. private _instanced;
  72917. /**
  72918. * Gets the byte stride.
  72919. */
  72920. readonly byteStride: number;
  72921. /**
  72922. * Constructor
  72923. * @param engine the engine
  72924. * @param data the data to use for this buffer
  72925. * @param updatable whether the data is updatable
  72926. * @param stride the stride (optional)
  72927. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72928. * @param instanced whether the buffer is instanced (optional)
  72929. * @param useBytes set to true if the stride in in bytes (optional)
  72930. */
  72931. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72932. /**
  72933. * Create a new VertexBuffer based on the current buffer
  72934. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72935. * @param offset defines offset in the buffer (0 by default)
  72936. * @param size defines the size in floats of attributes (position is 3 for instance)
  72937. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72938. * @param instanced defines if the vertex buffer contains indexed data
  72939. * @param useBytes defines if the offset and stride are in bytes
  72940. * @returns the new vertex buffer
  72941. */
  72942. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72943. /**
  72944. * Gets a boolean indicating if the Buffer is updatable?
  72945. * @returns true if the buffer is updatable
  72946. */
  72947. isUpdatable(): boolean;
  72948. /**
  72949. * Gets current buffer's data
  72950. * @returns a DataArray or null
  72951. */
  72952. getData(): Nullable<DataArray>;
  72953. /**
  72954. * Gets underlying native buffer
  72955. * @returns underlying native buffer
  72956. */
  72957. getBuffer(): Nullable<DataBuffer>;
  72958. /**
  72959. * Gets the stride in float32 units (i.e. byte stride / 4).
  72960. * May not be an integer if the byte stride is not divisible by 4.
  72961. * DEPRECATED. Use byteStride instead.
  72962. * @returns the stride in float32 units
  72963. */
  72964. getStrideSize(): number;
  72965. /**
  72966. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72967. * @param data defines the data to store
  72968. */
  72969. create(data?: Nullable<DataArray>): void;
  72970. /** @hidden */
  72971. _rebuild(): void;
  72972. /**
  72973. * Update current buffer data
  72974. * @param data defines the data to store
  72975. */
  72976. update(data: DataArray): void;
  72977. /**
  72978. * Updates the data directly.
  72979. * @param data the new data
  72980. * @param offset the new offset
  72981. * @param vertexCount the vertex count (optional)
  72982. * @param useBytes set to true if the offset is in bytes
  72983. */
  72984. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72985. /**
  72986. * Release all resources
  72987. */
  72988. dispose(): void;
  72989. }
  72990. /**
  72991. * Specialized buffer used to store vertex data
  72992. */
  72993. export class VertexBuffer {
  72994. /** @hidden */
  72995. _buffer: Buffer;
  72996. private _kind;
  72997. private _size;
  72998. private _ownsBuffer;
  72999. private _instanced;
  73000. private _instanceDivisor;
  73001. /**
  73002. * The byte type.
  73003. */
  73004. static readonly BYTE: number;
  73005. /**
  73006. * The unsigned byte type.
  73007. */
  73008. static readonly UNSIGNED_BYTE: number;
  73009. /**
  73010. * The short type.
  73011. */
  73012. static readonly SHORT: number;
  73013. /**
  73014. * The unsigned short type.
  73015. */
  73016. static readonly UNSIGNED_SHORT: number;
  73017. /**
  73018. * The integer type.
  73019. */
  73020. static readonly INT: number;
  73021. /**
  73022. * The unsigned integer type.
  73023. */
  73024. static readonly UNSIGNED_INT: number;
  73025. /**
  73026. * The float type.
  73027. */
  73028. static readonly FLOAT: number;
  73029. /**
  73030. * Gets or sets the instance divisor when in instanced mode
  73031. */
  73032. instanceDivisor: number;
  73033. /**
  73034. * Gets the byte stride.
  73035. */
  73036. readonly byteStride: number;
  73037. /**
  73038. * Gets the byte offset.
  73039. */
  73040. readonly byteOffset: number;
  73041. /**
  73042. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73043. */
  73044. readonly normalized: boolean;
  73045. /**
  73046. * Gets the data type of each component in the array.
  73047. */
  73048. readonly type: number;
  73049. /**
  73050. * Constructor
  73051. * @param engine the engine
  73052. * @param data the data to use for this vertex buffer
  73053. * @param kind the vertex buffer kind
  73054. * @param updatable whether the data is updatable
  73055. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73056. * @param stride the stride (optional)
  73057. * @param instanced whether the buffer is instanced (optional)
  73058. * @param offset the offset of the data (optional)
  73059. * @param size the number of components (optional)
  73060. * @param type the type of the component (optional)
  73061. * @param normalized whether the data contains normalized data (optional)
  73062. * @param useBytes set to true if stride and offset are in bytes (optional)
  73063. */
  73064. 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);
  73065. /** @hidden */
  73066. _rebuild(): void;
  73067. /**
  73068. * Returns the kind of the VertexBuffer (string)
  73069. * @returns a string
  73070. */
  73071. getKind(): string;
  73072. /**
  73073. * Gets a boolean indicating if the VertexBuffer is updatable?
  73074. * @returns true if the buffer is updatable
  73075. */
  73076. isUpdatable(): boolean;
  73077. /**
  73078. * Gets current buffer's data
  73079. * @returns a DataArray or null
  73080. */
  73081. getData(): Nullable<DataArray>;
  73082. /**
  73083. * Gets underlying native buffer
  73084. * @returns underlying native buffer
  73085. */
  73086. getBuffer(): Nullable<DataBuffer>;
  73087. /**
  73088. * Gets the stride in float32 units (i.e. byte stride / 4).
  73089. * May not be an integer if the byte stride is not divisible by 4.
  73090. * DEPRECATED. Use byteStride instead.
  73091. * @returns the stride in float32 units
  73092. */
  73093. getStrideSize(): number;
  73094. /**
  73095. * Returns the offset as a multiple of the type byte length.
  73096. * DEPRECATED. Use byteOffset instead.
  73097. * @returns the offset in bytes
  73098. */
  73099. getOffset(): number;
  73100. /**
  73101. * Returns the number of components per vertex attribute (integer)
  73102. * @returns the size in float
  73103. */
  73104. getSize(): number;
  73105. /**
  73106. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73107. * @returns true if this buffer is instanced
  73108. */
  73109. getIsInstanced(): boolean;
  73110. /**
  73111. * Returns the instancing divisor, zero for non-instanced (integer).
  73112. * @returns a number
  73113. */
  73114. getInstanceDivisor(): number;
  73115. /**
  73116. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73117. * @param data defines the data to store
  73118. */
  73119. create(data?: DataArray): void;
  73120. /**
  73121. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73122. * This function will create a new buffer if the current one is not updatable
  73123. * @param data defines the data to store
  73124. */
  73125. update(data: DataArray): void;
  73126. /**
  73127. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73128. * Returns the directly updated WebGLBuffer.
  73129. * @param data the new data
  73130. * @param offset the new offset
  73131. * @param useBytes set to true if the offset is in bytes
  73132. */
  73133. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73134. /**
  73135. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73136. */
  73137. dispose(): void;
  73138. /**
  73139. * Enumerates each value of this vertex buffer as numbers.
  73140. * @param count the number of values to enumerate
  73141. * @param callback the callback function called for each value
  73142. */
  73143. forEach(count: number, callback: (value: number, index: number) => void): void;
  73144. /**
  73145. * Positions
  73146. */
  73147. static readonly PositionKind: string;
  73148. /**
  73149. * Normals
  73150. */
  73151. static readonly NormalKind: string;
  73152. /**
  73153. * Tangents
  73154. */
  73155. static readonly TangentKind: string;
  73156. /**
  73157. * Texture coordinates
  73158. */
  73159. static readonly UVKind: string;
  73160. /**
  73161. * Texture coordinates 2
  73162. */
  73163. static readonly UV2Kind: string;
  73164. /**
  73165. * Texture coordinates 3
  73166. */
  73167. static readonly UV3Kind: string;
  73168. /**
  73169. * Texture coordinates 4
  73170. */
  73171. static readonly UV4Kind: string;
  73172. /**
  73173. * Texture coordinates 5
  73174. */
  73175. static readonly UV5Kind: string;
  73176. /**
  73177. * Texture coordinates 6
  73178. */
  73179. static readonly UV6Kind: string;
  73180. /**
  73181. * Colors
  73182. */
  73183. static readonly ColorKind: string;
  73184. /**
  73185. * Matrix indices (for bones)
  73186. */
  73187. static readonly MatricesIndicesKind: string;
  73188. /**
  73189. * Matrix weights (for bones)
  73190. */
  73191. static readonly MatricesWeightsKind: string;
  73192. /**
  73193. * Additional matrix indices (for bones)
  73194. */
  73195. static readonly MatricesIndicesExtraKind: string;
  73196. /**
  73197. * Additional matrix weights (for bones)
  73198. */
  73199. static readonly MatricesWeightsExtraKind: string;
  73200. /**
  73201. * Deduces the stride given a kind.
  73202. * @param kind The kind string to deduce
  73203. * @returns The deduced stride
  73204. */
  73205. static DeduceStride(kind: string): number;
  73206. /**
  73207. * Gets the byte length of the given type.
  73208. * @param type the type
  73209. * @returns the number of bytes
  73210. */
  73211. static GetTypeByteLength(type: number): number;
  73212. /**
  73213. * Enumerates each value of the given parameters as numbers.
  73214. * @param data the data to enumerate
  73215. * @param byteOffset the byte offset of the data
  73216. * @param byteStride the byte stride of the data
  73217. * @param componentCount the number of components per element
  73218. * @param componentType the type of the component
  73219. * @param count the number of values to enumerate
  73220. * @param normalized whether the data is normalized
  73221. * @param callback the callback function called for each value
  73222. */
  73223. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73224. private static _GetFloatValue;
  73225. }
  73226. }
  73227. declare module BABYLON {
  73228. /**
  73229. * @hidden
  73230. */
  73231. export class IntersectionInfo {
  73232. bu: Nullable<number>;
  73233. bv: Nullable<number>;
  73234. distance: number;
  73235. faceId: number;
  73236. subMeshId: number;
  73237. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73238. }
  73239. }
  73240. declare module BABYLON {
  73241. /**
  73242. * Represens a plane by the equation ax + by + cz + d = 0
  73243. */
  73244. export class Plane {
  73245. private static _TmpMatrix;
  73246. /**
  73247. * Normal of the plane (a,b,c)
  73248. */
  73249. normal: Vector3;
  73250. /**
  73251. * d component of the plane
  73252. */
  73253. d: number;
  73254. /**
  73255. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73256. * @param a a component of the plane
  73257. * @param b b component of the plane
  73258. * @param c c component of the plane
  73259. * @param d d component of the plane
  73260. */
  73261. constructor(a: number, b: number, c: number, d: number);
  73262. /**
  73263. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73264. */
  73265. asArray(): number[];
  73266. /**
  73267. * @returns a new plane copied from the current Plane.
  73268. */
  73269. clone(): Plane;
  73270. /**
  73271. * @returns the string "Plane".
  73272. */
  73273. getClassName(): string;
  73274. /**
  73275. * @returns the Plane hash code.
  73276. */
  73277. getHashCode(): number;
  73278. /**
  73279. * Normalize the current Plane in place.
  73280. * @returns the updated Plane.
  73281. */
  73282. normalize(): Plane;
  73283. /**
  73284. * Applies a transformation the plane and returns the result
  73285. * @param transformation the transformation matrix to be applied to the plane
  73286. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73287. */
  73288. transform(transformation: DeepImmutable<Matrix>): Plane;
  73289. /**
  73290. * Calcualtte the dot product between the point and the plane normal
  73291. * @param point point to calculate the dot product with
  73292. * @returns the dot product (float) of the point coordinates and the plane normal.
  73293. */
  73294. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73295. /**
  73296. * Updates the current Plane from the plane defined by the three given points.
  73297. * @param point1 one of the points used to contruct the plane
  73298. * @param point2 one of the points used to contruct the plane
  73299. * @param point3 one of the points used to contruct the plane
  73300. * @returns the updated Plane.
  73301. */
  73302. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73303. /**
  73304. * Checks if the plane is facing a given direction
  73305. * @param direction the direction to check if the plane is facing
  73306. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73307. * @returns True is the vector "direction" is the same side than the plane normal.
  73308. */
  73309. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73310. /**
  73311. * Calculates the distance to a point
  73312. * @param point point to calculate distance to
  73313. * @returns the signed distance (float) from the given point to the Plane.
  73314. */
  73315. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73316. /**
  73317. * Creates a plane from an array
  73318. * @param array the array to create a plane from
  73319. * @returns a new Plane from the given array.
  73320. */
  73321. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73322. /**
  73323. * Creates a plane from three points
  73324. * @param point1 point used to create the plane
  73325. * @param point2 point used to create the plane
  73326. * @param point3 point used to create the plane
  73327. * @returns a new Plane defined by the three given points.
  73328. */
  73329. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73330. /**
  73331. * Creates a plane from an origin point and a normal
  73332. * @param origin origin of the plane to be constructed
  73333. * @param normal normal of the plane to be constructed
  73334. * @returns a new Plane the normal vector to this plane at the given origin point.
  73335. * Note : the vector "normal" is updated because normalized.
  73336. */
  73337. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73338. /**
  73339. * Calculates the distance from a plane and a point
  73340. * @param origin origin of the plane to be constructed
  73341. * @param normal normal of the plane to be constructed
  73342. * @param point point to calculate distance to
  73343. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73344. */
  73345. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73346. }
  73347. }
  73348. declare module BABYLON {
  73349. /**
  73350. * Class used to store bounding sphere information
  73351. */
  73352. export class BoundingSphere {
  73353. /**
  73354. * Gets the center of the bounding sphere in local space
  73355. */
  73356. readonly center: Vector3;
  73357. /**
  73358. * Radius of the bounding sphere in local space
  73359. */
  73360. radius: number;
  73361. /**
  73362. * Gets the center of the bounding sphere in world space
  73363. */
  73364. readonly centerWorld: Vector3;
  73365. /**
  73366. * Radius of the bounding sphere in world space
  73367. */
  73368. radiusWorld: number;
  73369. /**
  73370. * Gets the minimum vector in local space
  73371. */
  73372. readonly minimum: Vector3;
  73373. /**
  73374. * Gets the maximum vector in local space
  73375. */
  73376. readonly maximum: Vector3;
  73377. private _worldMatrix;
  73378. private static readonly TmpVector3;
  73379. /**
  73380. * Creates a new bounding sphere
  73381. * @param min defines the minimum vector (in local space)
  73382. * @param max defines the maximum vector (in local space)
  73383. * @param worldMatrix defines the new world matrix
  73384. */
  73385. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73386. /**
  73387. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73388. * @param min defines the new minimum vector (in local space)
  73389. * @param max defines the new maximum vector (in local space)
  73390. * @param worldMatrix defines the new world matrix
  73391. */
  73392. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73393. /**
  73394. * Scale the current bounding sphere by applying a scale factor
  73395. * @param factor defines the scale factor to apply
  73396. * @returns the current bounding box
  73397. */
  73398. scale(factor: number): BoundingSphere;
  73399. /**
  73400. * Gets the world matrix of the bounding box
  73401. * @returns a matrix
  73402. */
  73403. getWorldMatrix(): DeepImmutable<Matrix>;
  73404. /** @hidden */
  73405. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73406. /**
  73407. * Tests if the bounding sphere is intersecting the frustum planes
  73408. * @param frustumPlanes defines the frustum planes to test
  73409. * @returns true if there is an intersection
  73410. */
  73411. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73412. /**
  73413. * Tests if the bounding sphere center is in between the frustum planes.
  73414. * Used for optimistic fast inclusion.
  73415. * @param frustumPlanes defines the frustum planes to test
  73416. * @returns true if the sphere center is in between the frustum planes
  73417. */
  73418. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73419. /**
  73420. * Tests if a point is inside the bounding sphere
  73421. * @param point defines the point to test
  73422. * @returns true if the point is inside the bounding sphere
  73423. */
  73424. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73425. /**
  73426. * Checks if two sphere intersct
  73427. * @param sphere0 sphere 0
  73428. * @param sphere1 sphere 1
  73429. * @returns true if the speres intersect
  73430. */
  73431. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73432. }
  73433. }
  73434. declare module BABYLON {
  73435. /**
  73436. * Class used to store bounding box information
  73437. */
  73438. export class BoundingBox implements ICullable {
  73439. /**
  73440. * Gets the 8 vectors representing the bounding box in local space
  73441. */
  73442. readonly vectors: Vector3[];
  73443. /**
  73444. * Gets the center of the bounding box in local space
  73445. */
  73446. readonly center: Vector3;
  73447. /**
  73448. * Gets the center of the bounding box in world space
  73449. */
  73450. readonly centerWorld: Vector3;
  73451. /**
  73452. * Gets the extend size in local space
  73453. */
  73454. readonly extendSize: Vector3;
  73455. /**
  73456. * Gets the extend size in world space
  73457. */
  73458. readonly extendSizeWorld: Vector3;
  73459. /**
  73460. * Gets the OBB (object bounding box) directions
  73461. */
  73462. readonly directions: Vector3[];
  73463. /**
  73464. * Gets the 8 vectors representing the bounding box in world space
  73465. */
  73466. readonly vectorsWorld: Vector3[];
  73467. /**
  73468. * Gets the minimum vector in world space
  73469. */
  73470. readonly minimumWorld: Vector3;
  73471. /**
  73472. * Gets the maximum vector in world space
  73473. */
  73474. readonly maximumWorld: Vector3;
  73475. /**
  73476. * Gets the minimum vector in local space
  73477. */
  73478. readonly minimum: Vector3;
  73479. /**
  73480. * Gets the maximum vector in local space
  73481. */
  73482. readonly maximum: Vector3;
  73483. private _worldMatrix;
  73484. private static readonly TmpVector3;
  73485. /**
  73486. * @hidden
  73487. */
  73488. _tag: number;
  73489. /**
  73490. * Creates a new bounding box
  73491. * @param min defines the minimum vector (in local space)
  73492. * @param max defines the maximum vector (in local space)
  73493. * @param worldMatrix defines the new world matrix
  73494. */
  73495. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73496. /**
  73497. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73498. * @param min defines the new minimum vector (in local space)
  73499. * @param max defines the new maximum vector (in local space)
  73500. * @param worldMatrix defines the new world matrix
  73501. */
  73502. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73503. /**
  73504. * Scale the current bounding box by applying a scale factor
  73505. * @param factor defines the scale factor to apply
  73506. * @returns the current bounding box
  73507. */
  73508. scale(factor: number): BoundingBox;
  73509. /**
  73510. * Gets the world matrix of the bounding box
  73511. * @returns a matrix
  73512. */
  73513. getWorldMatrix(): DeepImmutable<Matrix>;
  73514. /** @hidden */
  73515. _update(world: DeepImmutable<Matrix>): void;
  73516. /**
  73517. * Tests if the bounding box is intersecting the frustum planes
  73518. * @param frustumPlanes defines the frustum planes to test
  73519. * @returns true if there is an intersection
  73520. */
  73521. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73522. /**
  73523. * Tests if the bounding box is entirely inside the frustum planes
  73524. * @param frustumPlanes defines the frustum planes to test
  73525. * @returns true if there is an inclusion
  73526. */
  73527. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73528. /**
  73529. * Tests if a point is inside the bounding box
  73530. * @param point defines the point to test
  73531. * @returns true if the point is inside the bounding box
  73532. */
  73533. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73534. /**
  73535. * Tests if the bounding box intersects with a bounding sphere
  73536. * @param sphere defines the sphere to test
  73537. * @returns true if there is an intersection
  73538. */
  73539. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73540. /**
  73541. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73542. * @param min defines the min vector to use
  73543. * @param max defines the max vector to use
  73544. * @returns true if there is an intersection
  73545. */
  73546. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73547. /**
  73548. * Tests if two bounding boxes are intersections
  73549. * @param box0 defines the first box to test
  73550. * @param box1 defines the second box to test
  73551. * @returns true if there is an intersection
  73552. */
  73553. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73554. /**
  73555. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73556. * @param minPoint defines the minimum vector of the bounding box
  73557. * @param maxPoint defines the maximum vector of the bounding box
  73558. * @param sphereCenter defines the sphere center
  73559. * @param sphereRadius defines the sphere radius
  73560. * @returns true if there is an intersection
  73561. */
  73562. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73563. /**
  73564. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73565. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73566. * @param frustumPlanes defines the frustum planes to test
  73567. * @return true if there is an inclusion
  73568. */
  73569. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73570. /**
  73571. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73572. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73573. * @param frustumPlanes defines the frustum planes to test
  73574. * @return true if there is an intersection
  73575. */
  73576. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73577. }
  73578. }
  73579. declare module BABYLON {
  73580. /** @hidden */
  73581. export class Collider {
  73582. /** Define if a collision was found */
  73583. collisionFound: boolean;
  73584. /**
  73585. * Define last intersection point in local space
  73586. */
  73587. intersectionPoint: Vector3;
  73588. /**
  73589. * Define last collided mesh
  73590. */
  73591. collidedMesh: Nullable<AbstractMesh>;
  73592. private _collisionPoint;
  73593. private _planeIntersectionPoint;
  73594. private _tempVector;
  73595. private _tempVector2;
  73596. private _tempVector3;
  73597. private _tempVector4;
  73598. private _edge;
  73599. private _baseToVertex;
  73600. private _destinationPoint;
  73601. private _slidePlaneNormal;
  73602. private _displacementVector;
  73603. /** @hidden */
  73604. _radius: Vector3;
  73605. /** @hidden */
  73606. _retry: number;
  73607. private _velocity;
  73608. private _basePoint;
  73609. private _epsilon;
  73610. /** @hidden */
  73611. _velocityWorldLength: number;
  73612. /** @hidden */
  73613. _basePointWorld: Vector3;
  73614. private _velocityWorld;
  73615. private _normalizedVelocity;
  73616. /** @hidden */
  73617. _initialVelocity: Vector3;
  73618. /** @hidden */
  73619. _initialPosition: Vector3;
  73620. private _nearestDistance;
  73621. private _collisionMask;
  73622. collisionMask: number;
  73623. /**
  73624. * Gets the plane normal used to compute the sliding response (in local space)
  73625. */
  73626. readonly slidePlaneNormal: Vector3;
  73627. /** @hidden */
  73628. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73629. /** @hidden */
  73630. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73631. /** @hidden */
  73632. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73633. /** @hidden */
  73634. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73635. /** @hidden */
  73636. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73637. /** @hidden */
  73638. _getResponse(pos: Vector3, vel: Vector3): void;
  73639. }
  73640. }
  73641. declare module BABYLON {
  73642. /**
  73643. * Interface for cullable objects
  73644. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73645. */
  73646. export interface ICullable {
  73647. /**
  73648. * Checks if the object or part of the object is in the frustum
  73649. * @param frustumPlanes Camera near/planes
  73650. * @returns true if the object is in frustum otherwise false
  73651. */
  73652. isInFrustum(frustumPlanes: Plane[]): boolean;
  73653. /**
  73654. * Checks if a cullable object (mesh...) is in the camera frustum
  73655. * Unlike isInFrustum this cheks the full bounding box
  73656. * @param frustumPlanes Camera near/planes
  73657. * @returns true if the object is in frustum otherwise false
  73658. */
  73659. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73660. }
  73661. /**
  73662. * Info for a bounding data of a mesh
  73663. */
  73664. export class BoundingInfo implements ICullable {
  73665. /**
  73666. * Bounding box for the mesh
  73667. */
  73668. readonly boundingBox: BoundingBox;
  73669. /**
  73670. * Bounding sphere for the mesh
  73671. */
  73672. readonly boundingSphere: BoundingSphere;
  73673. private _isLocked;
  73674. private static readonly TmpVector3;
  73675. /**
  73676. * Constructs bounding info
  73677. * @param minimum min vector of the bounding box/sphere
  73678. * @param maximum max vector of the bounding box/sphere
  73679. * @param worldMatrix defines the new world matrix
  73680. */
  73681. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73682. /**
  73683. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73684. * @param min defines the new minimum vector (in local space)
  73685. * @param max defines the new maximum vector (in local space)
  73686. * @param worldMatrix defines the new world matrix
  73687. */
  73688. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73689. /**
  73690. * min vector of the bounding box/sphere
  73691. */
  73692. readonly minimum: Vector3;
  73693. /**
  73694. * max vector of the bounding box/sphere
  73695. */
  73696. readonly maximum: Vector3;
  73697. /**
  73698. * If the info is locked and won't be updated to avoid perf overhead
  73699. */
  73700. isLocked: boolean;
  73701. /**
  73702. * Updates the bounding sphere and box
  73703. * @param world world matrix to be used to update
  73704. */
  73705. update(world: DeepImmutable<Matrix>): void;
  73706. /**
  73707. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73708. * @param center New center of the bounding info
  73709. * @param extend New extend of the bounding info
  73710. * @returns the current bounding info
  73711. */
  73712. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73713. /**
  73714. * Scale the current bounding info by applying a scale factor
  73715. * @param factor defines the scale factor to apply
  73716. * @returns the current bounding info
  73717. */
  73718. scale(factor: number): BoundingInfo;
  73719. /**
  73720. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73721. * @param frustumPlanes defines the frustum to test
  73722. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73723. * @returns true if the bounding info is in the frustum planes
  73724. */
  73725. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73726. /**
  73727. * Gets the world distance between the min and max points of the bounding box
  73728. */
  73729. readonly diagonalLength: number;
  73730. /**
  73731. * Checks if a cullable object (mesh...) is in the camera frustum
  73732. * Unlike isInFrustum this cheks the full bounding box
  73733. * @param frustumPlanes Camera near/planes
  73734. * @returns true if the object is in frustum otherwise false
  73735. */
  73736. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73737. /** @hidden */
  73738. _checkCollision(collider: Collider): boolean;
  73739. /**
  73740. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73741. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73742. * @param point the point to check intersection with
  73743. * @returns if the point intersects
  73744. */
  73745. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73746. /**
  73747. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73748. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73749. * @param boundingInfo the bounding info to check intersection with
  73750. * @param precise if the intersection should be done using OBB
  73751. * @returns if the bounding info intersects
  73752. */
  73753. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73754. }
  73755. }
  73756. declare module BABYLON {
  73757. /**
  73758. * Extracts minimum and maximum values from a list of indexed positions
  73759. * @param positions defines the positions to use
  73760. * @param indices defines the indices to the positions
  73761. * @param indexStart defines the start index
  73762. * @param indexCount defines the end index
  73763. * @param bias defines bias value to add to the result
  73764. * @return minimum and maximum values
  73765. */
  73766. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73767. minimum: Vector3;
  73768. maximum: Vector3;
  73769. };
  73770. /**
  73771. * Extracts minimum and maximum values from a list of positions
  73772. * @param positions defines the positions to use
  73773. * @param start defines the start index in the positions array
  73774. * @param count defines the number of positions to handle
  73775. * @param bias defines bias value to add to the result
  73776. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73777. * @return minimum and maximum values
  73778. */
  73779. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73780. minimum: Vector3;
  73781. maximum: Vector3;
  73782. };
  73783. }
  73784. declare module BABYLON {
  73785. /** @hidden */
  73786. export class WebGLDataBuffer extends DataBuffer {
  73787. private _buffer;
  73788. constructor(resource: WebGLBuffer);
  73789. readonly underlyingResource: any;
  73790. }
  73791. }
  73792. declare module BABYLON {
  73793. /** @hidden */
  73794. export class WebGLPipelineContext implements IPipelineContext {
  73795. engine: ThinEngine;
  73796. program: Nullable<WebGLProgram>;
  73797. context?: WebGLRenderingContext;
  73798. vertexShader?: WebGLShader;
  73799. fragmentShader?: WebGLShader;
  73800. isParallelCompiled: boolean;
  73801. onCompiled?: () => void;
  73802. transformFeedback?: WebGLTransformFeedback | null;
  73803. readonly isAsync: boolean;
  73804. readonly isReady: boolean;
  73805. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73806. }
  73807. }
  73808. declare module BABYLON {
  73809. interface ThinEngine {
  73810. /**
  73811. * Create an uniform buffer
  73812. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73813. * @param elements defines the content of the uniform buffer
  73814. * @returns the webGL uniform buffer
  73815. */
  73816. createUniformBuffer(elements: FloatArray): DataBuffer;
  73817. /**
  73818. * Create a dynamic uniform buffer
  73819. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73820. * @param elements defines the content of the uniform buffer
  73821. * @returns the webGL uniform buffer
  73822. */
  73823. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73824. /**
  73825. * Update an existing uniform buffer
  73826. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73827. * @param uniformBuffer defines the target uniform buffer
  73828. * @param elements defines the content to update
  73829. * @param offset defines the offset in the uniform buffer where update should start
  73830. * @param count defines the size of the data to update
  73831. */
  73832. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73833. /**
  73834. * Bind an uniform buffer to the current webGL context
  73835. * @param buffer defines the buffer to bind
  73836. */
  73837. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73838. /**
  73839. * Bind a buffer to the current webGL context at a given location
  73840. * @param buffer defines the buffer to bind
  73841. * @param location defines the index where to bind the buffer
  73842. */
  73843. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73844. /**
  73845. * Bind a specific block at a given index in a specific shader program
  73846. * @param pipelineContext defines the pipeline context to use
  73847. * @param blockName defines the block name
  73848. * @param index defines the index where to bind the block
  73849. */
  73850. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73851. }
  73852. }
  73853. declare module BABYLON {
  73854. /**
  73855. * Uniform buffer objects.
  73856. *
  73857. * Handles blocks of uniform on the GPU.
  73858. *
  73859. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73860. *
  73861. * For more information, please refer to :
  73862. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73863. */
  73864. export class UniformBuffer {
  73865. private _engine;
  73866. private _buffer;
  73867. private _data;
  73868. private _bufferData;
  73869. private _dynamic?;
  73870. private _uniformLocations;
  73871. private _uniformSizes;
  73872. private _uniformLocationPointer;
  73873. private _needSync;
  73874. private _noUBO;
  73875. private _currentEffect;
  73876. private static _MAX_UNIFORM_SIZE;
  73877. private static _tempBuffer;
  73878. /**
  73879. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73880. * This is dynamic to allow compat with webgl 1 and 2.
  73881. * You will need to pass the name of the uniform as well as the value.
  73882. */
  73883. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73884. /**
  73885. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73886. * This is dynamic to allow compat with webgl 1 and 2.
  73887. * You will need to pass the name of the uniform as well as the value.
  73888. */
  73889. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73890. /**
  73891. * Lambda to Update a single float in a uniform buffer.
  73892. * This is dynamic to allow compat with webgl 1 and 2.
  73893. * You will need to pass the name of the uniform as well as the value.
  73894. */
  73895. updateFloat: (name: string, x: number) => void;
  73896. /**
  73897. * Lambda to Update a vec2 of float in a uniform buffer.
  73898. * This is dynamic to allow compat with webgl 1 and 2.
  73899. * You will need to pass the name of the uniform as well as the value.
  73900. */
  73901. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73902. /**
  73903. * Lambda to Update a vec3 of float in a uniform buffer.
  73904. * This is dynamic to allow compat with webgl 1 and 2.
  73905. * You will need to pass the name of the uniform as well as the value.
  73906. */
  73907. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73908. /**
  73909. * Lambda to Update a vec4 of float in a uniform buffer.
  73910. * This is dynamic to allow compat with webgl 1 and 2.
  73911. * You will need to pass the name of the uniform as well as the value.
  73912. */
  73913. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73914. /**
  73915. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73916. * This is dynamic to allow compat with webgl 1 and 2.
  73917. * You will need to pass the name of the uniform as well as the value.
  73918. */
  73919. updateMatrix: (name: string, mat: Matrix) => void;
  73920. /**
  73921. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73922. * This is dynamic to allow compat with webgl 1 and 2.
  73923. * You will need to pass the name of the uniform as well as the value.
  73924. */
  73925. updateVector3: (name: string, vector: Vector3) => void;
  73926. /**
  73927. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73928. * This is dynamic to allow compat with webgl 1 and 2.
  73929. * You will need to pass the name of the uniform as well as the value.
  73930. */
  73931. updateVector4: (name: string, vector: Vector4) => void;
  73932. /**
  73933. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73934. * This is dynamic to allow compat with webgl 1 and 2.
  73935. * You will need to pass the name of the uniform as well as the value.
  73936. */
  73937. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73938. /**
  73939. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73940. * This is dynamic to allow compat with webgl 1 and 2.
  73941. * You will need to pass the name of the uniform as well as the value.
  73942. */
  73943. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73944. /**
  73945. * Instantiates a new Uniform buffer objects.
  73946. *
  73947. * Handles blocks of uniform on the GPU.
  73948. *
  73949. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73950. *
  73951. * For more information, please refer to :
  73952. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73953. * @param engine Define the engine the buffer is associated with
  73954. * @param data Define the data contained in the buffer
  73955. * @param dynamic Define if the buffer is updatable
  73956. */
  73957. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73958. /**
  73959. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73960. * or just falling back on setUniformXXX calls.
  73961. */
  73962. readonly useUbo: boolean;
  73963. /**
  73964. * Indicates if the WebGL underlying uniform buffer is in sync
  73965. * with the javascript cache data.
  73966. */
  73967. readonly isSync: boolean;
  73968. /**
  73969. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73970. * Also, a dynamic UniformBuffer will disable cache verification and always
  73971. * update the underlying WebGL uniform buffer to the GPU.
  73972. * @returns if Dynamic, otherwise false
  73973. */
  73974. isDynamic(): boolean;
  73975. /**
  73976. * The data cache on JS side.
  73977. * @returns the underlying data as a float array
  73978. */
  73979. getData(): Float32Array;
  73980. /**
  73981. * The underlying WebGL Uniform buffer.
  73982. * @returns the webgl buffer
  73983. */
  73984. getBuffer(): Nullable<DataBuffer>;
  73985. /**
  73986. * std140 layout specifies how to align data within an UBO structure.
  73987. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73988. * for specs.
  73989. */
  73990. private _fillAlignment;
  73991. /**
  73992. * Adds an uniform in the buffer.
  73993. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73994. * for the layout to be correct !
  73995. * @param name Name of the uniform, as used in the uniform block in the shader.
  73996. * @param size Data size, or data directly.
  73997. */
  73998. addUniform(name: string, size: number | number[]): void;
  73999. /**
  74000. * Adds a Matrix 4x4 to the uniform buffer.
  74001. * @param name Name of the uniform, as used in the uniform block in the shader.
  74002. * @param mat A 4x4 matrix.
  74003. */
  74004. addMatrix(name: string, mat: Matrix): void;
  74005. /**
  74006. * Adds a vec2 to the uniform buffer.
  74007. * @param name Name of the uniform, as used in the uniform block in the shader.
  74008. * @param x Define the x component value of the vec2
  74009. * @param y Define the y component value of the vec2
  74010. */
  74011. addFloat2(name: string, x: number, y: number): void;
  74012. /**
  74013. * Adds a vec3 to the uniform buffer.
  74014. * @param name Name of the uniform, as used in the uniform block in the shader.
  74015. * @param x Define the x component value of the vec3
  74016. * @param y Define the y component value of the vec3
  74017. * @param z Define the z component value of the vec3
  74018. */
  74019. addFloat3(name: string, x: number, y: number, z: number): void;
  74020. /**
  74021. * Adds a vec3 to the uniform buffer.
  74022. * @param name Name of the uniform, as used in the uniform block in the shader.
  74023. * @param color Define the vec3 from a Color
  74024. */
  74025. addColor3(name: string, color: Color3): void;
  74026. /**
  74027. * Adds a vec4 to the uniform buffer.
  74028. * @param name Name of the uniform, as used in the uniform block in the shader.
  74029. * @param color Define the rgb components from a Color
  74030. * @param alpha Define the a component of the vec4
  74031. */
  74032. addColor4(name: string, color: Color3, alpha: number): void;
  74033. /**
  74034. * Adds a vec3 to the uniform buffer.
  74035. * @param name Name of the uniform, as used in the uniform block in the shader.
  74036. * @param vector Define the vec3 components from a Vector
  74037. */
  74038. addVector3(name: string, vector: Vector3): void;
  74039. /**
  74040. * Adds a Matrix 3x3 to the uniform buffer.
  74041. * @param name Name of the uniform, as used in the uniform block in the shader.
  74042. */
  74043. addMatrix3x3(name: string): void;
  74044. /**
  74045. * Adds a Matrix 2x2 to the uniform buffer.
  74046. * @param name Name of the uniform, as used in the uniform block in the shader.
  74047. */
  74048. addMatrix2x2(name: string): void;
  74049. /**
  74050. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74051. */
  74052. create(): void;
  74053. /** @hidden */
  74054. _rebuild(): void;
  74055. /**
  74056. * Updates the WebGL Uniform Buffer on the GPU.
  74057. * If the `dynamic` flag is set to true, no cache comparison is done.
  74058. * Otherwise, the buffer will be updated only if the cache differs.
  74059. */
  74060. update(): void;
  74061. /**
  74062. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74063. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74064. * @param data Define the flattened data
  74065. * @param size Define the size of the data.
  74066. */
  74067. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74068. private _valueCache;
  74069. private _cacheMatrix;
  74070. private _updateMatrix3x3ForUniform;
  74071. private _updateMatrix3x3ForEffect;
  74072. private _updateMatrix2x2ForEffect;
  74073. private _updateMatrix2x2ForUniform;
  74074. private _updateFloatForEffect;
  74075. private _updateFloatForUniform;
  74076. private _updateFloat2ForEffect;
  74077. private _updateFloat2ForUniform;
  74078. private _updateFloat3ForEffect;
  74079. private _updateFloat3ForUniform;
  74080. private _updateFloat4ForEffect;
  74081. private _updateFloat4ForUniform;
  74082. private _updateMatrixForEffect;
  74083. private _updateMatrixForUniform;
  74084. private _updateVector3ForEffect;
  74085. private _updateVector3ForUniform;
  74086. private _updateVector4ForEffect;
  74087. private _updateVector4ForUniform;
  74088. private _updateColor3ForEffect;
  74089. private _updateColor3ForUniform;
  74090. private _updateColor4ForEffect;
  74091. private _updateColor4ForUniform;
  74092. /**
  74093. * Sets a sampler uniform on the effect.
  74094. * @param name Define the name of the sampler.
  74095. * @param texture Define the texture to set in the sampler
  74096. */
  74097. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74098. /**
  74099. * Directly updates the value of the uniform in the cache AND on the GPU.
  74100. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74101. * @param data Define the flattened data
  74102. */
  74103. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74104. /**
  74105. * Binds this uniform buffer to an effect.
  74106. * @param effect Define the effect to bind the buffer to
  74107. * @param name Name of the uniform block in the shader.
  74108. */
  74109. bindToEffect(effect: Effect, name: string): void;
  74110. /**
  74111. * Disposes the uniform buffer.
  74112. */
  74113. dispose(): void;
  74114. }
  74115. }
  74116. declare module BABYLON {
  74117. /**
  74118. * Enum that determines the text-wrapping mode to use.
  74119. */
  74120. export enum InspectableType {
  74121. /**
  74122. * Checkbox for booleans
  74123. */
  74124. Checkbox = 0,
  74125. /**
  74126. * Sliders for numbers
  74127. */
  74128. Slider = 1,
  74129. /**
  74130. * Vector3
  74131. */
  74132. Vector3 = 2,
  74133. /**
  74134. * Quaternions
  74135. */
  74136. Quaternion = 3,
  74137. /**
  74138. * Color3
  74139. */
  74140. Color3 = 4,
  74141. /**
  74142. * String
  74143. */
  74144. String = 5
  74145. }
  74146. /**
  74147. * Interface used to define custom inspectable properties.
  74148. * This interface is used by the inspector to display custom property grids
  74149. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74150. */
  74151. export interface IInspectable {
  74152. /**
  74153. * Gets the label to display
  74154. */
  74155. label: string;
  74156. /**
  74157. * Gets the name of the property to edit
  74158. */
  74159. propertyName: string;
  74160. /**
  74161. * Gets the type of the editor to use
  74162. */
  74163. type: InspectableType;
  74164. /**
  74165. * Gets the minimum value of the property when using in "slider" mode
  74166. */
  74167. min?: number;
  74168. /**
  74169. * Gets the maximum value of the property when using in "slider" mode
  74170. */
  74171. max?: number;
  74172. /**
  74173. * Gets the setp to use when using in "slider" mode
  74174. */
  74175. step?: number;
  74176. }
  74177. }
  74178. declare module BABYLON {
  74179. /**
  74180. * Class used to provide helper for timing
  74181. */
  74182. export class TimingTools {
  74183. /**
  74184. * Polyfill for setImmediate
  74185. * @param action defines the action to execute after the current execution block
  74186. */
  74187. static SetImmediate(action: () => void): void;
  74188. }
  74189. }
  74190. declare module BABYLON {
  74191. /**
  74192. * Class used to enable instatition of objects by class name
  74193. */
  74194. export class InstantiationTools {
  74195. /**
  74196. * Use this object to register external classes like custom textures or material
  74197. * to allow the laoders to instantiate them
  74198. */
  74199. static RegisteredExternalClasses: {
  74200. [key: string]: Object;
  74201. };
  74202. /**
  74203. * Tries to instantiate a new object from a given class name
  74204. * @param className defines the class name to instantiate
  74205. * @returns the new object or null if the system was not able to do the instantiation
  74206. */
  74207. static Instantiate(className: string): any;
  74208. }
  74209. }
  74210. declare module BABYLON {
  74211. /**
  74212. * Define options used to create a depth texture
  74213. */
  74214. export class DepthTextureCreationOptions {
  74215. /** Specifies whether or not a stencil should be allocated in the texture */
  74216. generateStencil?: boolean;
  74217. /** Specifies whether or not bilinear filtering is enable on the texture */
  74218. bilinearFiltering?: boolean;
  74219. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74220. comparisonFunction?: number;
  74221. /** Specifies if the created texture is a cube texture */
  74222. isCube?: boolean;
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. interface ThinEngine {
  74227. /**
  74228. * Creates a depth stencil cube texture.
  74229. * This is only available in WebGL 2.
  74230. * @param size The size of face edge in the cube texture.
  74231. * @param options The options defining the cube texture.
  74232. * @returns The cube texture
  74233. */
  74234. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74235. /**
  74236. * Creates a cube texture
  74237. * @param rootUrl defines the url where the files to load is located
  74238. * @param scene defines the current scene
  74239. * @param files defines the list of files to load (1 per face)
  74240. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74241. * @param onLoad defines an optional callback raised when the texture is loaded
  74242. * @param onError defines an optional callback raised if there is an issue to load the texture
  74243. * @param format defines the format of the data
  74244. * @param forcedExtension defines the extension to use to pick the right loader
  74245. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74246. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74247. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74248. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74249. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74250. * @returns the cube texture as an InternalTexture
  74251. */
  74252. 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;
  74253. /**
  74254. * Creates a cube texture
  74255. * @param rootUrl defines the url where the files to load is located
  74256. * @param scene defines the current scene
  74257. * @param files defines the list of files to load (1 per face)
  74258. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74259. * @param onLoad defines an optional callback raised when the texture is loaded
  74260. * @param onError defines an optional callback raised if there is an issue to load the texture
  74261. * @param format defines the format of the data
  74262. * @param forcedExtension defines the extension to use to pick the right loader
  74263. * @returns the cube texture as an InternalTexture
  74264. */
  74265. 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;
  74266. /**
  74267. * Creates a cube texture
  74268. * @param rootUrl defines the url where the files to load is located
  74269. * @param scene defines the current scene
  74270. * @param files defines the list of files to load (1 per face)
  74271. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74272. * @param onLoad defines an optional callback raised when the texture is loaded
  74273. * @param onError defines an optional callback raised if there is an issue to load the texture
  74274. * @param format defines the format of the data
  74275. * @param forcedExtension defines the extension to use to pick the right loader
  74276. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74277. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74278. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74279. * @returns the cube texture as an InternalTexture
  74280. */
  74281. 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;
  74282. /** @hidden */
  74283. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74284. /** @hidden */
  74285. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74286. /** @hidden */
  74287. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74288. /** @hidden */
  74289. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74290. }
  74291. }
  74292. declare module BABYLON {
  74293. /**
  74294. * Class for creating a cube texture
  74295. */
  74296. export class CubeTexture extends BaseTexture {
  74297. private _delayedOnLoad;
  74298. /**
  74299. * The url of the texture
  74300. */
  74301. url: string;
  74302. /**
  74303. * Gets or sets the center of the bounding box associated with the cube texture.
  74304. * It must define where the camera used to render the texture was set
  74305. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74306. */
  74307. boundingBoxPosition: Vector3;
  74308. private _boundingBoxSize;
  74309. /**
  74310. * Gets or sets the size of the bounding box associated with the cube texture
  74311. * When defined, the cubemap will switch to local mode
  74312. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74313. * @example https://www.babylonjs-playground.com/#RNASML
  74314. */
  74315. /**
  74316. * Returns the bounding box size
  74317. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74318. */
  74319. boundingBoxSize: Vector3;
  74320. protected _rotationY: number;
  74321. /**
  74322. * Sets texture matrix rotation angle around Y axis in radians.
  74323. */
  74324. /**
  74325. * Gets texture matrix rotation angle around Y axis radians.
  74326. */
  74327. rotationY: number;
  74328. /**
  74329. * Are mip maps generated for this texture or not.
  74330. */
  74331. readonly noMipmap: boolean;
  74332. private _noMipmap;
  74333. private _files;
  74334. private _extensions;
  74335. private _textureMatrix;
  74336. private _format;
  74337. private _createPolynomials;
  74338. /** @hidden */
  74339. _prefiltered: boolean;
  74340. /**
  74341. * Creates a cube texture from an array of image urls
  74342. * @param files defines an array of image urls
  74343. * @param scene defines the hosting scene
  74344. * @param noMipmap specifies if mip maps are not used
  74345. * @returns a cube texture
  74346. */
  74347. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74348. /**
  74349. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74350. * @param url defines the url of the prefiltered texture
  74351. * @param scene defines the scene the texture is attached to
  74352. * @param forcedExtension defines the extension of the file if different from the url
  74353. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74354. * @return the prefiltered texture
  74355. */
  74356. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74357. /**
  74358. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74359. * as prefiltered data.
  74360. * @param rootUrl defines the url of the texture or the root name of the six images
  74361. * @param scene defines the scene the texture is attached to
  74362. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74363. * @param noMipmap defines if mipmaps should be created or not
  74364. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74365. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74366. * @param onError defines a callback triggered in case of error during load
  74367. * @param format defines the internal format to use for the texture once loaded
  74368. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74369. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74370. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74371. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74372. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74373. * @return the cube texture
  74374. */
  74375. 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);
  74376. /**
  74377. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74378. */
  74379. readonly isPrefiltered: boolean;
  74380. /**
  74381. * Get the current class name of the texture useful for serialization or dynamic coding.
  74382. * @returns "CubeTexture"
  74383. */
  74384. getClassName(): string;
  74385. /**
  74386. * Update the url (and optional buffer) of this texture if url was null during construction.
  74387. * @param url the url of the texture
  74388. * @param forcedExtension defines the extension to use
  74389. * @param onLoad callback called when the texture is loaded (defaults to null)
  74390. */
  74391. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74392. /**
  74393. * Delays loading of the cube texture
  74394. * @param forcedExtension defines the extension to use
  74395. */
  74396. delayLoad(forcedExtension?: string): void;
  74397. /**
  74398. * Returns the reflection texture matrix
  74399. * @returns the reflection texture matrix
  74400. */
  74401. getReflectionTextureMatrix(): Matrix;
  74402. /**
  74403. * Sets the reflection texture matrix
  74404. * @param value Reflection texture matrix
  74405. */
  74406. setReflectionTextureMatrix(value: Matrix): void;
  74407. /**
  74408. * Parses text to create a cube texture
  74409. * @param parsedTexture define the serialized text to read from
  74410. * @param scene defines the hosting scene
  74411. * @param rootUrl defines the root url of the cube texture
  74412. * @returns a cube texture
  74413. */
  74414. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74415. /**
  74416. * Makes a clone, or deep copy, of the cube texture
  74417. * @returns a new cube texture
  74418. */
  74419. clone(): CubeTexture;
  74420. }
  74421. }
  74422. declare module BABYLON {
  74423. /**
  74424. * Manages the defines for the Material
  74425. */
  74426. export class MaterialDefines {
  74427. /** @hidden */
  74428. protected _keys: string[];
  74429. private _isDirty;
  74430. /** @hidden */
  74431. _renderId: number;
  74432. /** @hidden */
  74433. _areLightsDirty: boolean;
  74434. /** @hidden */
  74435. _areLightsDisposed: boolean;
  74436. /** @hidden */
  74437. _areAttributesDirty: boolean;
  74438. /** @hidden */
  74439. _areTexturesDirty: boolean;
  74440. /** @hidden */
  74441. _areFresnelDirty: boolean;
  74442. /** @hidden */
  74443. _areMiscDirty: boolean;
  74444. /** @hidden */
  74445. _areImageProcessingDirty: boolean;
  74446. /** @hidden */
  74447. _normals: boolean;
  74448. /** @hidden */
  74449. _uvs: boolean;
  74450. /** @hidden */
  74451. _needNormals: boolean;
  74452. /** @hidden */
  74453. _needUVs: boolean;
  74454. [id: string]: any;
  74455. /**
  74456. * Specifies if the material needs to be re-calculated
  74457. */
  74458. readonly isDirty: boolean;
  74459. /**
  74460. * Marks the material to indicate that it has been re-calculated
  74461. */
  74462. markAsProcessed(): void;
  74463. /**
  74464. * Marks the material to indicate that it needs to be re-calculated
  74465. */
  74466. markAsUnprocessed(): void;
  74467. /**
  74468. * Marks the material to indicate all of its defines need to be re-calculated
  74469. */
  74470. markAllAsDirty(): void;
  74471. /**
  74472. * Marks the material to indicate that image processing needs to be re-calculated
  74473. */
  74474. markAsImageProcessingDirty(): void;
  74475. /**
  74476. * Marks the material to indicate the lights need to be re-calculated
  74477. * @param disposed Defines whether the light is dirty due to dispose or not
  74478. */
  74479. markAsLightDirty(disposed?: boolean): void;
  74480. /**
  74481. * Marks the attribute state as changed
  74482. */
  74483. markAsAttributesDirty(): void;
  74484. /**
  74485. * Marks the texture state as changed
  74486. */
  74487. markAsTexturesDirty(): void;
  74488. /**
  74489. * Marks the fresnel state as changed
  74490. */
  74491. markAsFresnelDirty(): void;
  74492. /**
  74493. * Marks the misc state as changed
  74494. */
  74495. markAsMiscDirty(): void;
  74496. /**
  74497. * Rebuilds the material defines
  74498. */
  74499. rebuild(): void;
  74500. /**
  74501. * Specifies if two material defines are equal
  74502. * @param other - A material define instance to compare to
  74503. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74504. */
  74505. isEqual(other: MaterialDefines): boolean;
  74506. /**
  74507. * Clones this instance's defines to another instance
  74508. * @param other - material defines to clone values to
  74509. */
  74510. cloneTo(other: MaterialDefines): void;
  74511. /**
  74512. * Resets the material define values
  74513. */
  74514. reset(): void;
  74515. /**
  74516. * Converts the material define values to a string
  74517. * @returns - String of material define information
  74518. */
  74519. toString(): string;
  74520. }
  74521. }
  74522. declare module BABYLON {
  74523. /**
  74524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74526. * 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;
  74527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74528. */
  74529. export class ColorCurves {
  74530. private _dirty;
  74531. private _tempColor;
  74532. private _globalCurve;
  74533. private _highlightsCurve;
  74534. private _midtonesCurve;
  74535. private _shadowsCurve;
  74536. private _positiveCurve;
  74537. private _negativeCurve;
  74538. private _globalHue;
  74539. private _globalDensity;
  74540. private _globalSaturation;
  74541. private _globalExposure;
  74542. /**
  74543. * Gets the global Hue value.
  74544. * 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).
  74545. */
  74546. /**
  74547. * Sets the global Hue value.
  74548. * 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).
  74549. */
  74550. globalHue: number;
  74551. /**
  74552. * Gets the global Density value.
  74553. * 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.
  74554. * Values less than zero provide a filter of opposite hue.
  74555. */
  74556. /**
  74557. * Sets 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. globalDensity: number;
  74562. /**
  74563. * Gets the global Saturation value.
  74564. * 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.
  74565. */
  74566. /**
  74567. * Sets the global Saturation value.
  74568. * 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.
  74569. */
  74570. globalSaturation: number;
  74571. /**
  74572. * Gets the global Exposure 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 exposure and negative values decrease exposure.
  74574. */
  74575. /**
  74576. * Sets the global Exposure value.
  74577. * 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.
  74578. */
  74579. globalExposure: number;
  74580. private _highlightsHue;
  74581. private _highlightsDensity;
  74582. private _highlightsSaturation;
  74583. private _highlightsExposure;
  74584. /**
  74585. * Gets the highlights Hue value.
  74586. * 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).
  74587. */
  74588. /**
  74589. * Sets the highlights Hue value.
  74590. * 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).
  74591. */
  74592. highlightsHue: number;
  74593. /**
  74594. * Gets the highlights Density value.
  74595. * 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.
  74596. * Values less than zero provide a filter of opposite hue.
  74597. */
  74598. /**
  74599. * Sets 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. highlightsDensity: number;
  74604. /**
  74605. * Gets the highlights Saturation value.
  74606. * 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.
  74607. */
  74608. /**
  74609. * Sets the highlights Saturation value.
  74610. * 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.
  74611. */
  74612. highlightsSaturation: number;
  74613. /**
  74614. * Gets the highlights Exposure 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 exposure and negative values decrease exposure.
  74616. */
  74617. /**
  74618. * Sets the highlights Exposure value.
  74619. * 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.
  74620. */
  74621. highlightsExposure: number;
  74622. private _midtonesHue;
  74623. private _midtonesDensity;
  74624. private _midtonesSaturation;
  74625. private _midtonesExposure;
  74626. /**
  74627. * Gets the midtones Hue value.
  74628. * 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).
  74629. */
  74630. /**
  74631. * Sets the midtones Hue value.
  74632. * 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).
  74633. */
  74634. midtonesHue: number;
  74635. /**
  74636. * Gets the midtones Density value.
  74637. * 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.
  74638. * Values less than zero provide a filter of opposite hue.
  74639. */
  74640. /**
  74641. * Sets 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. midtonesDensity: number;
  74646. /**
  74647. * Gets the midtones Saturation value.
  74648. * 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.
  74649. */
  74650. /**
  74651. * Sets the midtones Saturation value.
  74652. * 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.
  74653. */
  74654. midtonesSaturation: number;
  74655. /**
  74656. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  74658. */
  74659. /**
  74660. * Sets the midtones Exposure value.
  74661. * 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.
  74662. */
  74663. midtonesExposure: number;
  74664. private _shadowsHue;
  74665. private _shadowsDensity;
  74666. private _shadowsSaturation;
  74667. private _shadowsExposure;
  74668. /**
  74669. * Gets the shadows Hue value.
  74670. * 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).
  74671. */
  74672. /**
  74673. * Sets the shadows Hue value.
  74674. * 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).
  74675. */
  74676. shadowsHue: number;
  74677. /**
  74678. * Gets the shadows Density value.
  74679. * 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.
  74680. * Values less than zero provide a filter of opposite hue.
  74681. */
  74682. /**
  74683. * Sets 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. shadowsDensity: number;
  74688. /**
  74689. * Gets the shadows Saturation value.
  74690. * 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.
  74691. */
  74692. /**
  74693. * Sets the shadows Saturation value.
  74694. * 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.
  74695. */
  74696. shadowsSaturation: number;
  74697. /**
  74698. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  74700. */
  74701. /**
  74702. * Sets the shadows Exposure value.
  74703. * 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.
  74704. */
  74705. shadowsExposure: number;
  74706. /**
  74707. * Returns the class name
  74708. * @returns The class name
  74709. */
  74710. getClassName(): string;
  74711. /**
  74712. * Binds the color curves to the shader.
  74713. * @param colorCurves The color curve to bind
  74714. * @param effect The effect to bind to
  74715. * @param positiveUniform The positive uniform shader parameter
  74716. * @param neutralUniform The neutral uniform shader parameter
  74717. * @param negativeUniform The negative uniform shader parameter
  74718. */
  74719. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74720. /**
  74721. * Prepare the list of uniforms associated with the ColorCurves effects.
  74722. * @param uniformsList The list of uniforms used in the effect
  74723. */
  74724. static PrepareUniforms(uniformsList: string[]): void;
  74725. /**
  74726. * Returns color grading data based on a hue, density, saturation and exposure value.
  74727. * @param filterHue The hue of the color filter.
  74728. * @param filterDensity The density of the color filter.
  74729. * @param saturation The saturation.
  74730. * @param exposure The exposure.
  74731. * @param result The result data container.
  74732. */
  74733. private getColorGradingDataToRef;
  74734. /**
  74735. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74736. * @param value The input slider value in range [-100,100].
  74737. * @returns Adjusted value.
  74738. */
  74739. private static applyColorGradingSliderNonlinear;
  74740. /**
  74741. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74742. * @param hue The hue (H) input.
  74743. * @param saturation The saturation (S) input.
  74744. * @param brightness The brightness (B) input.
  74745. * @result An RGBA color represented as Vector4.
  74746. */
  74747. private static fromHSBToRef;
  74748. /**
  74749. * Returns a value clamped between min and max
  74750. * @param value The value to clamp
  74751. * @param min The minimum of value
  74752. * @param max The maximum of value
  74753. * @returns The clamped value.
  74754. */
  74755. private static clamp;
  74756. /**
  74757. * Clones the current color curve instance.
  74758. * @return The cloned curves
  74759. */
  74760. clone(): ColorCurves;
  74761. /**
  74762. * Serializes the current color curve instance to a json representation.
  74763. * @return a JSON representation
  74764. */
  74765. serialize(): any;
  74766. /**
  74767. * Parses the color curve from a json representation.
  74768. * @param source the JSON source to parse
  74769. * @return The parsed curves
  74770. */
  74771. static Parse(source: any): ColorCurves;
  74772. }
  74773. }
  74774. declare module BABYLON {
  74775. /**
  74776. * Interface to follow in your material defines to integrate easily the
  74777. * Image proccessing functions.
  74778. * @hidden
  74779. */
  74780. export interface IImageProcessingConfigurationDefines {
  74781. IMAGEPROCESSING: boolean;
  74782. VIGNETTE: boolean;
  74783. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74784. VIGNETTEBLENDMODEOPAQUE: boolean;
  74785. TONEMAPPING: boolean;
  74786. TONEMAPPING_ACES: boolean;
  74787. CONTRAST: boolean;
  74788. EXPOSURE: boolean;
  74789. COLORCURVES: boolean;
  74790. COLORGRADING: boolean;
  74791. COLORGRADING3D: boolean;
  74792. SAMPLER3DGREENDEPTH: boolean;
  74793. SAMPLER3DBGRMAP: boolean;
  74794. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74795. }
  74796. /**
  74797. * @hidden
  74798. */
  74799. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74800. IMAGEPROCESSING: boolean;
  74801. VIGNETTE: boolean;
  74802. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74803. VIGNETTEBLENDMODEOPAQUE: boolean;
  74804. TONEMAPPING: boolean;
  74805. TONEMAPPING_ACES: boolean;
  74806. CONTRAST: boolean;
  74807. COLORCURVES: boolean;
  74808. COLORGRADING: boolean;
  74809. COLORGRADING3D: boolean;
  74810. SAMPLER3DGREENDEPTH: boolean;
  74811. SAMPLER3DBGRMAP: boolean;
  74812. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74813. EXPOSURE: boolean;
  74814. constructor();
  74815. }
  74816. /**
  74817. * This groups together the common properties used for image processing either in direct forward pass
  74818. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74819. * or not.
  74820. */
  74821. export class ImageProcessingConfiguration {
  74822. /**
  74823. * Default tone mapping applied in BabylonJS.
  74824. */
  74825. static readonly TONEMAPPING_STANDARD: number;
  74826. /**
  74827. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74828. * to other engines rendering to increase portability.
  74829. */
  74830. static readonly TONEMAPPING_ACES: number;
  74831. /**
  74832. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74833. */
  74834. colorCurves: Nullable<ColorCurves>;
  74835. private _colorCurvesEnabled;
  74836. /**
  74837. * Gets wether the color curves effect is enabled.
  74838. */
  74839. /**
  74840. * Sets wether the color curves effect is enabled.
  74841. */
  74842. colorCurvesEnabled: boolean;
  74843. private _colorGradingTexture;
  74844. /**
  74845. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74846. */
  74847. /**
  74848. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74849. */
  74850. colorGradingTexture: Nullable<BaseTexture>;
  74851. private _colorGradingEnabled;
  74852. /**
  74853. * Gets wether the color grading effect is enabled.
  74854. */
  74855. /**
  74856. * Sets wether the color grading effect is enabled.
  74857. */
  74858. colorGradingEnabled: boolean;
  74859. private _colorGradingWithGreenDepth;
  74860. /**
  74861. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74862. */
  74863. /**
  74864. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74865. */
  74866. colorGradingWithGreenDepth: boolean;
  74867. private _colorGradingBGR;
  74868. /**
  74869. * Gets wether the color grading texture contains BGR values.
  74870. */
  74871. /**
  74872. * Sets wether the color grading texture contains BGR values.
  74873. */
  74874. colorGradingBGR: boolean;
  74875. /** @hidden */
  74876. _exposure: number;
  74877. /**
  74878. * Gets the Exposure used in the effect.
  74879. */
  74880. /**
  74881. * Sets the Exposure used in the effect.
  74882. */
  74883. exposure: number;
  74884. private _toneMappingEnabled;
  74885. /**
  74886. * Gets wether the tone mapping effect is enabled.
  74887. */
  74888. /**
  74889. * Sets wether the tone mapping effect is enabled.
  74890. */
  74891. toneMappingEnabled: boolean;
  74892. private _toneMappingType;
  74893. /**
  74894. * Gets the type of tone mapping effect.
  74895. */
  74896. /**
  74897. * Sets the type of tone mapping effect used in BabylonJS.
  74898. */
  74899. toneMappingType: number;
  74900. protected _contrast: number;
  74901. /**
  74902. * Gets the contrast used in the effect.
  74903. */
  74904. /**
  74905. * Sets the contrast used in the effect.
  74906. */
  74907. contrast: number;
  74908. /**
  74909. * Vignette stretch size.
  74910. */
  74911. vignetteStretch: number;
  74912. /**
  74913. * Vignette centre X Offset.
  74914. */
  74915. vignetteCentreX: number;
  74916. /**
  74917. * Vignette centre Y Offset.
  74918. */
  74919. vignetteCentreY: number;
  74920. /**
  74921. * Vignette weight or intensity of the vignette effect.
  74922. */
  74923. vignetteWeight: number;
  74924. /**
  74925. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74926. * if vignetteEnabled is set to true.
  74927. */
  74928. vignetteColor: Color4;
  74929. /**
  74930. * Camera field of view used by the Vignette effect.
  74931. */
  74932. vignetteCameraFov: number;
  74933. private _vignetteBlendMode;
  74934. /**
  74935. * Gets the vignette blend mode allowing different kind of effect.
  74936. */
  74937. /**
  74938. * Sets the vignette blend mode allowing different kind of effect.
  74939. */
  74940. vignetteBlendMode: number;
  74941. private _vignetteEnabled;
  74942. /**
  74943. * Gets wether the vignette effect is enabled.
  74944. */
  74945. /**
  74946. * Sets wether the vignette effect is enabled.
  74947. */
  74948. vignetteEnabled: boolean;
  74949. private _applyByPostProcess;
  74950. /**
  74951. * Gets wether the image processing is applied through a post process or not.
  74952. */
  74953. /**
  74954. * Sets wether the image processing is applied through a post process or not.
  74955. */
  74956. applyByPostProcess: boolean;
  74957. private _isEnabled;
  74958. /**
  74959. * Gets wether the image processing is enabled or not.
  74960. */
  74961. /**
  74962. * Sets wether the image processing is enabled or not.
  74963. */
  74964. isEnabled: boolean;
  74965. /**
  74966. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74967. */
  74968. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74969. /**
  74970. * Method called each time the image processing information changes requires to recompile the effect.
  74971. */
  74972. protected _updateParameters(): void;
  74973. /**
  74974. * Gets the current class name.
  74975. * @return "ImageProcessingConfiguration"
  74976. */
  74977. getClassName(): string;
  74978. /**
  74979. * Prepare the list of uniforms associated with the Image Processing effects.
  74980. * @param uniforms The list of uniforms used in the effect
  74981. * @param defines the list of defines currently in use
  74982. */
  74983. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74984. /**
  74985. * Prepare the list of samplers associated with the Image Processing effects.
  74986. * @param samplersList The list of uniforms used in the effect
  74987. * @param defines the list of defines currently in use
  74988. */
  74989. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74990. /**
  74991. * Prepare the list of defines associated to the shader.
  74992. * @param defines the list of defines to complete
  74993. * @param forPostProcess Define if we are currently in post process mode or not
  74994. */
  74995. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74996. /**
  74997. * Returns true if all the image processing information are ready.
  74998. * @returns True if ready, otherwise, false
  74999. */
  75000. isReady(): boolean;
  75001. /**
  75002. * Binds the image processing to the shader.
  75003. * @param effect The effect to bind to
  75004. * @param aspectRatio Define the current aspect ratio of the effect
  75005. */
  75006. bind(effect: Effect, aspectRatio?: number): void;
  75007. /**
  75008. * Clones the current image processing instance.
  75009. * @return The cloned image processing
  75010. */
  75011. clone(): ImageProcessingConfiguration;
  75012. /**
  75013. * Serializes the current image processing instance to a json representation.
  75014. * @return a JSON representation
  75015. */
  75016. serialize(): any;
  75017. /**
  75018. * Parses the image processing from a json representation.
  75019. * @param source the JSON source to parse
  75020. * @return The parsed image processing
  75021. */
  75022. static Parse(source: any): ImageProcessingConfiguration;
  75023. private static _VIGNETTEMODE_MULTIPLY;
  75024. private static _VIGNETTEMODE_OPAQUE;
  75025. /**
  75026. * Used to apply the vignette as a mix with the pixel color.
  75027. */
  75028. static readonly VIGNETTEMODE_MULTIPLY: number;
  75029. /**
  75030. * Used to apply the vignette as a replacement of the pixel color.
  75031. */
  75032. static readonly VIGNETTEMODE_OPAQUE: number;
  75033. }
  75034. }
  75035. declare module BABYLON {
  75036. /** @hidden */
  75037. export var postprocessVertexShader: {
  75038. name: string;
  75039. shader: string;
  75040. };
  75041. }
  75042. declare module BABYLON {
  75043. /** Defines supported spaces */
  75044. export enum Space {
  75045. /** Local (object) space */
  75046. LOCAL = 0,
  75047. /** World space */
  75048. WORLD = 1,
  75049. /** Bone space */
  75050. BONE = 2
  75051. }
  75052. /** Defines the 3 main axes */
  75053. export class Axis {
  75054. /** X axis */
  75055. static X: Vector3;
  75056. /** Y axis */
  75057. static Y: Vector3;
  75058. /** Z axis */
  75059. static Z: Vector3;
  75060. }
  75061. }
  75062. declare module BABYLON {
  75063. /**
  75064. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75065. * This is the base of the follow, arc rotate cameras and Free camera
  75066. * @see http://doc.babylonjs.com/features/cameras
  75067. */
  75068. export class TargetCamera extends Camera {
  75069. private static _RigCamTransformMatrix;
  75070. private static _TargetTransformMatrix;
  75071. private static _TargetFocalPoint;
  75072. /**
  75073. * Define the current direction the camera is moving to
  75074. */
  75075. cameraDirection: Vector3;
  75076. /**
  75077. * Define the current rotation the camera is rotating to
  75078. */
  75079. cameraRotation: Vector2;
  75080. /**
  75081. * When set, the up vector of the camera will be updated by the rotation of the camera
  75082. */
  75083. updateUpVectorFromRotation: boolean;
  75084. private _tmpQuaternion;
  75085. /**
  75086. * Define the current rotation of the camera
  75087. */
  75088. rotation: Vector3;
  75089. /**
  75090. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75091. */
  75092. rotationQuaternion: Quaternion;
  75093. /**
  75094. * Define the current speed of the camera
  75095. */
  75096. speed: number;
  75097. /**
  75098. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75099. * around all axis.
  75100. */
  75101. noRotationConstraint: boolean;
  75102. /**
  75103. * Define the current target of the camera as an object or a position.
  75104. */
  75105. lockedTarget: any;
  75106. /** @hidden */
  75107. _currentTarget: Vector3;
  75108. /** @hidden */
  75109. _initialFocalDistance: number;
  75110. /** @hidden */
  75111. _viewMatrix: Matrix;
  75112. /** @hidden */
  75113. _camMatrix: Matrix;
  75114. /** @hidden */
  75115. _cameraTransformMatrix: Matrix;
  75116. /** @hidden */
  75117. _cameraRotationMatrix: Matrix;
  75118. /** @hidden */
  75119. _referencePoint: Vector3;
  75120. /** @hidden */
  75121. _transformedReferencePoint: Vector3;
  75122. protected _globalCurrentTarget: Vector3;
  75123. protected _globalCurrentUpVector: Vector3;
  75124. /** @hidden */
  75125. _reset: () => void;
  75126. private _defaultUp;
  75127. /**
  75128. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75129. * This is the base of the follow, arc rotate cameras and Free camera
  75130. * @see http://doc.babylonjs.com/features/cameras
  75131. * @param name Defines the name of the camera in the scene
  75132. * @param position Defines the start position of the camera in the scene
  75133. * @param scene Defines the scene the camera belongs to
  75134. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75135. */
  75136. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75137. /**
  75138. * Gets the position in front of the camera at a given distance.
  75139. * @param distance The distance from the camera we want the position to be
  75140. * @returns the position
  75141. */
  75142. getFrontPosition(distance: number): Vector3;
  75143. /** @hidden */
  75144. _getLockedTargetPosition(): Nullable<Vector3>;
  75145. private _storedPosition;
  75146. private _storedRotation;
  75147. private _storedRotationQuaternion;
  75148. /**
  75149. * Store current camera state of the camera (fov, position, rotation, etc..)
  75150. * @returns the camera
  75151. */
  75152. storeState(): Camera;
  75153. /**
  75154. * Restored camera state. You must call storeState() first
  75155. * @returns whether it was successful or not
  75156. * @hidden
  75157. */
  75158. _restoreStateValues(): boolean;
  75159. /** @hidden */
  75160. _initCache(): void;
  75161. /** @hidden */
  75162. _updateCache(ignoreParentClass?: boolean): void;
  75163. /** @hidden */
  75164. _isSynchronizedViewMatrix(): boolean;
  75165. /** @hidden */
  75166. _computeLocalCameraSpeed(): number;
  75167. /**
  75168. * Defines the target the camera should look at.
  75169. * @param target Defines the new target as a Vector or a mesh
  75170. */
  75171. setTarget(target: Vector3): void;
  75172. /**
  75173. * Return the current target position of the camera. This value is expressed in local space.
  75174. * @returns the target position
  75175. */
  75176. getTarget(): Vector3;
  75177. /** @hidden */
  75178. _decideIfNeedsToMove(): boolean;
  75179. /** @hidden */
  75180. _updatePosition(): void;
  75181. /** @hidden */
  75182. _checkInputs(): void;
  75183. protected _updateCameraRotationMatrix(): void;
  75184. /**
  75185. * 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)
  75186. * @returns the current camera
  75187. */
  75188. private _rotateUpVectorWithCameraRotationMatrix;
  75189. private _cachedRotationZ;
  75190. private _cachedQuaternionRotationZ;
  75191. /** @hidden */
  75192. _getViewMatrix(): Matrix;
  75193. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75194. /**
  75195. * @hidden
  75196. */
  75197. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75198. /**
  75199. * @hidden
  75200. */
  75201. _updateRigCameras(): void;
  75202. private _getRigCamPositionAndTarget;
  75203. /**
  75204. * Gets the current object class name.
  75205. * @return the class name
  75206. */
  75207. getClassName(): string;
  75208. }
  75209. }
  75210. declare module BABYLON {
  75211. /**
  75212. * Gather the list of keyboard event types as constants.
  75213. */
  75214. export class KeyboardEventTypes {
  75215. /**
  75216. * The keydown event is fired when a key becomes active (pressed).
  75217. */
  75218. static readonly KEYDOWN: number;
  75219. /**
  75220. * The keyup event is fired when a key has been released.
  75221. */
  75222. static readonly KEYUP: number;
  75223. }
  75224. /**
  75225. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75226. */
  75227. export class KeyboardInfo {
  75228. /**
  75229. * Defines the type of event (KeyboardEventTypes)
  75230. */
  75231. type: number;
  75232. /**
  75233. * Defines the related dom event
  75234. */
  75235. event: KeyboardEvent;
  75236. /**
  75237. * Instantiates a new keyboard info.
  75238. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75239. * @param type Defines the type of event (KeyboardEventTypes)
  75240. * @param event Defines the related dom event
  75241. */
  75242. constructor(
  75243. /**
  75244. * Defines the type of event (KeyboardEventTypes)
  75245. */
  75246. type: number,
  75247. /**
  75248. * Defines the related dom event
  75249. */
  75250. event: KeyboardEvent);
  75251. }
  75252. /**
  75253. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75254. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75255. */
  75256. export class KeyboardInfoPre extends KeyboardInfo {
  75257. /**
  75258. * Defines the type of event (KeyboardEventTypes)
  75259. */
  75260. type: number;
  75261. /**
  75262. * Defines the related dom event
  75263. */
  75264. event: KeyboardEvent;
  75265. /**
  75266. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75267. */
  75268. skipOnPointerObservable: boolean;
  75269. /**
  75270. * Instantiates a new keyboard pre info.
  75271. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75272. * @param type Defines the type of event (KeyboardEventTypes)
  75273. * @param event Defines the related dom event
  75274. */
  75275. constructor(
  75276. /**
  75277. * Defines the type of event (KeyboardEventTypes)
  75278. */
  75279. type: number,
  75280. /**
  75281. * Defines the related dom event
  75282. */
  75283. event: KeyboardEvent);
  75284. }
  75285. }
  75286. declare module BABYLON {
  75287. /**
  75288. * Manage the keyboard inputs to control the movement of a free camera.
  75289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75290. */
  75291. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75292. /**
  75293. * Defines the camera the input is attached to.
  75294. */
  75295. camera: FreeCamera;
  75296. /**
  75297. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75298. */
  75299. keysUp: number[];
  75300. /**
  75301. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75302. */
  75303. keysDown: number[];
  75304. /**
  75305. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75306. */
  75307. keysLeft: number[];
  75308. /**
  75309. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75310. */
  75311. keysRight: number[];
  75312. private _keys;
  75313. private _onCanvasBlurObserver;
  75314. private _onKeyboardObserver;
  75315. private _engine;
  75316. private _scene;
  75317. /**
  75318. * Attach the input controls to a specific dom element to get the input from.
  75319. * @param element Defines the element the controls should be listened from
  75320. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75321. */
  75322. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75323. /**
  75324. * Detach the current controls from the specified dom element.
  75325. * @param element Defines the element to stop listening the inputs from
  75326. */
  75327. detachControl(element: Nullable<HTMLElement>): void;
  75328. /**
  75329. * Update the current camera state depending on the inputs that have been used this frame.
  75330. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75331. */
  75332. checkInputs(): void;
  75333. /**
  75334. * Gets the class name of the current intput.
  75335. * @returns the class name
  75336. */
  75337. getClassName(): string;
  75338. /** @hidden */
  75339. _onLostFocus(): void;
  75340. /**
  75341. * Get the friendly name associated with the input class.
  75342. * @returns the input friendly name
  75343. */
  75344. getSimpleName(): string;
  75345. }
  75346. }
  75347. declare module BABYLON {
  75348. /**
  75349. * Interface describing all the common properties and methods a shadow light needs to implement.
  75350. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75351. * as well as binding the different shadow properties to the effects.
  75352. */
  75353. export interface IShadowLight extends Light {
  75354. /**
  75355. * The light id in the scene (used in scene.findLighById for instance)
  75356. */
  75357. id: string;
  75358. /**
  75359. * The position the shdow will be casted from.
  75360. */
  75361. position: Vector3;
  75362. /**
  75363. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75364. */
  75365. direction: Vector3;
  75366. /**
  75367. * The transformed position. Position of the light in world space taking parenting in account.
  75368. */
  75369. transformedPosition: Vector3;
  75370. /**
  75371. * The transformed direction. Direction of the light in world space taking parenting in account.
  75372. */
  75373. transformedDirection: Vector3;
  75374. /**
  75375. * The friendly name of the light in the scene.
  75376. */
  75377. name: string;
  75378. /**
  75379. * Defines the shadow projection clipping minimum z value.
  75380. */
  75381. shadowMinZ: number;
  75382. /**
  75383. * Defines the shadow projection clipping maximum z value.
  75384. */
  75385. shadowMaxZ: number;
  75386. /**
  75387. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75388. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75389. */
  75390. computeTransformedInformation(): boolean;
  75391. /**
  75392. * Gets the scene the light belongs to.
  75393. * @returns The scene
  75394. */
  75395. getScene(): Scene;
  75396. /**
  75397. * Callback defining a custom Projection Matrix Builder.
  75398. * This can be used to override the default projection matrix computation.
  75399. */
  75400. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75401. /**
  75402. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75403. * @param matrix The materix to updated with the projection information
  75404. * @param viewMatrix The transform matrix of the light
  75405. * @param renderList The list of mesh to render in the map
  75406. * @returns The current light
  75407. */
  75408. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75409. /**
  75410. * Gets the current depth scale used in ESM.
  75411. * @returns The scale
  75412. */
  75413. getDepthScale(): number;
  75414. /**
  75415. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75416. * @returns true if a cube texture needs to be use
  75417. */
  75418. needCube(): boolean;
  75419. /**
  75420. * Detects if the projection matrix requires to be recomputed this frame.
  75421. * @returns true if it requires to be recomputed otherwise, false.
  75422. */
  75423. needProjectionMatrixCompute(): boolean;
  75424. /**
  75425. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75426. */
  75427. forceProjectionMatrixCompute(): void;
  75428. /**
  75429. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75430. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75431. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75432. */
  75433. getShadowDirection(faceIndex?: number): Vector3;
  75434. /**
  75435. * Gets the minZ used for shadow according to both the scene and the light.
  75436. * @param activeCamera The camera we are returning the min for
  75437. * @returns the depth min z
  75438. */
  75439. getDepthMinZ(activeCamera: Camera): number;
  75440. /**
  75441. * Gets the maxZ used for shadow according to both the scene and the light.
  75442. * @param activeCamera The camera we are returning the max for
  75443. * @returns the depth max z
  75444. */
  75445. getDepthMaxZ(activeCamera: Camera): number;
  75446. }
  75447. /**
  75448. * Base implementation IShadowLight
  75449. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75450. */
  75451. export abstract class ShadowLight extends Light implements IShadowLight {
  75452. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75453. protected _position: Vector3;
  75454. protected _setPosition(value: Vector3): void;
  75455. /**
  75456. * Sets the position the shadow will be casted from. Also use as the light position for both
  75457. * point and spot lights.
  75458. */
  75459. /**
  75460. * Sets the position the shadow will be casted from. Also use as the light position for both
  75461. * point and spot lights.
  75462. */
  75463. position: Vector3;
  75464. protected _direction: Vector3;
  75465. protected _setDirection(value: Vector3): void;
  75466. /**
  75467. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75468. * Also use as the light direction on spot and directional lights.
  75469. */
  75470. /**
  75471. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75472. * Also use as the light direction on spot and directional lights.
  75473. */
  75474. direction: Vector3;
  75475. private _shadowMinZ;
  75476. /**
  75477. * Gets the shadow projection clipping minimum z value.
  75478. */
  75479. /**
  75480. * Sets the shadow projection clipping minimum z value.
  75481. */
  75482. shadowMinZ: number;
  75483. private _shadowMaxZ;
  75484. /**
  75485. * Sets the shadow projection clipping maximum z value.
  75486. */
  75487. /**
  75488. * Gets the shadow projection clipping maximum z value.
  75489. */
  75490. shadowMaxZ: number;
  75491. /**
  75492. * Callback defining a custom Projection Matrix Builder.
  75493. * This can be used to override the default projection matrix computation.
  75494. */
  75495. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75496. /**
  75497. * The transformed position. Position of the light in world space taking parenting in account.
  75498. */
  75499. transformedPosition: Vector3;
  75500. /**
  75501. * The transformed direction. Direction of the light in world space taking parenting in account.
  75502. */
  75503. transformedDirection: Vector3;
  75504. private _needProjectionMatrixCompute;
  75505. /**
  75506. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75507. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75508. */
  75509. computeTransformedInformation(): boolean;
  75510. /**
  75511. * Return the depth scale used for the shadow map.
  75512. * @returns the depth scale.
  75513. */
  75514. getDepthScale(): number;
  75515. /**
  75516. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75517. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75518. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75519. */
  75520. getShadowDirection(faceIndex?: number): Vector3;
  75521. /**
  75522. * Returns the ShadowLight absolute position in the World.
  75523. * @returns the position vector in world space
  75524. */
  75525. getAbsolutePosition(): Vector3;
  75526. /**
  75527. * Sets the ShadowLight direction toward the passed target.
  75528. * @param target The point to target in local space
  75529. * @returns the updated ShadowLight direction
  75530. */
  75531. setDirectionToTarget(target: Vector3): Vector3;
  75532. /**
  75533. * Returns the light rotation in euler definition.
  75534. * @returns the x y z rotation in local space.
  75535. */
  75536. getRotation(): Vector3;
  75537. /**
  75538. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75539. * @returns true if a cube texture needs to be use
  75540. */
  75541. needCube(): boolean;
  75542. /**
  75543. * Detects if the projection matrix requires to be recomputed this frame.
  75544. * @returns true if it requires to be recomputed otherwise, false.
  75545. */
  75546. needProjectionMatrixCompute(): boolean;
  75547. /**
  75548. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75549. */
  75550. forceProjectionMatrixCompute(): void;
  75551. /** @hidden */
  75552. _initCache(): void;
  75553. /** @hidden */
  75554. _isSynchronized(): boolean;
  75555. /**
  75556. * Computes the world matrix of the node
  75557. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75558. * @returns the world matrix
  75559. */
  75560. computeWorldMatrix(force?: boolean): Matrix;
  75561. /**
  75562. * Gets the minZ used for shadow according to both the scene and the light.
  75563. * @param activeCamera The camera we are returning the min for
  75564. * @returns the depth min z
  75565. */
  75566. getDepthMinZ(activeCamera: Camera): number;
  75567. /**
  75568. * Gets the maxZ used for shadow according to both the scene and the light.
  75569. * @param activeCamera The camera we are returning the max for
  75570. * @returns the depth max z
  75571. */
  75572. getDepthMaxZ(activeCamera: Camera): number;
  75573. /**
  75574. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75575. * @param matrix The materix to updated with the projection information
  75576. * @param viewMatrix The transform matrix of the light
  75577. * @param renderList The list of mesh to render in the map
  75578. * @returns The current light
  75579. */
  75580. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75581. }
  75582. }
  75583. declare module BABYLON {
  75584. /**
  75585. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75586. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75587. */
  75588. export class EffectFallbacks implements IEffectFallbacks {
  75589. private _defines;
  75590. private _currentRank;
  75591. private _maxRank;
  75592. private _mesh;
  75593. /**
  75594. * Removes the fallback from the bound mesh.
  75595. */
  75596. unBindMesh(): void;
  75597. /**
  75598. * Adds a fallback on the specified property.
  75599. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75600. * @param define The name of the define in the shader
  75601. */
  75602. addFallback(rank: number, define: string): void;
  75603. /**
  75604. * Sets the mesh to use CPU skinning when needing to fallback.
  75605. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75606. * @param mesh The mesh to use the fallbacks.
  75607. */
  75608. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75609. /**
  75610. * Checks to see if more fallbacks are still availible.
  75611. */
  75612. readonly hasMoreFallbacks: boolean;
  75613. /**
  75614. * Removes the defines that should be removed when falling back.
  75615. * @param currentDefines defines the current define statements for the shader.
  75616. * @param effect defines the current effect we try to compile
  75617. * @returns The resulting defines with defines of the current rank removed.
  75618. */
  75619. reduce(currentDefines: string, effect: Effect): string;
  75620. }
  75621. }
  75622. declare module BABYLON {
  75623. /**
  75624. * "Static Class" containing the most commonly used helper while dealing with material for
  75625. * rendering purpose.
  75626. *
  75627. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75628. *
  75629. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75630. */
  75631. export class MaterialHelper {
  75632. /**
  75633. * Bind the current view position to an effect.
  75634. * @param effect The effect to be bound
  75635. * @param scene The scene the eyes position is used from
  75636. */
  75637. static BindEyePosition(effect: Effect, scene: Scene): void;
  75638. /**
  75639. * Helps preparing the defines values about the UVs in used in the effect.
  75640. * UVs are shared as much as we can accross channels in the shaders.
  75641. * @param texture The texture we are preparing the UVs for
  75642. * @param defines The defines to update
  75643. * @param key The channel key "diffuse", "specular"... used in the shader
  75644. */
  75645. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75646. /**
  75647. * Binds a texture matrix value to its corrsponding uniform
  75648. * @param texture The texture to bind the matrix for
  75649. * @param uniformBuffer The uniform buffer receivin the data
  75650. * @param key The channel key "diffuse", "specular"... used in the shader
  75651. */
  75652. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75653. /**
  75654. * Gets the current status of the fog (should it be enabled?)
  75655. * @param mesh defines the mesh to evaluate for fog support
  75656. * @param scene defines the hosting scene
  75657. * @returns true if fog must be enabled
  75658. */
  75659. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75660. /**
  75661. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75662. * @param mesh defines the current mesh
  75663. * @param scene defines the current scene
  75664. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75665. * @param pointsCloud defines if point cloud rendering has to be turned on
  75666. * @param fogEnabled defines if fog has to be turned on
  75667. * @param alphaTest defines if alpha testing has to be turned on
  75668. * @param defines defines the current list of defines
  75669. */
  75670. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75671. /**
  75672. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75673. * @param scene defines the current scene
  75674. * @param engine defines the current engine
  75675. * @param defines specifies the list of active defines
  75676. * @param useInstances defines if instances have to be turned on
  75677. * @param useClipPlane defines if clip plane have to be turned on
  75678. */
  75679. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75680. /**
  75681. * Prepares the defines for bones
  75682. * @param mesh The mesh containing the geometry data we will draw
  75683. * @param defines The defines to update
  75684. */
  75685. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75686. /**
  75687. * Prepares the defines for morph targets
  75688. * @param mesh The mesh containing the geometry data we will draw
  75689. * @param defines The defines to update
  75690. */
  75691. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75692. /**
  75693. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75694. * @param mesh The mesh containing the geometry data we will draw
  75695. * @param defines The defines to update
  75696. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75697. * @param useBones Precise whether bones should be used or not (override mesh info)
  75698. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75699. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75700. * @returns false if defines are considered not dirty and have not been checked
  75701. */
  75702. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75703. /**
  75704. * Prepares the defines related to multiview
  75705. * @param scene The scene we are intending to draw
  75706. * @param defines The defines to update
  75707. */
  75708. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75709. /**
  75710. * Prepares the defines related to the light information passed in parameter
  75711. * @param scene The scene we are intending to draw
  75712. * @param mesh The mesh the effect is compiling for
  75713. * @param light The light the effect is compiling for
  75714. * @param lightIndex The index of the light
  75715. * @param defines The defines to update
  75716. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75717. * @param state Defines the current state regarding what is needed (normals, etc...)
  75718. */
  75719. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75720. needNormals: boolean;
  75721. needRebuild: boolean;
  75722. shadowEnabled: boolean;
  75723. specularEnabled: boolean;
  75724. lightmapMode: boolean;
  75725. }): void;
  75726. /**
  75727. * Prepares the defines related to the light information passed in parameter
  75728. * @param scene The scene we are intending to draw
  75729. * @param mesh The mesh the effect is compiling for
  75730. * @param defines The defines to update
  75731. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75732. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75733. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75734. * @returns true if normals will be required for the rest of the effect
  75735. */
  75736. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75737. /**
  75738. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75739. * @param lightIndex defines the light index
  75740. * @param uniformsList The uniform list
  75741. * @param samplersList The sampler list
  75742. * @param projectedLightTexture defines if projected texture must be used
  75743. * @param uniformBuffersList defines an optional list of uniform buffers
  75744. */
  75745. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75746. /**
  75747. * Prepares the uniforms and samplers list to be used in the effect
  75748. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75749. * @param samplersList The sampler list
  75750. * @param defines The defines helping in the list generation
  75751. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75752. */
  75753. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75754. /**
  75755. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75756. * @param defines The defines to update while falling back
  75757. * @param fallbacks The authorized effect fallbacks
  75758. * @param maxSimultaneousLights The maximum number of lights allowed
  75759. * @param rank the current rank of the Effect
  75760. * @returns The newly affected rank
  75761. */
  75762. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75763. private static _TmpMorphInfluencers;
  75764. /**
  75765. * Prepares the list of attributes required for morph targets according to the effect defines.
  75766. * @param attribs The current list of supported attribs
  75767. * @param mesh The mesh to prepare the morph targets attributes for
  75768. * @param influencers The number of influencers
  75769. */
  75770. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75771. /**
  75772. * Prepares the list of attributes required for morph targets according to the effect defines.
  75773. * @param attribs The current list of supported attribs
  75774. * @param mesh The mesh to prepare the morph targets attributes for
  75775. * @param defines The current Defines of the effect
  75776. */
  75777. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75778. /**
  75779. * Prepares the list of attributes required for bones according to the effect defines.
  75780. * @param attribs The current list of supported attribs
  75781. * @param mesh The mesh to prepare the bones attributes for
  75782. * @param defines The current Defines of the effect
  75783. * @param fallbacks The current efffect fallback strategy
  75784. */
  75785. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75786. /**
  75787. * Check and prepare the list of attributes required for instances according to the effect defines.
  75788. * @param attribs The current list of supported attribs
  75789. * @param defines The current MaterialDefines of the effect
  75790. */
  75791. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75792. /**
  75793. * Add the list of attributes required for instances to the attribs array.
  75794. * @param attribs The current list of supported attribs
  75795. */
  75796. static PushAttributesForInstances(attribs: string[]): void;
  75797. /**
  75798. * Binds the light shadow information to the effect for the given mesh.
  75799. * @param light The light containing the generator
  75800. * @param scene The scene the lights belongs to
  75801. * @param mesh The mesh we are binding the information to render
  75802. * @param lightIndex The light index in the effect used to render the mesh
  75803. * @param effect The effect we are binding the data to
  75804. */
  75805. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75806. /**
  75807. * Binds the light information to the effect.
  75808. * @param light The light containing the generator
  75809. * @param effect The effect we are binding the data to
  75810. * @param lightIndex The light index in the effect used to render
  75811. */
  75812. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75813. /**
  75814. * Binds the lights information from the scene to the effect for the given mesh.
  75815. * @param light Light to bind
  75816. * @param lightIndex Light index
  75817. * @param scene The scene where the light belongs to
  75818. * @param mesh The mesh we are binding the information to render
  75819. * @param effect The effect we are binding the data to
  75820. * @param useSpecular Defines if specular is supported
  75821. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75823. */
  75824. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75825. /**
  75826. * Binds the lights information from the scene to the effect for the given mesh.
  75827. * @param scene The scene the lights belongs to
  75828. * @param mesh The mesh we are binding the information to render
  75829. * @param effect The effect we are binding the data to
  75830. * @param defines The generated defines for the effect
  75831. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75832. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75833. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75834. */
  75835. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75836. private static _tempFogColor;
  75837. /**
  75838. * Binds the fog information from the scene to the effect for the given mesh.
  75839. * @param scene The scene the lights belongs to
  75840. * @param mesh The mesh we are binding the information to render
  75841. * @param effect The effect we are binding the data to
  75842. * @param linearSpace Defines if the fog effect is applied in linear space
  75843. */
  75844. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75845. /**
  75846. * Binds the bones information from the mesh to the effect.
  75847. * @param mesh The mesh we are binding the information to render
  75848. * @param effect The effect we are binding the data to
  75849. */
  75850. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75851. /**
  75852. * Binds the morph targets information from the mesh to the effect.
  75853. * @param abstractMesh The mesh we are binding the information to render
  75854. * @param effect The effect we are binding the data to
  75855. */
  75856. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75857. /**
  75858. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75859. * @param defines The generated defines used in the effect
  75860. * @param effect The effect we are binding the data to
  75861. * @param scene The scene we are willing to render with logarithmic scale for
  75862. */
  75863. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75864. /**
  75865. * Binds the clip plane information from the scene to the effect.
  75866. * @param scene The scene the clip plane information are extracted from
  75867. * @param effect The effect we are binding the data to
  75868. */
  75869. static BindClipPlane(effect: Effect, scene: Scene): void;
  75870. }
  75871. }
  75872. declare module BABYLON {
  75873. /** @hidden */
  75874. export var packingFunctions: {
  75875. name: string;
  75876. shader: string;
  75877. };
  75878. }
  75879. declare module BABYLON {
  75880. /** @hidden */
  75881. export var shadowMapPixelShader: {
  75882. name: string;
  75883. shader: string;
  75884. };
  75885. }
  75886. declare module BABYLON {
  75887. /** @hidden */
  75888. export var bonesDeclaration: {
  75889. name: string;
  75890. shader: string;
  75891. };
  75892. }
  75893. declare module BABYLON {
  75894. /** @hidden */
  75895. export var morphTargetsVertexGlobalDeclaration: {
  75896. name: string;
  75897. shader: string;
  75898. };
  75899. }
  75900. declare module BABYLON {
  75901. /** @hidden */
  75902. export var morphTargetsVertexDeclaration: {
  75903. name: string;
  75904. shader: string;
  75905. };
  75906. }
  75907. declare module BABYLON {
  75908. /** @hidden */
  75909. export var instancesDeclaration: {
  75910. name: string;
  75911. shader: string;
  75912. };
  75913. }
  75914. declare module BABYLON {
  75915. /** @hidden */
  75916. export var helperFunctions: {
  75917. name: string;
  75918. shader: string;
  75919. };
  75920. }
  75921. declare module BABYLON {
  75922. /** @hidden */
  75923. export var morphTargetsVertex: {
  75924. name: string;
  75925. shader: string;
  75926. };
  75927. }
  75928. declare module BABYLON {
  75929. /** @hidden */
  75930. export var instancesVertex: {
  75931. name: string;
  75932. shader: string;
  75933. };
  75934. }
  75935. declare module BABYLON {
  75936. /** @hidden */
  75937. export var bonesVertex: {
  75938. name: string;
  75939. shader: string;
  75940. };
  75941. }
  75942. declare module BABYLON {
  75943. /** @hidden */
  75944. export var shadowMapVertexShader: {
  75945. name: string;
  75946. shader: string;
  75947. };
  75948. }
  75949. declare module BABYLON {
  75950. /** @hidden */
  75951. export var depthBoxBlurPixelShader: {
  75952. name: string;
  75953. shader: string;
  75954. };
  75955. }
  75956. declare module BABYLON {
  75957. /**
  75958. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75959. */
  75960. export interface ICustomShaderOptions {
  75961. /**
  75962. * Gets or sets the custom shader name to use
  75963. */
  75964. shaderName: string;
  75965. /**
  75966. * The list of attribute names used in the shader
  75967. */
  75968. attributes?: string[];
  75969. /**
  75970. * The list of unifrom names used in the shader
  75971. */
  75972. uniforms?: string[];
  75973. /**
  75974. * The list of sampler names used in the shader
  75975. */
  75976. samplers?: string[];
  75977. /**
  75978. * The list of defines used in the shader
  75979. */
  75980. defines?: string[];
  75981. }
  75982. /**
  75983. * Interface to implement to create a shadow generator compatible with BJS.
  75984. */
  75985. export interface IShadowGenerator {
  75986. /**
  75987. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75988. * @returns The render target texture if present otherwise, null
  75989. */
  75990. getShadowMap(): Nullable<RenderTargetTexture>;
  75991. /**
  75992. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75993. * @returns The render target texture if the shadow map is present otherwise, null
  75994. */
  75995. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75996. /**
  75997. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75998. * @param subMesh The submesh we want to render in the shadow map
  75999. * @param useInstances Defines wether will draw in the map using instances
  76000. * @returns true if ready otherwise, false
  76001. */
  76002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76003. /**
  76004. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76005. * @param defines Defines of the material we want to update
  76006. * @param lightIndex Index of the light in the enabled light list of the material
  76007. */
  76008. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76009. /**
  76010. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76011. * defined in the generator but impacting the effect).
  76012. * It implies the unifroms available on the materials are the standard BJS ones.
  76013. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76014. * @param effect The effect we are binfing the information for
  76015. */
  76016. bindShadowLight(lightIndex: string, effect: Effect): void;
  76017. /**
  76018. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76019. * (eq to shadow prjection matrix * light transform matrix)
  76020. * @returns The transform matrix used to create the shadow map
  76021. */
  76022. getTransformMatrix(): Matrix;
  76023. /**
  76024. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76025. * Cube and 2D textures for instance.
  76026. */
  76027. recreateShadowMap(): void;
  76028. /**
  76029. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76030. * @param onCompiled Callback triggered at the and of the effects compilation
  76031. * @param options Sets of optional options forcing the compilation with different modes
  76032. */
  76033. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76034. useInstances: boolean;
  76035. }>): void;
  76036. /**
  76037. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76038. * @param options Sets of optional options forcing the compilation with different modes
  76039. * @returns A promise that resolves when the compilation completes
  76040. */
  76041. forceCompilationAsync(options?: Partial<{
  76042. useInstances: boolean;
  76043. }>): Promise<void>;
  76044. /**
  76045. * Serializes the shadow generator setup to a json object.
  76046. * @returns The serialized JSON object
  76047. */
  76048. serialize(): any;
  76049. /**
  76050. * Disposes the Shadow map and related Textures and effects.
  76051. */
  76052. dispose(): void;
  76053. }
  76054. /**
  76055. * Default implementation IShadowGenerator.
  76056. * This is the main object responsible of generating shadows in the framework.
  76057. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76058. */
  76059. export class ShadowGenerator implements IShadowGenerator {
  76060. /**
  76061. * Shadow generator mode None: no filtering applied.
  76062. */
  76063. static readonly FILTER_NONE: number;
  76064. /**
  76065. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76066. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76067. */
  76068. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76069. /**
  76070. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76071. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76072. */
  76073. static readonly FILTER_POISSONSAMPLING: number;
  76074. /**
  76075. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76076. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76077. */
  76078. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76079. /**
  76080. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76081. * edge artifacts on steep falloff.
  76082. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76083. */
  76084. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76085. /**
  76086. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76087. * edge artifacts on steep falloff.
  76088. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76089. */
  76090. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76091. /**
  76092. * Shadow generator mode PCF: Percentage Closer Filtering
  76093. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76094. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76095. */
  76096. static readonly FILTER_PCF: number;
  76097. /**
  76098. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76099. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76100. * Contact Hardening
  76101. */
  76102. static readonly FILTER_PCSS: number;
  76103. /**
  76104. * Reserved for PCF and PCSS
  76105. * Highest Quality.
  76106. *
  76107. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76108. *
  76109. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76110. */
  76111. static readonly QUALITY_HIGH: number;
  76112. /**
  76113. * Reserved for PCF and PCSS
  76114. * Good tradeoff for quality/perf cross devices
  76115. *
  76116. * Execute PCF on a 3*3 kernel.
  76117. *
  76118. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76119. */
  76120. static readonly QUALITY_MEDIUM: number;
  76121. /**
  76122. * Reserved for PCF and PCSS
  76123. * The lowest quality but the fastest.
  76124. *
  76125. * Execute PCF on a 1*1 kernel.
  76126. *
  76127. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76128. */
  76129. static readonly QUALITY_LOW: number;
  76130. /** Gets or sets the custom shader name to use */
  76131. customShaderOptions: ICustomShaderOptions;
  76132. /**
  76133. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76134. */
  76135. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76136. /**
  76137. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76138. */
  76139. onAfterShadowMapRenderObservable: Observable<Effect>;
  76140. /**
  76141. * Observable triggered before a mesh is rendered in the shadow map.
  76142. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76143. */
  76144. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76145. /**
  76146. * Observable triggered after a mesh is rendered in the shadow map.
  76147. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76148. */
  76149. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76150. private _bias;
  76151. /**
  76152. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76153. */
  76154. /**
  76155. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76156. */
  76157. bias: number;
  76158. private _normalBias;
  76159. /**
  76160. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76161. */
  76162. /**
  76163. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76164. */
  76165. normalBias: number;
  76166. private _blurBoxOffset;
  76167. /**
  76168. * Gets the blur box offset: offset applied during the blur pass.
  76169. * Only useful if useKernelBlur = false
  76170. */
  76171. /**
  76172. * Sets the blur box offset: offset applied during the blur pass.
  76173. * Only useful if useKernelBlur = false
  76174. */
  76175. blurBoxOffset: number;
  76176. private _blurScale;
  76177. /**
  76178. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76179. * 2 means half of the size.
  76180. */
  76181. /**
  76182. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76183. * 2 means half of the size.
  76184. */
  76185. blurScale: number;
  76186. private _blurKernel;
  76187. /**
  76188. * Gets the blur kernel: kernel size of the blur pass.
  76189. * Only useful if useKernelBlur = true
  76190. */
  76191. /**
  76192. * Sets the blur kernel: kernel size of the blur pass.
  76193. * Only useful if useKernelBlur = true
  76194. */
  76195. blurKernel: number;
  76196. private _useKernelBlur;
  76197. /**
  76198. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76199. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76200. */
  76201. /**
  76202. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76203. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76204. */
  76205. useKernelBlur: boolean;
  76206. private _depthScale;
  76207. /**
  76208. * Gets the depth scale used in ESM mode.
  76209. */
  76210. /**
  76211. * Sets the depth scale used in ESM mode.
  76212. * This can override the scale stored on the light.
  76213. */
  76214. depthScale: number;
  76215. private _filter;
  76216. /**
  76217. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76218. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76219. */
  76220. /**
  76221. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76222. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76223. */
  76224. filter: number;
  76225. /**
  76226. * Gets if the current filter is set to Poisson Sampling.
  76227. */
  76228. /**
  76229. * Sets the current filter to Poisson Sampling.
  76230. */
  76231. usePoissonSampling: boolean;
  76232. /**
  76233. * Gets if the current filter is set to ESM.
  76234. */
  76235. /**
  76236. * Sets the current filter is to ESM.
  76237. */
  76238. useExponentialShadowMap: boolean;
  76239. /**
  76240. * Gets if the current filter is set to filtered ESM.
  76241. */
  76242. /**
  76243. * Gets if the current filter is set to filtered ESM.
  76244. */
  76245. useBlurExponentialShadowMap: boolean;
  76246. /**
  76247. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76248. * exponential to prevent steep falloff artifacts).
  76249. */
  76250. /**
  76251. * Sets the current filter to "close ESM" (using the inverse of the
  76252. * exponential to prevent steep falloff artifacts).
  76253. */
  76254. useCloseExponentialShadowMap: boolean;
  76255. /**
  76256. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76257. * exponential to prevent steep falloff artifacts).
  76258. */
  76259. /**
  76260. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76261. * exponential to prevent steep falloff artifacts).
  76262. */
  76263. useBlurCloseExponentialShadowMap: boolean;
  76264. /**
  76265. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76266. */
  76267. /**
  76268. * Sets the current filter to "PCF" (percentage closer filtering).
  76269. */
  76270. usePercentageCloserFiltering: boolean;
  76271. private _filteringQuality;
  76272. /**
  76273. * Gets the PCF or PCSS Quality.
  76274. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76275. */
  76276. /**
  76277. * Sets the PCF or PCSS Quality.
  76278. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76279. */
  76280. filteringQuality: number;
  76281. /**
  76282. * Gets if the current filter is set to "PCSS" (contact hardening).
  76283. */
  76284. /**
  76285. * Sets the current filter to "PCSS" (contact hardening).
  76286. */
  76287. useContactHardeningShadow: boolean;
  76288. private _contactHardeningLightSizeUVRatio;
  76289. /**
  76290. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76291. * Using a ratio helps keeping shape stability independently of the map size.
  76292. *
  76293. * It does not account for the light projection as it was having too much
  76294. * instability during the light setup or during light position changes.
  76295. *
  76296. * Only valid if useContactHardeningShadow is true.
  76297. */
  76298. /**
  76299. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76300. * Using a ratio helps keeping shape stability independently of the map size.
  76301. *
  76302. * It does not account for the light projection as it was having too much
  76303. * instability during the light setup or during light position changes.
  76304. *
  76305. * Only valid if useContactHardeningShadow is true.
  76306. */
  76307. contactHardeningLightSizeUVRatio: number;
  76308. private _darkness;
  76309. /** Gets or sets the actual darkness of a shadow */
  76310. darkness: number;
  76311. /**
  76312. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76313. * 0 means strongest and 1 would means no shadow.
  76314. * @returns the darkness.
  76315. */
  76316. getDarkness(): number;
  76317. /**
  76318. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76319. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76320. * @returns the shadow generator allowing fluent coding.
  76321. */
  76322. setDarkness(darkness: number): ShadowGenerator;
  76323. private _transparencyShadow;
  76324. /** Gets or sets the ability to have transparent shadow */
  76325. transparencyShadow: boolean;
  76326. /**
  76327. * Sets the ability to have transparent shadow (boolean).
  76328. * @param transparent True if transparent else False
  76329. * @returns the shadow generator allowing fluent coding
  76330. */
  76331. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76332. private _shadowMap;
  76333. private _shadowMap2;
  76334. /**
  76335. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76336. * @returns The render target texture if present otherwise, null
  76337. */
  76338. getShadowMap(): Nullable<RenderTargetTexture>;
  76339. /**
  76340. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76341. * @returns The render target texture if the shadow map is present otherwise, null
  76342. */
  76343. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76344. /**
  76345. * Gets the class name of that object
  76346. * @returns "ShadowGenerator"
  76347. */
  76348. getClassName(): string;
  76349. /**
  76350. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76351. * @param mesh Mesh to add
  76352. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76353. * @returns the Shadow Generator itself
  76354. */
  76355. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76356. /**
  76357. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76358. * @param mesh Mesh to remove
  76359. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76360. * @returns the Shadow Generator itself
  76361. */
  76362. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76363. /**
  76364. * Controls the extent to which the shadows fade out at the edge of the frustum
  76365. * Used only by directionals and spots
  76366. */
  76367. frustumEdgeFalloff: number;
  76368. private _light;
  76369. /**
  76370. * Returns the associated light object.
  76371. * @returns the light generating the shadow
  76372. */
  76373. getLight(): IShadowLight;
  76374. /**
  76375. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76376. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76377. * It might on the other hand introduce peter panning.
  76378. */
  76379. forceBackFacesOnly: boolean;
  76380. private _scene;
  76381. private _lightDirection;
  76382. private _effect;
  76383. private _viewMatrix;
  76384. private _projectionMatrix;
  76385. private _transformMatrix;
  76386. private _cachedPosition;
  76387. private _cachedDirection;
  76388. private _cachedDefines;
  76389. private _currentRenderID;
  76390. private _boxBlurPostprocess;
  76391. private _kernelBlurXPostprocess;
  76392. private _kernelBlurYPostprocess;
  76393. private _blurPostProcesses;
  76394. private _mapSize;
  76395. private _currentFaceIndex;
  76396. private _currentFaceIndexCache;
  76397. private _textureType;
  76398. private _defaultTextureMatrix;
  76399. /** @hidden */
  76400. static _SceneComponentInitialization: (scene: Scene) => void;
  76401. /**
  76402. * Creates a ShadowGenerator object.
  76403. * A ShadowGenerator is the required tool to use the shadows.
  76404. * Each light casting shadows needs to use its own ShadowGenerator.
  76405. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76406. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76407. * @param light The light object generating the shadows.
  76408. * @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.
  76409. */
  76410. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76411. private _initializeGenerator;
  76412. private _initializeShadowMap;
  76413. private _initializeBlurRTTAndPostProcesses;
  76414. private _renderForShadowMap;
  76415. private _renderSubMeshForShadowMap;
  76416. private _applyFilterValues;
  76417. /**
  76418. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76419. * @param onCompiled Callback triggered at the and of the effects compilation
  76420. * @param options Sets of optional options forcing the compilation with different modes
  76421. */
  76422. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76423. useInstances: boolean;
  76424. }>): void;
  76425. /**
  76426. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76427. * @param options Sets of optional options forcing the compilation with different modes
  76428. * @returns A promise that resolves when the compilation completes
  76429. */
  76430. forceCompilationAsync(options?: Partial<{
  76431. useInstances: boolean;
  76432. }>): Promise<void>;
  76433. /**
  76434. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76435. * @param subMesh The submesh we want to render in the shadow map
  76436. * @param useInstances Defines wether will draw in the map using instances
  76437. * @returns true if ready otherwise, false
  76438. */
  76439. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76440. /**
  76441. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76442. * @param defines Defines of the material we want to update
  76443. * @param lightIndex Index of the light in the enabled light list of the material
  76444. */
  76445. prepareDefines(defines: any, lightIndex: number): void;
  76446. /**
  76447. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76448. * defined in the generator but impacting the effect).
  76449. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76450. * @param effect The effect we are binfing the information for
  76451. */
  76452. bindShadowLight(lightIndex: string, effect: Effect): void;
  76453. /**
  76454. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76455. * (eq to shadow prjection matrix * light transform matrix)
  76456. * @returns The transform matrix used to create the shadow map
  76457. */
  76458. getTransformMatrix(): Matrix;
  76459. /**
  76460. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76461. * Cube and 2D textures for instance.
  76462. */
  76463. recreateShadowMap(): void;
  76464. private _disposeBlurPostProcesses;
  76465. private _disposeRTTandPostProcesses;
  76466. /**
  76467. * Disposes the ShadowGenerator.
  76468. * Returns nothing.
  76469. */
  76470. dispose(): void;
  76471. /**
  76472. * Serializes the shadow generator setup to a json object.
  76473. * @returns The serialized JSON object
  76474. */
  76475. serialize(): any;
  76476. /**
  76477. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76478. * @param parsedShadowGenerator The JSON object to parse
  76479. * @param scene The scene to create the shadow map for
  76480. * @returns The parsed shadow generator
  76481. */
  76482. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76483. }
  76484. }
  76485. declare module BABYLON {
  76486. /**
  76487. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76488. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76489. * 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.
  76490. */
  76491. export abstract class Light extends Node {
  76492. /**
  76493. * Falloff Default: light is falling off following the material specification:
  76494. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76495. */
  76496. static readonly FALLOFF_DEFAULT: number;
  76497. /**
  76498. * Falloff Physical: light is falling off following the inverse squared distance law.
  76499. */
  76500. static readonly FALLOFF_PHYSICAL: number;
  76501. /**
  76502. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76503. * to enhance interoperability with other engines.
  76504. */
  76505. static readonly FALLOFF_GLTF: number;
  76506. /**
  76507. * Falloff Standard: light is falling off like in the standard material
  76508. * to enhance interoperability with other materials.
  76509. */
  76510. static readonly FALLOFF_STANDARD: number;
  76511. /**
  76512. * If every light affecting the material is in this lightmapMode,
  76513. * material.lightmapTexture adds or multiplies
  76514. * (depends on material.useLightmapAsShadowmap)
  76515. * after every other light calculations.
  76516. */
  76517. static readonly LIGHTMAP_DEFAULT: number;
  76518. /**
  76519. * material.lightmapTexture as only diffuse lighting from this light
  76520. * adds only specular lighting from this light
  76521. * adds dynamic shadows
  76522. */
  76523. static readonly LIGHTMAP_SPECULAR: number;
  76524. /**
  76525. * material.lightmapTexture as only lighting
  76526. * no light calculation from this light
  76527. * only adds dynamic shadows from this light
  76528. */
  76529. static readonly LIGHTMAP_SHADOWSONLY: number;
  76530. /**
  76531. * Each light type uses the default quantity according to its type:
  76532. * point/spot lights use luminous intensity
  76533. * directional lights use illuminance
  76534. */
  76535. static readonly INTENSITYMODE_AUTOMATIC: number;
  76536. /**
  76537. * lumen (lm)
  76538. */
  76539. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76540. /**
  76541. * candela (lm/sr)
  76542. */
  76543. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76544. /**
  76545. * lux (lm/m^2)
  76546. */
  76547. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76548. /**
  76549. * nit (cd/m^2)
  76550. */
  76551. static readonly INTENSITYMODE_LUMINANCE: number;
  76552. /**
  76553. * Light type const id of the point light.
  76554. */
  76555. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76556. /**
  76557. * Light type const id of the directional light.
  76558. */
  76559. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76560. /**
  76561. * Light type const id of the spot light.
  76562. */
  76563. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76564. /**
  76565. * Light type const id of the hemispheric light.
  76566. */
  76567. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76568. /**
  76569. * Diffuse gives the basic color to an object.
  76570. */
  76571. diffuse: Color3;
  76572. /**
  76573. * Specular produces a highlight color on an object.
  76574. * Note: This is note affecting PBR materials.
  76575. */
  76576. specular: Color3;
  76577. /**
  76578. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76579. * falling off base on range or angle.
  76580. * This can be set to any values in Light.FALLOFF_x.
  76581. *
  76582. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76583. * other types of materials.
  76584. */
  76585. falloffType: number;
  76586. /**
  76587. * Strength of the light.
  76588. * Note: By default it is define in the framework own unit.
  76589. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76590. */
  76591. intensity: number;
  76592. private _range;
  76593. protected _inverseSquaredRange: number;
  76594. /**
  76595. * Defines how far from the source the light is impacting in scene units.
  76596. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76597. */
  76598. /**
  76599. * Defines how far from the source the light is impacting in scene units.
  76600. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76601. */
  76602. range: number;
  76603. /**
  76604. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76605. * of light.
  76606. */
  76607. private _photometricScale;
  76608. private _intensityMode;
  76609. /**
  76610. * Gets the photometric scale used to interpret the intensity.
  76611. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76612. */
  76613. /**
  76614. * Sets the photometric scale used to interpret the intensity.
  76615. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76616. */
  76617. intensityMode: number;
  76618. private _radius;
  76619. /**
  76620. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76621. */
  76622. /**
  76623. * sets the light radius used by PBR Materials to simulate soft area lights.
  76624. */
  76625. radius: number;
  76626. private _renderPriority;
  76627. /**
  76628. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76629. * exceeding the number allowed of the materials.
  76630. */
  76631. renderPriority: number;
  76632. private _shadowEnabled;
  76633. /**
  76634. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76635. * the current shadow generator.
  76636. */
  76637. /**
  76638. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76639. * the current shadow generator.
  76640. */
  76641. shadowEnabled: boolean;
  76642. private _includedOnlyMeshes;
  76643. /**
  76644. * Gets the only meshes impacted by this light.
  76645. */
  76646. /**
  76647. * Sets the only meshes impacted by this light.
  76648. */
  76649. includedOnlyMeshes: AbstractMesh[];
  76650. private _excludedMeshes;
  76651. /**
  76652. * Gets the meshes not impacted by this light.
  76653. */
  76654. /**
  76655. * Sets the meshes not impacted by this light.
  76656. */
  76657. excludedMeshes: AbstractMesh[];
  76658. private _excludeWithLayerMask;
  76659. /**
  76660. * Gets the layer id use to find what meshes are not impacted by the light.
  76661. * Inactive if 0
  76662. */
  76663. /**
  76664. * Sets the layer id use to find what meshes are not impacted by the light.
  76665. * Inactive if 0
  76666. */
  76667. excludeWithLayerMask: number;
  76668. private _includeOnlyWithLayerMask;
  76669. /**
  76670. * Gets the layer id use to find what meshes are impacted by the light.
  76671. * Inactive if 0
  76672. */
  76673. /**
  76674. * Sets the layer id use to find what meshes are impacted by the light.
  76675. * Inactive if 0
  76676. */
  76677. includeOnlyWithLayerMask: number;
  76678. private _lightmapMode;
  76679. /**
  76680. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76681. */
  76682. /**
  76683. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76684. */
  76685. lightmapMode: number;
  76686. /**
  76687. * Shadow generator associted to the light.
  76688. * @hidden Internal use only.
  76689. */
  76690. _shadowGenerator: Nullable<IShadowGenerator>;
  76691. /**
  76692. * @hidden Internal use only.
  76693. */
  76694. _excludedMeshesIds: string[];
  76695. /**
  76696. * @hidden Internal use only.
  76697. */
  76698. _includedOnlyMeshesIds: string[];
  76699. /**
  76700. * The current light unifom buffer.
  76701. * @hidden Internal use only.
  76702. */
  76703. _uniformBuffer: UniformBuffer;
  76704. /**
  76705. * Creates a Light object in the scene.
  76706. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76707. * @param name The firendly name of the light
  76708. * @param scene The scene the light belongs too
  76709. */
  76710. constructor(name: string, scene: Scene);
  76711. protected abstract _buildUniformLayout(): void;
  76712. /**
  76713. * Sets the passed Effect "effect" with the Light information.
  76714. * @param effect The effect to update
  76715. * @param lightIndex The index of the light in the effect to update
  76716. * @returns The light
  76717. */
  76718. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76719. /**
  76720. * Sets the passed Effect "effect" with the Light information.
  76721. * @param effect The effect to update
  76722. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76723. * @returns The light
  76724. */
  76725. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76726. /**
  76727. * Returns the string "Light".
  76728. * @returns the class name
  76729. */
  76730. getClassName(): string;
  76731. /** @hidden */
  76732. readonly _isLight: boolean;
  76733. /**
  76734. * Converts the light information to a readable string for debug purpose.
  76735. * @param fullDetails Supports for multiple levels of logging within scene loading
  76736. * @returns the human readable light info
  76737. */
  76738. toString(fullDetails?: boolean): string;
  76739. /** @hidden */
  76740. protected _syncParentEnabledState(): void;
  76741. /**
  76742. * Set the enabled state of this node.
  76743. * @param value - the new enabled state
  76744. */
  76745. setEnabled(value: boolean): void;
  76746. /**
  76747. * Returns the Light associated shadow generator if any.
  76748. * @return the associated shadow generator.
  76749. */
  76750. getShadowGenerator(): Nullable<IShadowGenerator>;
  76751. /**
  76752. * Returns a Vector3, the absolute light position in the World.
  76753. * @returns the world space position of the light
  76754. */
  76755. getAbsolutePosition(): Vector3;
  76756. /**
  76757. * Specifies if the light will affect the passed mesh.
  76758. * @param mesh The mesh to test against the light
  76759. * @return true the mesh is affected otherwise, false.
  76760. */
  76761. canAffectMesh(mesh: AbstractMesh): boolean;
  76762. /**
  76763. * Sort function to order lights for rendering.
  76764. * @param a First Light object to compare to second.
  76765. * @param b Second Light object to compare first.
  76766. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76767. */
  76768. static CompareLightsPriority(a: Light, b: Light): number;
  76769. /**
  76770. * Releases resources associated with this node.
  76771. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76772. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76773. */
  76774. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76775. /**
  76776. * Returns the light type ID (integer).
  76777. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76778. */
  76779. getTypeID(): number;
  76780. /**
  76781. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76782. * @returns the scaled intensity in intensity mode unit
  76783. */
  76784. getScaledIntensity(): number;
  76785. /**
  76786. * Returns a new Light object, named "name", from the current one.
  76787. * @param name The name of the cloned light
  76788. * @returns the new created light
  76789. */
  76790. clone(name: string): Nullable<Light>;
  76791. /**
  76792. * Serializes the current light into a Serialization object.
  76793. * @returns the serialized object.
  76794. */
  76795. serialize(): any;
  76796. /**
  76797. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76798. * This new light is named "name" and added to the passed scene.
  76799. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76800. * @param name The friendly name of the light
  76801. * @param scene The scene the new light will belong to
  76802. * @returns the constructor function
  76803. */
  76804. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76805. /**
  76806. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76807. * @param parsedLight The JSON representation of the light
  76808. * @param scene The scene to create the parsed light in
  76809. * @returns the created light after parsing
  76810. */
  76811. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76812. private _hookArrayForExcluded;
  76813. private _hookArrayForIncludedOnly;
  76814. private _resyncMeshes;
  76815. /**
  76816. * Forces the meshes to update their light related information in their rendering used effects
  76817. * @hidden Internal Use Only
  76818. */
  76819. _markMeshesAsLightDirty(): void;
  76820. /**
  76821. * Recomputes the cached photometric scale if needed.
  76822. */
  76823. private _computePhotometricScale;
  76824. /**
  76825. * Returns the Photometric Scale according to the light type and intensity mode.
  76826. */
  76827. private _getPhotometricScale;
  76828. /**
  76829. * Reorder the light in the scene according to their defined priority.
  76830. * @hidden Internal Use Only
  76831. */
  76832. _reorderLightsInScene(): void;
  76833. /**
  76834. * Prepares the list of defines specific to the light type.
  76835. * @param defines the list of defines
  76836. * @param lightIndex defines the index of the light for the effect
  76837. */
  76838. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76839. }
  76840. }
  76841. declare module BABYLON {
  76842. /**
  76843. * Interface used to define Action
  76844. */
  76845. export interface IAction {
  76846. /**
  76847. * Trigger for the action
  76848. */
  76849. trigger: number;
  76850. /** Options of the trigger */
  76851. triggerOptions: any;
  76852. /**
  76853. * Gets the trigger parameters
  76854. * @returns the trigger parameters
  76855. */
  76856. getTriggerParameter(): any;
  76857. /**
  76858. * Internal only - executes current action event
  76859. * @hidden
  76860. */
  76861. _executeCurrent(evt?: ActionEvent): void;
  76862. /**
  76863. * Serialize placeholder for child classes
  76864. * @param parent of child
  76865. * @returns the serialized object
  76866. */
  76867. serialize(parent: any): any;
  76868. /**
  76869. * Internal only
  76870. * @hidden
  76871. */
  76872. _prepare(): void;
  76873. /**
  76874. * Internal only - manager for action
  76875. * @hidden
  76876. */
  76877. _actionManager: AbstractActionManager;
  76878. /**
  76879. * Adds action to chain of actions, may be a DoNothingAction
  76880. * @param action defines the next action to execute
  76881. * @returns The action passed in
  76882. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76883. */
  76884. then(action: IAction): IAction;
  76885. }
  76886. /**
  76887. * The action to be carried out following a trigger
  76888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76889. */
  76890. export class Action implements IAction {
  76891. /** the trigger, with or without parameters, for the action */
  76892. triggerOptions: any;
  76893. /**
  76894. * Trigger for the action
  76895. */
  76896. trigger: number;
  76897. /**
  76898. * Internal only - manager for action
  76899. * @hidden
  76900. */
  76901. _actionManager: ActionManager;
  76902. private _nextActiveAction;
  76903. private _child;
  76904. private _condition?;
  76905. private _triggerParameter;
  76906. /**
  76907. * An event triggered prior to action being executed.
  76908. */
  76909. onBeforeExecuteObservable: Observable<Action>;
  76910. /**
  76911. * Creates a new Action
  76912. * @param triggerOptions the trigger, with or without parameters, for the action
  76913. * @param condition an optional determinant of action
  76914. */
  76915. constructor(
  76916. /** the trigger, with or without parameters, for the action */
  76917. triggerOptions: any, condition?: Condition);
  76918. /**
  76919. * Internal only
  76920. * @hidden
  76921. */
  76922. _prepare(): void;
  76923. /**
  76924. * Gets the trigger parameters
  76925. * @returns the trigger parameters
  76926. */
  76927. getTriggerParameter(): any;
  76928. /**
  76929. * Internal only - executes current action event
  76930. * @hidden
  76931. */
  76932. _executeCurrent(evt?: ActionEvent): void;
  76933. /**
  76934. * Execute placeholder for child classes
  76935. * @param evt optional action event
  76936. */
  76937. execute(evt?: ActionEvent): void;
  76938. /**
  76939. * Skips to next active action
  76940. */
  76941. skipToNextActiveAction(): void;
  76942. /**
  76943. * Adds action to chain of actions, may be a DoNothingAction
  76944. * @param action defines the next action to execute
  76945. * @returns The action passed in
  76946. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76947. */
  76948. then(action: Action): Action;
  76949. /**
  76950. * Internal only
  76951. * @hidden
  76952. */
  76953. _getProperty(propertyPath: string): string;
  76954. /**
  76955. * Internal only
  76956. * @hidden
  76957. */
  76958. _getEffectiveTarget(target: any, propertyPath: string): any;
  76959. /**
  76960. * Serialize placeholder for child classes
  76961. * @param parent of child
  76962. * @returns the serialized object
  76963. */
  76964. serialize(parent: any): any;
  76965. /**
  76966. * Internal only called by serialize
  76967. * @hidden
  76968. */
  76969. protected _serialize(serializedAction: any, parent?: any): any;
  76970. /**
  76971. * Internal only
  76972. * @hidden
  76973. */
  76974. static _SerializeValueAsString: (value: any) => string;
  76975. /**
  76976. * Internal only
  76977. * @hidden
  76978. */
  76979. static _GetTargetProperty: (target: Node | Scene) => {
  76980. name: string;
  76981. targetType: string;
  76982. value: string;
  76983. };
  76984. }
  76985. }
  76986. declare module BABYLON {
  76987. /**
  76988. * A Condition applied to an Action
  76989. */
  76990. export class Condition {
  76991. /**
  76992. * Internal only - manager for action
  76993. * @hidden
  76994. */
  76995. _actionManager: ActionManager;
  76996. /**
  76997. * Internal only
  76998. * @hidden
  76999. */
  77000. _evaluationId: number;
  77001. /**
  77002. * Internal only
  77003. * @hidden
  77004. */
  77005. _currentResult: boolean;
  77006. /**
  77007. * Creates a new Condition
  77008. * @param actionManager the manager of the action the condition is applied to
  77009. */
  77010. constructor(actionManager: ActionManager);
  77011. /**
  77012. * Check if the current condition is valid
  77013. * @returns a boolean
  77014. */
  77015. isValid(): boolean;
  77016. /**
  77017. * Internal only
  77018. * @hidden
  77019. */
  77020. _getProperty(propertyPath: string): string;
  77021. /**
  77022. * Internal only
  77023. * @hidden
  77024. */
  77025. _getEffectiveTarget(target: any, propertyPath: string): any;
  77026. /**
  77027. * Serialize placeholder for child classes
  77028. * @returns the serialized object
  77029. */
  77030. serialize(): any;
  77031. /**
  77032. * Internal only
  77033. * @hidden
  77034. */
  77035. protected _serialize(serializedCondition: any): any;
  77036. }
  77037. /**
  77038. * Defines specific conditional operators as extensions of Condition
  77039. */
  77040. export class ValueCondition extends Condition {
  77041. /** path to specify the property of the target the conditional operator uses */
  77042. propertyPath: string;
  77043. /** the value compared by the conditional operator against the current value of the property */
  77044. value: any;
  77045. /** the conditional operator, default ValueCondition.IsEqual */
  77046. operator: number;
  77047. /**
  77048. * Internal only
  77049. * @hidden
  77050. */
  77051. private static _IsEqual;
  77052. /**
  77053. * Internal only
  77054. * @hidden
  77055. */
  77056. private static _IsDifferent;
  77057. /**
  77058. * Internal only
  77059. * @hidden
  77060. */
  77061. private static _IsGreater;
  77062. /**
  77063. * Internal only
  77064. * @hidden
  77065. */
  77066. private static _IsLesser;
  77067. /**
  77068. * returns the number for IsEqual
  77069. */
  77070. static readonly IsEqual: number;
  77071. /**
  77072. * Returns the number for IsDifferent
  77073. */
  77074. static readonly IsDifferent: number;
  77075. /**
  77076. * Returns the number for IsGreater
  77077. */
  77078. static readonly IsGreater: number;
  77079. /**
  77080. * Returns the number for IsLesser
  77081. */
  77082. static readonly IsLesser: number;
  77083. /**
  77084. * Internal only The action manager for the condition
  77085. * @hidden
  77086. */
  77087. _actionManager: ActionManager;
  77088. /**
  77089. * Internal only
  77090. * @hidden
  77091. */
  77092. private _target;
  77093. /**
  77094. * Internal only
  77095. * @hidden
  77096. */
  77097. private _effectiveTarget;
  77098. /**
  77099. * Internal only
  77100. * @hidden
  77101. */
  77102. private _property;
  77103. /**
  77104. * Creates a new ValueCondition
  77105. * @param actionManager manager for the action the condition applies to
  77106. * @param target for the action
  77107. * @param propertyPath path to specify the property of the target the conditional operator uses
  77108. * @param value the value compared by the conditional operator against the current value of the property
  77109. * @param operator the conditional operator, default ValueCondition.IsEqual
  77110. */
  77111. constructor(actionManager: ActionManager, target: any,
  77112. /** path to specify the property of the target the conditional operator uses */
  77113. propertyPath: string,
  77114. /** the value compared by the conditional operator against the current value of the property */
  77115. value: any,
  77116. /** the conditional operator, default ValueCondition.IsEqual */
  77117. operator?: number);
  77118. /**
  77119. * Compares the given value with the property value for the specified conditional operator
  77120. * @returns the result of the comparison
  77121. */
  77122. isValid(): boolean;
  77123. /**
  77124. * Serialize the ValueCondition into a JSON compatible object
  77125. * @returns serialization object
  77126. */
  77127. serialize(): any;
  77128. /**
  77129. * Gets the name of the conditional operator for the ValueCondition
  77130. * @param operator the conditional operator
  77131. * @returns the name
  77132. */
  77133. static GetOperatorName(operator: number): string;
  77134. }
  77135. /**
  77136. * Defines a predicate condition as an extension of Condition
  77137. */
  77138. export class PredicateCondition extends Condition {
  77139. /** defines the predicate function used to validate the condition */
  77140. predicate: () => boolean;
  77141. /**
  77142. * Internal only - manager for action
  77143. * @hidden
  77144. */
  77145. _actionManager: ActionManager;
  77146. /**
  77147. * Creates a new PredicateCondition
  77148. * @param actionManager manager for the action the condition applies to
  77149. * @param predicate defines the predicate function used to validate the condition
  77150. */
  77151. constructor(actionManager: ActionManager,
  77152. /** defines the predicate function used to validate the condition */
  77153. predicate: () => boolean);
  77154. /**
  77155. * @returns the validity of the predicate condition
  77156. */
  77157. isValid(): boolean;
  77158. }
  77159. /**
  77160. * Defines a state condition as an extension of Condition
  77161. */
  77162. export class StateCondition extends Condition {
  77163. /** Value to compare with target state */
  77164. value: string;
  77165. /**
  77166. * Internal only - manager for action
  77167. * @hidden
  77168. */
  77169. _actionManager: ActionManager;
  77170. /**
  77171. * Internal only
  77172. * @hidden
  77173. */
  77174. private _target;
  77175. /**
  77176. * Creates a new StateCondition
  77177. * @param actionManager manager for the action the condition applies to
  77178. * @param target of the condition
  77179. * @param value to compare with target state
  77180. */
  77181. constructor(actionManager: ActionManager, target: any,
  77182. /** Value to compare with target state */
  77183. value: string);
  77184. /**
  77185. * Gets a boolean indicating if the current condition is met
  77186. * @returns the validity of the state
  77187. */
  77188. isValid(): boolean;
  77189. /**
  77190. * Serialize the StateCondition into a JSON compatible object
  77191. * @returns serialization object
  77192. */
  77193. serialize(): any;
  77194. }
  77195. }
  77196. declare module BABYLON {
  77197. /**
  77198. * This defines an action responsible to toggle a boolean once triggered.
  77199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77200. */
  77201. export class SwitchBooleanAction extends Action {
  77202. /**
  77203. * The path to the boolean property in the target object
  77204. */
  77205. propertyPath: string;
  77206. private _target;
  77207. private _effectiveTarget;
  77208. private _property;
  77209. /**
  77210. * Instantiate the action
  77211. * @param triggerOptions defines the trigger options
  77212. * @param target defines the object containing the boolean
  77213. * @param propertyPath defines the path to the boolean property in the target object
  77214. * @param condition defines the trigger related conditions
  77215. */
  77216. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77217. /** @hidden */
  77218. _prepare(): void;
  77219. /**
  77220. * Execute the action toggle the boolean value.
  77221. */
  77222. execute(): void;
  77223. /**
  77224. * Serializes the actions and its related information.
  77225. * @param parent defines the object to serialize in
  77226. * @returns the serialized object
  77227. */
  77228. serialize(parent: any): any;
  77229. }
  77230. /**
  77231. * This defines an action responsible to set a the state field of the target
  77232. * to a desired value once triggered.
  77233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77234. */
  77235. export class SetStateAction extends Action {
  77236. /**
  77237. * The value to store in the state field.
  77238. */
  77239. value: string;
  77240. private _target;
  77241. /**
  77242. * Instantiate the action
  77243. * @param triggerOptions defines the trigger options
  77244. * @param target defines the object containing the state property
  77245. * @param value defines the value to store in the state field
  77246. * @param condition defines the trigger related conditions
  77247. */
  77248. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77249. /**
  77250. * Execute the action and store the value on the target state property.
  77251. */
  77252. execute(): void;
  77253. /**
  77254. * Serializes the actions and its related information.
  77255. * @param parent defines the object to serialize in
  77256. * @returns the serialized object
  77257. */
  77258. serialize(parent: any): any;
  77259. }
  77260. /**
  77261. * This defines an action responsible to set a property of the target
  77262. * to a desired value once triggered.
  77263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77264. */
  77265. export class SetValueAction extends Action {
  77266. /**
  77267. * The path of the property to set in the target.
  77268. */
  77269. propertyPath: string;
  77270. /**
  77271. * The value to set in the property
  77272. */
  77273. value: any;
  77274. private _target;
  77275. private _effectiveTarget;
  77276. private _property;
  77277. /**
  77278. * Instantiate the action
  77279. * @param triggerOptions defines the trigger options
  77280. * @param target defines the object containing the property
  77281. * @param propertyPath defines the path of the property to set in the target
  77282. * @param value defines the value to set in the property
  77283. * @param condition defines the trigger related conditions
  77284. */
  77285. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77286. /** @hidden */
  77287. _prepare(): void;
  77288. /**
  77289. * Execute the action and set the targetted property to the desired value.
  77290. */
  77291. execute(): void;
  77292. /**
  77293. * Serializes the actions and its related information.
  77294. * @param parent defines the object to serialize in
  77295. * @returns the serialized object
  77296. */
  77297. serialize(parent: any): any;
  77298. }
  77299. /**
  77300. * This defines an action responsible to increment the target value
  77301. * to a desired value once triggered.
  77302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77303. */
  77304. export class IncrementValueAction extends Action {
  77305. /**
  77306. * The path of the property to increment in the target.
  77307. */
  77308. propertyPath: string;
  77309. /**
  77310. * The value we should increment the property by.
  77311. */
  77312. value: any;
  77313. private _target;
  77314. private _effectiveTarget;
  77315. private _property;
  77316. /**
  77317. * Instantiate the action
  77318. * @param triggerOptions defines the trigger options
  77319. * @param target defines the object containing the property
  77320. * @param propertyPath defines the path of the property to increment in the target
  77321. * @param value defines the value value we should increment the property by
  77322. * @param condition defines the trigger related conditions
  77323. */
  77324. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77325. /** @hidden */
  77326. _prepare(): void;
  77327. /**
  77328. * Execute the action and increment the target of the value amount.
  77329. */
  77330. execute(): void;
  77331. /**
  77332. * Serializes the actions and its related information.
  77333. * @param parent defines the object to serialize in
  77334. * @returns the serialized object
  77335. */
  77336. serialize(parent: any): any;
  77337. }
  77338. /**
  77339. * This defines an action responsible to start an animation once triggered.
  77340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77341. */
  77342. export class PlayAnimationAction extends Action {
  77343. /**
  77344. * Where the animation should start (animation frame)
  77345. */
  77346. from: number;
  77347. /**
  77348. * Where the animation should stop (animation frame)
  77349. */
  77350. to: number;
  77351. /**
  77352. * Define if the animation should loop or stop after the first play.
  77353. */
  77354. loop?: boolean;
  77355. private _target;
  77356. /**
  77357. * Instantiate the action
  77358. * @param triggerOptions defines the trigger options
  77359. * @param target defines the target animation or animation name
  77360. * @param from defines from where the animation should start (animation frame)
  77361. * @param end defines where the animation should stop (animation frame)
  77362. * @param loop defines if the animation should loop or stop after the first play
  77363. * @param condition defines the trigger related conditions
  77364. */
  77365. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77366. /** @hidden */
  77367. _prepare(): void;
  77368. /**
  77369. * Execute the action and play the animation.
  77370. */
  77371. execute(): void;
  77372. /**
  77373. * Serializes the actions and its related information.
  77374. * @param parent defines the object to serialize in
  77375. * @returns the serialized object
  77376. */
  77377. serialize(parent: any): any;
  77378. }
  77379. /**
  77380. * This defines an action responsible to stop an animation once triggered.
  77381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77382. */
  77383. export class StopAnimationAction extends Action {
  77384. private _target;
  77385. /**
  77386. * Instantiate the action
  77387. * @param triggerOptions defines the trigger options
  77388. * @param target defines the target animation or animation name
  77389. * @param condition defines the trigger related conditions
  77390. */
  77391. constructor(triggerOptions: any, target: any, condition?: Condition);
  77392. /** @hidden */
  77393. _prepare(): void;
  77394. /**
  77395. * Execute the action and stop the animation.
  77396. */
  77397. execute(): void;
  77398. /**
  77399. * Serializes the actions and its related information.
  77400. * @param parent defines the object to serialize in
  77401. * @returns the serialized object
  77402. */
  77403. serialize(parent: any): any;
  77404. }
  77405. /**
  77406. * This defines an action responsible that does nothing once triggered.
  77407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77408. */
  77409. export class DoNothingAction extends Action {
  77410. /**
  77411. * Instantiate the action
  77412. * @param triggerOptions defines the trigger options
  77413. * @param condition defines the trigger related conditions
  77414. */
  77415. constructor(triggerOptions?: any, condition?: Condition);
  77416. /**
  77417. * Execute the action and do nothing.
  77418. */
  77419. execute(): void;
  77420. /**
  77421. * Serializes the actions and its related information.
  77422. * @param parent defines the object to serialize in
  77423. * @returns the serialized object
  77424. */
  77425. serialize(parent: any): any;
  77426. }
  77427. /**
  77428. * This defines an action responsible to trigger several actions once triggered.
  77429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77430. */
  77431. export class CombineAction extends Action {
  77432. /**
  77433. * The list of aggregated animations to run.
  77434. */
  77435. children: Action[];
  77436. /**
  77437. * Instantiate the action
  77438. * @param triggerOptions defines the trigger options
  77439. * @param children defines the list of aggregated animations to run
  77440. * @param condition defines the trigger related conditions
  77441. */
  77442. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77443. /** @hidden */
  77444. _prepare(): void;
  77445. /**
  77446. * Execute the action and executes all the aggregated actions.
  77447. */
  77448. execute(evt: ActionEvent): void;
  77449. /**
  77450. * Serializes the actions and its related information.
  77451. * @param parent defines the object to serialize in
  77452. * @returns the serialized object
  77453. */
  77454. serialize(parent: any): any;
  77455. }
  77456. /**
  77457. * This defines an action responsible to run code (external event) once triggered.
  77458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77459. */
  77460. export class ExecuteCodeAction extends Action {
  77461. /**
  77462. * The callback function to run.
  77463. */
  77464. func: (evt: ActionEvent) => void;
  77465. /**
  77466. * Instantiate the action
  77467. * @param triggerOptions defines the trigger options
  77468. * @param func defines the callback function to run
  77469. * @param condition defines the trigger related conditions
  77470. */
  77471. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77472. /**
  77473. * Execute the action and run the attached code.
  77474. */
  77475. execute(evt: ActionEvent): void;
  77476. }
  77477. /**
  77478. * This defines an action responsible to set the parent property of the target once triggered.
  77479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77480. */
  77481. export class SetParentAction extends Action {
  77482. private _parent;
  77483. private _target;
  77484. /**
  77485. * Instantiate the action
  77486. * @param triggerOptions defines the trigger options
  77487. * @param target defines the target containing the parent property
  77488. * @param parent defines from where the animation should start (animation frame)
  77489. * @param condition defines the trigger related conditions
  77490. */
  77491. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77492. /** @hidden */
  77493. _prepare(): void;
  77494. /**
  77495. * Execute the action and set the parent property.
  77496. */
  77497. execute(): void;
  77498. /**
  77499. * Serializes the actions and its related information.
  77500. * @param parent defines the object to serialize in
  77501. * @returns the serialized object
  77502. */
  77503. serialize(parent: any): any;
  77504. }
  77505. }
  77506. declare module BABYLON {
  77507. /**
  77508. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77509. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77511. */
  77512. export class ActionManager extends AbstractActionManager {
  77513. /**
  77514. * Nothing
  77515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77516. */
  77517. static readonly NothingTrigger: number;
  77518. /**
  77519. * On pick
  77520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77521. */
  77522. static readonly OnPickTrigger: number;
  77523. /**
  77524. * On left pick
  77525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77526. */
  77527. static readonly OnLeftPickTrigger: number;
  77528. /**
  77529. * On right pick
  77530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77531. */
  77532. static readonly OnRightPickTrigger: number;
  77533. /**
  77534. * On center pick
  77535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77536. */
  77537. static readonly OnCenterPickTrigger: number;
  77538. /**
  77539. * On pick down
  77540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77541. */
  77542. static readonly OnPickDownTrigger: number;
  77543. /**
  77544. * On double pick
  77545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77546. */
  77547. static readonly OnDoublePickTrigger: number;
  77548. /**
  77549. * On pick up
  77550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77551. */
  77552. static readonly OnPickUpTrigger: number;
  77553. /**
  77554. * On pick out.
  77555. * This trigger will only be raised if you also declared a OnPickDown
  77556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77557. */
  77558. static readonly OnPickOutTrigger: number;
  77559. /**
  77560. * On long press
  77561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77562. */
  77563. static readonly OnLongPressTrigger: number;
  77564. /**
  77565. * On pointer over
  77566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77567. */
  77568. static readonly OnPointerOverTrigger: number;
  77569. /**
  77570. * On pointer out
  77571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77572. */
  77573. static readonly OnPointerOutTrigger: number;
  77574. /**
  77575. * On every frame
  77576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77577. */
  77578. static readonly OnEveryFrameTrigger: number;
  77579. /**
  77580. * On intersection enter
  77581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77582. */
  77583. static readonly OnIntersectionEnterTrigger: number;
  77584. /**
  77585. * On intersection exit
  77586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77587. */
  77588. static readonly OnIntersectionExitTrigger: number;
  77589. /**
  77590. * On key down
  77591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77592. */
  77593. static readonly OnKeyDownTrigger: number;
  77594. /**
  77595. * On key up
  77596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77597. */
  77598. static readonly OnKeyUpTrigger: number;
  77599. private _scene;
  77600. /**
  77601. * Creates a new action manager
  77602. * @param scene defines the hosting scene
  77603. */
  77604. constructor(scene: Scene);
  77605. /**
  77606. * Releases all associated resources
  77607. */
  77608. dispose(): void;
  77609. /**
  77610. * Gets hosting scene
  77611. * @returns the hosting scene
  77612. */
  77613. getScene(): Scene;
  77614. /**
  77615. * Does this action manager handles actions of any of the given triggers
  77616. * @param triggers defines the triggers to be tested
  77617. * @return a boolean indicating whether one (or more) of the triggers is handled
  77618. */
  77619. hasSpecificTriggers(triggers: number[]): boolean;
  77620. /**
  77621. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77622. * speed.
  77623. * @param triggerA defines the trigger to be tested
  77624. * @param triggerB defines the trigger to be tested
  77625. * @return a boolean indicating whether one (or more) of the triggers is handled
  77626. */
  77627. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77628. /**
  77629. * Does this action manager handles actions of a given trigger
  77630. * @param trigger defines the trigger to be tested
  77631. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77632. * @return whether the trigger is handled
  77633. */
  77634. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77635. /**
  77636. * Does this action manager has pointer triggers
  77637. */
  77638. readonly hasPointerTriggers: boolean;
  77639. /**
  77640. * Does this action manager has pick triggers
  77641. */
  77642. readonly hasPickTriggers: boolean;
  77643. /**
  77644. * Registers an action to this action manager
  77645. * @param action defines the action to be registered
  77646. * @return the action amended (prepared) after registration
  77647. */
  77648. registerAction(action: IAction): Nullable<IAction>;
  77649. /**
  77650. * Unregisters an action to this action manager
  77651. * @param action defines the action to be unregistered
  77652. * @return a boolean indicating whether the action has been unregistered
  77653. */
  77654. unregisterAction(action: IAction): Boolean;
  77655. /**
  77656. * Process a specific trigger
  77657. * @param trigger defines the trigger to process
  77658. * @param evt defines the event details to be processed
  77659. */
  77660. processTrigger(trigger: number, evt?: IActionEvent): void;
  77661. /** @hidden */
  77662. _getEffectiveTarget(target: any, propertyPath: string): any;
  77663. /** @hidden */
  77664. _getProperty(propertyPath: string): string;
  77665. /**
  77666. * Serialize this manager to a JSON object
  77667. * @param name defines the property name to store this manager
  77668. * @returns a JSON representation of this manager
  77669. */
  77670. serialize(name: string): any;
  77671. /**
  77672. * Creates a new ActionManager from a JSON data
  77673. * @param parsedActions defines the JSON data to read from
  77674. * @param object defines the hosting mesh
  77675. * @param scene defines the hosting scene
  77676. */
  77677. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77678. /**
  77679. * Get a trigger name by index
  77680. * @param trigger defines the trigger index
  77681. * @returns a trigger name
  77682. */
  77683. static GetTriggerName(trigger: number): string;
  77684. }
  77685. }
  77686. declare module BABYLON {
  77687. /**
  77688. * Class representing a ray with position and direction
  77689. */
  77690. export class Ray {
  77691. /** origin point */
  77692. origin: Vector3;
  77693. /** direction */
  77694. direction: Vector3;
  77695. /** length of the ray */
  77696. length: number;
  77697. private static readonly TmpVector3;
  77698. private _tmpRay;
  77699. /**
  77700. * Creates a new ray
  77701. * @param origin origin point
  77702. * @param direction direction
  77703. * @param length length of the ray
  77704. */
  77705. constructor(
  77706. /** origin point */
  77707. origin: Vector3,
  77708. /** direction */
  77709. direction: Vector3,
  77710. /** length of the ray */
  77711. length?: number);
  77712. /**
  77713. * Checks if the ray intersects a box
  77714. * @param minimum bound of the box
  77715. * @param maximum bound of the box
  77716. * @param intersectionTreshold extra extend to be added to the box in all direction
  77717. * @returns if the box was hit
  77718. */
  77719. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77720. /**
  77721. * Checks if the ray intersects a box
  77722. * @param box the bounding box to check
  77723. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77724. * @returns if the box was hit
  77725. */
  77726. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77727. /**
  77728. * If the ray hits a sphere
  77729. * @param sphere the bounding sphere to check
  77730. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77731. * @returns true if it hits the sphere
  77732. */
  77733. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77734. /**
  77735. * If the ray hits a triange
  77736. * @param vertex0 triangle vertex
  77737. * @param vertex1 triangle vertex
  77738. * @param vertex2 triangle vertex
  77739. * @returns intersection information if hit
  77740. */
  77741. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77742. /**
  77743. * Checks if ray intersects a plane
  77744. * @param plane the plane to check
  77745. * @returns the distance away it was hit
  77746. */
  77747. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77748. /**
  77749. * Calculate the intercept of a ray on a given axis
  77750. * @param axis to check 'x' | 'y' | 'z'
  77751. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77752. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77753. */
  77754. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77755. /**
  77756. * Checks if ray intersects a mesh
  77757. * @param mesh the mesh to check
  77758. * @param fastCheck if only the bounding box should checked
  77759. * @returns picking info of the intersecton
  77760. */
  77761. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77762. /**
  77763. * Checks if ray intersects a mesh
  77764. * @param meshes the meshes to check
  77765. * @param fastCheck if only the bounding box should checked
  77766. * @param results array to store result in
  77767. * @returns Array of picking infos
  77768. */
  77769. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77770. private _comparePickingInfo;
  77771. private static smallnum;
  77772. private static rayl;
  77773. /**
  77774. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77775. * @param sega the first point of the segment to test the intersection against
  77776. * @param segb the second point of the segment to test the intersection against
  77777. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77778. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77779. */
  77780. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77781. /**
  77782. * Update the ray from viewport position
  77783. * @param x position
  77784. * @param y y position
  77785. * @param viewportWidth viewport width
  77786. * @param viewportHeight viewport height
  77787. * @param world world matrix
  77788. * @param view view matrix
  77789. * @param projection projection matrix
  77790. * @returns this ray updated
  77791. */
  77792. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77793. /**
  77794. * Creates a ray with origin and direction of 0,0,0
  77795. * @returns the new ray
  77796. */
  77797. static Zero(): Ray;
  77798. /**
  77799. * Creates a new ray from screen space and viewport
  77800. * @param x position
  77801. * @param y y position
  77802. * @param viewportWidth viewport width
  77803. * @param viewportHeight viewport height
  77804. * @param world world matrix
  77805. * @param view view matrix
  77806. * @param projection projection matrix
  77807. * @returns new ray
  77808. */
  77809. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77810. /**
  77811. * 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
  77812. * transformed to the given world matrix.
  77813. * @param origin The origin point
  77814. * @param end The end point
  77815. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77816. * @returns the new ray
  77817. */
  77818. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77819. /**
  77820. * Transforms a ray by a matrix
  77821. * @param ray ray to transform
  77822. * @param matrix matrix to apply
  77823. * @returns the resulting new ray
  77824. */
  77825. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77826. /**
  77827. * Transforms a ray by a matrix
  77828. * @param ray ray to transform
  77829. * @param matrix matrix to apply
  77830. * @param result ray to store result in
  77831. */
  77832. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77833. /**
  77834. * Unproject a ray from screen space to object space
  77835. * @param sourceX defines the screen space x coordinate to use
  77836. * @param sourceY defines the screen space y coordinate to use
  77837. * @param viewportWidth defines the current width of the viewport
  77838. * @param viewportHeight defines the current height of the viewport
  77839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77840. * @param view defines the view matrix to use
  77841. * @param projection defines the projection matrix to use
  77842. */
  77843. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77844. }
  77845. /**
  77846. * Type used to define predicate used to select faces when a mesh intersection is detected
  77847. */
  77848. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77849. interface Scene {
  77850. /** @hidden */
  77851. _tempPickingRay: Nullable<Ray>;
  77852. /** @hidden */
  77853. _cachedRayForTransform: Ray;
  77854. /** @hidden */
  77855. _pickWithRayInverseMatrix: Matrix;
  77856. /** @hidden */
  77857. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77858. /** @hidden */
  77859. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77860. }
  77861. }
  77862. declare module BABYLON {
  77863. /**
  77864. * Groups all the scene component constants in one place to ease maintenance.
  77865. * @hidden
  77866. */
  77867. export class SceneComponentConstants {
  77868. static readonly NAME_EFFECTLAYER: string;
  77869. static readonly NAME_LAYER: string;
  77870. static readonly NAME_LENSFLARESYSTEM: string;
  77871. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77872. static readonly NAME_PARTICLESYSTEM: string;
  77873. static readonly NAME_GAMEPAD: string;
  77874. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77875. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77876. static readonly NAME_DEPTHRENDERER: string;
  77877. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77878. static readonly NAME_SPRITE: string;
  77879. static readonly NAME_OUTLINERENDERER: string;
  77880. static readonly NAME_PROCEDURALTEXTURE: string;
  77881. static readonly NAME_SHADOWGENERATOR: string;
  77882. static readonly NAME_OCTREE: string;
  77883. static readonly NAME_PHYSICSENGINE: string;
  77884. static readonly NAME_AUDIO: string;
  77885. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77886. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77887. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77888. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77889. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77890. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77891. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77892. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77893. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77894. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77895. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77896. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77897. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77898. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77899. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77900. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77901. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77902. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77903. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77904. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77905. static readonly STEP_AFTERRENDER_AUDIO: number;
  77906. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77907. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77908. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77909. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77910. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77911. static readonly STEP_POINTERMOVE_SPRITE: number;
  77912. static readonly STEP_POINTERDOWN_SPRITE: number;
  77913. static readonly STEP_POINTERUP_SPRITE: number;
  77914. }
  77915. /**
  77916. * This represents a scene component.
  77917. *
  77918. * This is used to decouple the dependency the scene is having on the different workloads like
  77919. * layers, post processes...
  77920. */
  77921. export interface ISceneComponent {
  77922. /**
  77923. * The name of the component. Each component must have a unique name.
  77924. */
  77925. name: string;
  77926. /**
  77927. * The scene the component belongs to.
  77928. */
  77929. scene: Scene;
  77930. /**
  77931. * Register the component to one instance of a scene.
  77932. */
  77933. register(): void;
  77934. /**
  77935. * Rebuilds the elements related to this component in case of
  77936. * context lost for instance.
  77937. */
  77938. rebuild(): void;
  77939. /**
  77940. * Disposes the component and the associated ressources.
  77941. */
  77942. dispose(): void;
  77943. }
  77944. /**
  77945. * This represents a SERIALIZABLE scene component.
  77946. *
  77947. * This extends Scene Component to add Serialization methods on top.
  77948. */
  77949. export interface ISceneSerializableComponent extends ISceneComponent {
  77950. /**
  77951. * Adds all the elements from the container to the scene
  77952. * @param container the container holding the elements
  77953. */
  77954. addFromContainer(container: AbstractScene): void;
  77955. /**
  77956. * Removes all the elements in the container from the scene
  77957. * @param container contains the elements to remove
  77958. * @param dispose if the removed element should be disposed (default: false)
  77959. */
  77960. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77961. /**
  77962. * Serializes the component data to the specified json object
  77963. * @param serializationObject The object to serialize to
  77964. */
  77965. serialize(serializationObject: any): void;
  77966. }
  77967. /**
  77968. * Strong typing of a Mesh related stage step action
  77969. */
  77970. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77971. /**
  77972. * Strong typing of a Evaluate Sub Mesh related stage step action
  77973. */
  77974. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77975. /**
  77976. * Strong typing of a Active Mesh related stage step action
  77977. */
  77978. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77979. /**
  77980. * Strong typing of a Camera related stage step action
  77981. */
  77982. export type CameraStageAction = (camera: Camera) => void;
  77983. /**
  77984. * Strong typing of a Camera Frame buffer related stage step action
  77985. */
  77986. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77987. /**
  77988. * Strong typing of a Render Target related stage step action
  77989. */
  77990. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77991. /**
  77992. * Strong typing of a RenderingGroup related stage step action
  77993. */
  77994. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77995. /**
  77996. * Strong typing of a Mesh Render related stage step action
  77997. */
  77998. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77999. /**
  78000. * Strong typing of a simple stage step action
  78001. */
  78002. export type SimpleStageAction = () => void;
  78003. /**
  78004. * Strong typing of a render target action.
  78005. */
  78006. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78007. /**
  78008. * Strong typing of a pointer move action.
  78009. */
  78010. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78011. /**
  78012. * Strong typing of a pointer up/down action.
  78013. */
  78014. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78015. /**
  78016. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78017. * @hidden
  78018. */
  78019. export class Stage<T extends Function> extends Array<{
  78020. index: number;
  78021. component: ISceneComponent;
  78022. action: T;
  78023. }> {
  78024. /**
  78025. * Hide ctor from the rest of the world.
  78026. * @param items The items to add.
  78027. */
  78028. private constructor();
  78029. /**
  78030. * Creates a new Stage.
  78031. * @returns A new instance of a Stage
  78032. */
  78033. static Create<T extends Function>(): Stage<T>;
  78034. /**
  78035. * Registers a step in an ordered way in the targeted stage.
  78036. * @param index Defines the position to register the step in
  78037. * @param component Defines the component attached to the step
  78038. * @param action Defines the action to launch during the step
  78039. */
  78040. registerStep(index: number, component: ISceneComponent, action: T): void;
  78041. /**
  78042. * Clears all the steps from the stage.
  78043. */
  78044. clear(): void;
  78045. }
  78046. }
  78047. declare module BABYLON {
  78048. interface Scene {
  78049. /** @hidden */
  78050. _pointerOverSprite: Nullable<Sprite>;
  78051. /** @hidden */
  78052. _pickedDownSprite: Nullable<Sprite>;
  78053. /** @hidden */
  78054. _tempSpritePickingRay: Nullable<Ray>;
  78055. /**
  78056. * All of the sprite managers added to this scene
  78057. * @see http://doc.babylonjs.com/babylon101/sprites
  78058. */
  78059. spriteManagers: Array<ISpriteManager>;
  78060. /**
  78061. * An event triggered when sprites rendering is about to start
  78062. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78063. */
  78064. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78065. /**
  78066. * An event triggered when sprites rendering is done
  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. onAfterSpritesRenderingObservable: Observable<Scene>;
  78070. /** @hidden */
  78071. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78072. /** Launch a ray to try to pick a sprite in the scene
  78073. * @param x position on screen
  78074. * @param y position on screen
  78075. * @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
  78076. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78077. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78078. * @returns a PickingInfo
  78079. */
  78080. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78081. /** Use the given ray to pick a sprite in the scene
  78082. * @param ray The ray (in world space) to use to pick meshes
  78083. * @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
  78084. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78085. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78086. * @returns a PickingInfo
  78087. */
  78088. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78089. /** @hidden */
  78090. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78091. /** Launch a ray to try to pick sprites in the scene
  78092. * @param x position on screen
  78093. * @param y position on screen
  78094. * @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
  78095. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78096. * @returns a PickingInfo array
  78097. */
  78098. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78099. /** Use the given ray to pick sprites in the scene
  78100. * @param ray The ray (in world space) to use to pick meshes
  78101. * @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
  78102. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78103. * @returns a PickingInfo array
  78104. */
  78105. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78106. /**
  78107. * Force the sprite under the pointer
  78108. * @param sprite defines the sprite to use
  78109. */
  78110. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78111. /**
  78112. * Gets the sprite under the pointer
  78113. * @returns a Sprite or null if no sprite is under the pointer
  78114. */
  78115. getPointerOverSprite(): Nullable<Sprite>;
  78116. }
  78117. /**
  78118. * Defines the sprite scene component responsible to manage sprites
  78119. * in a given scene.
  78120. */
  78121. export class SpriteSceneComponent implements ISceneComponent {
  78122. /**
  78123. * The component name helpfull to identify the component in the list of scene components.
  78124. */
  78125. readonly name: string;
  78126. /**
  78127. * The scene the component belongs to.
  78128. */
  78129. scene: Scene;
  78130. /** @hidden */
  78131. private _spritePredicate;
  78132. /**
  78133. * Creates a new instance of the component for the given scene
  78134. * @param scene Defines the scene to register the component in
  78135. */
  78136. constructor(scene: Scene);
  78137. /**
  78138. * Registers the component in a given scene
  78139. */
  78140. register(): void;
  78141. /**
  78142. * Rebuilds the elements related to this component in case of
  78143. * context lost for instance.
  78144. */
  78145. rebuild(): void;
  78146. /**
  78147. * Disposes the component and the associated ressources.
  78148. */
  78149. dispose(): void;
  78150. private _pickSpriteButKeepRay;
  78151. private _pointerMove;
  78152. private _pointerDown;
  78153. private _pointerUp;
  78154. }
  78155. }
  78156. declare module BABYLON {
  78157. /** @hidden */
  78158. export var fogFragmentDeclaration: {
  78159. name: string;
  78160. shader: string;
  78161. };
  78162. }
  78163. declare module BABYLON {
  78164. /** @hidden */
  78165. export var fogFragment: {
  78166. name: string;
  78167. shader: string;
  78168. };
  78169. }
  78170. declare module BABYLON {
  78171. /** @hidden */
  78172. export var spritesPixelShader: {
  78173. name: string;
  78174. shader: string;
  78175. };
  78176. }
  78177. declare module BABYLON {
  78178. /** @hidden */
  78179. export var fogVertexDeclaration: {
  78180. name: string;
  78181. shader: string;
  78182. };
  78183. }
  78184. declare module BABYLON {
  78185. /** @hidden */
  78186. export var spritesVertexShader: {
  78187. name: string;
  78188. shader: string;
  78189. };
  78190. }
  78191. declare module BABYLON {
  78192. /**
  78193. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78194. */
  78195. export interface ISpriteManager extends IDisposable {
  78196. /**
  78197. * Restricts the camera to viewing objects with the same layerMask.
  78198. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78199. */
  78200. layerMask: number;
  78201. /**
  78202. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78203. */
  78204. isPickable: boolean;
  78205. /**
  78206. * Specifies the rendering group id for this mesh (0 by default)
  78207. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78208. */
  78209. renderingGroupId: number;
  78210. /**
  78211. * Defines the list of sprites managed by the manager.
  78212. */
  78213. sprites: Array<Sprite>;
  78214. /**
  78215. * Tests the intersection of a sprite with a specific ray.
  78216. * @param ray The ray we are sending to test the collision
  78217. * @param camera The camera space we are sending rays in
  78218. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78219. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78220. * @returns picking info or null.
  78221. */
  78222. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78223. /**
  78224. * Intersects the sprites with a ray
  78225. * @param ray defines the ray to intersect with
  78226. * @param camera defines the current active camera
  78227. * @param predicate defines a predicate used to select candidate sprites
  78228. * @returns null if no hit or a PickingInfo array
  78229. */
  78230. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78231. /**
  78232. * Renders the list of sprites on screen.
  78233. */
  78234. render(): void;
  78235. }
  78236. /**
  78237. * Class used to manage multiple sprites on the same spritesheet
  78238. * @see http://doc.babylonjs.com/babylon101/sprites
  78239. */
  78240. export class SpriteManager implements ISpriteManager {
  78241. /** defines the manager's name */
  78242. name: string;
  78243. /** Gets the list of sprites */
  78244. sprites: Sprite[];
  78245. /** Gets or sets the rendering group id (0 by default) */
  78246. renderingGroupId: number;
  78247. /** Gets or sets camera layer mask */
  78248. layerMask: number;
  78249. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78250. fogEnabled: boolean;
  78251. /** Gets or sets a boolean indicating if the sprites are pickable */
  78252. isPickable: boolean;
  78253. /** Defines the default width of a cell in the spritesheet */
  78254. cellWidth: number;
  78255. /** Defines the default height of a cell in the spritesheet */
  78256. cellHeight: number;
  78257. /** Associative array from JSON sprite data file */
  78258. private _cellData;
  78259. /** Array of sprite names from JSON sprite data file */
  78260. private _spriteMap;
  78261. /** True when packed cell data from JSON file is ready*/
  78262. private _packedAndReady;
  78263. /**
  78264. * An event triggered when the manager is disposed.
  78265. */
  78266. onDisposeObservable: Observable<SpriteManager>;
  78267. private _onDisposeObserver;
  78268. /**
  78269. * Callback called when the manager is disposed
  78270. */
  78271. onDispose: () => void;
  78272. private _capacity;
  78273. private _fromPacked;
  78274. private _spriteTexture;
  78275. private _epsilon;
  78276. private _scene;
  78277. private _vertexData;
  78278. private _buffer;
  78279. private _vertexBuffers;
  78280. private _indexBuffer;
  78281. private _effectBase;
  78282. private _effectFog;
  78283. /**
  78284. * Gets or sets the spritesheet texture
  78285. */
  78286. texture: Texture;
  78287. /**
  78288. * Creates a new sprite manager
  78289. * @param name defines the manager's name
  78290. * @param imgUrl defines the sprite sheet url
  78291. * @param capacity defines the maximum allowed number of sprites
  78292. * @param cellSize defines the size of a sprite cell
  78293. * @param scene defines the hosting scene
  78294. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78295. * @param samplingMode defines the smapling mode to use with spritesheet
  78296. * @param fromPacked set to false; do not alter
  78297. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78298. */
  78299. constructor(
  78300. /** defines the manager's name */
  78301. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78302. private _makePacked;
  78303. private _appendSpriteVertex;
  78304. /**
  78305. * Intersects the sprites with a ray
  78306. * @param ray defines the ray to intersect with
  78307. * @param camera defines the current active camera
  78308. * @param predicate defines a predicate used to select candidate sprites
  78309. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78310. * @returns null if no hit or a PickingInfo
  78311. */
  78312. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78313. /**
  78314. * Intersects the sprites with a ray
  78315. * @param ray defines the ray to intersect with
  78316. * @param camera defines the current active camera
  78317. * @param predicate defines a predicate used to select candidate sprites
  78318. * @returns null if no hit or a PickingInfo array
  78319. */
  78320. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78321. /**
  78322. * Render all child sprites
  78323. */
  78324. render(): void;
  78325. /**
  78326. * Release associated resources
  78327. */
  78328. dispose(): void;
  78329. }
  78330. }
  78331. declare module BABYLON {
  78332. /**
  78333. * Class used to represent a sprite
  78334. * @see http://doc.babylonjs.com/babylon101/sprites
  78335. */
  78336. export class Sprite {
  78337. /** defines the name */
  78338. name: string;
  78339. /** Gets or sets the current world position */
  78340. position: Vector3;
  78341. /** Gets or sets the main color */
  78342. color: Color4;
  78343. /** Gets or sets the width */
  78344. width: number;
  78345. /** Gets or sets the height */
  78346. height: number;
  78347. /** Gets or sets rotation angle */
  78348. angle: number;
  78349. /** Gets or sets the cell index in the sprite sheet */
  78350. cellIndex: number;
  78351. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78352. cellRef: string;
  78353. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78354. invertU: number;
  78355. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78356. invertV: number;
  78357. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78358. disposeWhenFinishedAnimating: boolean;
  78359. /** Gets the list of attached animations */
  78360. animations: Animation[];
  78361. /** Gets or sets a boolean indicating if the sprite can be picked */
  78362. isPickable: boolean;
  78363. /**
  78364. * Gets or sets the associated action manager
  78365. */
  78366. actionManager: Nullable<ActionManager>;
  78367. private _animationStarted;
  78368. private _loopAnimation;
  78369. private _fromIndex;
  78370. private _toIndex;
  78371. private _delay;
  78372. private _direction;
  78373. private _manager;
  78374. private _time;
  78375. private _onAnimationEnd;
  78376. /**
  78377. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78378. */
  78379. isVisible: boolean;
  78380. /**
  78381. * Gets or sets the sprite size
  78382. */
  78383. size: number;
  78384. /**
  78385. * Creates a new Sprite
  78386. * @param name defines the name
  78387. * @param manager defines the manager
  78388. */
  78389. constructor(
  78390. /** defines the name */
  78391. name: string, manager: ISpriteManager);
  78392. /**
  78393. * Starts an animation
  78394. * @param from defines the initial key
  78395. * @param to defines the end key
  78396. * @param loop defines if the animation must loop
  78397. * @param delay defines the start delay (in ms)
  78398. * @param onAnimationEnd defines a callback to call when animation ends
  78399. */
  78400. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78401. /** Stops current animation (if any) */
  78402. stopAnimation(): void;
  78403. /** @hidden */
  78404. _animate(deltaTime: number): void;
  78405. /** Release associated resources */
  78406. dispose(): void;
  78407. }
  78408. }
  78409. declare module BABYLON {
  78410. /**
  78411. * Information about the result of picking within a scene
  78412. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78413. */
  78414. export class PickingInfo {
  78415. /** @hidden */
  78416. _pickingUnavailable: boolean;
  78417. /**
  78418. * If the pick collided with an object
  78419. */
  78420. hit: boolean;
  78421. /**
  78422. * Distance away where the pick collided
  78423. */
  78424. distance: number;
  78425. /**
  78426. * The location of pick collision
  78427. */
  78428. pickedPoint: Nullable<Vector3>;
  78429. /**
  78430. * The mesh corresponding the the pick collision
  78431. */
  78432. pickedMesh: Nullable<AbstractMesh>;
  78433. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78434. bu: number;
  78435. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78436. bv: number;
  78437. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78438. faceId: number;
  78439. /** Id of the the submesh that was picked */
  78440. subMeshId: number;
  78441. /** If a sprite was picked, this will be the sprite the pick collided with */
  78442. pickedSprite: Nullable<Sprite>;
  78443. /**
  78444. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78445. */
  78446. originMesh: Nullable<AbstractMesh>;
  78447. /**
  78448. * The ray that was used to perform the picking.
  78449. */
  78450. ray: Nullable<Ray>;
  78451. /**
  78452. * Gets the normal correspodning to the face the pick collided with
  78453. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78454. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78455. * @returns The normal correspodning to the face the pick collided with
  78456. */
  78457. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78458. /**
  78459. * Gets the texture coordinates of where the pick occured
  78460. * @returns the vector containing the coordnates of the texture
  78461. */
  78462. getTextureCoordinates(): Nullable<Vector2>;
  78463. }
  78464. }
  78465. declare module BABYLON {
  78466. /**
  78467. * Gather the list of pointer event types as constants.
  78468. */
  78469. export class PointerEventTypes {
  78470. /**
  78471. * 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.
  78472. */
  78473. static readonly POINTERDOWN: number;
  78474. /**
  78475. * The pointerup event is fired when a pointer is no longer active.
  78476. */
  78477. static readonly POINTERUP: number;
  78478. /**
  78479. * The pointermove event is fired when a pointer changes coordinates.
  78480. */
  78481. static readonly POINTERMOVE: number;
  78482. /**
  78483. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78484. */
  78485. static readonly POINTERWHEEL: number;
  78486. /**
  78487. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78488. */
  78489. static readonly POINTERPICK: number;
  78490. /**
  78491. * The pointertap event is fired when a the object has been touched and released without drag.
  78492. */
  78493. static readonly POINTERTAP: number;
  78494. /**
  78495. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78496. */
  78497. static readonly POINTERDOUBLETAP: number;
  78498. }
  78499. /**
  78500. * Base class of pointer info types.
  78501. */
  78502. export class PointerInfoBase {
  78503. /**
  78504. * Defines the type of event (PointerEventTypes)
  78505. */
  78506. type: number;
  78507. /**
  78508. * Defines the related dom event
  78509. */
  78510. event: PointerEvent | MouseWheelEvent;
  78511. /**
  78512. * Instantiates the base class of pointers info.
  78513. * @param type Defines the type of event (PointerEventTypes)
  78514. * @param event Defines the related dom event
  78515. */
  78516. constructor(
  78517. /**
  78518. * Defines the type of event (PointerEventTypes)
  78519. */
  78520. type: number,
  78521. /**
  78522. * Defines the related dom event
  78523. */
  78524. event: PointerEvent | MouseWheelEvent);
  78525. }
  78526. /**
  78527. * This class is used to store pointer related info for the onPrePointerObservable event.
  78528. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78529. */
  78530. export class PointerInfoPre extends PointerInfoBase {
  78531. /**
  78532. * Ray from a pointer if availible (eg. 6dof controller)
  78533. */
  78534. ray: Nullable<Ray>;
  78535. /**
  78536. * Defines the local position of the pointer on the canvas.
  78537. */
  78538. localPosition: Vector2;
  78539. /**
  78540. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78541. */
  78542. skipOnPointerObservable: boolean;
  78543. /**
  78544. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78545. * @param type Defines the type of event (PointerEventTypes)
  78546. * @param event Defines the related dom event
  78547. * @param localX Defines the local x coordinates of the pointer when the event occured
  78548. * @param localY Defines the local y coordinates of the pointer when the event occured
  78549. */
  78550. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78551. }
  78552. /**
  78553. * This type contains all the data related to a pointer event in Babylon.js.
  78554. * 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.
  78555. */
  78556. export class PointerInfo extends PointerInfoBase {
  78557. /**
  78558. * Defines the picking info associated to the info (if any)\
  78559. */
  78560. pickInfo: Nullable<PickingInfo>;
  78561. /**
  78562. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78563. * @param type Defines the type of event (PointerEventTypes)
  78564. * @param event Defines the related dom event
  78565. * @param pickInfo Defines the picking info associated to the info (if any)\
  78566. */
  78567. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78568. /**
  78569. * Defines the picking info associated to the info (if any)\
  78570. */
  78571. pickInfo: Nullable<PickingInfo>);
  78572. }
  78573. /**
  78574. * Data relating to a touch event on the screen.
  78575. */
  78576. export interface PointerTouch {
  78577. /**
  78578. * X coordinate of touch.
  78579. */
  78580. x: number;
  78581. /**
  78582. * Y coordinate of touch.
  78583. */
  78584. y: number;
  78585. /**
  78586. * Id of touch. Unique for each finger.
  78587. */
  78588. pointerId: number;
  78589. /**
  78590. * Event type passed from DOM.
  78591. */
  78592. type: any;
  78593. }
  78594. }
  78595. declare module BABYLON {
  78596. /**
  78597. * Manage the mouse inputs to control the movement of a free camera.
  78598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78599. */
  78600. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78601. /**
  78602. * Define if touch is enabled in the mouse input
  78603. */
  78604. touchEnabled: boolean;
  78605. /**
  78606. * Defines the camera the input is attached to.
  78607. */
  78608. camera: FreeCamera;
  78609. /**
  78610. * Defines the buttons associated with the input to handle camera move.
  78611. */
  78612. buttons: number[];
  78613. /**
  78614. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78615. */
  78616. angularSensibility: number;
  78617. private _pointerInput;
  78618. private _onMouseMove;
  78619. private _observer;
  78620. private previousPosition;
  78621. /**
  78622. * Observable for when a pointer move event occurs containing the move offset
  78623. */
  78624. onPointerMovedObservable: Observable<{
  78625. offsetX: number;
  78626. offsetY: number;
  78627. }>;
  78628. /**
  78629. * @hidden
  78630. * If the camera should be rotated automatically based on pointer movement
  78631. */
  78632. _allowCameraRotation: boolean;
  78633. /**
  78634. * Manage the mouse inputs to control the movement of a free camera.
  78635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78636. * @param touchEnabled Defines if touch is enabled or not
  78637. */
  78638. constructor(
  78639. /**
  78640. * Define if touch is enabled in the mouse input
  78641. */
  78642. touchEnabled?: boolean);
  78643. /**
  78644. * Attach the input controls to a specific dom element to get the input from.
  78645. * @param element Defines the element the controls should be listened from
  78646. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78647. */
  78648. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78649. /**
  78650. * Called on JS contextmenu event.
  78651. * Override this method to provide functionality.
  78652. */
  78653. protected onContextMenu(evt: PointerEvent): void;
  78654. /**
  78655. * Detach the current controls from the specified dom element.
  78656. * @param element Defines the element to stop listening the inputs from
  78657. */
  78658. detachControl(element: Nullable<HTMLElement>): void;
  78659. /**
  78660. * Gets the class name of the current intput.
  78661. * @returns the class name
  78662. */
  78663. getClassName(): string;
  78664. /**
  78665. * Get the friendly name associated with the input class.
  78666. * @returns the input friendly name
  78667. */
  78668. getSimpleName(): string;
  78669. }
  78670. }
  78671. declare module BABYLON {
  78672. /**
  78673. * Manage the touch inputs to control the movement of a free camera.
  78674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78675. */
  78676. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78677. /**
  78678. * Defines the camera the input is attached to.
  78679. */
  78680. camera: FreeCamera;
  78681. /**
  78682. * Defines the touch sensibility for rotation.
  78683. * The higher the faster.
  78684. */
  78685. touchAngularSensibility: number;
  78686. /**
  78687. * Defines the touch sensibility for move.
  78688. * The higher the faster.
  78689. */
  78690. touchMoveSensibility: number;
  78691. private _offsetX;
  78692. private _offsetY;
  78693. private _pointerPressed;
  78694. private _pointerInput;
  78695. private _observer;
  78696. private _onLostFocus;
  78697. /**
  78698. * Attach the input controls to a specific dom element to get the input from.
  78699. * @param element Defines the element the controls should be listened from
  78700. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78701. */
  78702. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78703. /**
  78704. * Detach the current controls from the specified dom element.
  78705. * @param element Defines the element to stop listening the inputs from
  78706. */
  78707. detachControl(element: Nullable<HTMLElement>): void;
  78708. /**
  78709. * Update the current camera state depending on the inputs that have been used this frame.
  78710. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78711. */
  78712. checkInputs(): void;
  78713. /**
  78714. * Gets the class name of the current intput.
  78715. * @returns the class name
  78716. */
  78717. getClassName(): string;
  78718. /**
  78719. * Get the friendly name associated with the input class.
  78720. * @returns the input friendly name
  78721. */
  78722. getSimpleName(): string;
  78723. }
  78724. }
  78725. declare module BABYLON {
  78726. /**
  78727. * Default Inputs manager for the FreeCamera.
  78728. * It groups all the default supported inputs for ease of use.
  78729. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78730. */
  78731. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78732. /**
  78733. * @hidden
  78734. */
  78735. _mouseInput: Nullable<FreeCameraMouseInput>;
  78736. /**
  78737. * Instantiates a new FreeCameraInputsManager.
  78738. * @param camera Defines the camera the inputs belong to
  78739. */
  78740. constructor(camera: FreeCamera);
  78741. /**
  78742. * Add keyboard input support to the input manager.
  78743. * @returns the current input manager
  78744. */
  78745. addKeyboard(): FreeCameraInputsManager;
  78746. /**
  78747. * Add mouse input support to the input manager.
  78748. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78749. * @returns the current input manager
  78750. */
  78751. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78752. /**
  78753. * Removes the mouse input support from the manager
  78754. * @returns the current input manager
  78755. */
  78756. removeMouse(): FreeCameraInputsManager;
  78757. /**
  78758. * Add touch input support to the input manager.
  78759. * @returns the current input manager
  78760. */
  78761. addTouch(): FreeCameraInputsManager;
  78762. /**
  78763. * Remove all attached input methods from a camera
  78764. */
  78765. clear(): void;
  78766. }
  78767. }
  78768. declare module BABYLON {
  78769. /**
  78770. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78771. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78773. */
  78774. export class FreeCamera extends TargetCamera {
  78775. /**
  78776. * Define the collision ellipsoid of the camera.
  78777. * This is helpful to simulate a camera body like the player body around the camera
  78778. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78779. */
  78780. ellipsoid: Vector3;
  78781. /**
  78782. * Define an offset for the position of the ellipsoid around the camera.
  78783. * This can be helpful to determine the center of the body near the gravity center of the body
  78784. * instead of its head.
  78785. */
  78786. ellipsoidOffset: Vector3;
  78787. /**
  78788. * Enable or disable collisions of the camera with the rest of the scene objects.
  78789. */
  78790. checkCollisions: boolean;
  78791. /**
  78792. * Enable or disable gravity on the camera.
  78793. */
  78794. applyGravity: boolean;
  78795. /**
  78796. * Define the input manager associated to the camera.
  78797. */
  78798. inputs: FreeCameraInputsManager;
  78799. /**
  78800. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78801. * Higher values reduce sensitivity.
  78802. */
  78803. /**
  78804. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78805. * Higher values reduce sensitivity.
  78806. */
  78807. angularSensibility: number;
  78808. /**
  78809. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78810. */
  78811. keysUp: number[];
  78812. /**
  78813. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78814. */
  78815. keysDown: number[];
  78816. /**
  78817. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78818. */
  78819. keysLeft: number[];
  78820. /**
  78821. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78822. */
  78823. keysRight: number[];
  78824. /**
  78825. * Event raised when the camera collide with a mesh in the scene.
  78826. */
  78827. onCollide: (collidedMesh: AbstractMesh) => void;
  78828. private _collider;
  78829. private _needMoveForGravity;
  78830. private _oldPosition;
  78831. private _diffPosition;
  78832. private _newPosition;
  78833. /** @hidden */
  78834. _localDirection: Vector3;
  78835. /** @hidden */
  78836. _transformedDirection: Vector3;
  78837. /**
  78838. * Instantiates a Free Camera.
  78839. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78840. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78841. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78842. * @param name Define the name of the camera in the scene
  78843. * @param position Define the start position of the camera in the scene
  78844. * @param scene Define the scene the camera belongs to
  78845. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78846. */
  78847. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78848. /**
  78849. * Attached controls to the current camera.
  78850. * @param element Defines the element the controls should be listened from
  78851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78852. */
  78853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78854. /**
  78855. * Detach the current controls from the camera.
  78856. * The camera will stop reacting to inputs.
  78857. * @param element Defines the element to stop listening the inputs from
  78858. */
  78859. detachControl(element: HTMLElement): void;
  78860. private _collisionMask;
  78861. /**
  78862. * Define a collision mask to limit the list of object the camera can collide with
  78863. */
  78864. collisionMask: number;
  78865. /** @hidden */
  78866. _collideWithWorld(displacement: Vector3): void;
  78867. private _onCollisionPositionChange;
  78868. /** @hidden */
  78869. _checkInputs(): void;
  78870. /** @hidden */
  78871. _decideIfNeedsToMove(): boolean;
  78872. /** @hidden */
  78873. _updatePosition(): void;
  78874. /**
  78875. * Destroy the camera and release the current resources hold by it.
  78876. */
  78877. dispose(): void;
  78878. /**
  78879. * Gets the current object class name.
  78880. * @return the class name
  78881. */
  78882. getClassName(): string;
  78883. }
  78884. }
  78885. declare module BABYLON {
  78886. /**
  78887. * Represents a gamepad control stick position
  78888. */
  78889. export class StickValues {
  78890. /**
  78891. * The x component of the control stick
  78892. */
  78893. x: number;
  78894. /**
  78895. * The y component of the control stick
  78896. */
  78897. y: number;
  78898. /**
  78899. * Initializes the gamepad x and y control stick values
  78900. * @param x The x component of the gamepad control stick value
  78901. * @param y The y component of the gamepad control stick value
  78902. */
  78903. constructor(
  78904. /**
  78905. * The x component of the control stick
  78906. */
  78907. x: number,
  78908. /**
  78909. * The y component of the control stick
  78910. */
  78911. y: number);
  78912. }
  78913. /**
  78914. * An interface which manages callbacks for gamepad button changes
  78915. */
  78916. export interface GamepadButtonChanges {
  78917. /**
  78918. * Called when a gamepad has been changed
  78919. */
  78920. changed: boolean;
  78921. /**
  78922. * Called when a gamepad press event has been triggered
  78923. */
  78924. pressChanged: boolean;
  78925. /**
  78926. * Called when a touch event has been triggered
  78927. */
  78928. touchChanged: boolean;
  78929. /**
  78930. * Called when a value has changed
  78931. */
  78932. valueChanged: boolean;
  78933. }
  78934. /**
  78935. * Represents a gamepad
  78936. */
  78937. export class Gamepad {
  78938. /**
  78939. * The id of the gamepad
  78940. */
  78941. id: string;
  78942. /**
  78943. * The index of the gamepad
  78944. */
  78945. index: number;
  78946. /**
  78947. * The browser gamepad
  78948. */
  78949. browserGamepad: any;
  78950. /**
  78951. * Specifies what type of gamepad this represents
  78952. */
  78953. type: number;
  78954. private _leftStick;
  78955. private _rightStick;
  78956. /** @hidden */
  78957. _isConnected: boolean;
  78958. private _leftStickAxisX;
  78959. private _leftStickAxisY;
  78960. private _rightStickAxisX;
  78961. private _rightStickAxisY;
  78962. /**
  78963. * Triggered when the left control stick has been changed
  78964. */
  78965. private _onleftstickchanged;
  78966. /**
  78967. * Triggered when the right control stick has been changed
  78968. */
  78969. private _onrightstickchanged;
  78970. /**
  78971. * Represents a gamepad controller
  78972. */
  78973. static GAMEPAD: number;
  78974. /**
  78975. * Represents a generic controller
  78976. */
  78977. static GENERIC: number;
  78978. /**
  78979. * Represents an XBox controller
  78980. */
  78981. static XBOX: number;
  78982. /**
  78983. * Represents a pose-enabled controller
  78984. */
  78985. static POSE_ENABLED: number;
  78986. /**
  78987. * Represents an Dual Shock controller
  78988. */
  78989. static DUALSHOCK: number;
  78990. /**
  78991. * Specifies whether the left control stick should be Y-inverted
  78992. */
  78993. protected _invertLeftStickY: boolean;
  78994. /**
  78995. * Specifies if the gamepad has been connected
  78996. */
  78997. readonly isConnected: boolean;
  78998. /**
  78999. * Initializes the gamepad
  79000. * @param id The id of the gamepad
  79001. * @param index The index of the gamepad
  79002. * @param browserGamepad The browser gamepad
  79003. * @param leftStickX The x component of the left joystick
  79004. * @param leftStickY The y component of the left joystick
  79005. * @param rightStickX The x component of the right joystick
  79006. * @param rightStickY The y component of the right joystick
  79007. */
  79008. constructor(
  79009. /**
  79010. * The id of the gamepad
  79011. */
  79012. id: string,
  79013. /**
  79014. * The index of the gamepad
  79015. */
  79016. index: number,
  79017. /**
  79018. * The browser gamepad
  79019. */
  79020. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79021. /**
  79022. * Callback triggered when the left joystick has changed
  79023. * @param callback
  79024. */
  79025. onleftstickchanged(callback: (values: StickValues) => void): void;
  79026. /**
  79027. * Callback triggered when the right joystick has changed
  79028. * @param callback
  79029. */
  79030. onrightstickchanged(callback: (values: StickValues) => void): void;
  79031. /**
  79032. * Gets the left joystick
  79033. */
  79034. /**
  79035. * Sets the left joystick values
  79036. */
  79037. leftStick: StickValues;
  79038. /**
  79039. * Gets the right joystick
  79040. */
  79041. /**
  79042. * Sets the right joystick value
  79043. */
  79044. rightStick: StickValues;
  79045. /**
  79046. * Updates the gamepad joystick positions
  79047. */
  79048. update(): void;
  79049. /**
  79050. * Disposes the gamepad
  79051. */
  79052. dispose(): void;
  79053. }
  79054. /**
  79055. * Represents a generic gamepad
  79056. */
  79057. export class GenericPad extends Gamepad {
  79058. private _buttons;
  79059. private _onbuttondown;
  79060. private _onbuttonup;
  79061. /**
  79062. * Observable triggered when a button has been pressed
  79063. */
  79064. onButtonDownObservable: Observable<number>;
  79065. /**
  79066. * Observable triggered when a button has been released
  79067. */
  79068. onButtonUpObservable: Observable<number>;
  79069. /**
  79070. * Callback triggered when a button has been pressed
  79071. * @param callback Called when a button has been pressed
  79072. */
  79073. onbuttondown(callback: (buttonPressed: number) => void): void;
  79074. /**
  79075. * Callback triggered when a button has been released
  79076. * @param callback Called when a button has been released
  79077. */
  79078. onbuttonup(callback: (buttonReleased: number) => void): void;
  79079. /**
  79080. * Initializes the generic gamepad
  79081. * @param id The id of the generic gamepad
  79082. * @param index The index of the generic gamepad
  79083. * @param browserGamepad The browser gamepad
  79084. */
  79085. constructor(id: string, index: number, browserGamepad: any);
  79086. private _setButtonValue;
  79087. /**
  79088. * Updates the generic gamepad
  79089. */
  79090. update(): void;
  79091. /**
  79092. * Disposes the generic gamepad
  79093. */
  79094. dispose(): void;
  79095. }
  79096. }
  79097. declare module BABYLON {
  79098. interface Engine {
  79099. /**
  79100. * Creates a raw texture
  79101. * @param data defines the data to store in the texture
  79102. * @param width defines the width of the texture
  79103. * @param height defines the height of the texture
  79104. * @param format defines the format of the data
  79105. * @param generateMipMaps defines if the engine should generate the mip levels
  79106. * @param invertY defines if data must be stored with Y axis inverted
  79107. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79108. * @param compression defines the compression used (null by default)
  79109. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79110. * @returns the raw texture inside an InternalTexture
  79111. */
  79112. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79113. /**
  79114. * Update a raw texture
  79115. * @param texture defines the texture to update
  79116. * @param data defines the data to store in the texture
  79117. * @param format defines the format of the data
  79118. * @param invertY defines if data must be stored with Y axis inverted
  79119. */
  79120. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79121. /**
  79122. * Update a raw texture
  79123. * @param texture defines the texture to update
  79124. * @param data defines the data to store in the texture
  79125. * @param format defines the format of the data
  79126. * @param invertY defines if data must be stored with Y axis inverted
  79127. * @param compression defines the compression used (null by default)
  79128. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79129. */
  79130. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79131. /**
  79132. * Creates a new raw cube texture
  79133. * @param data defines the array of data to use to create each face
  79134. * @param size defines the size of the textures
  79135. * @param format defines the format of the data
  79136. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79137. * @param generateMipMaps defines if the engine should generate the mip levels
  79138. * @param invertY defines if data must be stored with Y axis inverted
  79139. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79140. * @param compression defines the compression used (null by default)
  79141. * @returns the cube texture as an InternalTexture
  79142. */
  79143. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79144. /**
  79145. * Update a raw cube texture
  79146. * @param texture defines the texture to udpdate
  79147. * @param data defines the data to store
  79148. * @param format defines the data format
  79149. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79150. * @param invertY defines if data must be stored with Y axis inverted
  79151. */
  79152. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79153. /**
  79154. * Update a raw cube texture
  79155. * @param texture defines the texture to udpdate
  79156. * @param data defines the data to store
  79157. * @param format defines the data format
  79158. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79159. * @param invertY defines if data must be stored with Y axis inverted
  79160. * @param compression defines the compression used (null by default)
  79161. */
  79162. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79163. /**
  79164. * Update a raw cube texture
  79165. * @param texture defines the texture to udpdate
  79166. * @param data defines the data to store
  79167. * @param format defines the data format
  79168. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79169. * @param invertY defines if data must be stored with Y axis inverted
  79170. * @param compression defines the compression used (null by default)
  79171. * @param level defines which level of the texture to update
  79172. */
  79173. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79174. /**
  79175. * Creates a new raw cube texture from a specified url
  79176. * @param url defines the url where the data is located
  79177. * @param scene defines the current scene
  79178. * @param size defines the size of the textures
  79179. * @param format defines the format of the data
  79180. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79181. * @param noMipmap defines if the engine should avoid generating the mip levels
  79182. * @param callback defines a callback used to extract texture data from loaded data
  79183. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79184. * @param onLoad defines a callback called when texture is loaded
  79185. * @param onError defines a callback called if there is an error
  79186. * @returns the cube texture as an InternalTexture
  79187. */
  79188. 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;
  79189. /**
  79190. * Creates a new raw cube texture from a specified url
  79191. * @param url defines the url where the data is located
  79192. * @param scene defines the current scene
  79193. * @param size defines the size of the textures
  79194. * @param format defines the format of the data
  79195. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79196. * @param noMipmap defines if the engine should avoid generating the mip levels
  79197. * @param callback defines a callback used to extract texture data from loaded data
  79198. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79199. * @param onLoad defines a callback called when texture is loaded
  79200. * @param onError defines a callback called if there is an error
  79201. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79202. * @param invertY defines if data must be stored with Y axis inverted
  79203. * @returns the cube texture as an InternalTexture
  79204. */
  79205. 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;
  79206. /**
  79207. * Creates a new raw 3D texture
  79208. * @param data defines the data used to create the texture
  79209. * @param width defines the width of the texture
  79210. * @param height defines the height of the texture
  79211. * @param depth defines the depth of the texture
  79212. * @param format defines the format of the texture
  79213. * @param generateMipMaps defines if the engine must generate mip levels
  79214. * @param invertY defines if data must be stored with Y axis inverted
  79215. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79216. * @param compression defines the compressed used (can be null)
  79217. * @param textureType defines the compressed used (can be null)
  79218. * @returns a new raw 3D texture (stored in an InternalTexture)
  79219. */
  79220. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79221. /**
  79222. * Update a raw 3D texture
  79223. * @param texture defines the texture to update
  79224. * @param data defines the data to store
  79225. * @param format defines the data format
  79226. * @param invertY defines if data must be stored with Y axis inverted
  79227. */
  79228. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79229. /**
  79230. * Update a raw 3D texture
  79231. * @param texture defines the texture to update
  79232. * @param data defines the data to store
  79233. * @param format defines the data format
  79234. * @param invertY defines if data must be stored with Y axis inverted
  79235. * @param compression defines the used compression (can be null)
  79236. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79237. */
  79238. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79239. }
  79240. }
  79241. declare module BABYLON {
  79242. /**
  79243. * Raw texture can help creating a texture directly from an array of data.
  79244. * This can be super useful if you either get the data from an uncompressed source or
  79245. * if you wish to create your texture pixel by pixel.
  79246. */
  79247. export class RawTexture extends Texture {
  79248. /**
  79249. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79250. */
  79251. format: number;
  79252. private _engine;
  79253. /**
  79254. * Instantiates a new RawTexture.
  79255. * Raw texture can help creating a texture directly from an array of data.
  79256. * This can be super useful if you either get the data from an uncompressed source or
  79257. * if you wish to create your texture pixel by pixel.
  79258. * @param data define the array of data to use to create the texture
  79259. * @param width define the width of the texture
  79260. * @param height define the height of the texture
  79261. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79262. * @param scene define the scene the texture belongs to
  79263. * @param generateMipMaps define whether mip maps should be generated or not
  79264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79266. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79267. */
  79268. constructor(data: ArrayBufferView, width: number, height: number,
  79269. /**
  79270. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79271. */
  79272. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79273. /**
  79274. * Updates the texture underlying data.
  79275. * @param data Define the new data of the texture
  79276. */
  79277. update(data: ArrayBufferView): void;
  79278. /**
  79279. * Creates a luminance texture from some data.
  79280. * @param data Define the texture data
  79281. * @param width Define the width of the texture
  79282. * @param height Define the height of the texture
  79283. * @param scene Define the scene the texture belongs to
  79284. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79285. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79286. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79287. * @returns the luminance texture
  79288. */
  79289. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79290. /**
  79291. * Creates a luminance alpha texture from some data.
  79292. * @param data Define the texture data
  79293. * @param width Define the width of the texture
  79294. * @param height Define the height of the texture
  79295. * @param scene Define the scene the texture belongs to
  79296. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79297. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79298. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79299. * @returns the luminance alpha texture
  79300. */
  79301. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79302. /**
  79303. * Creates an alpha texture from some data.
  79304. * @param data Define the texture data
  79305. * @param width Define the width of the texture
  79306. * @param height Define the height of the texture
  79307. * @param scene Define the scene the texture belongs to
  79308. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79309. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79310. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79311. * @returns the alpha texture
  79312. */
  79313. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79314. /**
  79315. * Creates a RGB texture from some data.
  79316. * @param data Define the texture data
  79317. * @param width Define the width of the texture
  79318. * @param height Define the height of the texture
  79319. * @param scene Define the scene the texture belongs to
  79320. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79321. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79322. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79323. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79324. * @returns the RGB alpha texture
  79325. */
  79326. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79327. /**
  79328. * Creates a RGBA texture from some data.
  79329. * @param data Define the texture data
  79330. * @param width Define the width of the texture
  79331. * @param height Define the height of the texture
  79332. * @param scene Define the scene the texture belongs to
  79333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79336. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79337. * @returns the RGBA texture
  79338. */
  79339. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79340. /**
  79341. * Creates a R texture from some data.
  79342. * @param data Define the texture data
  79343. * @param width Define the width of the texture
  79344. * @param height Define the height of the texture
  79345. * @param scene Define the scene the texture belongs to
  79346. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79347. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79348. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79349. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79350. * @returns the R texture
  79351. */
  79352. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79353. }
  79354. }
  79355. declare module BABYLON {
  79356. /**
  79357. * Interface for the size containing width and height
  79358. */
  79359. export interface ISize {
  79360. /**
  79361. * Width
  79362. */
  79363. width: number;
  79364. /**
  79365. * Heighht
  79366. */
  79367. height: number;
  79368. }
  79369. /**
  79370. * Size containing widht and height
  79371. */
  79372. export class Size implements ISize {
  79373. /**
  79374. * Width
  79375. */
  79376. width: number;
  79377. /**
  79378. * Height
  79379. */
  79380. height: number;
  79381. /**
  79382. * Creates a Size object from the given width and height (floats).
  79383. * @param width width of the new size
  79384. * @param height height of the new size
  79385. */
  79386. constructor(width: number, height: number);
  79387. /**
  79388. * Returns a string with the Size width and height
  79389. * @returns a string with the Size width and height
  79390. */
  79391. toString(): string;
  79392. /**
  79393. * "Size"
  79394. * @returns the string "Size"
  79395. */
  79396. getClassName(): string;
  79397. /**
  79398. * Returns the Size hash code.
  79399. * @returns a hash code for a unique width and height
  79400. */
  79401. getHashCode(): number;
  79402. /**
  79403. * Updates the current size from the given one.
  79404. * @param src the given size
  79405. */
  79406. copyFrom(src: Size): void;
  79407. /**
  79408. * Updates in place the current Size from the given floats.
  79409. * @param width width of the new size
  79410. * @param height height of the new size
  79411. * @returns the updated Size.
  79412. */
  79413. copyFromFloats(width: number, height: number): Size;
  79414. /**
  79415. * Updates in place the current Size from the given floats.
  79416. * @param width width to set
  79417. * @param height height to set
  79418. * @returns the updated Size.
  79419. */
  79420. set(width: number, height: number): Size;
  79421. /**
  79422. * Multiplies the width and height by numbers
  79423. * @param w factor to multiple the width by
  79424. * @param h factor to multiple the height by
  79425. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79426. */
  79427. multiplyByFloats(w: number, h: number): Size;
  79428. /**
  79429. * Clones the size
  79430. * @returns a new Size copied from the given one.
  79431. */
  79432. clone(): Size;
  79433. /**
  79434. * True if the current Size and the given one width and height are strictly equal.
  79435. * @param other the other size to compare against
  79436. * @returns True if the current Size and the given one width and height are strictly equal.
  79437. */
  79438. equals(other: Size): boolean;
  79439. /**
  79440. * The surface of the Size : width * height (float).
  79441. */
  79442. readonly surface: number;
  79443. /**
  79444. * Create a new size of zero
  79445. * @returns a new Size set to (0.0, 0.0)
  79446. */
  79447. static Zero(): Size;
  79448. /**
  79449. * Sums the width and height of two sizes
  79450. * @param otherSize size to add to this size
  79451. * @returns a new Size set as the addition result of the current Size and the given one.
  79452. */
  79453. add(otherSize: Size): Size;
  79454. /**
  79455. * Subtracts the width and height of two
  79456. * @param otherSize size to subtract to this size
  79457. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79458. */
  79459. subtract(otherSize: Size): Size;
  79460. /**
  79461. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79462. * @param start starting size to lerp between
  79463. * @param end end size to lerp between
  79464. * @param amount amount to lerp between the start and end values
  79465. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79466. */
  79467. static Lerp(start: Size, end: Size, amount: number): Size;
  79468. }
  79469. }
  79470. declare module BABYLON {
  79471. /**
  79472. * Defines a runtime animation
  79473. */
  79474. export class RuntimeAnimation {
  79475. private _events;
  79476. /**
  79477. * The current frame of the runtime animation
  79478. */
  79479. private _currentFrame;
  79480. /**
  79481. * The animation used by the runtime animation
  79482. */
  79483. private _animation;
  79484. /**
  79485. * The target of the runtime animation
  79486. */
  79487. private _target;
  79488. /**
  79489. * The initiating animatable
  79490. */
  79491. private _host;
  79492. /**
  79493. * The original value of the runtime animation
  79494. */
  79495. private _originalValue;
  79496. /**
  79497. * The original blend value of the runtime animation
  79498. */
  79499. private _originalBlendValue;
  79500. /**
  79501. * The offsets cache of the runtime animation
  79502. */
  79503. private _offsetsCache;
  79504. /**
  79505. * The high limits cache of the runtime animation
  79506. */
  79507. private _highLimitsCache;
  79508. /**
  79509. * Specifies if the runtime animation has been stopped
  79510. */
  79511. private _stopped;
  79512. /**
  79513. * The blending factor of the runtime animation
  79514. */
  79515. private _blendingFactor;
  79516. /**
  79517. * The BabylonJS scene
  79518. */
  79519. private _scene;
  79520. /**
  79521. * The current value of the runtime animation
  79522. */
  79523. private _currentValue;
  79524. /** @hidden */
  79525. _animationState: _IAnimationState;
  79526. /**
  79527. * The active target of the runtime animation
  79528. */
  79529. private _activeTargets;
  79530. private _currentActiveTarget;
  79531. private _directTarget;
  79532. /**
  79533. * The target path of the runtime animation
  79534. */
  79535. private _targetPath;
  79536. /**
  79537. * The weight of the runtime animation
  79538. */
  79539. private _weight;
  79540. /**
  79541. * The ratio offset of the runtime animation
  79542. */
  79543. private _ratioOffset;
  79544. /**
  79545. * The previous delay of the runtime animation
  79546. */
  79547. private _previousDelay;
  79548. /**
  79549. * The previous ratio of the runtime animation
  79550. */
  79551. private _previousRatio;
  79552. private _enableBlending;
  79553. private _keys;
  79554. private _minFrame;
  79555. private _maxFrame;
  79556. private _minValue;
  79557. private _maxValue;
  79558. private _targetIsArray;
  79559. /**
  79560. * Gets the current frame of the runtime animation
  79561. */
  79562. readonly currentFrame: number;
  79563. /**
  79564. * Gets the weight of the runtime animation
  79565. */
  79566. readonly weight: number;
  79567. /**
  79568. * Gets the current value of the runtime animation
  79569. */
  79570. readonly currentValue: any;
  79571. /**
  79572. * Gets the target path of the runtime animation
  79573. */
  79574. readonly targetPath: string;
  79575. /**
  79576. * Gets the actual target of the runtime animation
  79577. */
  79578. readonly target: any;
  79579. /** @hidden */
  79580. _onLoop: () => void;
  79581. /**
  79582. * Create a new RuntimeAnimation object
  79583. * @param target defines the target of the animation
  79584. * @param animation defines the source animation object
  79585. * @param scene defines the hosting scene
  79586. * @param host defines the initiating Animatable
  79587. */
  79588. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79589. private _preparePath;
  79590. /**
  79591. * Gets the animation from the runtime animation
  79592. */
  79593. readonly animation: Animation;
  79594. /**
  79595. * Resets the runtime animation to the beginning
  79596. * @param restoreOriginal defines whether to restore the target property to the original value
  79597. */
  79598. reset(restoreOriginal?: boolean): void;
  79599. /**
  79600. * Specifies if the runtime animation is stopped
  79601. * @returns Boolean specifying if the runtime animation is stopped
  79602. */
  79603. isStopped(): boolean;
  79604. /**
  79605. * Disposes of the runtime animation
  79606. */
  79607. dispose(): void;
  79608. /**
  79609. * Apply the interpolated value to the target
  79610. * @param currentValue defines the value computed by the animation
  79611. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79612. */
  79613. setValue(currentValue: any, weight: number): void;
  79614. private _getOriginalValues;
  79615. private _setValue;
  79616. /**
  79617. * Gets the loop pmode of the runtime animation
  79618. * @returns Loop Mode
  79619. */
  79620. private _getCorrectLoopMode;
  79621. /**
  79622. * Move the current animation to a given frame
  79623. * @param frame defines the frame to move to
  79624. */
  79625. goToFrame(frame: number): void;
  79626. /**
  79627. * @hidden Internal use only
  79628. */
  79629. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79630. /**
  79631. * Execute the current animation
  79632. * @param delay defines the delay to add to the current frame
  79633. * @param from defines the lower bound of the animation range
  79634. * @param to defines the upper bound of the animation range
  79635. * @param loop defines if the current animation must loop
  79636. * @param speedRatio defines the current speed ratio
  79637. * @param weight defines the weight of the animation (default is -1 so no weight)
  79638. * @param onLoop optional callback called when animation loops
  79639. * @returns a boolean indicating if the animation is running
  79640. */
  79641. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79642. }
  79643. }
  79644. declare module BABYLON {
  79645. /**
  79646. * Class used to store an actual running animation
  79647. */
  79648. export class Animatable {
  79649. /** defines the target object */
  79650. target: any;
  79651. /** defines the starting frame number (default is 0) */
  79652. fromFrame: number;
  79653. /** defines the ending frame number (default is 100) */
  79654. toFrame: number;
  79655. /** defines if the animation must loop (default is false) */
  79656. loopAnimation: boolean;
  79657. /** defines a callback to call when animation ends if it is not looping */
  79658. onAnimationEnd?: (() => void) | null | undefined;
  79659. /** defines a callback to call when animation loops */
  79660. onAnimationLoop?: (() => void) | null | undefined;
  79661. private _localDelayOffset;
  79662. private _pausedDelay;
  79663. private _runtimeAnimations;
  79664. private _paused;
  79665. private _scene;
  79666. private _speedRatio;
  79667. private _weight;
  79668. private _syncRoot;
  79669. /**
  79670. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79671. * This will only apply for non looping animation (default is true)
  79672. */
  79673. disposeOnEnd: boolean;
  79674. /**
  79675. * Gets a boolean indicating if the animation has started
  79676. */
  79677. animationStarted: boolean;
  79678. /**
  79679. * Observer raised when the animation ends
  79680. */
  79681. onAnimationEndObservable: Observable<Animatable>;
  79682. /**
  79683. * Observer raised when the animation loops
  79684. */
  79685. onAnimationLoopObservable: Observable<Animatable>;
  79686. /**
  79687. * Gets the root Animatable used to synchronize and normalize animations
  79688. */
  79689. readonly syncRoot: Nullable<Animatable>;
  79690. /**
  79691. * Gets the current frame of the first RuntimeAnimation
  79692. * Used to synchronize Animatables
  79693. */
  79694. readonly masterFrame: number;
  79695. /**
  79696. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79697. */
  79698. weight: number;
  79699. /**
  79700. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79701. */
  79702. speedRatio: number;
  79703. /**
  79704. * Creates a new Animatable
  79705. * @param scene defines the hosting scene
  79706. * @param target defines the target object
  79707. * @param fromFrame defines the starting frame number (default is 0)
  79708. * @param toFrame defines the ending frame number (default is 100)
  79709. * @param loopAnimation defines if the animation must loop (default is false)
  79710. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79711. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79712. * @param animations defines a group of animation to add to the new Animatable
  79713. * @param onAnimationLoop defines a callback to call when animation loops
  79714. */
  79715. constructor(scene: Scene,
  79716. /** defines the target object */
  79717. target: any,
  79718. /** defines the starting frame number (default is 0) */
  79719. fromFrame?: number,
  79720. /** defines the ending frame number (default is 100) */
  79721. toFrame?: number,
  79722. /** defines if the animation must loop (default is false) */
  79723. loopAnimation?: boolean, speedRatio?: number,
  79724. /** defines a callback to call when animation ends if it is not looping */
  79725. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79726. /** defines a callback to call when animation loops */
  79727. onAnimationLoop?: (() => void) | null | undefined);
  79728. /**
  79729. * Synchronize and normalize current Animatable with a source Animatable
  79730. * This is useful when using animation weights and when animations are not of the same length
  79731. * @param root defines the root Animatable to synchronize with
  79732. * @returns the current Animatable
  79733. */
  79734. syncWith(root: Animatable): Animatable;
  79735. /**
  79736. * Gets the list of runtime animations
  79737. * @returns an array of RuntimeAnimation
  79738. */
  79739. getAnimations(): RuntimeAnimation[];
  79740. /**
  79741. * Adds more animations to the current animatable
  79742. * @param target defines the target of the animations
  79743. * @param animations defines the new animations to add
  79744. */
  79745. appendAnimations(target: any, animations: Animation[]): void;
  79746. /**
  79747. * Gets the source animation for a specific property
  79748. * @param property defines the propertyu to look for
  79749. * @returns null or the source animation for the given property
  79750. */
  79751. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79752. /**
  79753. * Gets the runtime animation for a specific property
  79754. * @param property defines the propertyu to look for
  79755. * @returns null or the runtime animation for the given property
  79756. */
  79757. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79758. /**
  79759. * Resets the animatable to its original state
  79760. */
  79761. reset(): void;
  79762. /**
  79763. * Allows the animatable to blend with current running animations
  79764. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79765. * @param blendingSpeed defines the blending speed to use
  79766. */
  79767. enableBlending(blendingSpeed: number): void;
  79768. /**
  79769. * Disable animation blending
  79770. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79771. */
  79772. disableBlending(): void;
  79773. /**
  79774. * Jump directly to a given frame
  79775. * @param frame defines the frame to jump to
  79776. */
  79777. goToFrame(frame: number): void;
  79778. /**
  79779. * Pause the animation
  79780. */
  79781. pause(): void;
  79782. /**
  79783. * Restart the animation
  79784. */
  79785. restart(): void;
  79786. private _raiseOnAnimationEnd;
  79787. /**
  79788. * Stop and delete the current animation
  79789. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79790. * @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)
  79791. */
  79792. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79793. /**
  79794. * Wait asynchronously for the animation to end
  79795. * @returns a promise which will be fullfilled when the animation ends
  79796. */
  79797. waitAsync(): Promise<Animatable>;
  79798. /** @hidden */
  79799. _animate(delay: number): boolean;
  79800. }
  79801. interface Scene {
  79802. /** @hidden */
  79803. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79804. /** @hidden */
  79805. _processLateAnimationBindingsForMatrices(holder: {
  79806. totalWeight: number;
  79807. animations: RuntimeAnimation[];
  79808. originalValue: Matrix;
  79809. }): any;
  79810. /** @hidden */
  79811. _processLateAnimationBindingsForQuaternions(holder: {
  79812. totalWeight: number;
  79813. animations: RuntimeAnimation[];
  79814. originalValue: Quaternion;
  79815. }, refQuaternion: Quaternion): Quaternion;
  79816. /** @hidden */
  79817. _processLateAnimationBindings(): void;
  79818. /**
  79819. * Will start the animation sequence of a given target
  79820. * @param target defines the target
  79821. * @param from defines from which frame should animation start
  79822. * @param to defines until which frame should animation run.
  79823. * @param weight defines the weight to apply to the animation (1.0 by default)
  79824. * @param loop defines if the animation loops
  79825. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79826. * @param onAnimationEnd defines the function to be executed when the animation ends
  79827. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79828. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79829. * @param onAnimationLoop defines the callback to call when an animation loops
  79830. * @returns the animatable object created for this animation
  79831. */
  79832. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79833. /**
  79834. * Will start the animation sequence of a given target
  79835. * @param target defines the target
  79836. * @param from defines from which frame should animation start
  79837. * @param to defines until which frame should animation run.
  79838. * @param loop defines if the animation loops
  79839. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79840. * @param onAnimationEnd defines the function to be executed when the animation ends
  79841. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79842. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79843. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79844. * @param onAnimationLoop defines the callback to call when an animation loops
  79845. * @returns the animatable object created for this animation
  79846. */
  79847. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79848. /**
  79849. * Will start the animation sequence of a given target and its hierarchy
  79850. * @param target defines the target
  79851. * @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.
  79852. * @param from defines from which frame should animation start
  79853. * @param to defines until which frame should animation run.
  79854. * @param loop defines if the animation loops
  79855. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79856. * @param onAnimationEnd defines the function to be executed when the animation ends
  79857. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79858. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79859. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79860. * @param onAnimationLoop defines the callback to call when an animation loops
  79861. * @returns the list of created animatables
  79862. */
  79863. 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[];
  79864. /**
  79865. * Begin a new animation on a given node
  79866. * @param target defines the target where the animation will take place
  79867. * @param animations defines the list of animations to start
  79868. * @param from defines the initial value
  79869. * @param to defines the final value
  79870. * @param loop defines if you want animation to loop (off by default)
  79871. * @param speedRatio defines the speed ratio to apply to all animations
  79872. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79873. * @param onAnimationLoop defines the callback to call when an animation loops
  79874. * @returns the list of created animatables
  79875. */
  79876. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79877. /**
  79878. * Begin a new animation on a given node and its hierarchy
  79879. * @param target defines the root node where the animation will take place
  79880. * @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.
  79881. * @param animations defines the list of animations to start
  79882. * @param from defines the initial value
  79883. * @param to defines the final value
  79884. * @param loop defines if you want animation to loop (off by default)
  79885. * @param speedRatio defines the speed ratio to apply to all animations
  79886. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79887. * @param onAnimationLoop defines the callback to call when an animation loops
  79888. * @returns the list of animatables created for all nodes
  79889. */
  79890. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79891. /**
  79892. * Gets the animatable associated with a specific target
  79893. * @param target defines the target of the animatable
  79894. * @returns the required animatable if found
  79895. */
  79896. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79897. /**
  79898. * Gets all animatables associated with a given target
  79899. * @param target defines the target to look animatables for
  79900. * @returns an array of Animatables
  79901. */
  79902. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79903. /**
  79904. * Stops and removes all animations that have been applied to the scene
  79905. */
  79906. stopAllAnimations(): void;
  79907. /**
  79908. * Gets the current delta time used by animation engine
  79909. */
  79910. deltaTime: number;
  79911. }
  79912. interface Bone {
  79913. /**
  79914. * Copy an animation range from another bone
  79915. * @param source defines the source bone
  79916. * @param rangeName defines the range name to copy
  79917. * @param frameOffset defines the frame offset
  79918. * @param rescaleAsRequired defines if rescaling must be applied if required
  79919. * @param skelDimensionsRatio defines the scaling ratio
  79920. * @returns true if operation was successful
  79921. */
  79922. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79923. }
  79924. }
  79925. declare module BABYLON {
  79926. /**
  79927. * Class used to override all child animations of a given target
  79928. */
  79929. export class AnimationPropertiesOverride {
  79930. /**
  79931. * Gets or sets a value indicating if animation blending must be used
  79932. */
  79933. enableBlending: boolean;
  79934. /**
  79935. * Gets or sets the blending speed to use when enableBlending is true
  79936. */
  79937. blendingSpeed: number;
  79938. /**
  79939. * Gets or sets the default loop mode to use
  79940. */
  79941. loopMode: number;
  79942. }
  79943. }
  79944. declare module BABYLON {
  79945. /**
  79946. * Class used to handle skinning animations
  79947. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79948. */
  79949. export class Skeleton implements IAnimatable {
  79950. /** defines the skeleton name */
  79951. name: string;
  79952. /** defines the skeleton Id */
  79953. id: string;
  79954. /**
  79955. * Defines the list of child bones
  79956. */
  79957. bones: Bone[];
  79958. /**
  79959. * Defines an estimate of the dimension of the skeleton at rest
  79960. */
  79961. dimensionsAtRest: Vector3;
  79962. /**
  79963. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79964. */
  79965. needInitialSkinMatrix: boolean;
  79966. /**
  79967. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79968. */
  79969. overrideMesh: Nullable<AbstractMesh>;
  79970. /**
  79971. * Gets the list of animations attached to this skeleton
  79972. */
  79973. animations: Array<Animation>;
  79974. private _scene;
  79975. private _isDirty;
  79976. private _transformMatrices;
  79977. private _transformMatrixTexture;
  79978. private _meshesWithPoseMatrix;
  79979. private _animatables;
  79980. private _identity;
  79981. private _synchronizedWithMesh;
  79982. private _ranges;
  79983. private _lastAbsoluteTransformsUpdateId;
  79984. private _canUseTextureForBones;
  79985. private _uniqueId;
  79986. /** @hidden */
  79987. _numBonesWithLinkedTransformNode: number;
  79988. /** @hidden */
  79989. _hasWaitingData: Nullable<boolean>;
  79990. /**
  79991. * Specifies if the skeleton should be serialized
  79992. */
  79993. doNotSerialize: boolean;
  79994. private _useTextureToStoreBoneMatrices;
  79995. /**
  79996. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79997. * Please note that this option is not available if the hardware does not support it
  79998. */
  79999. useTextureToStoreBoneMatrices: boolean;
  80000. private _animationPropertiesOverride;
  80001. /**
  80002. * Gets or sets the animation properties override
  80003. */
  80004. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80005. /**
  80006. * List of inspectable custom properties (used by the Inspector)
  80007. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80008. */
  80009. inspectableCustomProperties: IInspectable[];
  80010. /**
  80011. * An observable triggered before computing the skeleton's matrices
  80012. */
  80013. onBeforeComputeObservable: Observable<Skeleton>;
  80014. /**
  80015. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80016. */
  80017. readonly isUsingTextureForMatrices: boolean;
  80018. /**
  80019. * Gets the unique ID of this skeleton
  80020. */
  80021. readonly uniqueId: number;
  80022. /**
  80023. * Creates a new skeleton
  80024. * @param name defines the skeleton name
  80025. * @param id defines the skeleton Id
  80026. * @param scene defines the hosting scene
  80027. */
  80028. constructor(
  80029. /** defines the skeleton name */
  80030. name: string,
  80031. /** defines the skeleton Id */
  80032. id: string, scene: Scene);
  80033. /**
  80034. * Gets the current object class name.
  80035. * @return the class name
  80036. */
  80037. getClassName(): string;
  80038. /**
  80039. * Returns an array containing the root bones
  80040. * @returns an array containing the root bones
  80041. */
  80042. getChildren(): Array<Bone>;
  80043. /**
  80044. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80045. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80046. * @returns a Float32Array containing matrices data
  80047. */
  80048. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80049. /**
  80050. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80051. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80052. * @returns a raw texture containing the data
  80053. */
  80054. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80055. /**
  80056. * Gets the current hosting scene
  80057. * @returns a scene object
  80058. */
  80059. getScene(): Scene;
  80060. /**
  80061. * Gets a string representing the current skeleton data
  80062. * @param fullDetails defines a boolean indicating if we want a verbose version
  80063. * @returns a string representing the current skeleton data
  80064. */
  80065. toString(fullDetails?: boolean): string;
  80066. /**
  80067. * Get bone's index searching by name
  80068. * @param name defines bone's name to search for
  80069. * @return the indice of the bone. Returns -1 if not found
  80070. */
  80071. getBoneIndexByName(name: string): number;
  80072. /**
  80073. * Creater a new animation range
  80074. * @param name defines the name of the range
  80075. * @param from defines the start key
  80076. * @param to defines the end key
  80077. */
  80078. createAnimationRange(name: string, from: number, to: number): void;
  80079. /**
  80080. * Delete a specific animation range
  80081. * @param name defines the name of the range
  80082. * @param deleteFrames defines if frames must be removed as well
  80083. */
  80084. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80085. /**
  80086. * Gets a specific animation range
  80087. * @param name defines the name of the range to look for
  80088. * @returns the requested animation range or null if not found
  80089. */
  80090. getAnimationRange(name: string): Nullable<AnimationRange>;
  80091. /**
  80092. * Gets the list of all animation ranges defined on this skeleton
  80093. * @returns an array
  80094. */
  80095. getAnimationRanges(): Nullable<AnimationRange>[];
  80096. /**
  80097. * Copy animation range from a source skeleton.
  80098. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80099. * @param source defines the source skeleton
  80100. * @param name defines the name of the range to copy
  80101. * @param rescaleAsRequired defines if rescaling must be applied if required
  80102. * @returns true if operation was successful
  80103. */
  80104. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80105. /**
  80106. * Forces the skeleton to go to rest pose
  80107. */
  80108. returnToRest(): void;
  80109. private _getHighestAnimationFrame;
  80110. /**
  80111. * Begin a specific animation range
  80112. * @param name defines the name of the range to start
  80113. * @param loop defines if looping must be turned on (false by default)
  80114. * @param speedRatio defines the speed ratio to apply (1 by default)
  80115. * @param onAnimationEnd defines a callback which will be called when animation will end
  80116. * @returns a new animatable
  80117. */
  80118. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80119. /** @hidden */
  80120. _markAsDirty(): void;
  80121. /** @hidden */
  80122. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80123. /** @hidden */
  80124. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80125. private _computeTransformMatrices;
  80126. /**
  80127. * Build all resources required to render a skeleton
  80128. */
  80129. prepare(): void;
  80130. /**
  80131. * Gets the list of animatables currently running for this skeleton
  80132. * @returns an array of animatables
  80133. */
  80134. getAnimatables(): IAnimatable[];
  80135. /**
  80136. * Clone the current skeleton
  80137. * @param name defines the name of the new skeleton
  80138. * @param id defines the id of the new skeleton
  80139. * @returns the new skeleton
  80140. */
  80141. clone(name: string, id: string): Skeleton;
  80142. /**
  80143. * Enable animation blending for this skeleton
  80144. * @param blendingSpeed defines the blending speed to apply
  80145. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80146. */
  80147. enableBlending(blendingSpeed?: number): void;
  80148. /**
  80149. * Releases all resources associated with the current skeleton
  80150. */
  80151. dispose(): void;
  80152. /**
  80153. * Serialize the skeleton in a JSON object
  80154. * @returns a JSON object
  80155. */
  80156. serialize(): any;
  80157. /**
  80158. * Creates a new skeleton from serialized data
  80159. * @param parsedSkeleton defines the serialized data
  80160. * @param scene defines the hosting scene
  80161. * @returns a new skeleton
  80162. */
  80163. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80164. /**
  80165. * Compute all node absolute transforms
  80166. * @param forceUpdate defines if computation must be done even if cache is up to date
  80167. */
  80168. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80169. /**
  80170. * Gets the root pose matrix
  80171. * @returns a matrix
  80172. */
  80173. getPoseMatrix(): Nullable<Matrix>;
  80174. /**
  80175. * Sorts bones per internal index
  80176. */
  80177. sortBones(): void;
  80178. private _sortBones;
  80179. }
  80180. }
  80181. declare module BABYLON {
  80182. /**
  80183. * Class used to store bone information
  80184. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80185. */
  80186. export class Bone extends Node {
  80187. /**
  80188. * defines the bone name
  80189. */
  80190. name: string;
  80191. private static _tmpVecs;
  80192. private static _tmpQuat;
  80193. private static _tmpMats;
  80194. /**
  80195. * Gets the list of child bones
  80196. */
  80197. children: Bone[];
  80198. /** Gets the animations associated with this bone */
  80199. animations: Animation[];
  80200. /**
  80201. * Gets or sets bone length
  80202. */
  80203. length: number;
  80204. /**
  80205. * @hidden Internal only
  80206. * Set this value to map this bone to a different index in the transform matrices
  80207. * Set this value to -1 to exclude the bone from the transform matrices
  80208. */
  80209. _index: Nullable<number>;
  80210. private _skeleton;
  80211. private _localMatrix;
  80212. private _restPose;
  80213. private _baseMatrix;
  80214. private _absoluteTransform;
  80215. private _invertedAbsoluteTransform;
  80216. private _parent;
  80217. private _scalingDeterminant;
  80218. private _worldTransform;
  80219. private _localScaling;
  80220. private _localRotation;
  80221. private _localPosition;
  80222. private _needToDecompose;
  80223. private _needToCompose;
  80224. /** @hidden */
  80225. _linkedTransformNode: Nullable<TransformNode>;
  80226. /** @hidden */
  80227. _waitingTransformNodeId: Nullable<string>;
  80228. /** @hidden */
  80229. /** @hidden */
  80230. _matrix: Matrix;
  80231. /**
  80232. * Create a new bone
  80233. * @param name defines the bone name
  80234. * @param skeleton defines the parent skeleton
  80235. * @param parentBone defines the parent (can be null if the bone is the root)
  80236. * @param localMatrix defines the local matrix
  80237. * @param restPose defines the rest pose matrix
  80238. * @param baseMatrix defines the base matrix
  80239. * @param index defines index of the bone in the hiearchy
  80240. */
  80241. constructor(
  80242. /**
  80243. * defines the bone name
  80244. */
  80245. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80246. /**
  80247. * Gets the current object class name.
  80248. * @return the class name
  80249. */
  80250. getClassName(): string;
  80251. /**
  80252. * Gets the parent skeleton
  80253. * @returns a skeleton
  80254. */
  80255. getSkeleton(): Skeleton;
  80256. /**
  80257. * Gets parent bone
  80258. * @returns a bone or null if the bone is the root of the bone hierarchy
  80259. */
  80260. getParent(): Nullable<Bone>;
  80261. /**
  80262. * Returns an array containing the root bones
  80263. * @returns an array containing the root bones
  80264. */
  80265. getChildren(): Array<Bone>;
  80266. /**
  80267. * Sets the parent bone
  80268. * @param parent defines the parent (can be null if the bone is the root)
  80269. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80270. */
  80271. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80272. /**
  80273. * Gets the local matrix
  80274. * @returns a matrix
  80275. */
  80276. getLocalMatrix(): Matrix;
  80277. /**
  80278. * Gets the base matrix (initial matrix which remains unchanged)
  80279. * @returns a matrix
  80280. */
  80281. getBaseMatrix(): Matrix;
  80282. /**
  80283. * Gets the rest pose matrix
  80284. * @returns a matrix
  80285. */
  80286. getRestPose(): Matrix;
  80287. /**
  80288. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80289. */
  80290. getWorldMatrix(): Matrix;
  80291. /**
  80292. * Sets the local matrix to rest pose matrix
  80293. */
  80294. returnToRest(): void;
  80295. /**
  80296. * Gets the inverse of the absolute transform matrix.
  80297. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80298. * @returns a matrix
  80299. */
  80300. getInvertedAbsoluteTransform(): Matrix;
  80301. /**
  80302. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80303. * @returns a matrix
  80304. */
  80305. getAbsoluteTransform(): Matrix;
  80306. /**
  80307. * Links with the given transform node.
  80308. * The local matrix of this bone is copied from the transform node every frame.
  80309. * @param transformNode defines the transform node to link to
  80310. */
  80311. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80312. /**
  80313. * Gets the node used to drive the bone's transformation
  80314. * @returns a transform node or null
  80315. */
  80316. getTransformNode(): Nullable<TransformNode>;
  80317. /** Gets or sets current position (in local space) */
  80318. position: Vector3;
  80319. /** Gets or sets current rotation (in local space) */
  80320. rotation: Vector3;
  80321. /** Gets or sets current rotation quaternion (in local space) */
  80322. rotationQuaternion: Quaternion;
  80323. /** Gets or sets current scaling (in local space) */
  80324. scaling: Vector3;
  80325. /**
  80326. * Gets the animation properties override
  80327. */
  80328. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80329. private _decompose;
  80330. private _compose;
  80331. /**
  80332. * Update the base and local matrices
  80333. * @param matrix defines the new base or local matrix
  80334. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80335. * @param updateLocalMatrix defines if the local matrix should be updated
  80336. */
  80337. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80338. /** @hidden */
  80339. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80340. /**
  80341. * Flag the bone as dirty (Forcing it to update everything)
  80342. */
  80343. markAsDirty(): void;
  80344. /** @hidden */
  80345. _markAsDirtyAndCompose(): void;
  80346. private _markAsDirtyAndDecompose;
  80347. /**
  80348. * Translate the bone in local or world space
  80349. * @param vec The amount to translate the bone
  80350. * @param space The space that the translation is in
  80351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80352. */
  80353. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80354. /**
  80355. * Set the postion of the bone in local or world space
  80356. * @param position The position to set the bone
  80357. * @param space The space that the position is in
  80358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80359. */
  80360. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80361. /**
  80362. * Set the absolute position of the bone (world space)
  80363. * @param position The position to set the bone
  80364. * @param mesh The mesh that this bone is attached to
  80365. */
  80366. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80367. /**
  80368. * Scale the bone on the x, y and z axes (in local space)
  80369. * @param x The amount to scale the bone on the x axis
  80370. * @param y The amount to scale the bone on the y axis
  80371. * @param z The amount to scale the bone on the z axis
  80372. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80373. */
  80374. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80375. /**
  80376. * Set the bone scaling in local space
  80377. * @param scale defines the scaling vector
  80378. */
  80379. setScale(scale: Vector3): void;
  80380. /**
  80381. * Gets the current scaling in local space
  80382. * @returns the current scaling vector
  80383. */
  80384. getScale(): Vector3;
  80385. /**
  80386. * Gets the current scaling in local space and stores it in a target vector
  80387. * @param result defines the target vector
  80388. */
  80389. getScaleToRef(result: Vector3): void;
  80390. /**
  80391. * Set the yaw, pitch, and roll of the bone in local or world space
  80392. * @param yaw The rotation of the bone on the y axis
  80393. * @param pitch The rotation of the bone on the x axis
  80394. * @param roll The rotation of the bone on the z axis
  80395. * @param space The space that the axes of rotation are in
  80396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80397. */
  80398. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80399. /**
  80400. * Add a rotation to the bone on an axis in local or world space
  80401. * @param axis The axis to rotate the bone on
  80402. * @param amount The amount to rotate the bone
  80403. * @param space The space that the axis is in
  80404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80405. */
  80406. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80407. /**
  80408. * Set the rotation of the bone to a particular axis angle in local or world space
  80409. * @param axis The axis to rotate the bone on
  80410. * @param angle The angle that the bone should be rotated to
  80411. * @param space The space that the axis is in
  80412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80413. */
  80414. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80415. /**
  80416. * Set the euler rotation of the bone in local of world space
  80417. * @param rotation The euler rotation that the bone should be set to
  80418. * @param space The space that the rotation is in
  80419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80420. */
  80421. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80422. /**
  80423. * Set the quaternion rotation of the bone in local of world space
  80424. * @param quat The quaternion rotation that the bone should be set to
  80425. * @param space The space that the rotation is in
  80426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80427. */
  80428. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80429. /**
  80430. * Set the rotation matrix of the bone in local of world space
  80431. * @param rotMat The rotation matrix that the bone should be set to
  80432. * @param space The space that the rotation is in
  80433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80434. */
  80435. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80436. private _rotateWithMatrix;
  80437. private _getNegativeRotationToRef;
  80438. /**
  80439. * Get the position of the bone in local or world space
  80440. * @param space The space that the returned position is in
  80441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80442. * @returns The position of the bone
  80443. */
  80444. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80445. /**
  80446. * Copy the position of the bone to a vector3 in local or world space
  80447. * @param space The space that the returned position is in
  80448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80449. * @param result The vector3 to copy the position to
  80450. */
  80451. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80452. /**
  80453. * Get the absolute position of the bone (world space)
  80454. * @param mesh The mesh that this bone is attached to
  80455. * @returns The absolute position of the bone
  80456. */
  80457. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80458. /**
  80459. * Copy the absolute position of the bone (world space) to the result param
  80460. * @param mesh The mesh that this bone is attached to
  80461. * @param result The vector3 to copy the absolute position to
  80462. */
  80463. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80464. /**
  80465. * Compute the absolute transforms of this bone and its children
  80466. */
  80467. computeAbsoluteTransforms(): void;
  80468. /**
  80469. * Get the world direction from an axis that is in the local space of the bone
  80470. * @param localAxis The local direction that is used to compute the world direction
  80471. * @param mesh The mesh that this bone is attached to
  80472. * @returns The world direction
  80473. */
  80474. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80475. /**
  80476. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80477. * @param localAxis The local direction that is used to compute the world direction
  80478. * @param mesh The mesh that this bone is attached to
  80479. * @param result The vector3 that the world direction will be copied to
  80480. */
  80481. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80482. /**
  80483. * Get the euler rotation of the bone in local or world space
  80484. * @param space The space that the rotation should be in
  80485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80486. * @returns The euler rotation
  80487. */
  80488. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80489. /**
  80490. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80491. * @param space The space that the rotation should be in
  80492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80493. * @param result The vector3 that the rotation should be copied to
  80494. */
  80495. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80496. /**
  80497. * Get the quaternion rotation of the bone in either local or world space
  80498. * @param space The space that the rotation should be in
  80499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80500. * @returns The quaternion rotation
  80501. */
  80502. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80503. /**
  80504. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80505. * @param space The space that the rotation should be in
  80506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80507. * @param result The quaternion that the rotation should be copied to
  80508. */
  80509. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80510. /**
  80511. * Get the rotation matrix of the bone in local or world space
  80512. * @param space The space that the rotation should be in
  80513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80514. * @returns The rotation matrix
  80515. */
  80516. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80517. /**
  80518. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80519. * @param space The space that the rotation should be in
  80520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80521. * @param result The quaternion that the rotation should be copied to
  80522. */
  80523. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80524. /**
  80525. * Get the world position of a point that is in the local space of the bone
  80526. * @param position The local position
  80527. * @param mesh The mesh that this bone is attached to
  80528. * @returns The world position
  80529. */
  80530. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80531. /**
  80532. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80533. * @param position The local position
  80534. * @param mesh The mesh that this bone is attached to
  80535. * @param result The vector3 that the world position should be copied to
  80536. */
  80537. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80538. /**
  80539. * Get the local position of a point that is in world space
  80540. * @param position The world position
  80541. * @param mesh The mesh that this bone is attached to
  80542. * @returns The local position
  80543. */
  80544. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80545. /**
  80546. * Get the local position of a point that is in world space and copy it to the result param
  80547. * @param position The world position
  80548. * @param mesh The mesh that this bone is attached to
  80549. * @param result The vector3 that the local position should be copied to
  80550. */
  80551. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80552. }
  80553. }
  80554. declare module BABYLON {
  80555. /**
  80556. * 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.
  80557. * @see https://doc.babylonjs.com/how_to/transformnode
  80558. */
  80559. export class TransformNode extends Node {
  80560. /**
  80561. * Object will not rotate to face the camera
  80562. */
  80563. static BILLBOARDMODE_NONE: number;
  80564. /**
  80565. * Object will rotate to face the camera but only on the x axis
  80566. */
  80567. static BILLBOARDMODE_X: number;
  80568. /**
  80569. * Object will rotate to face the camera but only on the y axis
  80570. */
  80571. static BILLBOARDMODE_Y: number;
  80572. /**
  80573. * Object will rotate to face the camera but only on the z axis
  80574. */
  80575. static BILLBOARDMODE_Z: number;
  80576. /**
  80577. * Object will rotate to face the camera
  80578. */
  80579. static BILLBOARDMODE_ALL: number;
  80580. /**
  80581. * Object will rotate to face the camera's position instead of orientation
  80582. */
  80583. static BILLBOARDMODE_USE_POSITION: number;
  80584. private _forward;
  80585. private _forwardInverted;
  80586. private _up;
  80587. private _right;
  80588. private _rightInverted;
  80589. private _position;
  80590. private _rotation;
  80591. private _rotationQuaternion;
  80592. protected _scaling: Vector3;
  80593. protected _isDirty: boolean;
  80594. private _transformToBoneReferal;
  80595. private _isAbsoluteSynced;
  80596. private _billboardMode;
  80597. /**
  80598. * Gets or sets the billboard mode. Default is 0.
  80599. *
  80600. * | Value | Type | Description |
  80601. * | --- | --- | --- |
  80602. * | 0 | BILLBOARDMODE_NONE | |
  80603. * | 1 | BILLBOARDMODE_X | |
  80604. * | 2 | BILLBOARDMODE_Y | |
  80605. * | 4 | BILLBOARDMODE_Z | |
  80606. * | 7 | BILLBOARDMODE_ALL | |
  80607. *
  80608. */
  80609. billboardMode: number;
  80610. private _preserveParentRotationForBillboard;
  80611. /**
  80612. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80613. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80614. */
  80615. preserveParentRotationForBillboard: boolean;
  80616. /**
  80617. * 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
  80618. */
  80619. scalingDeterminant: number;
  80620. private _infiniteDistance;
  80621. /**
  80622. * Gets or sets the distance of the object to max, often used by skybox
  80623. */
  80624. infiniteDistance: boolean;
  80625. /**
  80626. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80627. * By default the system will update normals to compensate
  80628. */
  80629. ignoreNonUniformScaling: boolean;
  80630. /**
  80631. * 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
  80632. */
  80633. reIntegrateRotationIntoRotationQuaternion: boolean;
  80634. /** @hidden */
  80635. _poseMatrix: Nullable<Matrix>;
  80636. /** @hidden */
  80637. _localMatrix: Matrix;
  80638. private _usePivotMatrix;
  80639. private _absolutePosition;
  80640. private _absoluteScaling;
  80641. private _absoluteRotationQuaternion;
  80642. private _pivotMatrix;
  80643. private _pivotMatrixInverse;
  80644. protected _postMultiplyPivotMatrix: boolean;
  80645. protected _isWorldMatrixFrozen: boolean;
  80646. /** @hidden */
  80647. _indexInSceneTransformNodesArray: number;
  80648. /**
  80649. * An event triggered after the world matrix is updated
  80650. */
  80651. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80652. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80653. /**
  80654. * Gets a string identifying the name of the class
  80655. * @returns "TransformNode" string
  80656. */
  80657. getClassName(): string;
  80658. /**
  80659. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80660. */
  80661. position: Vector3;
  80662. /**
  80663. * 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)).
  80664. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80665. */
  80666. rotation: Vector3;
  80667. /**
  80668. * 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)).
  80669. */
  80670. scaling: Vector3;
  80671. /**
  80672. * 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).
  80673. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80674. */
  80675. rotationQuaternion: Nullable<Quaternion>;
  80676. /**
  80677. * The forward direction of that transform in world space.
  80678. */
  80679. readonly forward: Vector3;
  80680. /**
  80681. * The up direction of that transform in world space.
  80682. */
  80683. readonly up: Vector3;
  80684. /**
  80685. * The right direction of that transform in world space.
  80686. */
  80687. readonly right: Vector3;
  80688. /**
  80689. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80690. * @param matrix the matrix to copy the pose from
  80691. * @returns this TransformNode.
  80692. */
  80693. updatePoseMatrix(matrix: Matrix): TransformNode;
  80694. /**
  80695. * Returns the mesh Pose matrix.
  80696. * @returns the pose matrix
  80697. */
  80698. getPoseMatrix(): Matrix;
  80699. /** @hidden */
  80700. _isSynchronized(): boolean;
  80701. /** @hidden */
  80702. _initCache(): void;
  80703. /**
  80704. * Flag the transform node as dirty (Forcing it to update everything)
  80705. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80706. * @returns this transform node
  80707. */
  80708. markAsDirty(property: string): TransformNode;
  80709. /**
  80710. * Returns the current mesh absolute position.
  80711. * Returns a Vector3.
  80712. */
  80713. readonly absolutePosition: Vector3;
  80714. /**
  80715. * Returns the current mesh absolute scaling.
  80716. * Returns a Vector3.
  80717. */
  80718. readonly absoluteScaling: Vector3;
  80719. /**
  80720. * Returns the current mesh absolute rotation.
  80721. * Returns a Quaternion.
  80722. */
  80723. readonly absoluteRotationQuaternion: Quaternion;
  80724. /**
  80725. * Sets a new matrix to apply before all other transformation
  80726. * @param matrix defines the transform matrix
  80727. * @returns the current TransformNode
  80728. */
  80729. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80730. /**
  80731. * Sets a new pivot matrix to the current node
  80732. * @param matrix defines the new pivot matrix to use
  80733. * @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
  80734. * @returns the current TransformNode
  80735. */
  80736. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80737. /**
  80738. * Returns the mesh pivot matrix.
  80739. * Default : Identity.
  80740. * @returns the matrix
  80741. */
  80742. getPivotMatrix(): Matrix;
  80743. /**
  80744. * Instantiate (when possible) or clone that node with its hierarchy
  80745. * @param newParent defines the new parent to use for the instance (or clone)
  80746. * @returns an instance (or a clone) of the current node with its hiearchy
  80747. */
  80748. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80749. /**
  80750. * Prevents the World matrix to be computed any longer
  80751. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80752. * @returns the TransformNode.
  80753. */
  80754. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80755. /**
  80756. * Allows back the World matrix computation.
  80757. * @returns the TransformNode.
  80758. */
  80759. unfreezeWorldMatrix(): this;
  80760. /**
  80761. * True if the World matrix has been frozen.
  80762. */
  80763. readonly isWorldMatrixFrozen: boolean;
  80764. /**
  80765. * Retuns the mesh absolute position in the World.
  80766. * @returns a Vector3.
  80767. */
  80768. getAbsolutePosition(): Vector3;
  80769. /**
  80770. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80771. * @param absolutePosition the absolute position to set
  80772. * @returns the TransformNode.
  80773. */
  80774. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80775. /**
  80776. * Sets the mesh position in its local space.
  80777. * @param vector3 the position to set in localspace
  80778. * @returns the TransformNode.
  80779. */
  80780. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80781. /**
  80782. * Returns the mesh position in the local space from the current World matrix values.
  80783. * @returns a new Vector3.
  80784. */
  80785. getPositionExpressedInLocalSpace(): Vector3;
  80786. /**
  80787. * Translates the mesh along the passed Vector3 in its local space.
  80788. * @param vector3 the distance to translate in localspace
  80789. * @returns the TransformNode.
  80790. */
  80791. locallyTranslate(vector3: Vector3): TransformNode;
  80792. private static _lookAtVectorCache;
  80793. /**
  80794. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80795. * @param targetPoint the position (must be in same space as current mesh) to look at
  80796. * @param yawCor optional yaw (y-axis) correction in radians
  80797. * @param pitchCor optional pitch (x-axis) correction in radians
  80798. * @param rollCor optional roll (z-axis) correction in radians
  80799. * @param space the choosen space of the target
  80800. * @returns the TransformNode.
  80801. */
  80802. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80803. /**
  80804. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80805. * This Vector3 is expressed in the World space.
  80806. * @param localAxis axis to rotate
  80807. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80808. */
  80809. getDirection(localAxis: Vector3): Vector3;
  80810. /**
  80811. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80812. * localAxis is expressed in the mesh local space.
  80813. * result is computed in the Wordl space from the mesh World matrix.
  80814. * @param localAxis axis to rotate
  80815. * @param result the resulting transformnode
  80816. * @returns this TransformNode.
  80817. */
  80818. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80819. /**
  80820. * Sets this transform node rotation to the given local axis.
  80821. * @param localAxis the axis in local space
  80822. * @param yawCor optional yaw (y-axis) correction in radians
  80823. * @param pitchCor optional pitch (x-axis) correction in radians
  80824. * @param rollCor optional roll (z-axis) correction in radians
  80825. * @returns this TransformNode
  80826. */
  80827. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80828. /**
  80829. * Sets a new pivot point to the current node
  80830. * @param point defines the new pivot point to use
  80831. * @param space defines if the point is in world or local space (local by default)
  80832. * @returns the current TransformNode
  80833. */
  80834. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80835. /**
  80836. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80837. * @returns the pivot point
  80838. */
  80839. getPivotPoint(): Vector3;
  80840. /**
  80841. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80842. * @param result the vector3 to store the result
  80843. * @returns this TransformNode.
  80844. */
  80845. getPivotPointToRef(result: Vector3): TransformNode;
  80846. /**
  80847. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80848. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80849. */
  80850. getAbsolutePivotPoint(): Vector3;
  80851. /**
  80852. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80853. * @param result vector3 to store the result
  80854. * @returns this TransformNode.
  80855. */
  80856. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80857. /**
  80858. * Defines the passed node as the parent of the current node.
  80859. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80860. * @see https://doc.babylonjs.com/how_to/parenting
  80861. * @param node the node ot set as the parent
  80862. * @returns this TransformNode.
  80863. */
  80864. setParent(node: Nullable<Node>): TransformNode;
  80865. private _nonUniformScaling;
  80866. /**
  80867. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80868. */
  80869. readonly nonUniformScaling: boolean;
  80870. /** @hidden */
  80871. _updateNonUniformScalingState(value: boolean): boolean;
  80872. /**
  80873. * Attach the current TransformNode to another TransformNode associated with a bone
  80874. * @param bone Bone affecting the TransformNode
  80875. * @param affectedTransformNode TransformNode associated with the bone
  80876. * @returns this object
  80877. */
  80878. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80879. /**
  80880. * Detach the transform node if its associated with a bone
  80881. * @returns this object
  80882. */
  80883. detachFromBone(): TransformNode;
  80884. private static _rotationAxisCache;
  80885. /**
  80886. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80887. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80888. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80889. * The passed axis is also normalized.
  80890. * @param axis the axis to rotate around
  80891. * @param amount the amount to rotate in radians
  80892. * @param space Space to rotate in (Default: local)
  80893. * @returns the TransformNode.
  80894. */
  80895. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80896. /**
  80897. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80898. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80899. * The passed axis is also normalized. .
  80900. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80901. * @param point the point to rotate around
  80902. * @param axis the axis to rotate around
  80903. * @param amount the amount to rotate in radians
  80904. * @returns the TransformNode
  80905. */
  80906. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80907. /**
  80908. * Translates the mesh along the axis vector for the passed distance in the given space.
  80909. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80910. * @param axis the axis to translate in
  80911. * @param distance the distance to translate
  80912. * @param space Space to rotate in (Default: local)
  80913. * @returns the TransformNode.
  80914. */
  80915. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80916. /**
  80917. * Adds a rotation step to the mesh current rotation.
  80918. * x, y, z are Euler angles expressed in radians.
  80919. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80920. * This means this rotation is made in the mesh local space only.
  80921. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80922. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80923. * ```javascript
  80924. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80925. * ```
  80926. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80927. * 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.
  80928. * @param x Rotation to add
  80929. * @param y Rotation to add
  80930. * @param z Rotation to add
  80931. * @returns the TransformNode.
  80932. */
  80933. addRotation(x: number, y: number, z: number): TransformNode;
  80934. /**
  80935. * @hidden
  80936. */
  80937. protected _getEffectiveParent(): Nullable<Node>;
  80938. /**
  80939. * Computes the world matrix of the node
  80940. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80941. * @returns the world matrix
  80942. */
  80943. computeWorldMatrix(force?: boolean): Matrix;
  80944. protected _afterComputeWorldMatrix(): void;
  80945. /**
  80946. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80947. * @param func callback function to add
  80948. *
  80949. * @returns the TransformNode.
  80950. */
  80951. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80952. /**
  80953. * Removes a registered callback function.
  80954. * @param func callback function to remove
  80955. * @returns the TransformNode.
  80956. */
  80957. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80958. /**
  80959. * Gets the position of the current mesh in camera space
  80960. * @param camera defines the camera to use
  80961. * @returns a position
  80962. */
  80963. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80964. /**
  80965. * Returns the distance from the mesh to the active camera
  80966. * @param camera defines the camera to use
  80967. * @returns the distance
  80968. */
  80969. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80970. /**
  80971. * Clone the current transform node
  80972. * @param name Name of the new clone
  80973. * @param newParent New parent for the clone
  80974. * @param doNotCloneChildren Do not clone children hierarchy
  80975. * @returns the new transform node
  80976. */
  80977. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80978. /**
  80979. * Serializes the objects information.
  80980. * @param currentSerializationObject defines the object to serialize in
  80981. * @returns the serialized object
  80982. */
  80983. serialize(currentSerializationObject?: any): any;
  80984. /**
  80985. * Returns a new TransformNode object parsed from the source provided.
  80986. * @param parsedTransformNode is the source.
  80987. * @param scene the scne the object belongs to
  80988. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80989. * @returns a new TransformNode object parsed from the source provided.
  80990. */
  80991. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80992. /**
  80993. * Get all child-transformNodes of this node
  80994. * @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
  80995. * @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
  80996. * @returns an array of TransformNode
  80997. */
  80998. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80999. /**
  81000. * Releases resources associated with this transform node.
  81001. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81002. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81003. */
  81004. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81005. /**
  81006. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81007. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81008. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81009. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81010. * @returns the current mesh
  81011. */
  81012. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81013. private _syncAbsoluteScalingAndRotation;
  81014. }
  81015. }
  81016. declare module BABYLON {
  81017. /**
  81018. * Defines the types of pose enabled controllers that are supported
  81019. */
  81020. export enum PoseEnabledControllerType {
  81021. /**
  81022. * HTC Vive
  81023. */
  81024. VIVE = 0,
  81025. /**
  81026. * Oculus Rift
  81027. */
  81028. OCULUS = 1,
  81029. /**
  81030. * Windows mixed reality
  81031. */
  81032. WINDOWS = 2,
  81033. /**
  81034. * Samsung gear VR
  81035. */
  81036. GEAR_VR = 3,
  81037. /**
  81038. * Google Daydream
  81039. */
  81040. DAYDREAM = 4,
  81041. /**
  81042. * Generic
  81043. */
  81044. GENERIC = 5
  81045. }
  81046. /**
  81047. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81048. */
  81049. export interface MutableGamepadButton {
  81050. /**
  81051. * Value of the button/trigger
  81052. */
  81053. value: number;
  81054. /**
  81055. * If the button/trigger is currently touched
  81056. */
  81057. touched: boolean;
  81058. /**
  81059. * If the button/trigger is currently pressed
  81060. */
  81061. pressed: boolean;
  81062. }
  81063. /**
  81064. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81065. * @hidden
  81066. */
  81067. export interface ExtendedGamepadButton extends GamepadButton {
  81068. /**
  81069. * If the button/trigger is currently pressed
  81070. */
  81071. readonly pressed: boolean;
  81072. /**
  81073. * If the button/trigger is currently touched
  81074. */
  81075. readonly touched: boolean;
  81076. /**
  81077. * Value of the button/trigger
  81078. */
  81079. readonly value: number;
  81080. }
  81081. /** @hidden */
  81082. export interface _GamePadFactory {
  81083. /**
  81084. * Returns wether or not the current gamepad can be created for this type of controller.
  81085. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81086. * @returns true if it can be created, otherwise false
  81087. */
  81088. canCreate(gamepadInfo: any): boolean;
  81089. /**
  81090. * Creates a new instance of the Gamepad.
  81091. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81092. * @returns the new gamepad instance
  81093. */
  81094. create(gamepadInfo: any): Gamepad;
  81095. }
  81096. /**
  81097. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81098. */
  81099. export class PoseEnabledControllerHelper {
  81100. /** @hidden */
  81101. static _ControllerFactories: _GamePadFactory[];
  81102. /** @hidden */
  81103. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81104. /**
  81105. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81106. * @param vrGamepad the gamepad to initialized
  81107. * @returns a vr controller of the type the gamepad identified as
  81108. */
  81109. static InitiateController(vrGamepad: any): Gamepad;
  81110. }
  81111. /**
  81112. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81113. */
  81114. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81115. /**
  81116. * If the controller is used in a webXR session
  81117. */
  81118. isXR: boolean;
  81119. private _deviceRoomPosition;
  81120. private _deviceRoomRotationQuaternion;
  81121. /**
  81122. * The device position in babylon space
  81123. */
  81124. devicePosition: Vector3;
  81125. /**
  81126. * The device rotation in babylon space
  81127. */
  81128. deviceRotationQuaternion: Quaternion;
  81129. /**
  81130. * The scale factor of the device in babylon space
  81131. */
  81132. deviceScaleFactor: number;
  81133. /**
  81134. * (Likely devicePosition should be used instead) The device position in its room space
  81135. */
  81136. position: Vector3;
  81137. /**
  81138. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81139. */
  81140. rotationQuaternion: Quaternion;
  81141. /**
  81142. * The type of controller (Eg. Windows mixed reality)
  81143. */
  81144. controllerType: PoseEnabledControllerType;
  81145. protected _calculatedPosition: Vector3;
  81146. private _calculatedRotation;
  81147. /**
  81148. * The raw pose from the device
  81149. */
  81150. rawPose: DevicePose;
  81151. private _trackPosition;
  81152. private _maxRotationDistFromHeadset;
  81153. private _draggedRoomRotation;
  81154. /**
  81155. * @hidden
  81156. */
  81157. _disableTrackPosition(fixedPosition: Vector3): void;
  81158. /**
  81159. * Internal, the mesh attached to the controller
  81160. * @hidden
  81161. */
  81162. _mesh: Nullable<AbstractMesh>;
  81163. private _poseControlledCamera;
  81164. private _leftHandSystemQuaternion;
  81165. /**
  81166. * Internal, matrix used to convert room space to babylon space
  81167. * @hidden
  81168. */
  81169. _deviceToWorld: Matrix;
  81170. /**
  81171. * Node to be used when casting a ray from the controller
  81172. * @hidden
  81173. */
  81174. _pointingPoseNode: Nullable<TransformNode>;
  81175. /**
  81176. * Name of the child mesh that can be used to cast a ray from the controller
  81177. */
  81178. static readonly POINTING_POSE: string;
  81179. /**
  81180. * Creates a new PoseEnabledController from a gamepad
  81181. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81182. */
  81183. constructor(browserGamepad: any);
  81184. private _workingMatrix;
  81185. /**
  81186. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81187. */
  81188. update(): void;
  81189. /**
  81190. * Updates only the pose device and mesh without doing any button event checking
  81191. */
  81192. protected _updatePoseAndMesh(): void;
  81193. /**
  81194. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81195. * @param poseData raw pose fromthe device
  81196. */
  81197. updateFromDevice(poseData: DevicePose): void;
  81198. /**
  81199. * @hidden
  81200. */
  81201. _meshAttachedObservable: Observable<AbstractMesh>;
  81202. /**
  81203. * Attaches a mesh to the controller
  81204. * @param mesh the mesh to be attached
  81205. */
  81206. attachToMesh(mesh: AbstractMesh): void;
  81207. /**
  81208. * Attaches the controllers mesh to a camera
  81209. * @param camera the camera the mesh should be attached to
  81210. */
  81211. attachToPoseControlledCamera(camera: TargetCamera): void;
  81212. /**
  81213. * Disposes of the controller
  81214. */
  81215. dispose(): void;
  81216. /**
  81217. * The mesh that is attached to the controller
  81218. */
  81219. readonly mesh: Nullable<AbstractMesh>;
  81220. /**
  81221. * Gets the ray of the controller in the direction the controller is pointing
  81222. * @param length the length the resulting ray should be
  81223. * @returns a ray in the direction the controller is pointing
  81224. */
  81225. getForwardRay(length?: number): Ray;
  81226. }
  81227. }
  81228. declare module BABYLON {
  81229. /**
  81230. * Defines the WebVRController object that represents controllers tracked in 3D space
  81231. */
  81232. export abstract class WebVRController extends PoseEnabledController {
  81233. /**
  81234. * Internal, the default controller model for the controller
  81235. */
  81236. protected _defaultModel: Nullable<AbstractMesh>;
  81237. /**
  81238. * Fired when the trigger state has changed
  81239. */
  81240. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81241. /**
  81242. * Fired when the main button state has changed
  81243. */
  81244. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81245. /**
  81246. * Fired when the secondary button state has changed
  81247. */
  81248. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81249. /**
  81250. * Fired when the pad state has changed
  81251. */
  81252. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81253. /**
  81254. * Fired when controllers stick values have changed
  81255. */
  81256. onPadValuesChangedObservable: Observable<StickValues>;
  81257. /**
  81258. * Array of button availible on the controller
  81259. */
  81260. protected _buttons: Array<MutableGamepadButton>;
  81261. private _onButtonStateChange;
  81262. /**
  81263. * Fired when a controller button's state has changed
  81264. * @param callback the callback containing the button that was modified
  81265. */
  81266. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81267. /**
  81268. * X and Y axis corresponding to the controllers joystick
  81269. */
  81270. pad: StickValues;
  81271. /**
  81272. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81273. */
  81274. hand: string;
  81275. /**
  81276. * The default controller model for the controller
  81277. */
  81278. readonly defaultModel: Nullable<AbstractMesh>;
  81279. /**
  81280. * Creates a new WebVRController from a gamepad
  81281. * @param vrGamepad the gamepad that the WebVRController should be created from
  81282. */
  81283. constructor(vrGamepad: any);
  81284. /**
  81285. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81286. */
  81287. update(): void;
  81288. /**
  81289. * Function to be called when a button is modified
  81290. */
  81291. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81292. /**
  81293. * Loads a mesh and attaches it to the controller
  81294. * @param scene the scene the mesh should be added to
  81295. * @param meshLoaded callback for when the mesh has been loaded
  81296. */
  81297. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81298. private _setButtonValue;
  81299. private _changes;
  81300. private _checkChanges;
  81301. /**
  81302. * Disposes of th webVRCOntroller
  81303. */
  81304. dispose(): void;
  81305. }
  81306. }
  81307. declare module BABYLON {
  81308. /**
  81309. * The HemisphericLight simulates the ambient environment light,
  81310. * so the passed direction is the light reflection direction, not the incoming direction.
  81311. */
  81312. export class HemisphericLight extends Light {
  81313. /**
  81314. * The groundColor is the light in the opposite direction to the one specified during creation.
  81315. * 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.
  81316. */
  81317. groundColor: Color3;
  81318. /**
  81319. * The light reflection direction, not the incoming direction.
  81320. */
  81321. direction: Vector3;
  81322. /**
  81323. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81324. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81325. * The HemisphericLight can't cast shadows.
  81326. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81327. * @param name The friendly name of the light
  81328. * @param direction The direction of the light reflection
  81329. * @param scene The scene the light belongs to
  81330. */
  81331. constructor(name: string, direction: Vector3, scene: Scene);
  81332. protected _buildUniformLayout(): void;
  81333. /**
  81334. * Returns the string "HemisphericLight".
  81335. * @return The class name
  81336. */
  81337. getClassName(): string;
  81338. /**
  81339. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81340. * Returns the updated direction.
  81341. * @param target The target the direction should point to
  81342. * @return The computed direction
  81343. */
  81344. setDirectionToTarget(target: Vector3): Vector3;
  81345. /**
  81346. * Returns the shadow generator associated to the light.
  81347. * @returns Always null for hemispheric lights because it does not support shadows.
  81348. */
  81349. getShadowGenerator(): Nullable<IShadowGenerator>;
  81350. /**
  81351. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81352. * @param effect The effect to update
  81353. * @param lightIndex The index of the light in the effect to update
  81354. * @returns The hemispheric light
  81355. */
  81356. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81357. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81358. /**
  81359. * Computes the world matrix of the node
  81360. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81361. * @param useWasUpdatedFlag defines a reserved property
  81362. * @returns the world matrix
  81363. */
  81364. computeWorldMatrix(): Matrix;
  81365. /**
  81366. * Returns the integer 3.
  81367. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81368. */
  81369. getTypeID(): number;
  81370. /**
  81371. * Prepares the list of defines specific to the light type.
  81372. * @param defines the list of defines
  81373. * @param lightIndex defines the index of the light for the effect
  81374. */
  81375. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81376. }
  81377. }
  81378. declare module BABYLON {
  81379. /** @hidden */
  81380. export var vrMultiviewToSingleviewPixelShader: {
  81381. name: string;
  81382. shader: string;
  81383. };
  81384. }
  81385. declare module BABYLON {
  81386. /**
  81387. * Renders to multiple views with a single draw call
  81388. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81389. */
  81390. export class MultiviewRenderTarget extends RenderTargetTexture {
  81391. /**
  81392. * Creates a multiview render target
  81393. * @param scene scene used with the render target
  81394. * @param size the size of the render target (used for each view)
  81395. */
  81396. constructor(scene: Scene, size?: number | {
  81397. width: number;
  81398. height: number;
  81399. } | {
  81400. ratio: number;
  81401. });
  81402. /**
  81403. * @hidden
  81404. * @param faceIndex the face index, if its a cube texture
  81405. */
  81406. _bindFrameBuffer(faceIndex?: number): void;
  81407. /**
  81408. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81409. * @returns the view count
  81410. */
  81411. getViewCount(): number;
  81412. }
  81413. }
  81414. declare module BABYLON {
  81415. /**
  81416. * Represents a camera frustum
  81417. */
  81418. export class Frustum {
  81419. /**
  81420. * Gets the planes representing the frustum
  81421. * @param transform matrix to be applied to the returned planes
  81422. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81423. */
  81424. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81425. /**
  81426. * Gets the near frustum plane transformed by the transform matrix
  81427. * @param transform transformation matrix to be applied to the resulting frustum plane
  81428. * @param frustumPlane the resuling frustum plane
  81429. */
  81430. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81431. /**
  81432. * Gets the far frustum plane transformed by the transform matrix
  81433. * @param transform transformation matrix to be applied to the resulting frustum plane
  81434. * @param frustumPlane the resuling frustum plane
  81435. */
  81436. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81437. /**
  81438. * Gets the left frustum plane transformed by the transform matrix
  81439. * @param transform transformation matrix to be applied to the resulting frustum plane
  81440. * @param frustumPlane the resuling frustum plane
  81441. */
  81442. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81443. /**
  81444. * Gets the right frustum plane transformed by the transform matrix
  81445. * @param transform transformation matrix to be applied to the resulting frustum plane
  81446. * @param frustumPlane the resuling frustum plane
  81447. */
  81448. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81449. /**
  81450. * Gets the top frustum plane transformed by the transform matrix
  81451. * @param transform transformation matrix to be applied to the resulting frustum plane
  81452. * @param frustumPlane the resuling frustum plane
  81453. */
  81454. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81455. /**
  81456. * Gets the bottom frustum plane transformed by the transform matrix
  81457. * @param transform transformation matrix to be applied to the resulting frustum plane
  81458. * @param frustumPlane the resuling frustum plane
  81459. */
  81460. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81461. /**
  81462. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81463. * @param transform transformation matrix to be applied to the resulting frustum planes
  81464. * @param frustumPlanes the resuling frustum planes
  81465. */
  81466. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81467. }
  81468. }
  81469. declare module BABYLON {
  81470. interface Engine {
  81471. /**
  81472. * Creates a new multiview render target
  81473. * @param width defines the width of the texture
  81474. * @param height defines the height of the texture
  81475. * @returns the created multiview texture
  81476. */
  81477. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81478. /**
  81479. * Binds a multiview framebuffer to be drawn to
  81480. * @param multiviewTexture texture to bind
  81481. */
  81482. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81483. }
  81484. interface Camera {
  81485. /**
  81486. * @hidden
  81487. * 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)
  81488. */
  81489. _useMultiviewToSingleView: boolean;
  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. _multiviewTexture: Nullable<RenderTargetTexture>;
  81495. /**
  81496. * @hidden
  81497. * ensures the multiview texture of the camera exists and has the specified width/height
  81498. * @param width height to set on the multiview texture
  81499. * @param height width to set on the multiview texture
  81500. */
  81501. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81502. }
  81503. interface Scene {
  81504. /** @hidden */
  81505. _transformMatrixR: Matrix;
  81506. /** @hidden */
  81507. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81508. /** @hidden */
  81509. _createMultiviewUbo(): void;
  81510. /** @hidden */
  81511. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81512. /** @hidden */
  81513. _renderMultiviewToSingleView(camera: Camera): void;
  81514. }
  81515. }
  81516. declare module BABYLON {
  81517. /**
  81518. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81519. * This will not be used for webXR as it supports displaying texture arrays directly
  81520. */
  81521. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81522. /**
  81523. * Initializes a VRMultiviewToSingleview
  81524. * @param name name of the post process
  81525. * @param camera camera to be applied to
  81526. * @param scaleFactor scaling factor to the size of the output texture
  81527. */
  81528. constructor(name: string, camera: Camera, scaleFactor: number);
  81529. }
  81530. }
  81531. declare module BABYLON {
  81532. interface Engine {
  81533. /** @hidden */
  81534. _vrDisplay: any;
  81535. /** @hidden */
  81536. _vrSupported: boolean;
  81537. /** @hidden */
  81538. _oldSize: Size;
  81539. /** @hidden */
  81540. _oldHardwareScaleFactor: number;
  81541. /** @hidden */
  81542. _vrExclusivePointerMode: boolean;
  81543. /** @hidden */
  81544. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81545. /** @hidden */
  81546. _onVRDisplayPointerRestricted: () => void;
  81547. /** @hidden */
  81548. _onVRDisplayPointerUnrestricted: () => void;
  81549. /** @hidden */
  81550. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81551. /** @hidden */
  81552. _onVrDisplayDisconnect: Nullable<() => void>;
  81553. /** @hidden */
  81554. _onVrDisplayPresentChange: Nullable<() => void>;
  81555. /**
  81556. * Observable signaled when VR display mode changes
  81557. */
  81558. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81559. /**
  81560. * Observable signaled when VR request present is complete
  81561. */
  81562. onVRRequestPresentComplete: Observable<boolean>;
  81563. /**
  81564. * Observable signaled when VR request present starts
  81565. */
  81566. onVRRequestPresentStart: Observable<Engine>;
  81567. /**
  81568. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81569. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81570. */
  81571. isInVRExclusivePointerMode: boolean;
  81572. /**
  81573. * Gets a boolean indicating if a webVR device was detected
  81574. * @returns true if a webVR device was detected
  81575. */
  81576. isVRDevicePresent(): boolean;
  81577. /**
  81578. * Gets the current webVR device
  81579. * @returns the current webVR device (or null)
  81580. */
  81581. getVRDevice(): any;
  81582. /**
  81583. * Initializes a webVR display and starts listening to display change events
  81584. * The onVRDisplayChangedObservable will be notified upon these changes
  81585. * @returns A promise containing a VRDisplay and if vr is supported
  81586. */
  81587. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81588. /** @hidden */
  81589. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81590. /**
  81591. * Call this function to switch to webVR mode
  81592. * Will do nothing if webVR is not supported or if there is no webVR device
  81593. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81594. */
  81595. enableVR(): void;
  81596. /** @hidden */
  81597. _onVRFullScreenTriggered(): void;
  81598. }
  81599. }
  81600. declare module BABYLON {
  81601. /**
  81602. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81603. * IMPORTANT!! The data is right-hand data.
  81604. * @export
  81605. * @interface DevicePose
  81606. */
  81607. export interface DevicePose {
  81608. /**
  81609. * The position of the device, values in array are [x,y,z].
  81610. */
  81611. readonly position: Nullable<Float32Array>;
  81612. /**
  81613. * The linearVelocity of the device, values in array are [x,y,z].
  81614. */
  81615. readonly linearVelocity: Nullable<Float32Array>;
  81616. /**
  81617. * The linearAcceleration of the device, values in array are [x,y,z].
  81618. */
  81619. readonly linearAcceleration: Nullable<Float32Array>;
  81620. /**
  81621. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81622. */
  81623. readonly orientation: Nullable<Float32Array>;
  81624. /**
  81625. * The angularVelocity of the device, values in array are [x,y,z].
  81626. */
  81627. readonly angularVelocity: Nullable<Float32Array>;
  81628. /**
  81629. * The angularAcceleration of the device, values in array are [x,y,z].
  81630. */
  81631. readonly angularAcceleration: Nullable<Float32Array>;
  81632. }
  81633. /**
  81634. * Interface representing a pose controlled object in Babylon.
  81635. * A pose controlled object has both regular pose values as well as pose values
  81636. * from an external device such as a VR head mounted display
  81637. */
  81638. export interface PoseControlled {
  81639. /**
  81640. * The position of the object in babylon space.
  81641. */
  81642. position: Vector3;
  81643. /**
  81644. * The rotation quaternion of the object in babylon space.
  81645. */
  81646. rotationQuaternion: Quaternion;
  81647. /**
  81648. * The position of the device in babylon space.
  81649. */
  81650. devicePosition?: Vector3;
  81651. /**
  81652. * The rotation quaternion of the device in babylon space.
  81653. */
  81654. deviceRotationQuaternion: Quaternion;
  81655. /**
  81656. * The raw pose coming from the device.
  81657. */
  81658. rawPose: Nullable<DevicePose>;
  81659. /**
  81660. * The scale of the device to be used when translating from device space to babylon space.
  81661. */
  81662. deviceScaleFactor: number;
  81663. /**
  81664. * Updates the poseControlled values based on the input device pose.
  81665. * @param poseData the pose data to update the object with
  81666. */
  81667. updateFromDevice(poseData: DevicePose): void;
  81668. }
  81669. /**
  81670. * Set of options to customize the webVRCamera
  81671. */
  81672. export interface WebVROptions {
  81673. /**
  81674. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81675. */
  81676. trackPosition?: boolean;
  81677. /**
  81678. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81679. */
  81680. positionScale?: number;
  81681. /**
  81682. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81683. */
  81684. displayName?: string;
  81685. /**
  81686. * Should the native controller meshes be initialized. (default: true)
  81687. */
  81688. controllerMeshes?: boolean;
  81689. /**
  81690. * Creating a default HemiLight only on controllers. (default: true)
  81691. */
  81692. defaultLightingOnControllers?: boolean;
  81693. /**
  81694. * If you don't want to use the default VR button of the helper. (default: false)
  81695. */
  81696. useCustomVRButton?: boolean;
  81697. /**
  81698. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81699. */
  81700. customVRButton?: HTMLButtonElement;
  81701. /**
  81702. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81703. */
  81704. rayLength?: number;
  81705. /**
  81706. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81707. */
  81708. defaultHeight?: number;
  81709. /**
  81710. * If multiview should be used if availible (default: false)
  81711. */
  81712. useMultiview?: boolean;
  81713. }
  81714. /**
  81715. * This represents a WebVR camera.
  81716. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81717. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81718. */
  81719. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81720. private webVROptions;
  81721. /**
  81722. * @hidden
  81723. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81724. */
  81725. _vrDevice: any;
  81726. /**
  81727. * The rawPose of the vrDevice.
  81728. */
  81729. rawPose: Nullable<DevicePose>;
  81730. private _onVREnabled;
  81731. private _specsVersion;
  81732. private _attached;
  81733. private _frameData;
  81734. protected _descendants: Array<Node>;
  81735. private _deviceRoomPosition;
  81736. /** @hidden */
  81737. _deviceRoomRotationQuaternion: Quaternion;
  81738. private _standingMatrix;
  81739. /**
  81740. * Represents device position in babylon space.
  81741. */
  81742. devicePosition: Vector3;
  81743. /**
  81744. * Represents device rotation in babylon space.
  81745. */
  81746. deviceRotationQuaternion: Quaternion;
  81747. /**
  81748. * The scale of the device to be used when translating from device space to babylon space.
  81749. */
  81750. deviceScaleFactor: number;
  81751. private _deviceToWorld;
  81752. private _worldToDevice;
  81753. /**
  81754. * References to the webVR controllers for the vrDevice.
  81755. */
  81756. controllers: Array<WebVRController>;
  81757. /**
  81758. * Emits an event when a controller is attached.
  81759. */
  81760. onControllersAttachedObservable: Observable<WebVRController[]>;
  81761. /**
  81762. * Emits an event when a controller's mesh has been loaded;
  81763. */
  81764. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81765. /**
  81766. * Emits an event when the HMD's pose has been updated.
  81767. */
  81768. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81769. private _poseSet;
  81770. /**
  81771. * If the rig cameras be used as parent instead of this camera.
  81772. */
  81773. rigParenting: boolean;
  81774. private _lightOnControllers;
  81775. private _defaultHeight?;
  81776. /**
  81777. * Instantiates a WebVRFreeCamera.
  81778. * @param name The name of the WebVRFreeCamera
  81779. * @param position The starting anchor position for the camera
  81780. * @param scene The scene the camera belongs to
  81781. * @param webVROptions a set of customizable options for the webVRCamera
  81782. */
  81783. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81784. /**
  81785. * Gets the device distance from the ground in meters.
  81786. * @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.
  81787. */
  81788. deviceDistanceToRoomGround(): number;
  81789. /**
  81790. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81791. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81792. */
  81793. useStandingMatrix(callback?: (bool: boolean) => void): void;
  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. * @returns A promise with a boolean set to if the standing matrix is supported.
  81797. */
  81798. useStandingMatrixAsync(): Promise<boolean>;
  81799. /**
  81800. * Disposes the camera
  81801. */
  81802. dispose(): void;
  81803. /**
  81804. * Gets a vrController by name.
  81805. * @param name The name of the controller to retreive
  81806. * @returns the controller matching the name specified or null if not found
  81807. */
  81808. getControllerByName(name: string): Nullable<WebVRController>;
  81809. private _leftController;
  81810. /**
  81811. * The controller corresponding to the users left hand.
  81812. */
  81813. readonly leftController: Nullable<WebVRController>;
  81814. private _rightController;
  81815. /**
  81816. * The controller corresponding to the users right hand.
  81817. */
  81818. readonly rightController: Nullable<WebVRController>;
  81819. /**
  81820. * Casts a ray forward from the vrCamera's gaze.
  81821. * @param length Length of the ray (default: 100)
  81822. * @returns the ray corresponding to the gaze
  81823. */
  81824. getForwardRay(length?: number): Ray;
  81825. /**
  81826. * @hidden
  81827. * Updates the camera based on device's frame data
  81828. */
  81829. _checkInputs(): void;
  81830. /**
  81831. * Updates the poseControlled values based on the input device pose.
  81832. * @param poseData Pose coming from the device
  81833. */
  81834. updateFromDevice(poseData: DevicePose): void;
  81835. private _htmlElementAttached;
  81836. private _detachIfAttached;
  81837. /**
  81838. * WebVR's attach control will start broadcasting frames to the device.
  81839. * Note that in certain browsers (chrome for example) this function must be called
  81840. * within a user-interaction callback. Example:
  81841. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81842. *
  81843. * @param element html element to attach the vrDevice to
  81844. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81845. */
  81846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81847. /**
  81848. * Detaches the camera from the html element and disables VR
  81849. *
  81850. * @param element html element to detach from
  81851. */
  81852. detachControl(element: HTMLElement): void;
  81853. /**
  81854. * @returns the name of this class
  81855. */
  81856. getClassName(): string;
  81857. /**
  81858. * Calls resetPose on the vrDisplay
  81859. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81860. */
  81861. resetToCurrentRotation(): void;
  81862. /**
  81863. * @hidden
  81864. * Updates the rig cameras (left and right eye)
  81865. */
  81866. _updateRigCameras(): void;
  81867. private _workingVector;
  81868. private _oneVector;
  81869. private _workingMatrix;
  81870. private updateCacheCalled;
  81871. private _correctPositionIfNotTrackPosition;
  81872. /**
  81873. * @hidden
  81874. * Updates the cached values of the camera
  81875. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81876. */
  81877. _updateCache(ignoreParentClass?: boolean): void;
  81878. /**
  81879. * @hidden
  81880. * Get current device position in babylon world
  81881. */
  81882. _computeDevicePosition(): void;
  81883. /**
  81884. * Updates the current device position and rotation in the babylon world
  81885. */
  81886. update(): void;
  81887. /**
  81888. * @hidden
  81889. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81890. * @returns an identity matrix
  81891. */
  81892. _getViewMatrix(): Matrix;
  81893. private _tmpMatrix;
  81894. /**
  81895. * This function is called by the two RIG cameras.
  81896. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81897. * @hidden
  81898. */
  81899. _getWebVRViewMatrix(): Matrix;
  81900. /** @hidden */
  81901. _getWebVRProjectionMatrix(): Matrix;
  81902. private _onGamepadConnectedObserver;
  81903. private _onGamepadDisconnectedObserver;
  81904. private _updateCacheWhenTrackingDisabledObserver;
  81905. /**
  81906. * Initializes the controllers and their meshes
  81907. */
  81908. initControllers(): void;
  81909. }
  81910. }
  81911. declare module BABYLON {
  81912. /**
  81913. * Size options for a post process
  81914. */
  81915. export type PostProcessOptions = {
  81916. width: number;
  81917. height: number;
  81918. };
  81919. /**
  81920. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81921. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81922. */
  81923. export class PostProcess {
  81924. /** Name of the PostProcess. */
  81925. name: string;
  81926. /**
  81927. * Gets or sets the unique id of the post process
  81928. */
  81929. uniqueId: number;
  81930. /**
  81931. * Width of the texture to apply the post process on
  81932. */
  81933. width: number;
  81934. /**
  81935. * Height of the texture to apply the post process on
  81936. */
  81937. height: number;
  81938. /**
  81939. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81940. * @hidden
  81941. */
  81942. _outputTexture: Nullable<InternalTexture>;
  81943. /**
  81944. * Sampling mode used by the shader
  81945. * See https://doc.babylonjs.com/classes/3.1/texture
  81946. */
  81947. renderTargetSamplingMode: number;
  81948. /**
  81949. * Clear color to use when screen clearing
  81950. */
  81951. clearColor: Color4;
  81952. /**
  81953. * If the buffer needs to be cleared before applying the post process. (default: true)
  81954. * Should be set to false if shader will overwrite all previous pixels.
  81955. */
  81956. autoClear: boolean;
  81957. /**
  81958. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81959. */
  81960. alphaMode: number;
  81961. /**
  81962. * Sets the setAlphaBlendConstants of the babylon engine
  81963. */
  81964. alphaConstants: Color4;
  81965. /**
  81966. * Animations to be used for the post processing
  81967. */
  81968. animations: Animation[];
  81969. /**
  81970. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81971. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81972. */
  81973. enablePixelPerfectMode: boolean;
  81974. /**
  81975. * Force the postprocess to be applied without taking in account viewport
  81976. */
  81977. forceFullscreenViewport: boolean;
  81978. /**
  81979. * List of inspectable custom properties (used by the Inspector)
  81980. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81981. */
  81982. inspectableCustomProperties: IInspectable[];
  81983. /**
  81984. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81985. *
  81986. * | Value | Type | Description |
  81987. * | ----- | ----------------------------------- | ----------- |
  81988. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81989. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81990. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81991. *
  81992. */
  81993. scaleMode: number;
  81994. /**
  81995. * Force textures to be a power of two (default: false)
  81996. */
  81997. alwaysForcePOT: boolean;
  81998. private _samples;
  81999. /**
  82000. * Number of sample textures (default: 1)
  82001. */
  82002. samples: number;
  82003. /**
  82004. * Modify the scale of the post process to be the same as the viewport (default: false)
  82005. */
  82006. adaptScaleToCurrentViewport: boolean;
  82007. private _camera;
  82008. private _scene;
  82009. private _engine;
  82010. private _options;
  82011. private _reusable;
  82012. private _textureType;
  82013. /**
  82014. * Smart array of input and output textures for the post process.
  82015. * @hidden
  82016. */
  82017. _textures: SmartArray<InternalTexture>;
  82018. /**
  82019. * The index in _textures that corresponds to the output texture.
  82020. * @hidden
  82021. */
  82022. _currentRenderTextureInd: number;
  82023. private _effect;
  82024. private _samplers;
  82025. private _fragmentUrl;
  82026. private _vertexUrl;
  82027. private _parameters;
  82028. private _scaleRatio;
  82029. protected _indexParameters: any;
  82030. private _shareOutputWithPostProcess;
  82031. private _texelSize;
  82032. private _forcedOutputTexture;
  82033. /**
  82034. * Returns the fragment url or shader name used in the post process.
  82035. * @returns the fragment url or name in the shader store.
  82036. */
  82037. getEffectName(): string;
  82038. /**
  82039. * An event triggered when the postprocess is activated.
  82040. */
  82041. onActivateObservable: Observable<Camera>;
  82042. private _onActivateObserver;
  82043. /**
  82044. * A function that is added to the onActivateObservable
  82045. */
  82046. onActivate: Nullable<(camera: Camera) => void>;
  82047. /**
  82048. * An event triggered when the postprocess changes its size.
  82049. */
  82050. onSizeChangedObservable: Observable<PostProcess>;
  82051. private _onSizeChangedObserver;
  82052. /**
  82053. * A function that is added to the onSizeChangedObservable
  82054. */
  82055. onSizeChanged: (postProcess: PostProcess) => void;
  82056. /**
  82057. * An event triggered when the postprocess applies its effect.
  82058. */
  82059. onApplyObservable: Observable<Effect>;
  82060. private _onApplyObserver;
  82061. /**
  82062. * A function that is added to the onApplyObservable
  82063. */
  82064. onApply: (effect: Effect) => void;
  82065. /**
  82066. * An event triggered before rendering the postprocess
  82067. */
  82068. onBeforeRenderObservable: Observable<Effect>;
  82069. private _onBeforeRenderObserver;
  82070. /**
  82071. * A function that is added to the onBeforeRenderObservable
  82072. */
  82073. onBeforeRender: (effect: Effect) => void;
  82074. /**
  82075. * An event triggered after rendering the postprocess
  82076. */
  82077. onAfterRenderObservable: Observable<Effect>;
  82078. private _onAfterRenderObserver;
  82079. /**
  82080. * A function that is added to the onAfterRenderObservable
  82081. */
  82082. onAfterRender: (efect: Effect) => void;
  82083. /**
  82084. * 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
  82085. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82086. */
  82087. inputTexture: InternalTexture;
  82088. /**
  82089. * Gets the camera which post process is applied to.
  82090. * @returns The camera the post process is applied to.
  82091. */
  82092. getCamera(): Camera;
  82093. /**
  82094. * Gets the texel size of the postprocess.
  82095. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82096. */
  82097. readonly texelSize: Vector2;
  82098. /**
  82099. * Creates a new instance PostProcess
  82100. * @param name The name of the PostProcess.
  82101. * @param fragmentUrl The url of the fragment shader to be used.
  82102. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82103. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82104. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82105. * @param camera The camera to apply the render pass to.
  82106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82107. * @param engine The engine which the post process will be applied. (default: current engine)
  82108. * @param reusable If the post process can be reused on the same frame. (default: false)
  82109. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82110. * @param textureType Type of textures used when performing the post process. (default: 0)
  82111. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82112. * @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
  82113. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82114. */
  82115. constructor(
  82116. /** Name of the PostProcess. */
  82117. 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);
  82118. /**
  82119. * Gets a string idenfifying the name of the class
  82120. * @returns "PostProcess" string
  82121. */
  82122. getClassName(): string;
  82123. /**
  82124. * Gets the engine which this post process belongs to.
  82125. * @returns The engine the post process was enabled with.
  82126. */
  82127. getEngine(): Engine;
  82128. /**
  82129. * The effect that is created when initializing the post process.
  82130. * @returns The created effect corresponding the the postprocess.
  82131. */
  82132. getEffect(): Effect;
  82133. /**
  82134. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82135. * @param postProcess The post process to share the output with.
  82136. * @returns This post process.
  82137. */
  82138. shareOutputWith(postProcess: PostProcess): PostProcess;
  82139. /**
  82140. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82141. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82142. */
  82143. useOwnOutput(): void;
  82144. /**
  82145. * Updates the effect with the current post process compile time values and recompiles the shader.
  82146. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82147. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82148. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82149. * @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
  82150. * @param onCompiled Called when the shader has been compiled.
  82151. * @param onError Called if there is an error when compiling a shader.
  82152. */
  82153. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82154. /**
  82155. * The post process is reusable if it can be used multiple times within one frame.
  82156. * @returns If the post process is reusable
  82157. */
  82158. isReusable(): boolean;
  82159. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82160. markTextureDirty(): void;
  82161. /**
  82162. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82163. * 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.
  82164. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82165. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82166. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82167. * @returns The target texture that was bound to be written to.
  82168. */
  82169. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82170. /**
  82171. * If the post process is supported.
  82172. */
  82173. readonly isSupported: boolean;
  82174. /**
  82175. * The aspect ratio of the output texture.
  82176. */
  82177. readonly aspectRatio: number;
  82178. /**
  82179. * Get a value indicating if the post-process is ready to be used
  82180. * @returns true if the post-process is ready (shader is compiled)
  82181. */
  82182. isReady(): boolean;
  82183. /**
  82184. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82185. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82186. */
  82187. apply(): Nullable<Effect>;
  82188. private _disposeTextures;
  82189. /**
  82190. * Disposes the post process.
  82191. * @param camera The camera to dispose the post process on.
  82192. */
  82193. dispose(camera?: Camera): void;
  82194. }
  82195. }
  82196. declare module BABYLON {
  82197. /** @hidden */
  82198. export var kernelBlurVaryingDeclaration: {
  82199. name: string;
  82200. shader: string;
  82201. };
  82202. }
  82203. declare module BABYLON {
  82204. /** @hidden */
  82205. export var kernelBlurFragment: {
  82206. name: string;
  82207. shader: string;
  82208. };
  82209. }
  82210. declare module BABYLON {
  82211. /** @hidden */
  82212. export var kernelBlurFragment2: {
  82213. name: string;
  82214. shader: string;
  82215. };
  82216. }
  82217. declare module BABYLON {
  82218. /** @hidden */
  82219. export var kernelBlurPixelShader: {
  82220. name: string;
  82221. shader: string;
  82222. };
  82223. }
  82224. declare module BABYLON {
  82225. /** @hidden */
  82226. export var kernelBlurVertex: {
  82227. name: string;
  82228. shader: string;
  82229. };
  82230. }
  82231. declare module BABYLON {
  82232. /** @hidden */
  82233. export var kernelBlurVertexShader: {
  82234. name: string;
  82235. shader: string;
  82236. };
  82237. }
  82238. declare module BABYLON {
  82239. /**
  82240. * The Blur Post Process which blurs an image based on a kernel and direction.
  82241. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82242. */
  82243. export class BlurPostProcess extends PostProcess {
  82244. /** The direction in which to blur the image. */
  82245. direction: Vector2;
  82246. private blockCompilation;
  82247. protected _kernel: number;
  82248. protected _idealKernel: number;
  82249. protected _packedFloat: boolean;
  82250. private _staticDefines;
  82251. /**
  82252. * Sets the length in pixels of the blur sample region
  82253. */
  82254. /**
  82255. * Gets the length in pixels of the blur sample region
  82256. */
  82257. kernel: number;
  82258. /**
  82259. * Sets wether or not the blur needs to unpack/repack floats
  82260. */
  82261. /**
  82262. * Gets wether or not the blur is unpacking/repacking floats
  82263. */
  82264. packedFloat: boolean;
  82265. /**
  82266. * Creates a new instance BlurPostProcess
  82267. * @param name The name of the effect.
  82268. * @param direction The direction in which to blur the image.
  82269. * @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.
  82270. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82271. * @param camera The camera to apply the render pass to.
  82272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82273. * @param engine The engine which the post process will be applied. (default: current engine)
  82274. * @param reusable If the post process can be reused on the same frame. (default: false)
  82275. * @param textureType Type of textures used when performing the post process. (default: 0)
  82276. * @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)
  82277. */
  82278. constructor(name: string,
  82279. /** The direction in which to blur the image. */
  82280. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82281. /**
  82282. * Updates the effect with the current post process compile time values and recompiles the shader.
  82283. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82284. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82285. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82286. * @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
  82287. * @param onCompiled Called when the shader has been compiled.
  82288. * @param onError Called if there is an error when compiling a shader.
  82289. */
  82290. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82291. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82292. /**
  82293. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82294. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82295. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82296. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82297. * The gaps between physical kernels are compensated for in the weighting of the samples
  82298. * @param idealKernel Ideal blur kernel.
  82299. * @return Nearest best kernel.
  82300. */
  82301. protected _nearestBestKernel(idealKernel: number): number;
  82302. /**
  82303. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82304. * @param x The point on the Gaussian distribution to sample.
  82305. * @return the value of the Gaussian function at x.
  82306. */
  82307. protected _gaussianWeight(x: number): number;
  82308. /**
  82309. * Generates a string that can be used as a floating point number in GLSL.
  82310. * @param x Value to print.
  82311. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82312. * @return GLSL float string.
  82313. */
  82314. protected _glslFloat(x: number, decimalFigures?: number): string;
  82315. }
  82316. }
  82317. declare module BABYLON {
  82318. /**
  82319. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82320. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82321. * You can then easily use it as a reflectionTexture on a flat surface.
  82322. * In case the surface is not a plane, please consider relying on reflection probes.
  82323. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82324. */
  82325. export class MirrorTexture extends RenderTargetTexture {
  82326. private scene;
  82327. /**
  82328. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82329. * 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.
  82330. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82331. */
  82332. mirrorPlane: Plane;
  82333. /**
  82334. * Define the blur ratio used to blur the reflection if needed.
  82335. */
  82336. blurRatio: number;
  82337. /**
  82338. * Define the adaptive blur kernel used to blur the reflection if needed.
  82339. * This will autocompute the closest best match for the `blurKernel`
  82340. */
  82341. adaptiveBlurKernel: number;
  82342. /**
  82343. * Define the blur kernel used to blur the reflection if needed.
  82344. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82345. */
  82346. blurKernel: number;
  82347. /**
  82348. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82349. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82350. */
  82351. blurKernelX: number;
  82352. /**
  82353. * Define the blur kernel on the Y 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. blurKernelY: number;
  82357. private _autoComputeBlurKernel;
  82358. protected _onRatioRescale(): void;
  82359. private _updateGammaSpace;
  82360. private _imageProcessingConfigChangeObserver;
  82361. private _transformMatrix;
  82362. private _mirrorMatrix;
  82363. private _savedViewMatrix;
  82364. private _blurX;
  82365. private _blurY;
  82366. private _adaptiveBlurKernel;
  82367. private _blurKernelX;
  82368. private _blurKernelY;
  82369. private _blurRatio;
  82370. /**
  82371. * Instantiates a Mirror Texture.
  82372. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82373. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82374. * You can then easily use it as a reflectionTexture on a flat surface.
  82375. * In case the surface is not a plane, please consider relying on reflection probes.
  82376. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82377. * @param name
  82378. * @param size
  82379. * @param scene
  82380. * @param generateMipMaps
  82381. * @param type
  82382. * @param samplingMode
  82383. * @param generateDepthBuffer
  82384. */
  82385. constructor(name: string, size: number | {
  82386. width: number;
  82387. height: number;
  82388. } | {
  82389. ratio: number;
  82390. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82391. private _preparePostProcesses;
  82392. /**
  82393. * Clone the mirror texture.
  82394. * @returns the cloned texture
  82395. */
  82396. clone(): MirrorTexture;
  82397. /**
  82398. * Serialize the texture to a JSON representation you could use in Parse later on
  82399. * @returns the serialized JSON representation
  82400. */
  82401. serialize(): any;
  82402. /**
  82403. * Dispose the texture and release its associated resources.
  82404. */
  82405. dispose(): void;
  82406. }
  82407. }
  82408. declare module BABYLON {
  82409. /**
  82410. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82411. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82412. */
  82413. export class Texture extends BaseTexture {
  82414. /**
  82415. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82416. */
  82417. static SerializeBuffers: boolean;
  82418. /** @hidden */
  82419. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82420. /** @hidden */
  82421. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82422. /** @hidden */
  82423. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82424. /** nearest is mag = nearest and min = nearest and mip = linear */
  82425. static readonly NEAREST_SAMPLINGMODE: number;
  82426. /** nearest is mag = nearest and min = nearest and mip = linear */
  82427. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82428. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82429. static readonly BILINEAR_SAMPLINGMODE: number;
  82430. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82431. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82432. /** Trilinear is mag = linear and min = linear and mip = linear */
  82433. static readonly TRILINEAR_SAMPLINGMODE: number;
  82434. /** Trilinear is mag = linear and min = linear and mip = linear */
  82435. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82436. /** mag = nearest and min = nearest and mip = nearest */
  82437. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82438. /** mag = nearest and min = linear and mip = nearest */
  82439. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82440. /** mag = nearest and min = linear and mip = linear */
  82441. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82442. /** mag = nearest and min = linear and mip = none */
  82443. static readonly NEAREST_LINEAR: number;
  82444. /** mag = nearest and min = nearest and mip = none */
  82445. static readonly NEAREST_NEAREST: number;
  82446. /** mag = linear and min = nearest and mip = nearest */
  82447. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82448. /** mag = linear and min = nearest and mip = linear */
  82449. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82450. /** mag = linear and min = linear and mip = none */
  82451. static readonly LINEAR_LINEAR: number;
  82452. /** mag = linear and min = nearest and mip = none */
  82453. static readonly LINEAR_NEAREST: number;
  82454. /** Explicit coordinates mode */
  82455. static readonly EXPLICIT_MODE: number;
  82456. /** Spherical coordinates mode */
  82457. static readonly SPHERICAL_MODE: number;
  82458. /** Planar coordinates mode */
  82459. static readonly PLANAR_MODE: number;
  82460. /** Cubic coordinates mode */
  82461. static readonly CUBIC_MODE: number;
  82462. /** Projection coordinates mode */
  82463. static readonly PROJECTION_MODE: number;
  82464. /** Inverse Cubic coordinates mode */
  82465. static readonly SKYBOX_MODE: number;
  82466. /** Inverse Cubic coordinates mode */
  82467. static readonly INVCUBIC_MODE: number;
  82468. /** Equirectangular coordinates mode */
  82469. static readonly EQUIRECTANGULAR_MODE: number;
  82470. /** Equirectangular Fixed coordinates mode */
  82471. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82472. /** Equirectangular Fixed Mirrored coordinates mode */
  82473. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82474. /** Texture is not repeating outside of 0..1 UVs */
  82475. static readonly CLAMP_ADDRESSMODE: number;
  82476. /** Texture is repeating outside of 0..1 UVs */
  82477. static readonly WRAP_ADDRESSMODE: number;
  82478. /** Texture is repeating and mirrored */
  82479. static readonly MIRROR_ADDRESSMODE: number;
  82480. /**
  82481. * 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
  82482. */
  82483. static UseSerializedUrlIfAny: boolean;
  82484. /**
  82485. * Define the url of the texture.
  82486. */
  82487. url: Nullable<string>;
  82488. /**
  82489. * Define an offset on the texture to offset the u coordinates of the UVs
  82490. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82491. */
  82492. uOffset: number;
  82493. /**
  82494. * Define an offset on the texture to offset the v coordinates of the UVs
  82495. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82496. */
  82497. vOffset: number;
  82498. /**
  82499. * Define an offset on the texture to scale the u coordinates of the UVs
  82500. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82501. */
  82502. uScale: number;
  82503. /**
  82504. * Define an offset on the texture to scale the v coordinates of the UVs
  82505. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82506. */
  82507. vScale: number;
  82508. /**
  82509. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82510. * @see http://doc.babylonjs.com/how_to/more_materials
  82511. */
  82512. uAng: number;
  82513. /**
  82514. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82515. * @see http://doc.babylonjs.com/how_to/more_materials
  82516. */
  82517. vAng: number;
  82518. /**
  82519. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82520. * @see http://doc.babylonjs.com/how_to/more_materials
  82521. */
  82522. wAng: number;
  82523. /**
  82524. * Defines the center of rotation (U)
  82525. */
  82526. uRotationCenter: number;
  82527. /**
  82528. * Defines the center of rotation (V)
  82529. */
  82530. vRotationCenter: number;
  82531. /**
  82532. * Defines the center of rotation (W)
  82533. */
  82534. wRotationCenter: number;
  82535. /**
  82536. * Are mip maps generated for this texture or not.
  82537. */
  82538. readonly noMipmap: boolean;
  82539. /**
  82540. * List of inspectable custom properties (used by the Inspector)
  82541. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82542. */
  82543. inspectableCustomProperties: Nullable<IInspectable[]>;
  82544. private _noMipmap;
  82545. /** @hidden */
  82546. _invertY: boolean;
  82547. private _rowGenerationMatrix;
  82548. private _cachedTextureMatrix;
  82549. private _projectionModeMatrix;
  82550. private _t0;
  82551. private _t1;
  82552. private _t2;
  82553. private _cachedUOffset;
  82554. private _cachedVOffset;
  82555. private _cachedUScale;
  82556. private _cachedVScale;
  82557. private _cachedUAng;
  82558. private _cachedVAng;
  82559. private _cachedWAng;
  82560. private _cachedProjectionMatrixId;
  82561. private _cachedCoordinatesMode;
  82562. /** @hidden */
  82563. protected _initialSamplingMode: number;
  82564. /** @hidden */
  82565. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82566. private _deleteBuffer;
  82567. protected _format: Nullable<number>;
  82568. private _delayedOnLoad;
  82569. private _delayedOnError;
  82570. /**
  82571. * Observable triggered once the texture has been loaded.
  82572. */
  82573. onLoadObservable: Observable<Texture>;
  82574. protected _isBlocking: boolean;
  82575. /**
  82576. * Is the texture preventing material to render while loading.
  82577. * If false, a default texture will be used instead of the loading one during the preparation step.
  82578. */
  82579. isBlocking: boolean;
  82580. /**
  82581. * Get the current sampling mode associated with the texture.
  82582. */
  82583. readonly samplingMode: number;
  82584. /**
  82585. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82586. */
  82587. readonly invertY: boolean;
  82588. /**
  82589. * Instantiates a new texture.
  82590. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82591. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82592. * @param url define the url of the picture to load as a texture
  82593. * @param scene define the scene or engine the texture will belong to
  82594. * @param noMipmap define if the texture will require mip maps or not
  82595. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82596. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82597. * @param onLoad define a callback triggered when the texture has been loaded
  82598. * @param onError define a callback triggered when an error occurred during the loading session
  82599. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82600. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82601. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82602. */
  82603. 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);
  82604. /**
  82605. * Update the url (and optional buffer) of this texture if url was null during construction.
  82606. * @param url the url of the texture
  82607. * @param buffer the buffer of the texture (defaults to null)
  82608. * @param onLoad callback called when the texture is loaded (defaults to null)
  82609. */
  82610. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82611. /**
  82612. * Finish the loading sequence of a texture flagged as delayed load.
  82613. * @hidden
  82614. */
  82615. delayLoad(): void;
  82616. private _prepareRowForTextureGeneration;
  82617. /**
  82618. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82619. * @returns the transform matrix of the texture.
  82620. */
  82621. getTextureMatrix(): Matrix;
  82622. /**
  82623. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82624. * @returns The reflection texture transform
  82625. */
  82626. getReflectionTextureMatrix(): Matrix;
  82627. /**
  82628. * Clones the texture.
  82629. * @returns the cloned texture
  82630. */
  82631. clone(): Texture;
  82632. /**
  82633. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82634. * @returns The JSON representation of the texture
  82635. */
  82636. serialize(): any;
  82637. /**
  82638. * Get the current class name of the texture useful for serialization or dynamic coding.
  82639. * @returns "Texture"
  82640. */
  82641. getClassName(): string;
  82642. /**
  82643. * Dispose the texture and release its associated resources.
  82644. */
  82645. dispose(): void;
  82646. /**
  82647. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82648. * @param parsedTexture Define the JSON representation of the texture
  82649. * @param scene Define the scene the parsed texture should be instantiated in
  82650. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82651. * @returns The parsed texture if successful
  82652. */
  82653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82654. /**
  82655. * Creates a texture from its base 64 representation.
  82656. * @param data Define the base64 payload without the data: prefix
  82657. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82658. * @param scene Define the scene the texture should belong to
  82659. * @param noMipmap Forces the texture to not create mip map information if true
  82660. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82661. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82662. * @param onLoad define a callback triggered when the texture has been loaded
  82663. * @param onError define a callback triggered when an error occurred during the loading session
  82664. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82665. * @returns the created texture
  82666. */
  82667. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82668. /**
  82669. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82670. * @param data Define the base64 payload without the data: prefix
  82671. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82672. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82673. * @param scene Define the scene the texture should belong to
  82674. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82675. * @param noMipmap Forces the texture to not create mip map information if true
  82676. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82677. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82678. * @param onLoad define a callback triggered when the texture has been loaded
  82679. * @param onError define a callback triggered when an error occurred during the loading session
  82680. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82681. * @returns the created texture
  82682. */
  82683. 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;
  82684. }
  82685. }
  82686. declare module BABYLON {
  82687. /**
  82688. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82689. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82690. */
  82691. export class PostProcessManager {
  82692. private _scene;
  82693. private _indexBuffer;
  82694. private _vertexBuffers;
  82695. /**
  82696. * Creates a new instance PostProcess
  82697. * @param scene The scene that the post process is associated with.
  82698. */
  82699. constructor(scene: Scene);
  82700. private _prepareBuffers;
  82701. private _buildIndexBuffer;
  82702. /**
  82703. * Rebuilds the vertex buffers of the manager.
  82704. * @hidden
  82705. */
  82706. _rebuild(): void;
  82707. /**
  82708. * Prepares a frame to be run through a post process.
  82709. * @param sourceTexture The input texture to the post procesess. (default: null)
  82710. * @param postProcesses An array of post processes to be run. (default: null)
  82711. * @returns True if the post processes were able to be run.
  82712. * @hidden
  82713. */
  82714. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82715. /**
  82716. * Manually render a set of post processes to a texture.
  82717. * @param postProcesses An array of post processes to be run.
  82718. * @param targetTexture The target texture to render to.
  82719. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82720. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82721. * @param lodLevel defines which lod of the texture to render to
  82722. */
  82723. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82724. /**
  82725. * Finalize the result of the output of the postprocesses.
  82726. * @param doNotPresent If true the result will not be displayed to the screen.
  82727. * @param targetTexture The target texture to render to.
  82728. * @param faceIndex The index of the face to bind the target texture to.
  82729. * @param postProcesses The array of post processes to render.
  82730. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82731. * @hidden
  82732. */
  82733. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82734. /**
  82735. * Disposes of the post process manager.
  82736. */
  82737. dispose(): void;
  82738. }
  82739. }
  82740. declare module BABYLON {
  82741. /** Interface used by value gradients (color, factor, ...) */
  82742. export interface IValueGradient {
  82743. /**
  82744. * Gets or sets the gradient value (between 0 and 1)
  82745. */
  82746. gradient: number;
  82747. }
  82748. /** Class used to store color4 gradient */
  82749. export class ColorGradient implements IValueGradient {
  82750. /**
  82751. * Gets or sets the gradient value (between 0 and 1)
  82752. */
  82753. gradient: number;
  82754. /**
  82755. * Gets or sets first associated color
  82756. */
  82757. color1: Color4;
  82758. /**
  82759. * Gets or sets second associated color
  82760. */
  82761. color2?: Color4;
  82762. /**
  82763. * Will get a color picked randomly between color1 and color2.
  82764. * If color2 is undefined then color1 will be used
  82765. * @param result defines the target Color4 to store the result in
  82766. */
  82767. getColorToRef(result: Color4): void;
  82768. }
  82769. /** Class used to store color 3 gradient */
  82770. export class Color3Gradient implements IValueGradient {
  82771. /**
  82772. * Gets or sets the gradient value (between 0 and 1)
  82773. */
  82774. gradient: number;
  82775. /**
  82776. * Gets or sets the associated color
  82777. */
  82778. color: Color3;
  82779. }
  82780. /** Class used to store factor gradient */
  82781. export class FactorGradient implements IValueGradient {
  82782. /**
  82783. * Gets or sets the gradient value (between 0 and 1)
  82784. */
  82785. gradient: number;
  82786. /**
  82787. * Gets or sets first associated factor
  82788. */
  82789. factor1: number;
  82790. /**
  82791. * Gets or sets second associated factor
  82792. */
  82793. factor2?: number;
  82794. /**
  82795. * Will get a number picked randomly between factor1 and factor2.
  82796. * If factor2 is undefined then factor1 will be used
  82797. * @returns the picked number
  82798. */
  82799. getFactor(): number;
  82800. }
  82801. /**
  82802. * Helper used to simplify some generic gradient tasks
  82803. */
  82804. export class GradientHelper {
  82805. /**
  82806. * Gets the current gradient from an array of IValueGradient
  82807. * @param ratio defines the current ratio to get
  82808. * @param gradients defines the array of IValueGradient
  82809. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82810. */
  82811. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82812. }
  82813. }
  82814. declare module BABYLON {
  82815. interface ThinEngine {
  82816. /**
  82817. * Creates a dynamic texture
  82818. * @param width defines the width of the texture
  82819. * @param height defines the height of the texture
  82820. * @param generateMipMaps defines if the engine should generate the mip levels
  82821. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82822. * @returns the dynamic texture inside an InternalTexture
  82823. */
  82824. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82825. /**
  82826. * Update the content of a dynamic texture
  82827. * @param texture defines the texture to update
  82828. * @param canvas defines the canvas containing the source
  82829. * @param invertY defines if data must be stored with Y axis inverted
  82830. * @param premulAlpha defines if alpha is stored as premultiplied
  82831. * @param format defines the format of the data
  82832. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82833. */
  82834. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82835. }
  82836. }
  82837. declare module BABYLON {
  82838. /**
  82839. * A class extending Texture allowing drawing on a texture
  82840. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82841. */
  82842. export class DynamicTexture extends Texture {
  82843. private _generateMipMaps;
  82844. private _canvas;
  82845. private _context;
  82846. private _engine;
  82847. /**
  82848. * Creates a DynamicTexture
  82849. * @param name defines the name of the texture
  82850. * @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
  82851. * @param scene defines the scene where you want the texture
  82852. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82853. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82854. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82855. */
  82856. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82857. /**
  82858. * Get the current class name of the texture useful for serialization or dynamic coding.
  82859. * @returns "DynamicTexture"
  82860. */
  82861. getClassName(): string;
  82862. /**
  82863. * Gets the current state of canRescale
  82864. */
  82865. readonly canRescale: boolean;
  82866. private _recreate;
  82867. /**
  82868. * Scales the texture
  82869. * @param ratio the scale factor to apply to both width and height
  82870. */
  82871. scale(ratio: number): void;
  82872. /**
  82873. * Resizes the texture
  82874. * @param width the new width
  82875. * @param height the new height
  82876. */
  82877. scaleTo(width: number, height: number): void;
  82878. /**
  82879. * Gets the context of the canvas used by the texture
  82880. * @returns the canvas context of the dynamic texture
  82881. */
  82882. getContext(): CanvasRenderingContext2D;
  82883. /**
  82884. * Clears the texture
  82885. */
  82886. clear(): void;
  82887. /**
  82888. * Updates the texture
  82889. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82890. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82891. */
  82892. update(invertY?: boolean, premulAlpha?: boolean): void;
  82893. /**
  82894. * Draws text onto the texture
  82895. * @param text defines the text to be drawn
  82896. * @param x defines the placement of the text from the left
  82897. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82898. * @param font defines the font to be used with font-style, font-size, font-name
  82899. * @param color defines the color used for the text
  82900. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82901. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82902. * @param update defines whether texture is immediately update (default is true)
  82903. */
  82904. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82905. /**
  82906. * Clones the texture
  82907. * @returns the clone of the texture.
  82908. */
  82909. clone(): DynamicTexture;
  82910. /**
  82911. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82912. * @returns a serialized dynamic texture object
  82913. */
  82914. serialize(): any;
  82915. /** @hidden */
  82916. _rebuild(): void;
  82917. }
  82918. }
  82919. declare module BABYLON {
  82920. interface AbstractScene {
  82921. /**
  82922. * The list of procedural textures added to the scene
  82923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82924. */
  82925. proceduralTextures: Array<ProceduralTexture>;
  82926. }
  82927. /**
  82928. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82929. * in a given scene.
  82930. */
  82931. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82932. /**
  82933. * The component name helpfull to identify the component in the list of scene components.
  82934. */
  82935. readonly name: string;
  82936. /**
  82937. * The scene the component belongs to.
  82938. */
  82939. scene: Scene;
  82940. /**
  82941. * Creates a new instance of the component for the given scene
  82942. * @param scene Defines the scene to register the component in
  82943. */
  82944. constructor(scene: Scene);
  82945. /**
  82946. * Registers the component in a given scene
  82947. */
  82948. register(): void;
  82949. /**
  82950. * Rebuilds the elements related to this component in case of
  82951. * context lost for instance.
  82952. */
  82953. rebuild(): void;
  82954. /**
  82955. * Disposes the component and the associated ressources.
  82956. */
  82957. dispose(): void;
  82958. private _beforeClear;
  82959. }
  82960. }
  82961. declare module BABYLON {
  82962. interface ThinEngine {
  82963. /**
  82964. * Creates a new render target cube texture
  82965. * @param size defines the size of the texture
  82966. * @param options defines the options used to create the texture
  82967. * @returns a new render target cube texture stored in an InternalTexture
  82968. */
  82969. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82970. }
  82971. }
  82972. declare module BABYLON {
  82973. /** @hidden */
  82974. export var proceduralVertexShader: {
  82975. name: string;
  82976. shader: string;
  82977. };
  82978. }
  82979. declare module BABYLON {
  82980. /**
  82981. * 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.
  82982. * This is the base class of any Procedural texture and contains most of the shareable code.
  82983. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82984. */
  82985. export class ProceduralTexture extends Texture {
  82986. isCube: boolean;
  82987. /**
  82988. * Define if the texture is enabled or not (disabled texture will not render)
  82989. */
  82990. isEnabled: boolean;
  82991. /**
  82992. * Define if the texture must be cleared before rendering (default is true)
  82993. */
  82994. autoClear: boolean;
  82995. /**
  82996. * Callback called when the texture is generated
  82997. */
  82998. onGenerated: () => void;
  82999. /**
  83000. * Event raised when the texture is generated
  83001. */
  83002. onGeneratedObservable: Observable<ProceduralTexture>;
  83003. /** @hidden */
  83004. _generateMipMaps: boolean;
  83005. /** @hidden **/
  83006. _effect: Effect;
  83007. /** @hidden */
  83008. _textures: {
  83009. [key: string]: Texture;
  83010. };
  83011. private _size;
  83012. private _currentRefreshId;
  83013. private _refreshRate;
  83014. private _vertexBuffers;
  83015. private _indexBuffer;
  83016. private _uniforms;
  83017. private _samplers;
  83018. private _fragment;
  83019. private _floats;
  83020. private _ints;
  83021. private _floatsArrays;
  83022. private _colors3;
  83023. private _colors4;
  83024. private _vectors2;
  83025. private _vectors3;
  83026. private _matrices;
  83027. private _fallbackTexture;
  83028. private _fallbackTextureUsed;
  83029. private _engine;
  83030. private _cachedDefines;
  83031. private _contentUpdateId;
  83032. private _contentData;
  83033. /**
  83034. * Instantiates a new procedural texture.
  83035. * 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.
  83036. * This is the base class of any Procedural texture and contains most of the shareable code.
  83037. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83038. * @param name Define the name of the texture
  83039. * @param size Define the size of the texture to create
  83040. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83041. * @param scene Define the scene the texture belongs to
  83042. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83043. * @param generateMipMaps Define if the texture should creates mip maps or not
  83044. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83045. */
  83046. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83047. /**
  83048. * The effect that is created when initializing the post process.
  83049. * @returns The created effect corresponding the the postprocess.
  83050. */
  83051. getEffect(): Effect;
  83052. /**
  83053. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83054. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83055. */
  83056. getContent(): Nullable<ArrayBufferView>;
  83057. private _createIndexBuffer;
  83058. /** @hidden */
  83059. _rebuild(): void;
  83060. /**
  83061. * Resets the texture in order to recreate its associated resources.
  83062. * This can be called in case of context loss
  83063. */
  83064. reset(): void;
  83065. protected _getDefines(): string;
  83066. /**
  83067. * Is the texture ready to be used ? (rendered at least once)
  83068. * @returns true if ready, otherwise, false.
  83069. */
  83070. isReady(): boolean;
  83071. /**
  83072. * Resets the refresh counter of the texture and start bak from scratch.
  83073. * Could be useful to regenerate the texture if it is setup to render only once.
  83074. */
  83075. resetRefreshCounter(): void;
  83076. /**
  83077. * Set the fragment shader to use in order to render the texture.
  83078. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83079. */
  83080. setFragment(fragment: any): void;
  83081. /**
  83082. * Define the refresh rate of the texture or the rendering frequency.
  83083. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83084. */
  83085. refreshRate: number;
  83086. /** @hidden */
  83087. _shouldRender(): boolean;
  83088. /**
  83089. * Get the size the texture is rendering at.
  83090. * @returns the size (texture is always squared)
  83091. */
  83092. getRenderSize(): number;
  83093. /**
  83094. * Resize the texture to new value.
  83095. * @param size Define the new size the texture should have
  83096. * @param generateMipMaps Define whether the new texture should create mip maps
  83097. */
  83098. resize(size: number, generateMipMaps: boolean): void;
  83099. private _checkUniform;
  83100. /**
  83101. * Set a texture in the shader program used to render.
  83102. * @param name Define the name of the uniform samplers as defined in the shader
  83103. * @param texture Define the texture to bind to this sampler
  83104. * @return the texture itself allowing "fluent" like uniform updates
  83105. */
  83106. setTexture(name: string, texture: Texture): ProceduralTexture;
  83107. /**
  83108. * Set a float in the shader.
  83109. * @param name Define the name of the uniform as defined in the shader
  83110. * @param value Define the value to give to the uniform
  83111. * @return the texture itself allowing "fluent" like uniform updates
  83112. */
  83113. setFloat(name: string, value: number): ProceduralTexture;
  83114. /**
  83115. * Set a int in the shader.
  83116. * @param name Define the name of the uniform as defined in the shader
  83117. * @param value Define the value to give to the uniform
  83118. * @return the texture itself allowing "fluent" like uniform updates
  83119. */
  83120. setInt(name: string, value: number): ProceduralTexture;
  83121. /**
  83122. * Set an array of floats in the shader.
  83123. * @param name Define the name of the uniform as defined in the shader
  83124. * @param value Define the value to give to the uniform
  83125. * @return the texture itself allowing "fluent" like uniform updates
  83126. */
  83127. setFloats(name: string, value: number[]): ProceduralTexture;
  83128. /**
  83129. * Set a vec3 in the shader from a Color3.
  83130. * @param name Define the name of the uniform as defined in the shader
  83131. * @param value Define the value to give to the uniform
  83132. * @return the texture itself allowing "fluent" like uniform updates
  83133. */
  83134. setColor3(name: string, value: Color3): ProceduralTexture;
  83135. /**
  83136. * Set a vec4 in the shader from a Color4.
  83137. * @param name Define the name of the uniform as defined in the shader
  83138. * @param value Define the value to give to the uniform
  83139. * @return the texture itself allowing "fluent" like uniform updates
  83140. */
  83141. setColor4(name: string, value: Color4): ProceduralTexture;
  83142. /**
  83143. * Set a vec2 in the shader from a Vector2.
  83144. * @param name Define the name of the uniform as defined in the shader
  83145. * @param value Define the value to give to the uniform
  83146. * @return the texture itself allowing "fluent" like uniform updates
  83147. */
  83148. setVector2(name: string, value: Vector2): ProceduralTexture;
  83149. /**
  83150. * Set a vec3 in the shader from a Vector3.
  83151. * @param name Define the name of the uniform as defined in the shader
  83152. * @param value Define the value to give to the uniform
  83153. * @return the texture itself allowing "fluent" like uniform updates
  83154. */
  83155. setVector3(name: string, value: Vector3): ProceduralTexture;
  83156. /**
  83157. * Set a mat4 in the shader from a MAtrix.
  83158. * @param name Define the name of the uniform as defined in the shader
  83159. * @param value Define the value to give to the uniform
  83160. * @return the texture itself allowing "fluent" like uniform updates
  83161. */
  83162. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83163. /**
  83164. * Render the texture to its associated render target.
  83165. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83166. */
  83167. render(useCameraPostProcess?: boolean): void;
  83168. /**
  83169. * Clone the texture.
  83170. * @returns the cloned texture
  83171. */
  83172. clone(): ProceduralTexture;
  83173. /**
  83174. * Dispose the texture and release its asoociated resources.
  83175. */
  83176. dispose(): void;
  83177. }
  83178. }
  83179. declare module BABYLON {
  83180. /**
  83181. * This represents the base class for particle system in Babylon.
  83182. * 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.
  83183. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83184. * @example https://doc.babylonjs.com/babylon101/particles
  83185. */
  83186. export class BaseParticleSystem {
  83187. /**
  83188. * Source color is added to the destination color without alpha affecting the result
  83189. */
  83190. static BLENDMODE_ONEONE: number;
  83191. /**
  83192. * Blend current color and particle color using particle’s alpha
  83193. */
  83194. static BLENDMODE_STANDARD: number;
  83195. /**
  83196. * Add current color and particle color multiplied by particle’s alpha
  83197. */
  83198. static BLENDMODE_ADD: number;
  83199. /**
  83200. * Multiply current color with particle color
  83201. */
  83202. static BLENDMODE_MULTIPLY: number;
  83203. /**
  83204. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83205. */
  83206. static BLENDMODE_MULTIPLYADD: number;
  83207. /**
  83208. * List of animations used by the particle system.
  83209. */
  83210. animations: Animation[];
  83211. /**
  83212. * The id of the Particle system.
  83213. */
  83214. id: string;
  83215. /**
  83216. * The friendly name of the Particle system.
  83217. */
  83218. name: string;
  83219. /**
  83220. * The rendering group used by the Particle system to chose when to render.
  83221. */
  83222. renderingGroupId: number;
  83223. /**
  83224. * The emitter represents the Mesh or position we are attaching the particle system to.
  83225. */
  83226. emitter: Nullable<AbstractMesh | Vector3>;
  83227. /**
  83228. * The maximum number of particles to emit per frame
  83229. */
  83230. emitRate: number;
  83231. /**
  83232. * If you want to launch only a few particles at once, that can be done, as well.
  83233. */
  83234. manualEmitCount: number;
  83235. /**
  83236. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83237. */
  83238. updateSpeed: number;
  83239. /**
  83240. * The amount of time the particle system is running (depends of the overall update speed).
  83241. */
  83242. targetStopDuration: number;
  83243. /**
  83244. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83245. */
  83246. disposeOnStop: boolean;
  83247. /**
  83248. * Minimum power of emitting particles.
  83249. */
  83250. minEmitPower: number;
  83251. /**
  83252. * Maximum power of emitting particles.
  83253. */
  83254. maxEmitPower: number;
  83255. /**
  83256. * Minimum life time of emitting particles.
  83257. */
  83258. minLifeTime: number;
  83259. /**
  83260. * Maximum life time of emitting particles.
  83261. */
  83262. maxLifeTime: number;
  83263. /**
  83264. * Minimum Size of emitting particles.
  83265. */
  83266. minSize: number;
  83267. /**
  83268. * Maximum Size of emitting particles.
  83269. */
  83270. maxSize: number;
  83271. /**
  83272. * Minimum scale of emitting particles on X axis.
  83273. */
  83274. minScaleX: number;
  83275. /**
  83276. * Maximum scale of emitting particles on X axis.
  83277. */
  83278. maxScaleX: number;
  83279. /**
  83280. * Minimum scale of emitting particles on Y axis.
  83281. */
  83282. minScaleY: number;
  83283. /**
  83284. * Maximum scale of emitting particles on Y axis.
  83285. */
  83286. maxScaleY: number;
  83287. /**
  83288. * Gets or sets the minimal initial rotation in radians.
  83289. */
  83290. minInitialRotation: number;
  83291. /**
  83292. * Gets or sets the maximal initial rotation in radians.
  83293. */
  83294. maxInitialRotation: number;
  83295. /**
  83296. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83297. */
  83298. minAngularSpeed: number;
  83299. /**
  83300. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83301. */
  83302. maxAngularSpeed: number;
  83303. /**
  83304. * The texture used to render each particle. (this can be a spritesheet)
  83305. */
  83306. particleTexture: Nullable<Texture>;
  83307. /**
  83308. * The layer mask we are rendering the particles through.
  83309. */
  83310. layerMask: number;
  83311. /**
  83312. * This can help using your own shader to render the particle system.
  83313. * The according effect will be created
  83314. */
  83315. customShader: any;
  83316. /**
  83317. * By default particle system starts as soon as they are created. This prevents the
  83318. * automatic start to happen and let you decide when to start emitting particles.
  83319. */
  83320. preventAutoStart: boolean;
  83321. private _noiseTexture;
  83322. /**
  83323. * Gets or sets a texture used to add random noise to particle positions
  83324. */
  83325. noiseTexture: Nullable<ProceduralTexture>;
  83326. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83327. noiseStrength: Vector3;
  83328. /**
  83329. * Callback triggered when the particle animation is ending.
  83330. */
  83331. onAnimationEnd: Nullable<() => void>;
  83332. /**
  83333. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83334. */
  83335. blendMode: number;
  83336. /**
  83337. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83338. * to override the particles.
  83339. */
  83340. forceDepthWrite: boolean;
  83341. /** 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 */
  83342. preWarmCycles: number;
  83343. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83344. preWarmStepOffset: number;
  83345. /**
  83346. * 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)
  83347. */
  83348. spriteCellChangeSpeed: number;
  83349. /**
  83350. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83351. */
  83352. startSpriteCellID: number;
  83353. /**
  83354. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83355. */
  83356. endSpriteCellID: number;
  83357. /**
  83358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83359. */
  83360. spriteCellWidth: number;
  83361. /**
  83362. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83363. */
  83364. spriteCellHeight: number;
  83365. /**
  83366. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83367. */
  83368. spriteRandomStartCell: boolean;
  83369. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83370. translationPivot: Vector2;
  83371. /** @hidden */
  83372. protected _isAnimationSheetEnabled: boolean;
  83373. /**
  83374. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83375. */
  83376. beginAnimationOnStart: boolean;
  83377. /**
  83378. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83379. */
  83380. beginAnimationFrom: number;
  83381. /**
  83382. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83383. */
  83384. beginAnimationTo: number;
  83385. /**
  83386. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83387. */
  83388. beginAnimationLoop: boolean;
  83389. /**
  83390. * Gets or sets a world offset applied to all particles
  83391. */
  83392. worldOffset: Vector3;
  83393. /**
  83394. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83395. */
  83396. isAnimationSheetEnabled: boolean;
  83397. /**
  83398. * Get hosting scene
  83399. * @returns the scene
  83400. */
  83401. getScene(): Scene;
  83402. /**
  83403. * You can use gravity if you want to give an orientation to your particles.
  83404. */
  83405. gravity: Vector3;
  83406. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83407. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83408. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83409. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83410. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83411. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83412. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83413. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83414. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83415. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83416. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83417. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83418. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83419. /**
  83420. * Defines the delay in milliseconds before starting the system (0 by default)
  83421. */
  83422. startDelay: number;
  83423. /**
  83424. * Gets the current list of drag gradients.
  83425. * You must use addDragGradient and removeDragGradient to udpate this list
  83426. * @returns the list of drag gradients
  83427. */
  83428. getDragGradients(): Nullable<Array<FactorGradient>>;
  83429. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83430. limitVelocityDamping: number;
  83431. /**
  83432. * Gets the current list of limit velocity gradients.
  83433. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83434. * @returns the list of limit velocity gradients
  83435. */
  83436. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83437. /**
  83438. * Gets the current list of color gradients.
  83439. * You must use addColorGradient and removeColorGradient to udpate this list
  83440. * @returns the list of color gradients
  83441. */
  83442. getColorGradients(): Nullable<Array<ColorGradient>>;
  83443. /**
  83444. * Gets the current list of size gradients.
  83445. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83446. * @returns the list of size gradients
  83447. */
  83448. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83449. /**
  83450. * Gets the current list of color remap gradients.
  83451. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83452. * @returns the list of color remap gradients
  83453. */
  83454. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83455. /**
  83456. * Gets the current list of alpha remap gradients.
  83457. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83458. * @returns the list of alpha remap gradients
  83459. */
  83460. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83461. /**
  83462. * Gets the current list of life time gradients.
  83463. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83464. * @returns the list of life time gradients
  83465. */
  83466. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83467. /**
  83468. * Gets the current list of angular speed gradients.
  83469. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83470. * @returns the list of angular speed gradients
  83471. */
  83472. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83473. /**
  83474. * Gets the current list of velocity gradients.
  83475. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83476. * @returns the list of velocity gradients
  83477. */
  83478. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83479. /**
  83480. * Gets the current list of start size gradients.
  83481. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83482. * @returns the list of start size gradients
  83483. */
  83484. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83485. /**
  83486. * Gets the current list of emit rate gradients.
  83487. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83488. * @returns the list of emit rate gradients
  83489. */
  83490. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83491. /**
  83492. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83493. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83494. */
  83495. direction1: Vector3;
  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. direction2: Vector3;
  83501. /**
  83502. * 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.
  83503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83504. */
  83505. minEmitBox: Vector3;
  83506. /**
  83507. * 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.
  83508. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83509. */
  83510. maxEmitBox: Vector3;
  83511. /**
  83512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83513. */
  83514. color1: Color4;
  83515. /**
  83516. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83517. */
  83518. color2: Color4;
  83519. /**
  83520. * Color the particle will have at the end of its lifetime
  83521. */
  83522. colorDead: Color4;
  83523. /**
  83524. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83525. */
  83526. textureMask: Color4;
  83527. /**
  83528. * The particle emitter type defines the emitter used by the particle system.
  83529. * It can be for example box, sphere, or cone...
  83530. */
  83531. particleEmitterType: IParticleEmitterType;
  83532. /** @hidden */
  83533. _isSubEmitter: boolean;
  83534. /**
  83535. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83536. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83537. */
  83538. billboardMode: number;
  83539. protected _isBillboardBased: boolean;
  83540. /**
  83541. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83542. */
  83543. isBillboardBased: boolean;
  83544. /**
  83545. * The scene the particle system belongs to.
  83546. */
  83547. protected _scene: Scene;
  83548. /**
  83549. * Local cache of defines for image processing.
  83550. */
  83551. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83552. /**
  83553. * Default configuration related to image processing available in the standard Material.
  83554. */
  83555. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83556. /**
  83557. * Gets the image processing configuration used either in this material.
  83558. */
  83559. /**
  83560. * Sets the Default image processing configuration used either in the this material.
  83561. *
  83562. * If sets to null, the scene one is in use.
  83563. */
  83564. imageProcessingConfiguration: ImageProcessingConfiguration;
  83565. /**
  83566. * Attaches a new image processing configuration to the Standard Material.
  83567. * @param configuration
  83568. */
  83569. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83570. /** @hidden */
  83571. protected _reset(): void;
  83572. /** @hidden */
  83573. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83574. /**
  83575. * Instantiates a particle system.
  83576. * 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.
  83577. * @param name The name of the particle system
  83578. */
  83579. constructor(name: string);
  83580. /**
  83581. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83584. * @returns the emitter
  83585. */
  83586. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83587. /**
  83588. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83589. * @param radius The radius of the hemisphere to emit from
  83590. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83591. * @returns the emitter
  83592. */
  83593. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83594. /**
  83595. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83596. * @param radius The radius of the sphere to emit from
  83597. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83598. * @returns the emitter
  83599. */
  83600. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83601. /**
  83602. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83603. * @param radius The radius of the sphere to emit from
  83604. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83605. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83606. * @returns the emitter
  83607. */
  83608. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83609. /**
  83610. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83611. * @param radius The radius of the emission cylinder
  83612. * @param height The height of the emission cylinder
  83613. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83614. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83615. * @returns the emitter
  83616. */
  83617. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83618. /**
  83619. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83620. * @param radius The radius of the cylinder to emit from
  83621. * @param height The height of the emission cylinder
  83622. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83625. * @returns the emitter
  83626. */
  83627. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83628. /**
  83629. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83630. * @param radius The radius of the cone to emit from
  83631. * @param angle The base angle of the cone
  83632. * @returns the emitter
  83633. */
  83634. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83635. /**
  83636. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83637. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83638. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83639. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83640. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83641. * @returns the emitter
  83642. */
  83643. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83644. }
  83645. }
  83646. declare module BABYLON {
  83647. /**
  83648. * Type of sub emitter
  83649. */
  83650. export enum SubEmitterType {
  83651. /**
  83652. * Attached to the particle over it's lifetime
  83653. */
  83654. ATTACHED = 0,
  83655. /**
  83656. * Created when the particle dies
  83657. */
  83658. END = 1
  83659. }
  83660. /**
  83661. * Sub emitter class used to emit particles from an existing particle
  83662. */
  83663. export class SubEmitter {
  83664. /**
  83665. * the particle system to be used by the sub emitter
  83666. */
  83667. particleSystem: ParticleSystem;
  83668. /**
  83669. * Type of the submitter (Default: END)
  83670. */
  83671. type: SubEmitterType;
  83672. /**
  83673. * 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)
  83674. * Note: This only is supported when using an emitter of type Mesh
  83675. */
  83676. inheritDirection: boolean;
  83677. /**
  83678. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83679. */
  83680. inheritedVelocityAmount: number;
  83681. /**
  83682. * Creates a sub emitter
  83683. * @param particleSystem the particle system to be used by the sub emitter
  83684. */
  83685. constructor(
  83686. /**
  83687. * the particle system to be used by the sub emitter
  83688. */
  83689. particleSystem: ParticleSystem);
  83690. /**
  83691. * Clones the sub emitter
  83692. * @returns the cloned sub emitter
  83693. */
  83694. clone(): SubEmitter;
  83695. /**
  83696. * Serialize current object to a JSON object
  83697. * @returns the serialized object
  83698. */
  83699. serialize(): any;
  83700. /** @hidden */
  83701. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83702. /**
  83703. * Creates a new SubEmitter from a serialized JSON version
  83704. * @param serializationObject defines the JSON object to read from
  83705. * @param scene defines the hosting scene
  83706. * @param rootUrl defines the rootUrl for data loading
  83707. * @returns a new SubEmitter
  83708. */
  83709. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83710. /** Release associated resources */
  83711. dispose(): void;
  83712. }
  83713. }
  83714. declare module BABYLON {
  83715. /** @hidden */
  83716. export var clipPlaneFragmentDeclaration: {
  83717. name: string;
  83718. shader: string;
  83719. };
  83720. }
  83721. declare module BABYLON {
  83722. /** @hidden */
  83723. export var imageProcessingDeclaration: {
  83724. name: string;
  83725. shader: string;
  83726. };
  83727. }
  83728. declare module BABYLON {
  83729. /** @hidden */
  83730. export var imageProcessingFunctions: {
  83731. name: string;
  83732. shader: string;
  83733. };
  83734. }
  83735. declare module BABYLON {
  83736. /** @hidden */
  83737. export var clipPlaneFragment: {
  83738. name: string;
  83739. shader: string;
  83740. };
  83741. }
  83742. declare module BABYLON {
  83743. /** @hidden */
  83744. export var particlesPixelShader: {
  83745. name: string;
  83746. shader: string;
  83747. };
  83748. }
  83749. declare module BABYLON {
  83750. /** @hidden */
  83751. export var clipPlaneVertexDeclaration: {
  83752. name: string;
  83753. shader: string;
  83754. };
  83755. }
  83756. declare module BABYLON {
  83757. /** @hidden */
  83758. export var clipPlaneVertex: {
  83759. name: string;
  83760. shader: string;
  83761. };
  83762. }
  83763. declare module BABYLON {
  83764. /** @hidden */
  83765. export var particlesVertexShader: {
  83766. name: string;
  83767. shader: string;
  83768. };
  83769. }
  83770. declare module BABYLON {
  83771. /**
  83772. * This represents a particle system in Babylon.
  83773. * 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.
  83774. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83775. * @example https://doc.babylonjs.com/babylon101/particles
  83776. */
  83777. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83778. /**
  83779. * Billboard mode will only apply to Y axis
  83780. */
  83781. static readonly BILLBOARDMODE_Y: number;
  83782. /**
  83783. * Billboard mode will apply to all axes
  83784. */
  83785. static readonly BILLBOARDMODE_ALL: number;
  83786. /**
  83787. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83788. */
  83789. static readonly BILLBOARDMODE_STRETCHED: number;
  83790. /**
  83791. * This function can be defined to provide custom update for active particles.
  83792. * This function will be called instead of regular update (age, position, color, etc.).
  83793. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83794. */
  83795. updateFunction: (particles: Particle[]) => void;
  83796. private _emitterWorldMatrix;
  83797. /**
  83798. * This function can be defined to specify initial direction for every new particle.
  83799. * It by default use the emitterType defined function
  83800. */
  83801. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83802. /**
  83803. * This function can be defined to specify initial position for every new particle.
  83804. * It by default use the emitterType defined function
  83805. */
  83806. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83807. /**
  83808. * @hidden
  83809. */
  83810. _inheritedVelocityOffset: Vector3;
  83811. /**
  83812. * An event triggered when the system is disposed
  83813. */
  83814. onDisposeObservable: Observable<ParticleSystem>;
  83815. private _onDisposeObserver;
  83816. /**
  83817. * Sets a callback that will be triggered when the system is disposed
  83818. */
  83819. onDispose: () => void;
  83820. private _particles;
  83821. private _epsilon;
  83822. private _capacity;
  83823. private _stockParticles;
  83824. private _newPartsExcess;
  83825. private _vertexData;
  83826. private _vertexBuffer;
  83827. private _vertexBuffers;
  83828. private _spriteBuffer;
  83829. private _indexBuffer;
  83830. private _effect;
  83831. private _customEffect;
  83832. private _cachedDefines;
  83833. private _scaledColorStep;
  83834. private _colorDiff;
  83835. private _scaledDirection;
  83836. private _scaledGravity;
  83837. private _currentRenderId;
  83838. private _alive;
  83839. private _useInstancing;
  83840. private _started;
  83841. private _stopped;
  83842. private _actualFrame;
  83843. private _scaledUpdateSpeed;
  83844. private _vertexBufferSize;
  83845. /** @hidden */
  83846. _currentEmitRateGradient: Nullable<FactorGradient>;
  83847. /** @hidden */
  83848. _currentEmitRate1: number;
  83849. /** @hidden */
  83850. _currentEmitRate2: number;
  83851. /** @hidden */
  83852. _currentStartSizeGradient: Nullable<FactorGradient>;
  83853. /** @hidden */
  83854. _currentStartSize1: number;
  83855. /** @hidden */
  83856. _currentStartSize2: number;
  83857. private readonly _rawTextureWidth;
  83858. private _rampGradientsTexture;
  83859. private _useRampGradients;
  83860. /** Gets or sets a boolean indicating that ramp gradients must be used
  83861. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83862. */
  83863. useRampGradients: boolean;
  83864. /**
  83865. * 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.
  83866. * 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: [])
  83867. */
  83868. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83869. private _subEmitters;
  83870. /**
  83871. * @hidden
  83872. * If the particle systems emitter should be disposed when the particle system is disposed
  83873. */
  83874. _disposeEmitterOnDispose: boolean;
  83875. /**
  83876. * The current active Sub-systems, this property is used by the root particle system only.
  83877. */
  83878. activeSubSystems: Array<ParticleSystem>;
  83879. private _rootParticleSystem;
  83880. /**
  83881. * Gets the current list of active particles
  83882. */
  83883. readonly particles: Particle[];
  83884. /**
  83885. * Returns the string "ParticleSystem"
  83886. * @returns a string containing the class name
  83887. */
  83888. getClassName(): string;
  83889. /**
  83890. * Instantiates a particle system.
  83891. * 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.
  83892. * @param name The name of the particle system
  83893. * @param capacity The max number of particles alive at the same time
  83894. * @param scene The scene the particle system belongs to
  83895. * @param customEffect a custom effect used to change the way particles are rendered by default
  83896. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83897. * @param epsilon Offset used to render the particles
  83898. */
  83899. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83900. private _addFactorGradient;
  83901. private _removeFactorGradient;
  83902. /**
  83903. * Adds a new life time gradient
  83904. * @param gradient defines the gradient to use (between 0 and 1)
  83905. * @param factor defines the life time factor to affect to the specified gradient
  83906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83907. * @returns the current particle system
  83908. */
  83909. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83910. /**
  83911. * Remove a specific life time gradient
  83912. * @param gradient defines the gradient to remove
  83913. * @returns the current particle system
  83914. */
  83915. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83916. /**
  83917. * Adds a new size gradient
  83918. * @param gradient defines the gradient to use (between 0 and 1)
  83919. * @param factor defines the size factor to affect to the specified gradient
  83920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83921. * @returns the current particle system
  83922. */
  83923. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83924. /**
  83925. * Remove a specific size gradient
  83926. * @param gradient defines the gradient to remove
  83927. * @returns the current particle system
  83928. */
  83929. removeSizeGradient(gradient: number): IParticleSystem;
  83930. /**
  83931. * Adds a new color remap gradient
  83932. * @param gradient defines the gradient to use (between 0 and 1)
  83933. * @param min defines the color remap minimal range
  83934. * @param max defines the color remap maximal range
  83935. * @returns the current particle system
  83936. */
  83937. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83938. /**
  83939. * Remove a specific color remap gradient
  83940. * @param gradient defines the gradient to remove
  83941. * @returns the current particle system
  83942. */
  83943. removeColorRemapGradient(gradient: number): IParticleSystem;
  83944. /**
  83945. * Adds a new alpha remap gradient
  83946. * @param gradient defines the gradient to use (between 0 and 1)
  83947. * @param min defines the alpha remap minimal range
  83948. * @param max defines the alpha remap maximal range
  83949. * @returns the current particle system
  83950. */
  83951. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83952. /**
  83953. * Remove a specific alpha remap gradient
  83954. * @param gradient defines the gradient to remove
  83955. * @returns the current particle system
  83956. */
  83957. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83958. /**
  83959. * Adds a new angular speed gradient
  83960. * @param gradient defines the gradient to use (between 0 and 1)
  83961. * @param factor defines the angular speed to affect to the specified gradient
  83962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83963. * @returns the current particle system
  83964. */
  83965. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83966. /**
  83967. * Remove a specific angular speed gradient
  83968. * @param gradient defines the gradient to remove
  83969. * @returns the current particle system
  83970. */
  83971. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83972. /**
  83973. * Adds a new velocity gradient
  83974. * @param gradient defines the gradient to use (between 0 and 1)
  83975. * @param factor defines the velocity to affect to the specified gradient
  83976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83977. * @returns the current particle system
  83978. */
  83979. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83980. /**
  83981. * Remove a specific velocity gradient
  83982. * @param gradient defines the gradient to remove
  83983. * @returns the current particle system
  83984. */
  83985. removeVelocityGradient(gradient: number): IParticleSystem;
  83986. /**
  83987. * Adds a new limit velocity gradient
  83988. * @param gradient defines the gradient to use (between 0 and 1)
  83989. * @param factor defines the limit velocity value to affect to the specified gradient
  83990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83991. * @returns the current particle system
  83992. */
  83993. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83994. /**
  83995. * Remove a specific limit velocity gradient
  83996. * @param gradient defines the gradient to remove
  83997. * @returns the current particle system
  83998. */
  83999. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84000. /**
  84001. * Adds a new drag gradient
  84002. * @param gradient defines the gradient to use (between 0 and 1)
  84003. * @param factor defines the drag value to affect to the specified gradient
  84004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84005. * @returns the current particle system
  84006. */
  84007. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84008. /**
  84009. * Remove a specific drag gradient
  84010. * @param gradient defines the gradient to remove
  84011. * @returns the current particle system
  84012. */
  84013. removeDragGradient(gradient: number): IParticleSystem;
  84014. /**
  84015. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84016. * @param gradient defines the gradient to use (between 0 and 1)
  84017. * @param factor defines the emit rate value to affect to the specified gradient
  84018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84019. * @returns the current particle system
  84020. */
  84021. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84022. /**
  84023. * Remove a specific emit rate gradient
  84024. * @param gradient defines the gradient to remove
  84025. * @returns the current particle system
  84026. */
  84027. removeEmitRateGradient(gradient: number): IParticleSystem;
  84028. /**
  84029. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84030. * @param gradient defines the gradient to use (between 0 and 1)
  84031. * @param factor defines the start size value to affect to the specified gradient
  84032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84033. * @returns the current particle system
  84034. */
  84035. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84036. /**
  84037. * Remove a specific start size gradient
  84038. * @param gradient defines the gradient to remove
  84039. * @returns the current particle system
  84040. */
  84041. removeStartSizeGradient(gradient: number): IParticleSystem;
  84042. private _createRampGradientTexture;
  84043. /**
  84044. * Gets the current list of ramp gradients.
  84045. * You must use addRampGradient and removeRampGradient to udpate this list
  84046. * @returns the list of ramp gradients
  84047. */
  84048. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84049. /**
  84050. * Adds a new ramp gradient used to remap particle colors
  84051. * @param gradient defines the gradient to use (between 0 and 1)
  84052. * @param color defines the color to affect to the specified gradient
  84053. * @returns the current particle system
  84054. */
  84055. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84056. /**
  84057. * Remove a specific ramp gradient
  84058. * @param gradient defines the gradient to remove
  84059. * @returns the current particle system
  84060. */
  84061. removeRampGradient(gradient: number): ParticleSystem;
  84062. /**
  84063. * Adds a new color gradient
  84064. * @param gradient defines the gradient to use (between 0 and 1)
  84065. * @param color1 defines the color to affect to the specified gradient
  84066. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84067. * @returns this particle system
  84068. */
  84069. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84070. /**
  84071. * Remove a specific color gradient
  84072. * @param gradient defines the gradient to remove
  84073. * @returns this particle system
  84074. */
  84075. removeColorGradient(gradient: number): IParticleSystem;
  84076. private _fetchR;
  84077. protected _reset(): void;
  84078. private _resetEffect;
  84079. private _createVertexBuffers;
  84080. private _createIndexBuffer;
  84081. /**
  84082. * Gets the maximum number of particles active at the same time.
  84083. * @returns The max number of active particles.
  84084. */
  84085. getCapacity(): number;
  84086. /**
  84087. * Gets whether there are still active particles in the system.
  84088. * @returns True if it is alive, otherwise false.
  84089. */
  84090. isAlive(): boolean;
  84091. /**
  84092. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84093. * @returns True if it has been started, otherwise false.
  84094. */
  84095. isStarted(): boolean;
  84096. private _prepareSubEmitterInternalArray;
  84097. /**
  84098. * Starts the particle system and begins to emit
  84099. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84100. */
  84101. start(delay?: number): void;
  84102. /**
  84103. * Stops the particle system.
  84104. * @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.
  84105. */
  84106. stop(stopSubEmitters?: boolean): void;
  84107. /**
  84108. * Remove all active particles
  84109. */
  84110. reset(): void;
  84111. /**
  84112. * @hidden (for internal use only)
  84113. */
  84114. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84115. /**
  84116. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84117. * Its lifetime will start back at 0.
  84118. */
  84119. recycleParticle: (particle: Particle) => void;
  84120. private _stopSubEmitters;
  84121. private _createParticle;
  84122. private _removeFromRoot;
  84123. private _emitFromParticle;
  84124. private _update;
  84125. /** @hidden */
  84126. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84127. /** @hidden */
  84128. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84129. /** @hidden */
  84130. private _getEffect;
  84131. /**
  84132. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84133. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84134. */
  84135. animate(preWarmOnly?: boolean): void;
  84136. private _appendParticleVertices;
  84137. /**
  84138. * Rebuilds the particle system.
  84139. */
  84140. rebuild(): void;
  84141. /**
  84142. * Is this system ready to be used/rendered
  84143. * @return true if the system is ready
  84144. */
  84145. isReady(): boolean;
  84146. private _render;
  84147. /**
  84148. * Renders the particle system in its current state.
  84149. * @returns the current number of particles
  84150. */
  84151. render(): number;
  84152. /**
  84153. * Disposes the particle system and free the associated resources
  84154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84155. */
  84156. dispose(disposeTexture?: boolean): void;
  84157. /**
  84158. * Clones the particle system.
  84159. * @param name The name of the cloned object
  84160. * @param newEmitter The new emitter to use
  84161. * @returns the cloned particle system
  84162. */
  84163. clone(name: string, newEmitter: any): ParticleSystem;
  84164. /**
  84165. * Serializes the particle system to a JSON object.
  84166. * @returns the JSON object
  84167. */
  84168. serialize(): any;
  84169. /** @hidden */
  84170. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84171. /** @hidden */
  84172. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84173. /**
  84174. * Parses a JSON object to create a particle system.
  84175. * @param parsedParticleSystem The JSON object to parse
  84176. * @param scene The scene to create the particle system in
  84177. * @param rootUrl The root url to use to load external dependencies like texture
  84178. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84179. * @returns the Parsed particle system
  84180. */
  84181. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84182. }
  84183. }
  84184. declare module BABYLON {
  84185. /**
  84186. * A particle represents one of the element emitted by a particle system.
  84187. * This is mainly define by its coordinates, direction, velocity and age.
  84188. */
  84189. export class Particle {
  84190. /**
  84191. * The particle system the particle belongs to.
  84192. */
  84193. particleSystem: ParticleSystem;
  84194. private static _Count;
  84195. /**
  84196. * Unique ID of the particle
  84197. */
  84198. id: number;
  84199. /**
  84200. * The world position of the particle in the scene.
  84201. */
  84202. position: Vector3;
  84203. /**
  84204. * The world direction of the particle in the scene.
  84205. */
  84206. direction: Vector3;
  84207. /**
  84208. * The color of the particle.
  84209. */
  84210. color: Color4;
  84211. /**
  84212. * The color change of the particle per step.
  84213. */
  84214. colorStep: Color4;
  84215. /**
  84216. * Defines how long will the life of the particle be.
  84217. */
  84218. lifeTime: number;
  84219. /**
  84220. * The current age of the particle.
  84221. */
  84222. age: number;
  84223. /**
  84224. * The current size of the particle.
  84225. */
  84226. size: number;
  84227. /**
  84228. * The current scale of the particle.
  84229. */
  84230. scale: Vector2;
  84231. /**
  84232. * The current angle of the particle.
  84233. */
  84234. angle: number;
  84235. /**
  84236. * Defines how fast is the angle changing.
  84237. */
  84238. angularSpeed: number;
  84239. /**
  84240. * Defines the cell index used by the particle to be rendered from a sprite.
  84241. */
  84242. cellIndex: number;
  84243. /**
  84244. * The information required to support color remapping
  84245. */
  84246. remapData: Vector4;
  84247. /** @hidden */
  84248. _randomCellOffset?: number;
  84249. /** @hidden */
  84250. _initialDirection: Nullable<Vector3>;
  84251. /** @hidden */
  84252. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84253. /** @hidden */
  84254. _initialStartSpriteCellID: number;
  84255. /** @hidden */
  84256. _initialEndSpriteCellID: number;
  84257. /** @hidden */
  84258. _currentColorGradient: Nullable<ColorGradient>;
  84259. /** @hidden */
  84260. _currentColor1: Color4;
  84261. /** @hidden */
  84262. _currentColor2: Color4;
  84263. /** @hidden */
  84264. _currentSizeGradient: Nullable<FactorGradient>;
  84265. /** @hidden */
  84266. _currentSize1: number;
  84267. /** @hidden */
  84268. _currentSize2: number;
  84269. /** @hidden */
  84270. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84271. /** @hidden */
  84272. _currentAngularSpeed1: number;
  84273. /** @hidden */
  84274. _currentAngularSpeed2: number;
  84275. /** @hidden */
  84276. _currentVelocityGradient: Nullable<FactorGradient>;
  84277. /** @hidden */
  84278. _currentVelocity1: number;
  84279. /** @hidden */
  84280. _currentVelocity2: number;
  84281. /** @hidden */
  84282. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84283. /** @hidden */
  84284. _currentLimitVelocity1: number;
  84285. /** @hidden */
  84286. _currentLimitVelocity2: number;
  84287. /** @hidden */
  84288. _currentDragGradient: Nullable<FactorGradient>;
  84289. /** @hidden */
  84290. _currentDrag1: number;
  84291. /** @hidden */
  84292. _currentDrag2: number;
  84293. /** @hidden */
  84294. _randomNoiseCoordinates1: Vector3;
  84295. /** @hidden */
  84296. _randomNoiseCoordinates2: Vector3;
  84297. /**
  84298. * Creates a new instance Particle
  84299. * @param particleSystem the particle system the particle belongs to
  84300. */
  84301. constructor(
  84302. /**
  84303. * The particle system the particle belongs to.
  84304. */
  84305. particleSystem: ParticleSystem);
  84306. private updateCellInfoFromSystem;
  84307. /**
  84308. * Defines how the sprite cell index is updated for the particle
  84309. */
  84310. updateCellIndex(): void;
  84311. /** @hidden */
  84312. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84313. /** @hidden */
  84314. _inheritParticleInfoToSubEmitters(): void;
  84315. /** @hidden */
  84316. _reset(): void;
  84317. /**
  84318. * Copy the properties of particle to another one.
  84319. * @param other the particle to copy the information to.
  84320. */
  84321. copyTo(other: Particle): void;
  84322. }
  84323. }
  84324. declare module BABYLON {
  84325. /**
  84326. * Particle emitter represents a volume emitting particles.
  84327. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84328. */
  84329. export interface IParticleEmitterType {
  84330. /**
  84331. * Called by the particle System when the direction is computed for the created particle.
  84332. * @param worldMatrix is the world matrix of the particle system
  84333. * @param directionToUpdate is the direction vector to update with the result
  84334. * @param particle is the particle we are computed the direction for
  84335. */
  84336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84337. /**
  84338. * Called by the particle System when the position is computed for the created particle.
  84339. * @param worldMatrix is the world matrix of the particle system
  84340. * @param positionToUpdate is the position vector to update with the result
  84341. * @param particle is the particle we are computed the position for
  84342. */
  84343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84344. /**
  84345. * Clones the current emitter and returns a copy of it
  84346. * @returns the new emitter
  84347. */
  84348. clone(): IParticleEmitterType;
  84349. /**
  84350. * Called by the GPUParticleSystem to setup the update shader
  84351. * @param effect defines the update shader
  84352. */
  84353. applyToShader(effect: Effect): void;
  84354. /**
  84355. * Returns a string to use to update the GPU particles update shader
  84356. * @returns the effect defines string
  84357. */
  84358. getEffectDefines(): string;
  84359. /**
  84360. * Returns a string representing the class name
  84361. * @returns a string containing the class name
  84362. */
  84363. getClassName(): string;
  84364. /**
  84365. * Serializes the particle system to a JSON object.
  84366. * @returns the JSON object
  84367. */
  84368. serialize(): any;
  84369. /**
  84370. * Parse properties from a JSON object
  84371. * @param serializationObject defines the JSON object
  84372. */
  84373. parse(serializationObject: any): void;
  84374. }
  84375. }
  84376. declare module BABYLON {
  84377. /**
  84378. * Particle emitter emitting particles from the inside of a box.
  84379. * It emits the particles randomly between 2 given directions.
  84380. */
  84381. export class BoxParticleEmitter implements IParticleEmitterType {
  84382. /**
  84383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84384. */
  84385. direction1: Vector3;
  84386. /**
  84387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84388. */
  84389. direction2: Vector3;
  84390. /**
  84391. * 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.
  84392. */
  84393. minEmitBox: Vector3;
  84394. /**
  84395. * 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.
  84396. */
  84397. maxEmitBox: Vector3;
  84398. /**
  84399. * Creates a new instance BoxParticleEmitter
  84400. */
  84401. constructor();
  84402. /**
  84403. * Called by the particle System when the direction is computed for the created particle.
  84404. * @param worldMatrix is the world matrix of the particle system
  84405. * @param directionToUpdate is the direction vector to update with the result
  84406. * @param particle is the particle we are computed the direction for
  84407. */
  84408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84409. /**
  84410. * Called by the particle System when the position is computed for the created particle.
  84411. * @param worldMatrix is the world matrix of the particle system
  84412. * @param positionToUpdate is the position vector to update with the result
  84413. * @param particle is the particle we are computed the position for
  84414. */
  84415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84416. /**
  84417. * Clones the current emitter and returns a copy of it
  84418. * @returns the new emitter
  84419. */
  84420. clone(): BoxParticleEmitter;
  84421. /**
  84422. * Called by the GPUParticleSystem to setup the update shader
  84423. * @param effect defines the update shader
  84424. */
  84425. applyToShader(effect: Effect): void;
  84426. /**
  84427. * Returns a string to use to update the GPU particles update shader
  84428. * @returns a string containng the defines string
  84429. */
  84430. getEffectDefines(): string;
  84431. /**
  84432. * Returns the string "BoxParticleEmitter"
  84433. * @returns a string containing the class name
  84434. */
  84435. getClassName(): string;
  84436. /**
  84437. * Serializes the particle system to a JSON object.
  84438. * @returns the JSON object
  84439. */
  84440. serialize(): any;
  84441. /**
  84442. * Parse properties from a JSON object
  84443. * @param serializationObject defines the JSON object
  84444. */
  84445. parse(serializationObject: any): void;
  84446. }
  84447. }
  84448. declare module BABYLON {
  84449. /**
  84450. * Particle emitter emitting particles from the inside of a cone.
  84451. * It emits the particles alongside the cone volume from the base to the particle.
  84452. * The emission direction might be randomized.
  84453. */
  84454. export class ConeParticleEmitter implements IParticleEmitterType {
  84455. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84456. directionRandomizer: number;
  84457. private _radius;
  84458. private _angle;
  84459. private _height;
  84460. /**
  84461. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84462. */
  84463. radiusRange: number;
  84464. /**
  84465. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84466. */
  84467. heightRange: number;
  84468. /**
  84469. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84470. */
  84471. emitFromSpawnPointOnly: boolean;
  84472. /**
  84473. * Gets or sets the radius of the emission cone
  84474. */
  84475. radius: number;
  84476. /**
  84477. * Gets or sets the angle of the emission cone
  84478. */
  84479. angle: number;
  84480. private _buildHeight;
  84481. /**
  84482. * Creates a new instance ConeParticleEmitter
  84483. * @param radius the radius of the emission cone (1 by default)
  84484. * @param angle the cone base angle (PI by default)
  84485. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84486. */
  84487. constructor(radius?: number, angle?: number,
  84488. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84489. directionRandomizer?: number);
  84490. /**
  84491. * Called by the particle System when the direction is computed for the created particle.
  84492. * @param worldMatrix is the world matrix of the particle system
  84493. * @param directionToUpdate is the direction vector to update with the result
  84494. * @param particle is the particle we are computed the direction for
  84495. */
  84496. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84497. /**
  84498. * Called by the particle System when the position is computed for the created particle.
  84499. * @param worldMatrix is the world matrix of the particle system
  84500. * @param positionToUpdate is the position vector to update with the result
  84501. * @param particle is the particle we are computed the position for
  84502. */
  84503. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84504. /**
  84505. * Clones the current emitter and returns a copy of it
  84506. * @returns the new emitter
  84507. */
  84508. clone(): ConeParticleEmitter;
  84509. /**
  84510. * Called by the GPUParticleSystem to setup the update shader
  84511. * @param effect defines the update shader
  84512. */
  84513. applyToShader(effect: Effect): void;
  84514. /**
  84515. * Returns a string to use to update the GPU particles update shader
  84516. * @returns a string containng the defines string
  84517. */
  84518. getEffectDefines(): string;
  84519. /**
  84520. * Returns the string "ConeParticleEmitter"
  84521. * @returns a string containing the class name
  84522. */
  84523. getClassName(): string;
  84524. /**
  84525. * Serializes the particle system to a JSON object.
  84526. * @returns the JSON object
  84527. */
  84528. serialize(): any;
  84529. /**
  84530. * Parse properties from a JSON object
  84531. * @param serializationObject defines the JSON object
  84532. */
  84533. parse(serializationObject: any): void;
  84534. }
  84535. }
  84536. declare module BABYLON {
  84537. /**
  84538. * Particle emitter emitting particles from the inside of a cylinder.
  84539. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84540. */
  84541. export class CylinderParticleEmitter implements IParticleEmitterType {
  84542. /**
  84543. * The radius of the emission cylinder.
  84544. */
  84545. radius: number;
  84546. /**
  84547. * The height of the emission cylinder.
  84548. */
  84549. height: number;
  84550. /**
  84551. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84552. */
  84553. radiusRange: number;
  84554. /**
  84555. * How much to randomize the particle direction [0-1].
  84556. */
  84557. directionRandomizer: number;
  84558. /**
  84559. * Creates a new instance CylinderParticleEmitter
  84560. * @param radius the radius of the emission cylinder (1 by default)
  84561. * @param height the height of the emission cylinder (1 by default)
  84562. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84563. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84564. */
  84565. constructor(
  84566. /**
  84567. * The radius of the emission cylinder.
  84568. */
  84569. radius?: number,
  84570. /**
  84571. * The height of the emission cylinder.
  84572. */
  84573. height?: number,
  84574. /**
  84575. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84576. */
  84577. radiusRange?: number,
  84578. /**
  84579. * How much to randomize the particle direction [0-1].
  84580. */
  84581. directionRandomizer?: number);
  84582. /**
  84583. * Called by the particle System when the direction is computed for the created particle.
  84584. * @param worldMatrix is the world matrix of the particle system
  84585. * @param directionToUpdate is the direction vector to update with the result
  84586. * @param particle is the particle we are computed the direction for
  84587. */
  84588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84589. /**
  84590. * Called by the particle System when the position is computed for the created particle.
  84591. * @param worldMatrix is the world matrix of the particle system
  84592. * @param positionToUpdate is the position vector to update with the result
  84593. * @param particle is the particle we are computed the position for
  84594. */
  84595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84596. /**
  84597. * Clones the current emitter and returns a copy of it
  84598. * @returns the new emitter
  84599. */
  84600. clone(): CylinderParticleEmitter;
  84601. /**
  84602. * Called by the GPUParticleSystem to setup the update shader
  84603. * @param effect defines the update shader
  84604. */
  84605. applyToShader(effect: Effect): void;
  84606. /**
  84607. * Returns a string to use to update the GPU particles update shader
  84608. * @returns a string containng the defines string
  84609. */
  84610. getEffectDefines(): string;
  84611. /**
  84612. * Returns the string "CylinderParticleEmitter"
  84613. * @returns a string containing the class name
  84614. */
  84615. getClassName(): string;
  84616. /**
  84617. * Serializes the particle system to a JSON object.
  84618. * @returns the JSON object
  84619. */
  84620. serialize(): any;
  84621. /**
  84622. * Parse properties from a JSON object
  84623. * @param serializationObject defines the JSON object
  84624. */
  84625. parse(serializationObject: any): void;
  84626. }
  84627. /**
  84628. * Particle emitter emitting particles from the inside of a cylinder.
  84629. * It emits the particles randomly between two vectors.
  84630. */
  84631. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84632. /**
  84633. * The min limit of the emission direction.
  84634. */
  84635. direction1: Vector3;
  84636. /**
  84637. * The max limit of the emission direction.
  84638. */
  84639. direction2: Vector3;
  84640. /**
  84641. * Creates a new instance CylinderDirectedParticleEmitter
  84642. * @param radius the radius of the emission cylinder (1 by default)
  84643. * @param height the height of the emission cylinder (1 by default)
  84644. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84645. * @param direction1 the min limit of the emission direction (up vector by default)
  84646. * @param direction2 the max limit of the emission direction (up vector by default)
  84647. */
  84648. constructor(radius?: number, height?: number, radiusRange?: number,
  84649. /**
  84650. * The min limit of the emission direction.
  84651. */
  84652. direction1?: Vector3,
  84653. /**
  84654. * The max limit of the emission direction.
  84655. */
  84656. direction2?: Vector3);
  84657. /**
  84658. * Called by the particle System when the direction is computed for the created particle.
  84659. * @param worldMatrix is the world matrix of the particle system
  84660. * @param directionToUpdate is the direction vector to update with the result
  84661. * @param particle is the particle we are computed the direction for
  84662. */
  84663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84664. /**
  84665. * Clones the current emitter and returns a copy of it
  84666. * @returns the new emitter
  84667. */
  84668. clone(): CylinderDirectedParticleEmitter;
  84669. /**
  84670. * Called by the GPUParticleSystem to setup the update shader
  84671. * @param effect defines the update shader
  84672. */
  84673. applyToShader(effect: Effect): void;
  84674. /**
  84675. * Returns a string to use to update the GPU particles update shader
  84676. * @returns a string containng the defines string
  84677. */
  84678. getEffectDefines(): string;
  84679. /**
  84680. * Returns the string "CylinderDirectedParticleEmitter"
  84681. * @returns a string containing the class name
  84682. */
  84683. getClassName(): string;
  84684. /**
  84685. * Serializes the particle system to a JSON object.
  84686. * @returns the JSON object
  84687. */
  84688. serialize(): any;
  84689. /**
  84690. * Parse properties from a JSON object
  84691. * @param serializationObject defines the JSON object
  84692. */
  84693. parse(serializationObject: any): void;
  84694. }
  84695. }
  84696. declare module BABYLON {
  84697. /**
  84698. * Particle emitter emitting particles from the inside of a hemisphere.
  84699. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84700. */
  84701. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84702. /**
  84703. * The radius of the emission hemisphere.
  84704. */
  84705. radius: number;
  84706. /**
  84707. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84708. */
  84709. radiusRange: number;
  84710. /**
  84711. * How much to randomize the particle direction [0-1].
  84712. */
  84713. directionRandomizer: number;
  84714. /**
  84715. * Creates a new instance HemisphericParticleEmitter
  84716. * @param radius the radius of the emission hemisphere (1 by default)
  84717. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84718. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84719. */
  84720. constructor(
  84721. /**
  84722. * The radius of the emission hemisphere.
  84723. */
  84724. radius?: number,
  84725. /**
  84726. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84727. */
  84728. radiusRange?: number,
  84729. /**
  84730. * How much to randomize the particle direction [0-1].
  84731. */
  84732. directionRandomizer?: number);
  84733. /**
  84734. * Called by the particle System when the direction is computed for the created particle.
  84735. * @param worldMatrix is the world matrix of the particle system
  84736. * @param directionToUpdate is the direction vector to update with the result
  84737. * @param particle is the particle we are computed the direction for
  84738. */
  84739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84740. /**
  84741. * Called by the particle System when the position is computed for the created particle.
  84742. * @param worldMatrix is the world matrix of the particle system
  84743. * @param positionToUpdate is the position vector to update with the result
  84744. * @param particle is the particle we are computed the position for
  84745. */
  84746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84747. /**
  84748. * Clones the current emitter and returns a copy of it
  84749. * @returns the new emitter
  84750. */
  84751. clone(): HemisphericParticleEmitter;
  84752. /**
  84753. * Called by the GPUParticleSystem to setup the update shader
  84754. * @param effect defines the update shader
  84755. */
  84756. applyToShader(effect: Effect): void;
  84757. /**
  84758. * Returns a string to use to update the GPU particles update shader
  84759. * @returns a string containng the defines string
  84760. */
  84761. getEffectDefines(): string;
  84762. /**
  84763. * Returns the string "HemisphericParticleEmitter"
  84764. * @returns a string containing the class name
  84765. */
  84766. getClassName(): string;
  84767. /**
  84768. * Serializes the particle system to a JSON object.
  84769. * @returns the JSON object
  84770. */
  84771. serialize(): any;
  84772. /**
  84773. * Parse properties from a JSON object
  84774. * @param serializationObject defines the JSON object
  84775. */
  84776. parse(serializationObject: any): void;
  84777. }
  84778. }
  84779. declare module BABYLON {
  84780. /**
  84781. * Particle emitter emitting particles from a point.
  84782. * It emits the particles randomly between 2 given directions.
  84783. */
  84784. export class PointParticleEmitter implements IParticleEmitterType {
  84785. /**
  84786. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84787. */
  84788. direction1: Vector3;
  84789. /**
  84790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84791. */
  84792. direction2: Vector3;
  84793. /**
  84794. * Creates a new instance PointParticleEmitter
  84795. */
  84796. constructor();
  84797. /**
  84798. * Called by the particle System when the direction is computed for the created particle.
  84799. * @param worldMatrix is the world matrix of the particle system
  84800. * @param directionToUpdate is the direction vector to update with the result
  84801. * @param particle is the particle we are computed the direction for
  84802. */
  84803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84804. /**
  84805. * Called by the particle System when the position is computed for the created particle.
  84806. * @param worldMatrix is the world matrix of the particle system
  84807. * @param positionToUpdate is the position vector to update with the result
  84808. * @param particle is the particle we are computed the position for
  84809. */
  84810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84811. /**
  84812. * Clones the current emitter and returns a copy of it
  84813. * @returns the new emitter
  84814. */
  84815. clone(): PointParticleEmitter;
  84816. /**
  84817. * Called by the GPUParticleSystem to setup the update shader
  84818. * @param effect defines the update shader
  84819. */
  84820. applyToShader(effect: Effect): void;
  84821. /**
  84822. * Returns a string to use to update the GPU particles update shader
  84823. * @returns a string containng the defines string
  84824. */
  84825. getEffectDefines(): string;
  84826. /**
  84827. * Returns the string "PointParticleEmitter"
  84828. * @returns a string containing the class name
  84829. */
  84830. getClassName(): string;
  84831. /**
  84832. * Serializes the particle system to a JSON object.
  84833. * @returns the JSON object
  84834. */
  84835. serialize(): any;
  84836. /**
  84837. * Parse properties from a JSON object
  84838. * @param serializationObject defines the JSON object
  84839. */
  84840. parse(serializationObject: any): void;
  84841. }
  84842. }
  84843. declare module BABYLON {
  84844. /**
  84845. * Particle emitter emitting particles from the inside of a sphere.
  84846. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84847. */
  84848. export class SphereParticleEmitter implements IParticleEmitterType {
  84849. /**
  84850. * The radius of the emission sphere.
  84851. */
  84852. radius: number;
  84853. /**
  84854. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84855. */
  84856. radiusRange: number;
  84857. /**
  84858. * How much to randomize the particle direction [0-1].
  84859. */
  84860. directionRandomizer: number;
  84861. /**
  84862. * Creates a new instance SphereParticleEmitter
  84863. * @param radius the radius of the emission sphere (1 by default)
  84864. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84865. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84866. */
  84867. constructor(
  84868. /**
  84869. * The radius of the emission sphere.
  84870. */
  84871. radius?: number,
  84872. /**
  84873. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84874. */
  84875. radiusRange?: number,
  84876. /**
  84877. * How much to randomize the particle direction [0-1].
  84878. */
  84879. directionRandomizer?: number);
  84880. /**
  84881. * Called by the particle System when the direction is computed for the created particle.
  84882. * @param worldMatrix is the world matrix of the particle system
  84883. * @param directionToUpdate is the direction vector to update with the result
  84884. * @param particle is the particle we are computed the direction for
  84885. */
  84886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84887. /**
  84888. * Called by the particle System when the position is computed for the created particle.
  84889. * @param worldMatrix is the world matrix of the particle system
  84890. * @param positionToUpdate is the position vector to update with the result
  84891. * @param particle is the particle we are computed the position for
  84892. */
  84893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84894. /**
  84895. * Clones the current emitter and returns a copy of it
  84896. * @returns the new emitter
  84897. */
  84898. clone(): SphereParticleEmitter;
  84899. /**
  84900. * Called by the GPUParticleSystem to setup the update shader
  84901. * @param effect defines the update shader
  84902. */
  84903. applyToShader(effect: Effect): void;
  84904. /**
  84905. * Returns a string to use to update the GPU particles update shader
  84906. * @returns a string containng the defines string
  84907. */
  84908. getEffectDefines(): string;
  84909. /**
  84910. * Returns the string "SphereParticleEmitter"
  84911. * @returns a string containing the class name
  84912. */
  84913. getClassName(): string;
  84914. /**
  84915. * Serializes the particle system to a JSON object.
  84916. * @returns the JSON object
  84917. */
  84918. serialize(): any;
  84919. /**
  84920. * Parse properties from a JSON object
  84921. * @param serializationObject defines the JSON object
  84922. */
  84923. parse(serializationObject: any): void;
  84924. }
  84925. /**
  84926. * Particle emitter emitting particles from the inside of a sphere.
  84927. * It emits the particles randomly between two vectors.
  84928. */
  84929. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84930. /**
  84931. * The min limit of the emission direction.
  84932. */
  84933. direction1: Vector3;
  84934. /**
  84935. * The max limit of the emission direction.
  84936. */
  84937. direction2: Vector3;
  84938. /**
  84939. * Creates a new instance SphereDirectedParticleEmitter
  84940. * @param radius the radius of the emission sphere (1 by default)
  84941. * @param direction1 the min limit of the emission direction (up vector by default)
  84942. * @param direction2 the max limit of the emission direction (up vector by default)
  84943. */
  84944. constructor(radius?: number,
  84945. /**
  84946. * The min limit of the emission direction.
  84947. */
  84948. direction1?: Vector3,
  84949. /**
  84950. * The max limit of the emission direction.
  84951. */
  84952. direction2?: Vector3);
  84953. /**
  84954. * Called by the particle System when the direction is computed for the created particle.
  84955. * @param worldMatrix is the world matrix of the particle system
  84956. * @param directionToUpdate is the direction vector to update with the result
  84957. * @param particle is the particle we are computed the direction for
  84958. */
  84959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84960. /**
  84961. * Clones the current emitter and returns a copy of it
  84962. * @returns the new emitter
  84963. */
  84964. clone(): SphereDirectedParticleEmitter;
  84965. /**
  84966. * Called by the GPUParticleSystem to setup the update shader
  84967. * @param effect defines the update shader
  84968. */
  84969. applyToShader(effect: Effect): void;
  84970. /**
  84971. * Returns a string to use to update the GPU particles update shader
  84972. * @returns a string containng the defines string
  84973. */
  84974. getEffectDefines(): string;
  84975. /**
  84976. * Returns the string "SphereDirectedParticleEmitter"
  84977. * @returns a string containing the class name
  84978. */
  84979. getClassName(): string;
  84980. /**
  84981. * Serializes the particle system to a JSON object.
  84982. * @returns the JSON object
  84983. */
  84984. serialize(): any;
  84985. /**
  84986. * Parse properties from a JSON object
  84987. * @param serializationObject defines the JSON object
  84988. */
  84989. parse(serializationObject: any): void;
  84990. }
  84991. }
  84992. declare module BABYLON {
  84993. /**
  84994. * Interface representing a particle system in Babylon.js.
  84995. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84996. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84997. */
  84998. export interface IParticleSystem {
  84999. /**
  85000. * List of animations used by the particle system.
  85001. */
  85002. animations: Animation[];
  85003. /**
  85004. * The id of the Particle system.
  85005. */
  85006. id: string;
  85007. /**
  85008. * The name of the Particle system.
  85009. */
  85010. name: string;
  85011. /**
  85012. * The emitter represents the Mesh or position we are attaching the particle system to.
  85013. */
  85014. emitter: Nullable<AbstractMesh | Vector3>;
  85015. /**
  85016. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85017. */
  85018. isBillboardBased: boolean;
  85019. /**
  85020. * The rendering group used by the Particle system to chose when to render.
  85021. */
  85022. renderingGroupId: number;
  85023. /**
  85024. * The layer mask we are rendering the particles through.
  85025. */
  85026. layerMask: number;
  85027. /**
  85028. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85029. */
  85030. updateSpeed: number;
  85031. /**
  85032. * The amount of time the particle system is running (depends of the overall update speed).
  85033. */
  85034. targetStopDuration: number;
  85035. /**
  85036. * The texture used to render each particle. (this can be a spritesheet)
  85037. */
  85038. particleTexture: Nullable<Texture>;
  85039. /**
  85040. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85041. */
  85042. blendMode: number;
  85043. /**
  85044. * Minimum life time of emitting particles.
  85045. */
  85046. minLifeTime: number;
  85047. /**
  85048. * Maximum life time of emitting particles.
  85049. */
  85050. maxLifeTime: number;
  85051. /**
  85052. * Minimum Size of emitting particles.
  85053. */
  85054. minSize: number;
  85055. /**
  85056. * Maximum Size of emitting particles.
  85057. */
  85058. maxSize: number;
  85059. /**
  85060. * Minimum scale of emitting particles on X axis.
  85061. */
  85062. minScaleX: number;
  85063. /**
  85064. * Maximum scale of emitting particles on X axis.
  85065. */
  85066. maxScaleX: number;
  85067. /**
  85068. * Minimum scale of emitting particles on Y axis.
  85069. */
  85070. minScaleY: number;
  85071. /**
  85072. * Maximum scale of emitting particles on Y axis.
  85073. */
  85074. maxScaleY: number;
  85075. /**
  85076. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85077. */
  85078. color1: Color4;
  85079. /**
  85080. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85081. */
  85082. color2: Color4;
  85083. /**
  85084. * Color the particle will have at the end of its lifetime.
  85085. */
  85086. colorDead: Color4;
  85087. /**
  85088. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85089. */
  85090. emitRate: number;
  85091. /**
  85092. * You can use gravity if you want to give an orientation to your particles.
  85093. */
  85094. gravity: Vector3;
  85095. /**
  85096. * Minimum power of emitting particles.
  85097. */
  85098. minEmitPower: number;
  85099. /**
  85100. * Maximum power of emitting particles.
  85101. */
  85102. maxEmitPower: number;
  85103. /**
  85104. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85105. */
  85106. minAngularSpeed: number;
  85107. /**
  85108. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85109. */
  85110. maxAngularSpeed: number;
  85111. /**
  85112. * Gets or sets the minimal initial rotation in radians.
  85113. */
  85114. minInitialRotation: number;
  85115. /**
  85116. * Gets or sets the maximal initial rotation in radians.
  85117. */
  85118. maxInitialRotation: number;
  85119. /**
  85120. * The particle emitter type defines the emitter used by the particle system.
  85121. * It can be for example box, sphere, or cone...
  85122. */
  85123. particleEmitterType: Nullable<IParticleEmitterType>;
  85124. /**
  85125. * Defines the delay in milliseconds before starting the system (0 by default)
  85126. */
  85127. startDelay: number;
  85128. /**
  85129. * 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
  85130. */
  85131. preWarmCycles: number;
  85132. /**
  85133. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85134. */
  85135. preWarmStepOffset: number;
  85136. /**
  85137. * 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)
  85138. */
  85139. spriteCellChangeSpeed: number;
  85140. /**
  85141. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85142. */
  85143. startSpriteCellID: number;
  85144. /**
  85145. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85146. */
  85147. endSpriteCellID: number;
  85148. /**
  85149. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85150. */
  85151. spriteCellWidth: number;
  85152. /**
  85153. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85154. */
  85155. spriteCellHeight: number;
  85156. /**
  85157. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85158. */
  85159. spriteRandomStartCell: boolean;
  85160. /**
  85161. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85162. */
  85163. isAnimationSheetEnabled: boolean;
  85164. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85165. translationPivot: Vector2;
  85166. /**
  85167. * Gets or sets a texture used to add random noise to particle positions
  85168. */
  85169. noiseTexture: Nullable<BaseTexture>;
  85170. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85171. noiseStrength: Vector3;
  85172. /**
  85173. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85174. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85175. */
  85176. billboardMode: number;
  85177. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85178. limitVelocityDamping: number;
  85179. /**
  85180. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85181. */
  85182. beginAnimationOnStart: boolean;
  85183. /**
  85184. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85185. */
  85186. beginAnimationFrom: number;
  85187. /**
  85188. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85189. */
  85190. beginAnimationTo: number;
  85191. /**
  85192. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85193. */
  85194. beginAnimationLoop: boolean;
  85195. /**
  85196. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85197. */
  85198. disposeOnStop: boolean;
  85199. /**
  85200. * Gets the maximum number of particles active at the same time.
  85201. * @returns The max number of active particles.
  85202. */
  85203. getCapacity(): number;
  85204. /**
  85205. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85206. * @returns True if it has been started, otherwise false.
  85207. */
  85208. isStarted(): boolean;
  85209. /**
  85210. * Animates the particle system for this frame.
  85211. */
  85212. animate(): void;
  85213. /**
  85214. * Renders the particle system in its current state.
  85215. * @returns the current number of particles
  85216. */
  85217. render(): number;
  85218. /**
  85219. * Dispose the particle system and frees its associated resources.
  85220. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85221. */
  85222. dispose(disposeTexture?: boolean): void;
  85223. /**
  85224. * Clones the particle system.
  85225. * @param name The name of the cloned object
  85226. * @param newEmitter The new emitter to use
  85227. * @returns the cloned particle system
  85228. */
  85229. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85230. /**
  85231. * Serializes the particle system to a JSON object.
  85232. * @returns the JSON object
  85233. */
  85234. serialize(): any;
  85235. /**
  85236. * Rebuild the particle system
  85237. */
  85238. rebuild(): void;
  85239. /**
  85240. * Starts the particle system and begins to emit
  85241. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85242. */
  85243. start(delay?: number): void;
  85244. /**
  85245. * Stops the particle system.
  85246. */
  85247. stop(): void;
  85248. /**
  85249. * Remove all active particles
  85250. */
  85251. reset(): void;
  85252. /**
  85253. * Is this system ready to be used/rendered
  85254. * @return true if the system is ready
  85255. */
  85256. isReady(): boolean;
  85257. /**
  85258. * Adds a new color gradient
  85259. * @param gradient defines the gradient to use (between 0 and 1)
  85260. * @param color1 defines the color to affect to the specified gradient
  85261. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85262. * @returns the current particle system
  85263. */
  85264. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85265. /**
  85266. * Remove a specific color gradient
  85267. * @param gradient defines the gradient to remove
  85268. * @returns the current particle system
  85269. */
  85270. removeColorGradient(gradient: number): IParticleSystem;
  85271. /**
  85272. * Adds a new size gradient
  85273. * @param gradient defines the gradient to use (between 0 and 1)
  85274. * @param factor defines the size factor to affect to the specified gradient
  85275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85276. * @returns the current particle system
  85277. */
  85278. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85279. /**
  85280. * Remove a specific size gradient
  85281. * @param gradient defines the gradient to remove
  85282. * @returns the current particle system
  85283. */
  85284. removeSizeGradient(gradient: number): IParticleSystem;
  85285. /**
  85286. * Gets the current list of color gradients.
  85287. * You must use addColorGradient and removeColorGradient to udpate this list
  85288. * @returns the list of color gradients
  85289. */
  85290. getColorGradients(): Nullable<Array<ColorGradient>>;
  85291. /**
  85292. * Gets the current list of size gradients.
  85293. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85294. * @returns the list of size gradients
  85295. */
  85296. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85297. /**
  85298. * Gets the current list of angular speed gradients.
  85299. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85300. * @returns the list of angular speed gradients
  85301. */
  85302. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85303. /**
  85304. * Adds a new angular speed gradient
  85305. * @param gradient defines the gradient to use (between 0 and 1)
  85306. * @param factor defines the angular speed to affect to the specified gradient
  85307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85308. * @returns the current particle system
  85309. */
  85310. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85311. /**
  85312. * Remove a specific angular speed gradient
  85313. * @param gradient defines the gradient to remove
  85314. * @returns the current particle system
  85315. */
  85316. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85317. /**
  85318. * Gets the current list of velocity gradients.
  85319. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85320. * @returns the list of velocity gradients
  85321. */
  85322. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85323. /**
  85324. * Adds a new velocity gradient
  85325. * @param gradient defines the gradient to use (between 0 and 1)
  85326. * @param factor defines the velocity to affect to the specified gradient
  85327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85328. * @returns the current particle system
  85329. */
  85330. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85331. /**
  85332. * Remove a specific velocity gradient
  85333. * @param gradient defines the gradient to remove
  85334. * @returns the current particle system
  85335. */
  85336. removeVelocityGradient(gradient: number): IParticleSystem;
  85337. /**
  85338. * Gets the current list of limit velocity gradients.
  85339. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85340. * @returns the list of limit velocity gradients
  85341. */
  85342. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85343. /**
  85344. * Adds a new limit velocity gradient
  85345. * @param gradient defines the gradient to use (between 0 and 1)
  85346. * @param factor defines the limit velocity to affect to the specified gradient
  85347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85348. * @returns the current particle system
  85349. */
  85350. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85351. /**
  85352. * Remove a specific limit velocity gradient
  85353. * @param gradient defines the gradient to remove
  85354. * @returns the current particle system
  85355. */
  85356. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85357. /**
  85358. * Adds a new drag gradient
  85359. * @param gradient defines the gradient to use (between 0 and 1)
  85360. * @param factor defines the drag to affect to the specified gradient
  85361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85362. * @returns the current particle system
  85363. */
  85364. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85365. /**
  85366. * Remove a specific drag gradient
  85367. * @param gradient defines the gradient to remove
  85368. * @returns the current particle system
  85369. */
  85370. removeDragGradient(gradient: number): IParticleSystem;
  85371. /**
  85372. * Gets the current list of drag gradients.
  85373. * You must use addDragGradient and removeDragGradient to udpate this list
  85374. * @returns the list of drag gradients
  85375. */
  85376. getDragGradients(): Nullable<Array<FactorGradient>>;
  85377. /**
  85378. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85379. * @param gradient defines the gradient to use (between 0 and 1)
  85380. * @param factor defines the emit rate to affect to the specified gradient
  85381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85382. * @returns the current particle system
  85383. */
  85384. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85385. /**
  85386. * Remove a specific emit rate gradient
  85387. * @param gradient defines the gradient to remove
  85388. * @returns the current particle system
  85389. */
  85390. removeEmitRateGradient(gradient: number): IParticleSystem;
  85391. /**
  85392. * Gets the current list of emit rate gradients.
  85393. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85394. * @returns the list of emit rate gradients
  85395. */
  85396. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85397. /**
  85398. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85399. * @param gradient defines the gradient to use (between 0 and 1)
  85400. * @param factor defines the start size to affect to the specified gradient
  85401. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85402. * @returns the current particle system
  85403. */
  85404. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85405. /**
  85406. * Remove a specific start size gradient
  85407. * @param gradient defines the gradient to remove
  85408. * @returns the current particle system
  85409. */
  85410. removeStartSizeGradient(gradient: number): IParticleSystem;
  85411. /**
  85412. * Gets the current list of start size gradients.
  85413. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85414. * @returns the list of start size gradients
  85415. */
  85416. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85417. /**
  85418. * Adds a new life time gradient
  85419. * @param gradient defines the gradient to use (between 0 and 1)
  85420. * @param factor defines the life time factor to affect to the specified gradient
  85421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85422. * @returns the current particle system
  85423. */
  85424. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85425. /**
  85426. * Remove a specific life time gradient
  85427. * @param gradient defines the gradient to remove
  85428. * @returns the current particle system
  85429. */
  85430. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85431. /**
  85432. * Gets the current list of life time gradients.
  85433. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85434. * @returns the list of life time gradients
  85435. */
  85436. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85437. /**
  85438. * Gets the current list of color gradients.
  85439. * You must use addColorGradient and removeColorGradient to udpate this list
  85440. * @returns the list of color gradients
  85441. */
  85442. getColorGradients(): Nullable<Array<ColorGradient>>;
  85443. /**
  85444. * Adds a new ramp gradient used to remap particle colors
  85445. * @param gradient defines the gradient to use (between 0 and 1)
  85446. * @param color defines the color to affect to the specified gradient
  85447. * @returns the current particle system
  85448. */
  85449. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85450. /**
  85451. * Gets the current list of ramp gradients.
  85452. * You must use addRampGradient and removeRampGradient to udpate this list
  85453. * @returns the list of ramp gradients
  85454. */
  85455. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85456. /** Gets or sets a boolean indicating that ramp gradients must be used
  85457. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85458. */
  85459. useRampGradients: boolean;
  85460. /**
  85461. * Adds a new color remap gradient
  85462. * @param gradient defines the gradient to use (between 0 and 1)
  85463. * @param min defines the color remap minimal range
  85464. * @param max defines the color remap maximal range
  85465. * @returns the current particle system
  85466. */
  85467. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85468. /**
  85469. * Gets the current list of color remap gradients.
  85470. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85471. * @returns the list of color remap gradients
  85472. */
  85473. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85474. /**
  85475. * Adds a new alpha remap gradient
  85476. * @param gradient defines the gradient to use (between 0 and 1)
  85477. * @param min defines the alpha remap minimal range
  85478. * @param max defines the alpha remap maximal range
  85479. * @returns the current particle system
  85480. */
  85481. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85482. /**
  85483. * Gets the current list of alpha remap gradients.
  85484. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85485. * @returns the list of alpha remap gradients
  85486. */
  85487. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85488. /**
  85489. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85492. * @returns the emitter
  85493. */
  85494. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85495. /**
  85496. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85497. * @param radius The radius of the hemisphere to emit from
  85498. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85499. * @returns the emitter
  85500. */
  85501. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85502. /**
  85503. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85504. * @param radius The radius of the sphere to emit from
  85505. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85506. * @returns the emitter
  85507. */
  85508. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85509. /**
  85510. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85511. * @param radius The radius of the sphere to emit from
  85512. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85513. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85514. * @returns the emitter
  85515. */
  85516. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85517. /**
  85518. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85519. * @param radius The radius of the emission cylinder
  85520. * @param height The height of the emission cylinder
  85521. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85522. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85523. * @returns the emitter
  85524. */
  85525. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85526. /**
  85527. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85528. * @param radius The radius of the cylinder to emit from
  85529. * @param height The height of the emission cylinder
  85530. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85533. * @returns the emitter
  85534. */
  85535. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85536. /**
  85537. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85538. * @param radius The radius of the cone to emit from
  85539. * @param angle The base angle of the cone
  85540. * @returns the emitter
  85541. */
  85542. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85543. /**
  85544. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85545. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85546. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85547. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85548. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85549. * @returns the emitter
  85550. */
  85551. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85552. /**
  85553. * Get hosting scene
  85554. * @returns the scene
  85555. */
  85556. getScene(): Scene;
  85557. }
  85558. }
  85559. declare module BABYLON {
  85560. /**
  85561. * Creates an instance based on a source mesh.
  85562. */
  85563. export class InstancedMesh extends AbstractMesh {
  85564. private _sourceMesh;
  85565. private _currentLOD;
  85566. /** @hidden */
  85567. _indexInSourceMeshInstanceArray: number;
  85568. constructor(name: string, source: Mesh);
  85569. /**
  85570. * Returns the string "InstancedMesh".
  85571. */
  85572. getClassName(): string;
  85573. /** Gets the list of lights affecting that mesh */
  85574. readonly lightSources: Light[];
  85575. _resyncLightSources(): void;
  85576. _resyncLighSource(light: Light): void;
  85577. _removeLightSource(light: Light, dispose: boolean): void;
  85578. /**
  85579. * If the source mesh receives shadows
  85580. */
  85581. readonly receiveShadows: boolean;
  85582. /**
  85583. * The material of the source mesh
  85584. */
  85585. readonly material: Nullable<Material>;
  85586. /**
  85587. * Visibility of the source mesh
  85588. */
  85589. readonly visibility: number;
  85590. /**
  85591. * Skeleton of the source mesh
  85592. */
  85593. readonly skeleton: Nullable<Skeleton>;
  85594. /**
  85595. * Rendering ground id of the source mesh
  85596. */
  85597. renderingGroupId: number;
  85598. /**
  85599. * Returns the total number of vertices (integer).
  85600. */
  85601. getTotalVertices(): number;
  85602. /**
  85603. * Returns a positive integer : the total number of indices in this mesh geometry.
  85604. * @returns the numner of indices or zero if the mesh has no geometry.
  85605. */
  85606. getTotalIndices(): number;
  85607. /**
  85608. * The source mesh of the instance
  85609. */
  85610. readonly sourceMesh: Mesh;
  85611. /**
  85612. * Is this node ready to be used/rendered
  85613. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85614. * @return {boolean} is it ready
  85615. */
  85616. isReady(completeCheck?: boolean): boolean;
  85617. /**
  85618. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85619. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85620. * @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.
  85621. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85622. */
  85623. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85624. /**
  85625. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85626. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85627. * The `data` are either a numeric array either a Float32Array.
  85628. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85629. * 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).
  85630. * Note that a new underlying VertexBuffer object is created each call.
  85631. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85632. *
  85633. * Possible `kind` values :
  85634. * - VertexBuffer.PositionKind
  85635. * - VertexBuffer.UVKind
  85636. * - VertexBuffer.UV2Kind
  85637. * - VertexBuffer.UV3Kind
  85638. * - VertexBuffer.UV4Kind
  85639. * - VertexBuffer.UV5Kind
  85640. * - VertexBuffer.UV6Kind
  85641. * - VertexBuffer.ColorKind
  85642. * - VertexBuffer.MatricesIndicesKind
  85643. * - VertexBuffer.MatricesIndicesExtraKind
  85644. * - VertexBuffer.MatricesWeightsKind
  85645. * - VertexBuffer.MatricesWeightsExtraKind
  85646. *
  85647. * Returns the Mesh.
  85648. */
  85649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85650. /**
  85651. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85652. * If the mesh has no geometry, it is simply returned as it is.
  85653. * The `data` are either a numeric array either a Float32Array.
  85654. * No new underlying VertexBuffer object is created.
  85655. * 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.
  85656. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85657. *
  85658. * Possible `kind` values :
  85659. * - VertexBuffer.PositionKind
  85660. * - VertexBuffer.UVKind
  85661. * - VertexBuffer.UV2Kind
  85662. * - VertexBuffer.UV3Kind
  85663. * - VertexBuffer.UV4Kind
  85664. * - VertexBuffer.UV5Kind
  85665. * - VertexBuffer.UV6Kind
  85666. * - VertexBuffer.ColorKind
  85667. * - VertexBuffer.MatricesIndicesKind
  85668. * - VertexBuffer.MatricesIndicesExtraKind
  85669. * - VertexBuffer.MatricesWeightsKind
  85670. * - VertexBuffer.MatricesWeightsExtraKind
  85671. *
  85672. * Returns the Mesh.
  85673. */
  85674. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85675. /**
  85676. * Sets the mesh indices.
  85677. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85678. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85679. * This method creates a new index buffer each call.
  85680. * Returns the Mesh.
  85681. */
  85682. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85683. /**
  85684. * Boolean : True if the mesh owns the requested kind of data.
  85685. */
  85686. isVerticesDataPresent(kind: string): boolean;
  85687. /**
  85688. * Returns an array of indices (IndicesArray).
  85689. */
  85690. getIndices(): Nullable<IndicesArray>;
  85691. readonly _positions: Nullable<Vector3[]>;
  85692. /**
  85693. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85694. * This means the mesh underlying bounding box and sphere are recomputed.
  85695. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85696. * @returns the current mesh
  85697. */
  85698. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85699. /** @hidden */
  85700. _preActivate(): InstancedMesh;
  85701. /** @hidden */
  85702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85703. /** @hidden */
  85704. _postActivate(): void;
  85705. getWorldMatrix(): Matrix;
  85706. readonly isAnInstance: boolean;
  85707. /**
  85708. * Returns the current associated LOD AbstractMesh.
  85709. */
  85710. getLOD(camera: Camera): AbstractMesh;
  85711. /** @hidden */
  85712. _syncSubMeshes(): InstancedMesh;
  85713. /** @hidden */
  85714. _generatePointsArray(): boolean;
  85715. /**
  85716. * Creates a new InstancedMesh from the current mesh.
  85717. * - name (string) : the cloned mesh name
  85718. * - newParent (optional Node) : the optional Node to parent the clone to.
  85719. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85720. *
  85721. * Returns the clone.
  85722. */
  85723. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85724. /**
  85725. * Disposes the InstancedMesh.
  85726. * Returns nothing.
  85727. */
  85728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85729. }
  85730. }
  85731. declare module BABYLON {
  85732. /**
  85733. * Defines the options associated with the creation of a shader material.
  85734. */
  85735. export interface IShaderMaterialOptions {
  85736. /**
  85737. * Does the material work in alpha blend mode
  85738. */
  85739. needAlphaBlending: boolean;
  85740. /**
  85741. * Does the material work in alpha test mode
  85742. */
  85743. needAlphaTesting: boolean;
  85744. /**
  85745. * The list of attribute names used in the shader
  85746. */
  85747. attributes: string[];
  85748. /**
  85749. * The list of unifrom names used in the shader
  85750. */
  85751. uniforms: string[];
  85752. /**
  85753. * The list of UBO names used in the shader
  85754. */
  85755. uniformBuffers: string[];
  85756. /**
  85757. * The list of sampler names used in the shader
  85758. */
  85759. samplers: string[];
  85760. /**
  85761. * The list of defines used in the shader
  85762. */
  85763. defines: string[];
  85764. }
  85765. /**
  85766. * 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.
  85767. *
  85768. * This returned material effects how the mesh will look based on the code in the shaders.
  85769. *
  85770. * @see http://doc.babylonjs.com/how_to/shader_material
  85771. */
  85772. export class ShaderMaterial extends Material {
  85773. private _shaderPath;
  85774. private _options;
  85775. private _textures;
  85776. private _textureArrays;
  85777. private _floats;
  85778. private _ints;
  85779. private _floatsArrays;
  85780. private _colors3;
  85781. private _colors3Arrays;
  85782. private _colors4;
  85783. private _colors4Arrays;
  85784. private _vectors2;
  85785. private _vectors3;
  85786. private _vectors4;
  85787. private _matrices;
  85788. private _matrices3x3;
  85789. private _matrices2x2;
  85790. private _vectors2Arrays;
  85791. private _vectors3Arrays;
  85792. private _vectors4Arrays;
  85793. private _cachedWorldViewMatrix;
  85794. private _cachedWorldViewProjectionMatrix;
  85795. private _renderId;
  85796. /**
  85797. * Instantiate a new shader material.
  85798. * 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.
  85799. * This returned material effects how the mesh will look based on the code in the shaders.
  85800. * @see http://doc.babylonjs.com/how_to/shader_material
  85801. * @param name Define the name of the material in the scene
  85802. * @param scene Define the scene the material belongs to
  85803. * @param shaderPath Defines the route to the shader code in one of three ways:
  85804. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85805. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85806. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85807. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85808. * @param options Define the options used to create the shader
  85809. */
  85810. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85811. /**
  85812. * Gets the options used to compile the shader.
  85813. * They can be modified to trigger a new compilation
  85814. */
  85815. readonly options: IShaderMaterialOptions;
  85816. /**
  85817. * Gets the current class name of the material e.g. "ShaderMaterial"
  85818. * Mainly use in serialization.
  85819. * @returns the class name
  85820. */
  85821. getClassName(): string;
  85822. /**
  85823. * Specifies if the material will require alpha blending
  85824. * @returns a boolean specifying if alpha blending is needed
  85825. */
  85826. needAlphaBlending(): boolean;
  85827. /**
  85828. * Specifies if this material should be rendered in alpha test mode
  85829. * @returns a boolean specifying if an alpha test is needed.
  85830. */
  85831. needAlphaTesting(): boolean;
  85832. private _checkUniform;
  85833. /**
  85834. * Set a texture in the shader.
  85835. * @param name Define the name of the uniform samplers as defined in the shader
  85836. * @param texture Define the texture to bind to this sampler
  85837. * @return the material itself allowing "fluent" like uniform updates
  85838. */
  85839. setTexture(name: string, texture: Texture): ShaderMaterial;
  85840. /**
  85841. * Set a texture array in the shader.
  85842. * @param name Define the name of the uniform sampler array as defined in the shader
  85843. * @param textures Define the list of textures to bind to this sampler
  85844. * @return the material itself allowing "fluent" like uniform updates
  85845. */
  85846. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85847. /**
  85848. * Set a float in the shader.
  85849. * @param name Define the name of the uniform as defined in the shader
  85850. * @param value Define the value to give to the uniform
  85851. * @return the material itself allowing "fluent" like uniform updates
  85852. */
  85853. setFloat(name: string, value: number): ShaderMaterial;
  85854. /**
  85855. * Set a int in the shader.
  85856. * @param name Define the name of the uniform as defined in the shader
  85857. * @param value Define the value to give to the uniform
  85858. * @return the material itself allowing "fluent" like uniform updates
  85859. */
  85860. setInt(name: string, value: number): ShaderMaterial;
  85861. /**
  85862. * Set an array of floats in the shader.
  85863. * @param name Define the name of the uniform as defined in the shader
  85864. * @param value Define the value to give to the uniform
  85865. * @return the material itself allowing "fluent" like uniform updates
  85866. */
  85867. setFloats(name: string, value: number[]): ShaderMaterial;
  85868. /**
  85869. * Set a vec3 in the shader from a Color3.
  85870. * @param name Define the name of the uniform as defined in the shader
  85871. * @param value Define the value to give to the uniform
  85872. * @return the material itself allowing "fluent" like uniform updates
  85873. */
  85874. setColor3(name: string, value: Color3): ShaderMaterial;
  85875. /**
  85876. * Set a vec3 array in the shader from a Color3 array.
  85877. * @param name Define the name of the uniform as defined in the shader
  85878. * @param value Define the value to give to the uniform
  85879. * @return the material itself allowing "fluent" like uniform updates
  85880. */
  85881. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85882. /**
  85883. * Set a vec4 in the shader from a Color4.
  85884. * @param name Define the name of the uniform as defined in the shader
  85885. * @param value Define the value to give to the uniform
  85886. * @return the material itself allowing "fluent" like uniform updates
  85887. */
  85888. setColor4(name: string, value: Color4): ShaderMaterial;
  85889. /**
  85890. * Set a vec4 array in the shader from a Color4 array.
  85891. * @param name Define the name of the uniform as defined in the shader
  85892. * @param value Define the value to give to the uniform
  85893. * @return the material itself allowing "fluent" like uniform updates
  85894. */
  85895. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85896. /**
  85897. * Set a vec2 in the shader from a Vector2.
  85898. * @param name Define the name of the uniform as defined in the shader
  85899. * @param value Define the value to give to the uniform
  85900. * @return the material itself allowing "fluent" like uniform updates
  85901. */
  85902. setVector2(name: string, value: Vector2): ShaderMaterial;
  85903. /**
  85904. * Set a vec3 in the shader from a Vector3.
  85905. * @param name Define the name of the uniform as defined in the shader
  85906. * @param value Define the value to give to the uniform
  85907. * @return the material itself allowing "fluent" like uniform updates
  85908. */
  85909. setVector3(name: string, value: Vector3): ShaderMaterial;
  85910. /**
  85911. * Set a vec4 in the shader from a Vector4.
  85912. * @param name Define the name of the uniform as defined in the shader
  85913. * @param value Define the value to give to the uniform
  85914. * @return the material itself allowing "fluent" like uniform updates
  85915. */
  85916. setVector4(name: string, value: Vector4): ShaderMaterial;
  85917. /**
  85918. * Set a mat4 in the shader from a Matrix.
  85919. * @param name Define the name of the uniform as defined in the shader
  85920. * @param value Define the value to give to the uniform
  85921. * @return the material itself allowing "fluent" like uniform updates
  85922. */
  85923. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85924. /**
  85925. * Set a mat3 in the shader from a Float32Array.
  85926. * @param name Define the name of the uniform as defined in the shader
  85927. * @param value Define the value to give to the uniform
  85928. * @return the material itself allowing "fluent" like uniform updates
  85929. */
  85930. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85931. /**
  85932. * Set a mat2 in the shader from a Float32Array.
  85933. * @param name Define the name of the uniform as defined in the shader
  85934. * @param value Define the value to give to the uniform
  85935. * @return the material itself allowing "fluent" like uniform updates
  85936. */
  85937. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85938. /**
  85939. * Set a vec2 array in the shader from a number array.
  85940. * @param name Define the name of the uniform as defined in the shader
  85941. * @param value Define the value to give to the uniform
  85942. * @return the material itself allowing "fluent" like uniform updates
  85943. */
  85944. setArray2(name: string, value: number[]): ShaderMaterial;
  85945. /**
  85946. * Set a vec3 array in the shader from a number array.
  85947. * @param name Define the name of the uniform as defined in the shader
  85948. * @param value Define the value to give to the uniform
  85949. * @return the material itself allowing "fluent" like uniform updates
  85950. */
  85951. setArray3(name: string, value: number[]): ShaderMaterial;
  85952. /**
  85953. * Set a vec4 array in the shader from a number array.
  85954. * @param name Define the name of the uniform as defined in the shader
  85955. * @param value Define the value to give to the uniform
  85956. * @return the material itself allowing "fluent" like uniform updates
  85957. */
  85958. setArray4(name: string, value: number[]): ShaderMaterial;
  85959. private _checkCache;
  85960. /**
  85961. * Specifies that the submesh is ready to be used
  85962. * @param mesh defines the mesh to check
  85963. * @param subMesh defines which submesh to check
  85964. * @param useInstances specifies that instances should be used
  85965. * @returns a boolean indicating that the submesh is ready or not
  85966. */
  85967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85968. /**
  85969. * Checks if the material is ready to render the requested mesh
  85970. * @param mesh Define the mesh to render
  85971. * @param useInstances Define whether or not the material is used with instances
  85972. * @returns true if ready, otherwise false
  85973. */
  85974. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85975. /**
  85976. * Binds the world matrix to the material
  85977. * @param world defines the world transformation matrix
  85978. */
  85979. bindOnlyWorldMatrix(world: Matrix): void;
  85980. /**
  85981. * Binds the material to the mesh
  85982. * @param world defines the world transformation matrix
  85983. * @param mesh defines the mesh to bind the material to
  85984. */
  85985. bind(world: Matrix, mesh?: Mesh): void;
  85986. /**
  85987. * Gets the active textures from the material
  85988. * @returns an array of textures
  85989. */
  85990. getActiveTextures(): BaseTexture[];
  85991. /**
  85992. * Specifies if the material uses a texture
  85993. * @param texture defines the texture to check against the material
  85994. * @returns a boolean specifying if the material uses the texture
  85995. */
  85996. hasTexture(texture: BaseTexture): boolean;
  85997. /**
  85998. * Makes a duplicate of the material, and gives it a new name
  85999. * @param name defines the new name for the duplicated material
  86000. * @returns the cloned material
  86001. */
  86002. clone(name: string): ShaderMaterial;
  86003. /**
  86004. * Disposes the material
  86005. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86006. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86007. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86008. */
  86009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86010. /**
  86011. * Serializes this material in a JSON representation
  86012. * @returns the serialized material object
  86013. */
  86014. serialize(): any;
  86015. /**
  86016. * Creates a shader material from parsed shader material data
  86017. * @param source defines the JSON represnetation of the material
  86018. * @param scene defines the hosting scene
  86019. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86020. * @returns a new material
  86021. */
  86022. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86023. }
  86024. }
  86025. declare module BABYLON {
  86026. /** @hidden */
  86027. export var colorPixelShader: {
  86028. name: string;
  86029. shader: string;
  86030. };
  86031. }
  86032. declare module BABYLON {
  86033. /** @hidden */
  86034. export var colorVertexShader: {
  86035. name: string;
  86036. shader: string;
  86037. };
  86038. }
  86039. declare module BABYLON {
  86040. /**
  86041. * Line mesh
  86042. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86043. */
  86044. export class LinesMesh extends Mesh {
  86045. /**
  86046. * If vertex color should be applied to the mesh
  86047. */
  86048. readonly useVertexColor?: boolean | undefined;
  86049. /**
  86050. * If vertex alpha should be applied to the mesh
  86051. */
  86052. readonly useVertexAlpha?: boolean | undefined;
  86053. /**
  86054. * Color of the line (Default: White)
  86055. */
  86056. color: Color3;
  86057. /**
  86058. * Alpha of the line (Default: 1)
  86059. */
  86060. alpha: number;
  86061. /**
  86062. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86063. * This margin is expressed in world space coordinates, so its value may vary.
  86064. * Default value is 0.1
  86065. */
  86066. intersectionThreshold: number;
  86067. private _colorShader;
  86068. private color4;
  86069. /**
  86070. * Creates a new LinesMesh
  86071. * @param name defines the name
  86072. * @param scene defines the hosting scene
  86073. * @param parent defines the parent mesh if any
  86074. * @param source defines the optional source LinesMesh used to clone data from
  86075. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86076. * When false, achieved by calling a clone(), also passing False.
  86077. * This will make creation of children, recursive.
  86078. * @param useVertexColor defines if this LinesMesh supports vertex color
  86079. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86080. */
  86081. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86082. /**
  86083. * If vertex color should be applied to the mesh
  86084. */
  86085. useVertexColor?: boolean | undefined,
  86086. /**
  86087. * If vertex alpha should be applied to the mesh
  86088. */
  86089. useVertexAlpha?: boolean | undefined);
  86090. private _addClipPlaneDefine;
  86091. private _removeClipPlaneDefine;
  86092. isReady(): boolean;
  86093. /**
  86094. * Returns the string "LineMesh"
  86095. */
  86096. getClassName(): string;
  86097. /**
  86098. * @hidden
  86099. */
  86100. /**
  86101. * @hidden
  86102. */
  86103. material: Material;
  86104. /**
  86105. * @hidden
  86106. */
  86107. readonly checkCollisions: boolean;
  86108. /** @hidden */
  86109. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86110. /** @hidden */
  86111. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86112. /**
  86113. * Disposes of the line mesh
  86114. * @param doNotRecurse If children should be disposed
  86115. */
  86116. dispose(doNotRecurse?: boolean): void;
  86117. /**
  86118. * Returns a new LineMesh object cloned from the current one.
  86119. */
  86120. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86121. /**
  86122. * Creates a new InstancedLinesMesh object from the mesh model.
  86123. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86124. * @param name defines the name of the new instance
  86125. * @returns a new InstancedLinesMesh
  86126. */
  86127. createInstance(name: string): InstancedLinesMesh;
  86128. }
  86129. /**
  86130. * Creates an instance based on a source LinesMesh
  86131. */
  86132. export class InstancedLinesMesh extends InstancedMesh {
  86133. /**
  86134. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86135. * This margin is expressed in world space coordinates, so its value may vary.
  86136. * Initilized with the intersectionThreshold value of the source LinesMesh
  86137. */
  86138. intersectionThreshold: number;
  86139. constructor(name: string, source: LinesMesh);
  86140. /**
  86141. * Returns the string "InstancedLinesMesh".
  86142. */
  86143. getClassName(): string;
  86144. }
  86145. }
  86146. declare module BABYLON {
  86147. /** @hidden */
  86148. export var linePixelShader: {
  86149. name: string;
  86150. shader: string;
  86151. };
  86152. }
  86153. declare module BABYLON {
  86154. /** @hidden */
  86155. export var lineVertexShader: {
  86156. name: string;
  86157. shader: string;
  86158. };
  86159. }
  86160. declare module BABYLON {
  86161. interface AbstractMesh {
  86162. /**
  86163. * Gets the edgesRenderer associated with the mesh
  86164. */
  86165. edgesRenderer: Nullable<EdgesRenderer>;
  86166. }
  86167. interface LinesMesh {
  86168. /**
  86169. * Enables the edge rendering mode on the mesh.
  86170. * This mode makes the mesh edges visible
  86171. * @param epsilon defines the maximal distance between two angles to detect a face
  86172. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86173. * @returns the currentAbstractMesh
  86174. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86175. */
  86176. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86177. }
  86178. interface InstancedLinesMesh {
  86179. /**
  86180. * Enables the edge rendering mode on the mesh.
  86181. * This mode makes the mesh edges visible
  86182. * @param epsilon defines the maximal distance between two angles to detect a face
  86183. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86184. * @returns the current InstancedLinesMesh
  86185. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86186. */
  86187. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86188. }
  86189. /**
  86190. * Defines the minimum contract an Edges renderer should follow.
  86191. */
  86192. export interface IEdgesRenderer extends IDisposable {
  86193. /**
  86194. * Gets or sets a boolean indicating if the edgesRenderer is active
  86195. */
  86196. isEnabled: boolean;
  86197. /**
  86198. * Renders the edges of the attached mesh,
  86199. */
  86200. render(): void;
  86201. /**
  86202. * Checks wether or not the edges renderer is ready to render.
  86203. * @return true if ready, otherwise false.
  86204. */
  86205. isReady(): boolean;
  86206. }
  86207. /**
  86208. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86209. */
  86210. export class EdgesRenderer implements IEdgesRenderer {
  86211. /**
  86212. * Define the size of the edges with an orthographic camera
  86213. */
  86214. edgesWidthScalerForOrthographic: number;
  86215. /**
  86216. * Define the size of the edges with a perspective camera
  86217. */
  86218. edgesWidthScalerForPerspective: number;
  86219. protected _source: AbstractMesh;
  86220. protected _linesPositions: number[];
  86221. protected _linesNormals: number[];
  86222. protected _linesIndices: number[];
  86223. protected _epsilon: number;
  86224. protected _indicesCount: number;
  86225. protected _lineShader: ShaderMaterial;
  86226. protected _ib: DataBuffer;
  86227. protected _buffers: {
  86228. [key: string]: Nullable<VertexBuffer>;
  86229. };
  86230. protected _checkVerticesInsteadOfIndices: boolean;
  86231. private _meshRebuildObserver;
  86232. private _meshDisposeObserver;
  86233. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86234. isEnabled: boolean;
  86235. /**
  86236. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86237. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86238. * @param source Mesh used to create edges
  86239. * @param epsilon sum of angles in adjacency to check for edge
  86240. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86241. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86242. */
  86243. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86244. protected _prepareRessources(): void;
  86245. /** @hidden */
  86246. _rebuild(): void;
  86247. /**
  86248. * Releases the required resources for the edges renderer
  86249. */
  86250. dispose(): void;
  86251. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86252. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86253. /**
  86254. * Checks if the pair of p0 and p1 is en edge
  86255. * @param faceIndex
  86256. * @param edge
  86257. * @param faceNormals
  86258. * @param p0
  86259. * @param p1
  86260. * @private
  86261. */
  86262. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86263. /**
  86264. * push line into the position, normal and index buffer
  86265. * @protected
  86266. */
  86267. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86268. /**
  86269. * Generates lines edges from adjacencjes
  86270. * @private
  86271. */
  86272. _generateEdgesLines(): void;
  86273. /**
  86274. * Checks wether or not the edges renderer is ready to render.
  86275. * @return true if ready, otherwise false.
  86276. */
  86277. isReady(): boolean;
  86278. /**
  86279. * Renders the edges of the attached mesh,
  86280. */
  86281. render(): void;
  86282. }
  86283. /**
  86284. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86285. */
  86286. export class LineEdgesRenderer extends EdgesRenderer {
  86287. /**
  86288. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86289. * @param source LineMesh used to generate edges
  86290. * @param epsilon not important (specified angle for edge detection)
  86291. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86292. */
  86293. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86294. /**
  86295. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86296. */
  86297. _generateEdgesLines(): void;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /**
  86302. * This represents the object necessary to create a rendering group.
  86303. * This is exclusively used and created by the rendering manager.
  86304. * To modify the behavior, you use the available helpers in your scene or meshes.
  86305. * @hidden
  86306. */
  86307. export class RenderingGroup {
  86308. index: number;
  86309. private static _zeroVector;
  86310. private _scene;
  86311. private _opaqueSubMeshes;
  86312. private _transparentSubMeshes;
  86313. private _alphaTestSubMeshes;
  86314. private _depthOnlySubMeshes;
  86315. private _particleSystems;
  86316. private _spriteManagers;
  86317. private _opaqueSortCompareFn;
  86318. private _alphaTestSortCompareFn;
  86319. private _transparentSortCompareFn;
  86320. private _renderOpaque;
  86321. private _renderAlphaTest;
  86322. private _renderTransparent;
  86323. /** @hidden */
  86324. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86325. onBeforeTransparentRendering: () => void;
  86326. /**
  86327. * Set the opaque sort comparison function.
  86328. * If null the sub meshes will be render in the order they were created
  86329. */
  86330. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86331. /**
  86332. * Set the alpha test sort comparison function.
  86333. * If null the sub meshes will be render in the order they were created
  86334. */
  86335. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86336. /**
  86337. * Set the transparent sort comparison function.
  86338. * If null the sub meshes will be render in the order they were created
  86339. */
  86340. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86341. /**
  86342. * Creates a new rendering group.
  86343. * @param index The rendering group index
  86344. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86345. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86346. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86347. */
  86348. 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>);
  86349. /**
  86350. * Render all the sub meshes contained in the group.
  86351. * @param customRenderFunction Used to override the default render behaviour of the group.
  86352. * @returns true if rendered some submeshes.
  86353. */
  86354. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86355. /**
  86356. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86357. * @param subMeshes The submeshes to render
  86358. */
  86359. private renderOpaqueSorted;
  86360. /**
  86361. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86362. * @param subMeshes The submeshes to render
  86363. */
  86364. private renderAlphaTestSorted;
  86365. /**
  86366. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86367. * @param subMeshes The submeshes to render
  86368. */
  86369. private renderTransparentSorted;
  86370. /**
  86371. * Renders the submeshes in a specified order.
  86372. * @param subMeshes The submeshes to sort before render
  86373. * @param sortCompareFn The comparison function use to sort
  86374. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86375. * @param transparent Specifies to activate blending if true
  86376. */
  86377. private static renderSorted;
  86378. /**
  86379. * Renders the submeshes in the order they were dispatched (no sort applied).
  86380. * @param subMeshes The submeshes to render
  86381. */
  86382. private static renderUnsorted;
  86383. /**
  86384. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86385. * are rendered back to front if in the same alpha index.
  86386. *
  86387. * @param a The first submesh
  86388. * @param b The second submesh
  86389. * @returns The result of the comparison
  86390. */
  86391. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86392. /**
  86393. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86394. * are rendered back to front.
  86395. *
  86396. * @param a The first submesh
  86397. * @param b The second submesh
  86398. * @returns The result of the comparison
  86399. */
  86400. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86401. /**
  86402. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86403. * are rendered front to back (prevent overdraw).
  86404. *
  86405. * @param a The first submesh
  86406. * @param b The second submesh
  86407. * @returns The result of the comparison
  86408. */
  86409. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86410. /**
  86411. * Resets the different lists of submeshes to prepare a new frame.
  86412. */
  86413. prepare(): void;
  86414. dispose(): void;
  86415. /**
  86416. * Inserts the submesh in its correct queue depending on its material.
  86417. * @param subMesh The submesh to dispatch
  86418. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86419. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86420. */
  86421. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86422. dispatchSprites(spriteManager: ISpriteManager): void;
  86423. dispatchParticles(particleSystem: IParticleSystem): void;
  86424. private _renderParticles;
  86425. private _renderSprites;
  86426. }
  86427. }
  86428. declare module BABYLON {
  86429. /**
  86430. * Interface describing the different options available in the rendering manager
  86431. * regarding Auto Clear between groups.
  86432. */
  86433. export interface IRenderingManagerAutoClearSetup {
  86434. /**
  86435. * Defines whether or not autoclear is enable.
  86436. */
  86437. autoClear: boolean;
  86438. /**
  86439. * Defines whether or not to autoclear the depth buffer.
  86440. */
  86441. depth: boolean;
  86442. /**
  86443. * Defines whether or not to autoclear the stencil buffer.
  86444. */
  86445. stencil: boolean;
  86446. }
  86447. /**
  86448. * This class is used by the onRenderingGroupObservable
  86449. */
  86450. export class RenderingGroupInfo {
  86451. /**
  86452. * The Scene that being rendered
  86453. */
  86454. scene: Scene;
  86455. /**
  86456. * The camera currently used for the rendering pass
  86457. */
  86458. camera: Nullable<Camera>;
  86459. /**
  86460. * The ID of the renderingGroup being processed
  86461. */
  86462. renderingGroupId: number;
  86463. }
  86464. /**
  86465. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86466. * It is enable to manage the different groups as well as the different necessary sort functions.
  86467. * This should not be used directly aside of the few static configurations
  86468. */
  86469. export class RenderingManager {
  86470. /**
  86471. * The max id used for rendering groups (not included)
  86472. */
  86473. static MAX_RENDERINGGROUPS: number;
  86474. /**
  86475. * The min id used for rendering groups (included)
  86476. */
  86477. static MIN_RENDERINGGROUPS: number;
  86478. /**
  86479. * Used to globally prevent autoclearing scenes.
  86480. */
  86481. static AUTOCLEAR: boolean;
  86482. /**
  86483. * @hidden
  86484. */
  86485. _useSceneAutoClearSetup: boolean;
  86486. private _scene;
  86487. private _renderingGroups;
  86488. private _depthStencilBufferAlreadyCleaned;
  86489. private _autoClearDepthStencil;
  86490. private _customOpaqueSortCompareFn;
  86491. private _customAlphaTestSortCompareFn;
  86492. private _customTransparentSortCompareFn;
  86493. private _renderingGroupInfo;
  86494. /**
  86495. * Instantiates a new rendering group for a particular scene
  86496. * @param scene Defines the scene the groups belongs to
  86497. */
  86498. constructor(scene: Scene);
  86499. private _clearDepthStencilBuffer;
  86500. /**
  86501. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86502. * @hidden
  86503. */
  86504. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86505. /**
  86506. * Resets the different information of the group to prepare a new frame
  86507. * @hidden
  86508. */
  86509. reset(): void;
  86510. /**
  86511. * Dispose and release the group and its associated resources.
  86512. * @hidden
  86513. */
  86514. dispose(): void;
  86515. /**
  86516. * Clear the info related to rendering groups preventing retention points during dispose.
  86517. */
  86518. freeRenderingGroups(): void;
  86519. private _prepareRenderingGroup;
  86520. /**
  86521. * Add a sprite manager to the rendering manager in order to render it this frame.
  86522. * @param spriteManager Define the sprite manager to render
  86523. */
  86524. dispatchSprites(spriteManager: ISpriteManager): void;
  86525. /**
  86526. * Add a particle system to the rendering manager in order to render it this frame.
  86527. * @param particleSystem Define the particle system to render
  86528. */
  86529. dispatchParticles(particleSystem: IParticleSystem): void;
  86530. /**
  86531. * Add a submesh to the manager in order to render it this frame
  86532. * @param subMesh The submesh to dispatch
  86533. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86534. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86535. */
  86536. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86537. /**
  86538. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86539. * This allowed control for front to back rendering or reversly depending of the special needs.
  86540. *
  86541. * @param renderingGroupId The rendering group id corresponding to its index
  86542. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86543. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86544. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86545. */
  86546. 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;
  86547. /**
  86548. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86549. *
  86550. * @param renderingGroupId The rendering group id corresponding to its index
  86551. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86552. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86553. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86554. */
  86555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86556. /**
  86557. * Gets the current auto clear configuration for one rendering group of the rendering
  86558. * manager.
  86559. * @param index the rendering group index to get the information for
  86560. * @returns The auto clear setup for the requested rendering group
  86561. */
  86562. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86563. }
  86564. }
  86565. declare module BABYLON {
  86566. /**
  86567. * This Helps creating a texture that will be created from a camera in your scene.
  86568. * It is basically a dynamic texture that could be used to create special effects for instance.
  86569. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86570. */
  86571. export class RenderTargetTexture extends Texture {
  86572. isCube: boolean;
  86573. /**
  86574. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86575. */
  86576. static readonly REFRESHRATE_RENDER_ONCE: number;
  86577. /**
  86578. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86579. */
  86580. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86581. /**
  86582. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86583. * the central point of your effect and can save a lot of performances.
  86584. */
  86585. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86586. /**
  86587. * Use this predicate to dynamically define the list of mesh you want to render.
  86588. * If set, the renderList property will be overwritten.
  86589. */
  86590. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86591. private _renderList;
  86592. /**
  86593. * Use this list to define the list of mesh you want to render.
  86594. */
  86595. renderList: Nullable<Array<AbstractMesh>>;
  86596. private _hookArray;
  86597. /**
  86598. * Define if particles should be rendered in your texture.
  86599. */
  86600. renderParticles: boolean;
  86601. /**
  86602. * Define if sprites should be rendered in your texture.
  86603. */
  86604. renderSprites: boolean;
  86605. /**
  86606. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86607. */
  86608. coordinatesMode: number;
  86609. /**
  86610. * Define the camera used to render the texture.
  86611. */
  86612. activeCamera: Nullable<Camera>;
  86613. /**
  86614. * Override the render function of the texture with your own one.
  86615. */
  86616. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86617. /**
  86618. * Define if camera post processes should be use while rendering the texture.
  86619. */
  86620. useCameraPostProcesses: boolean;
  86621. /**
  86622. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86623. */
  86624. ignoreCameraViewport: boolean;
  86625. private _postProcessManager;
  86626. private _postProcesses;
  86627. private _resizeObserver;
  86628. /**
  86629. * An event triggered when the texture is unbind.
  86630. */
  86631. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86632. /**
  86633. * An event triggered when the texture is unbind.
  86634. */
  86635. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86636. private _onAfterUnbindObserver;
  86637. /**
  86638. * Set a after unbind callback in the texture.
  86639. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86640. */
  86641. onAfterUnbind: () => void;
  86642. /**
  86643. * An event triggered before rendering the texture
  86644. */
  86645. onBeforeRenderObservable: Observable<number>;
  86646. private _onBeforeRenderObserver;
  86647. /**
  86648. * Set a before render callback in the texture.
  86649. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86650. */
  86651. onBeforeRender: (faceIndex: number) => void;
  86652. /**
  86653. * An event triggered after rendering the texture
  86654. */
  86655. onAfterRenderObservable: Observable<number>;
  86656. private _onAfterRenderObserver;
  86657. /**
  86658. * Set a after render callback in the texture.
  86659. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86660. */
  86661. onAfterRender: (faceIndex: number) => void;
  86662. /**
  86663. * An event triggered after the texture clear
  86664. */
  86665. onClearObservable: Observable<Engine>;
  86666. private _onClearObserver;
  86667. /**
  86668. * Set a clear callback in the texture.
  86669. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86670. */
  86671. onClear: (Engine: Engine) => void;
  86672. /**
  86673. * An event triggered when the texture is resized.
  86674. */
  86675. onResizeObservable: Observable<RenderTargetTexture>;
  86676. /**
  86677. * Define the clear color of the Render Target if it should be different from the scene.
  86678. */
  86679. clearColor: Color4;
  86680. protected _size: number | {
  86681. width: number;
  86682. height: number;
  86683. };
  86684. protected _initialSizeParameter: number | {
  86685. width: number;
  86686. height: number;
  86687. } | {
  86688. ratio: number;
  86689. };
  86690. protected _sizeRatio: Nullable<number>;
  86691. /** @hidden */
  86692. _generateMipMaps: boolean;
  86693. protected _renderingManager: RenderingManager;
  86694. /** @hidden */
  86695. _waitingRenderList: string[];
  86696. protected _doNotChangeAspectRatio: boolean;
  86697. protected _currentRefreshId: number;
  86698. protected _refreshRate: number;
  86699. protected _textureMatrix: Matrix;
  86700. protected _samples: number;
  86701. protected _renderTargetOptions: RenderTargetCreationOptions;
  86702. /**
  86703. * Gets render target creation options that were used.
  86704. */
  86705. readonly renderTargetOptions: RenderTargetCreationOptions;
  86706. protected _engine: Engine;
  86707. protected _onRatioRescale(): void;
  86708. /**
  86709. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86710. * It must define where the camera used to render the texture is set
  86711. */
  86712. boundingBoxPosition: Vector3;
  86713. private _boundingBoxSize;
  86714. /**
  86715. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86716. * When defined, the cubemap will switch to local mode
  86717. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86718. * @example https://www.babylonjs-playground.com/#RNASML
  86719. */
  86720. boundingBoxSize: Vector3;
  86721. /**
  86722. * In case the RTT has been created with a depth texture, get the associated
  86723. * depth texture.
  86724. * Otherwise, return null.
  86725. */
  86726. depthStencilTexture: Nullable<InternalTexture>;
  86727. /**
  86728. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86729. * or used a shadow, depth texture...
  86730. * @param name The friendly name of the texture
  86731. * @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)
  86732. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86733. * @param generateMipMaps True if mip maps need to be generated after render.
  86734. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86735. * @param type The type of the buffer in the RTT (int, half float, float...)
  86736. * @param isCube True if a cube texture needs to be created
  86737. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86738. * @param generateDepthBuffer True to generate a depth buffer
  86739. * @param generateStencilBuffer True to generate a stencil buffer
  86740. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86741. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86742. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86743. */
  86744. constructor(name: string, size: number | {
  86745. width: number;
  86746. height: number;
  86747. } | {
  86748. ratio: number;
  86749. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86750. /**
  86751. * Creates a depth stencil texture.
  86752. * This is only available in WebGL 2 or with the depth texture extension available.
  86753. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86754. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86755. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86756. */
  86757. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86758. private _processSizeParameter;
  86759. /**
  86760. * Define the number of samples to use in case of MSAA.
  86761. * It defaults to one meaning no MSAA has been enabled.
  86762. */
  86763. samples: number;
  86764. /**
  86765. * Resets the refresh counter of the texture and start bak from scratch.
  86766. * Could be useful to regenerate the texture if it is setup to render only once.
  86767. */
  86768. resetRefreshCounter(): void;
  86769. /**
  86770. * Define the refresh rate of the texture or the rendering frequency.
  86771. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86772. */
  86773. refreshRate: number;
  86774. /**
  86775. * Adds a post process to the render target rendering passes.
  86776. * @param postProcess define the post process to add
  86777. */
  86778. addPostProcess(postProcess: PostProcess): void;
  86779. /**
  86780. * Clear all the post processes attached to the render target
  86781. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86782. */
  86783. clearPostProcesses(dispose?: boolean): void;
  86784. /**
  86785. * Remove one of the post process from the list of attached post processes to the texture
  86786. * @param postProcess define the post process to remove from the list
  86787. */
  86788. removePostProcess(postProcess: PostProcess): void;
  86789. /** @hidden */
  86790. _shouldRender(): boolean;
  86791. /**
  86792. * Gets the actual render size of the texture.
  86793. * @returns the width of the render size
  86794. */
  86795. getRenderSize(): number;
  86796. /**
  86797. * Gets the actual render width of the texture.
  86798. * @returns the width of the render size
  86799. */
  86800. getRenderWidth(): number;
  86801. /**
  86802. * Gets the actual render height of the texture.
  86803. * @returns the height of the render size
  86804. */
  86805. getRenderHeight(): number;
  86806. /**
  86807. * Get if the texture can be rescaled or not.
  86808. */
  86809. readonly canRescale: boolean;
  86810. /**
  86811. * Resize the texture using a ratio.
  86812. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86813. */
  86814. scale(ratio: number): void;
  86815. /**
  86816. * Get the texture reflection matrix used to rotate/transform the reflection.
  86817. * @returns the reflection matrix
  86818. */
  86819. getReflectionTextureMatrix(): Matrix;
  86820. /**
  86821. * Resize the texture to a new desired size.
  86822. * Be carrefull as it will recreate all the data in the new texture.
  86823. * @param size Define the new size. It can be:
  86824. * - a number for squared texture,
  86825. * - an object containing { width: number, height: number }
  86826. * - or an object containing a ratio { ratio: number }
  86827. */
  86828. resize(size: number | {
  86829. width: number;
  86830. height: number;
  86831. } | {
  86832. ratio: number;
  86833. }): void;
  86834. /**
  86835. * Renders all the objects from the render list into the texture.
  86836. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86837. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86838. */
  86839. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86840. private _bestReflectionRenderTargetDimension;
  86841. /**
  86842. * @hidden
  86843. * @param faceIndex face index to bind to if this is a cubetexture
  86844. */
  86845. _bindFrameBuffer(faceIndex?: number): void;
  86846. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86847. private renderToTarget;
  86848. /**
  86849. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86850. * This allowed control for front to back rendering or reversly depending of the special needs.
  86851. *
  86852. * @param renderingGroupId The rendering group id corresponding to its index
  86853. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86854. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86855. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86856. */
  86857. 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;
  86858. /**
  86859. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86860. *
  86861. * @param renderingGroupId The rendering group id corresponding to its index
  86862. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86863. */
  86864. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86865. /**
  86866. * Clones the texture.
  86867. * @returns the cloned texture
  86868. */
  86869. clone(): RenderTargetTexture;
  86870. /**
  86871. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86872. * @returns The JSON representation of the texture
  86873. */
  86874. serialize(): any;
  86875. /**
  86876. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86877. */
  86878. disposeFramebufferObjects(): void;
  86879. /**
  86880. * Dispose the texture and release its associated resources.
  86881. */
  86882. dispose(): void;
  86883. /** @hidden */
  86884. _rebuild(): void;
  86885. /**
  86886. * Clear the info related to rendering groups preventing retention point in material dispose.
  86887. */
  86888. freeRenderingGroups(): void;
  86889. /**
  86890. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86891. * @returns the view count
  86892. */
  86893. getViewCount(): number;
  86894. }
  86895. }
  86896. declare module BABYLON {
  86897. /**
  86898. * Base class for the main features of a material in Babylon.js
  86899. */
  86900. export class Material implements IAnimatable {
  86901. /**
  86902. * Returns the triangle fill mode
  86903. */
  86904. static readonly TriangleFillMode: number;
  86905. /**
  86906. * Returns the wireframe mode
  86907. */
  86908. static readonly WireFrameFillMode: number;
  86909. /**
  86910. * Returns the point fill mode
  86911. */
  86912. static readonly PointFillMode: number;
  86913. /**
  86914. * Returns the point list draw mode
  86915. */
  86916. static readonly PointListDrawMode: number;
  86917. /**
  86918. * Returns the line list draw mode
  86919. */
  86920. static readonly LineListDrawMode: number;
  86921. /**
  86922. * Returns the line loop draw mode
  86923. */
  86924. static readonly LineLoopDrawMode: number;
  86925. /**
  86926. * Returns the line strip draw mode
  86927. */
  86928. static readonly LineStripDrawMode: number;
  86929. /**
  86930. * Returns the triangle strip draw mode
  86931. */
  86932. static readonly TriangleStripDrawMode: number;
  86933. /**
  86934. * Returns the triangle fan draw mode
  86935. */
  86936. static readonly TriangleFanDrawMode: number;
  86937. /**
  86938. * Stores the clock-wise side orientation
  86939. */
  86940. static readonly ClockWiseSideOrientation: number;
  86941. /**
  86942. * Stores the counter clock-wise side orientation
  86943. */
  86944. static readonly CounterClockWiseSideOrientation: number;
  86945. /**
  86946. * The dirty texture flag value
  86947. */
  86948. static readonly TextureDirtyFlag: number;
  86949. /**
  86950. * The dirty light flag value
  86951. */
  86952. static readonly LightDirtyFlag: number;
  86953. /**
  86954. * The dirty fresnel flag value
  86955. */
  86956. static readonly FresnelDirtyFlag: number;
  86957. /**
  86958. * The dirty attribute flag value
  86959. */
  86960. static readonly AttributesDirtyFlag: number;
  86961. /**
  86962. * The dirty misc flag value
  86963. */
  86964. static readonly MiscDirtyFlag: number;
  86965. /**
  86966. * The all dirty flag value
  86967. */
  86968. static readonly AllDirtyFlag: number;
  86969. /**
  86970. * The ID of the material
  86971. */
  86972. id: string;
  86973. /**
  86974. * Gets or sets the unique id of the material
  86975. */
  86976. uniqueId: number;
  86977. /**
  86978. * The name of the material
  86979. */
  86980. name: string;
  86981. /**
  86982. * Gets or sets user defined metadata
  86983. */
  86984. metadata: any;
  86985. /**
  86986. * For internal use only. Please do not use.
  86987. */
  86988. reservedDataStore: any;
  86989. /**
  86990. * Specifies if the ready state should be checked on each call
  86991. */
  86992. checkReadyOnEveryCall: boolean;
  86993. /**
  86994. * Specifies if the ready state should be checked once
  86995. */
  86996. checkReadyOnlyOnce: boolean;
  86997. /**
  86998. * The state of the material
  86999. */
  87000. state: string;
  87001. /**
  87002. * The alpha value of the material
  87003. */
  87004. protected _alpha: number;
  87005. /**
  87006. * List of inspectable custom properties (used by the Inspector)
  87007. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87008. */
  87009. inspectableCustomProperties: IInspectable[];
  87010. /**
  87011. * Sets the alpha value of the material
  87012. */
  87013. /**
  87014. * Gets the alpha value of the material
  87015. */
  87016. alpha: number;
  87017. /**
  87018. * Specifies if back face culling is enabled
  87019. */
  87020. protected _backFaceCulling: boolean;
  87021. /**
  87022. * Sets the back-face culling state
  87023. */
  87024. /**
  87025. * Gets the back-face culling state
  87026. */
  87027. backFaceCulling: boolean;
  87028. /**
  87029. * Stores the value for side orientation
  87030. */
  87031. sideOrientation: number;
  87032. /**
  87033. * Callback triggered when the material is compiled
  87034. */
  87035. onCompiled: Nullable<(effect: Effect) => void>;
  87036. /**
  87037. * Callback triggered when an error occurs
  87038. */
  87039. onError: Nullable<(effect: Effect, errors: string) => void>;
  87040. /**
  87041. * Callback triggered to get the render target textures
  87042. */
  87043. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87044. /**
  87045. * Gets a boolean indicating that current material needs to register RTT
  87046. */
  87047. readonly hasRenderTargetTextures: boolean;
  87048. /**
  87049. * Specifies if the material should be serialized
  87050. */
  87051. doNotSerialize: boolean;
  87052. /**
  87053. * @hidden
  87054. */
  87055. _storeEffectOnSubMeshes: boolean;
  87056. /**
  87057. * Stores the animations for the material
  87058. */
  87059. animations: Nullable<Array<Animation>>;
  87060. /**
  87061. * An event triggered when the material is disposed
  87062. */
  87063. onDisposeObservable: Observable<Material>;
  87064. /**
  87065. * An observer which watches for dispose events
  87066. */
  87067. private _onDisposeObserver;
  87068. private _onUnBindObservable;
  87069. /**
  87070. * Called during a dispose event
  87071. */
  87072. onDispose: () => void;
  87073. private _onBindObservable;
  87074. /**
  87075. * An event triggered when the material is bound
  87076. */
  87077. readonly onBindObservable: Observable<AbstractMesh>;
  87078. /**
  87079. * An observer which watches for bind events
  87080. */
  87081. private _onBindObserver;
  87082. /**
  87083. * Called during a bind event
  87084. */
  87085. onBind: (Mesh: AbstractMesh) => void;
  87086. /**
  87087. * An event triggered when the material is unbound
  87088. */
  87089. readonly onUnBindObservable: Observable<Material>;
  87090. /**
  87091. * Stores the value of the alpha mode
  87092. */
  87093. private _alphaMode;
  87094. /**
  87095. * Sets the value of the alpha mode.
  87096. *
  87097. * | Value | Type | Description |
  87098. * | --- | --- | --- |
  87099. * | 0 | ALPHA_DISABLE | |
  87100. * | 1 | ALPHA_ADD | |
  87101. * | 2 | ALPHA_COMBINE | |
  87102. * | 3 | ALPHA_SUBTRACT | |
  87103. * | 4 | ALPHA_MULTIPLY | |
  87104. * | 5 | ALPHA_MAXIMIZED | |
  87105. * | 6 | ALPHA_ONEONE | |
  87106. * | 7 | ALPHA_PREMULTIPLIED | |
  87107. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87108. * | 9 | ALPHA_INTERPOLATE | |
  87109. * | 10 | ALPHA_SCREENMODE | |
  87110. *
  87111. */
  87112. /**
  87113. * Gets the value of the alpha mode
  87114. */
  87115. alphaMode: number;
  87116. /**
  87117. * Stores the state of the need depth pre-pass value
  87118. */
  87119. private _needDepthPrePass;
  87120. /**
  87121. * Sets the need depth pre-pass value
  87122. */
  87123. /**
  87124. * Gets the depth pre-pass value
  87125. */
  87126. needDepthPrePass: boolean;
  87127. /**
  87128. * Specifies if depth writing should be disabled
  87129. */
  87130. disableDepthWrite: boolean;
  87131. /**
  87132. * Specifies if depth writing should be forced
  87133. */
  87134. forceDepthWrite: boolean;
  87135. /**
  87136. * Specifies if there should be a separate pass for culling
  87137. */
  87138. separateCullingPass: boolean;
  87139. /**
  87140. * Stores the state specifing if fog should be enabled
  87141. */
  87142. private _fogEnabled;
  87143. /**
  87144. * Sets the state for enabling fog
  87145. */
  87146. /**
  87147. * Gets the value of the fog enabled state
  87148. */
  87149. fogEnabled: boolean;
  87150. /**
  87151. * Stores the size of points
  87152. */
  87153. pointSize: number;
  87154. /**
  87155. * Stores the z offset value
  87156. */
  87157. zOffset: number;
  87158. /**
  87159. * Gets a value specifying if wireframe mode is enabled
  87160. */
  87161. /**
  87162. * Sets the state of wireframe mode
  87163. */
  87164. wireframe: boolean;
  87165. /**
  87166. * Gets the value specifying if point clouds are enabled
  87167. */
  87168. /**
  87169. * Sets the state of point cloud mode
  87170. */
  87171. pointsCloud: boolean;
  87172. /**
  87173. * Gets the material fill mode
  87174. */
  87175. /**
  87176. * Sets the material fill mode
  87177. */
  87178. fillMode: number;
  87179. /**
  87180. * @hidden
  87181. * Stores the effects for the material
  87182. */
  87183. _effect: Nullable<Effect>;
  87184. /**
  87185. * @hidden
  87186. * Specifies if the material was previously ready
  87187. */
  87188. _wasPreviouslyReady: boolean;
  87189. /**
  87190. * Specifies if uniform buffers should be used
  87191. */
  87192. private _useUBO;
  87193. /**
  87194. * Stores a reference to the scene
  87195. */
  87196. private _scene;
  87197. /**
  87198. * Stores the fill mode state
  87199. */
  87200. private _fillMode;
  87201. /**
  87202. * Specifies if the depth write state should be cached
  87203. */
  87204. private _cachedDepthWriteState;
  87205. /**
  87206. * Stores the uniform buffer
  87207. */
  87208. protected _uniformBuffer: UniformBuffer;
  87209. /** @hidden */
  87210. _indexInSceneMaterialArray: number;
  87211. /** @hidden */
  87212. meshMap: Nullable<{
  87213. [id: string]: AbstractMesh | undefined;
  87214. }>;
  87215. /**
  87216. * Creates a material instance
  87217. * @param name defines the name of the material
  87218. * @param scene defines the scene to reference
  87219. * @param doNotAdd specifies if the material should be added to the scene
  87220. */
  87221. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87222. /**
  87223. * Returns a string representation of the current material
  87224. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87225. * @returns a string with material information
  87226. */
  87227. toString(fullDetails?: boolean): string;
  87228. /**
  87229. * Gets the class name of the material
  87230. * @returns a string with the class name of the material
  87231. */
  87232. getClassName(): string;
  87233. /**
  87234. * Specifies if updates for the material been locked
  87235. */
  87236. readonly isFrozen: boolean;
  87237. /**
  87238. * Locks updates for the material
  87239. */
  87240. freeze(): void;
  87241. /**
  87242. * Unlocks updates for the material
  87243. */
  87244. unfreeze(): void;
  87245. /**
  87246. * Specifies if the material is ready to be used
  87247. * @param mesh defines the mesh to check
  87248. * @param useInstances specifies if instances should be used
  87249. * @returns a boolean indicating if the material is ready to be used
  87250. */
  87251. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87252. /**
  87253. * Specifies that the submesh is ready to be used
  87254. * @param mesh defines the mesh to check
  87255. * @param subMesh defines which submesh to check
  87256. * @param useInstances specifies that instances should be used
  87257. * @returns a boolean indicating that the submesh is ready or not
  87258. */
  87259. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87260. /**
  87261. * Returns the material effect
  87262. * @returns the effect associated with the material
  87263. */
  87264. getEffect(): Nullable<Effect>;
  87265. /**
  87266. * Returns the current scene
  87267. * @returns a Scene
  87268. */
  87269. getScene(): Scene;
  87270. /**
  87271. * Specifies if the material will require alpha blending
  87272. * @returns a boolean specifying if alpha blending is needed
  87273. */
  87274. needAlphaBlending(): boolean;
  87275. /**
  87276. * Specifies if the mesh will require alpha blending
  87277. * @param mesh defines the mesh to check
  87278. * @returns a boolean specifying if alpha blending is needed for the mesh
  87279. */
  87280. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87281. /**
  87282. * Specifies if this material should be rendered in alpha test mode
  87283. * @returns a boolean specifying if an alpha test is needed.
  87284. */
  87285. needAlphaTesting(): boolean;
  87286. /**
  87287. * Gets the texture used for the alpha test
  87288. * @returns the texture to use for alpha testing
  87289. */
  87290. getAlphaTestTexture(): Nullable<BaseTexture>;
  87291. /**
  87292. * Marks the material to indicate that it needs to be re-calculated
  87293. */
  87294. markDirty(): void;
  87295. /** @hidden */
  87296. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87297. /**
  87298. * Binds the material to the mesh
  87299. * @param world defines the world transformation matrix
  87300. * @param mesh defines the mesh to bind the material to
  87301. */
  87302. bind(world: Matrix, mesh?: Mesh): void;
  87303. /**
  87304. * Binds the submesh to the material
  87305. * @param world defines the world transformation matrix
  87306. * @param mesh defines the mesh containing the submesh
  87307. * @param subMesh defines the submesh to bind the material to
  87308. */
  87309. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87310. /**
  87311. * Binds the world matrix to the material
  87312. * @param world defines the world transformation matrix
  87313. */
  87314. bindOnlyWorldMatrix(world: Matrix): void;
  87315. /**
  87316. * Binds the scene's uniform buffer to the effect.
  87317. * @param effect defines the effect to bind to the scene uniform buffer
  87318. * @param sceneUbo defines the uniform buffer storing scene data
  87319. */
  87320. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87321. /**
  87322. * Binds the view matrix to the effect
  87323. * @param effect defines the effect to bind the view matrix to
  87324. */
  87325. bindView(effect: Effect): void;
  87326. /**
  87327. * Binds the view projection matrix to the effect
  87328. * @param effect defines the effect to bind the view projection matrix to
  87329. */
  87330. bindViewProjection(effect: Effect): void;
  87331. /**
  87332. * Specifies if material alpha testing should be turned on for the mesh
  87333. * @param mesh defines the mesh to check
  87334. */
  87335. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87336. /**
  87337. * Processes to execute after binding the material to a mesh
  87338. * @param mesh defines the rendered mesh
  87339. */
  87340. protected _afterBind(mesh?: Mesh): void;
  87341. /**
  87342. * Unbinds the material from the mesh
  87343. */
  87344. unbind(): void;
  87345. /**
  87346. * Gets the active textures from the material
  87347. * @returns an array of textures
  87348. */
  87349. getActiveTextures(): BaseTexture[];
  87350. /**
  87351. * Specifies if the material uses a texture
  87352. * @param texture defines the texture to check against the material
  87353. * @returns a boolean specifying if the material uses the texture
  87354. */
  87355. hasTexture(texture: BaseTexture): boolean;
  87356. /**
  87357. * Makes a duplicate of the material, and gives it a new name
  87358. * @param name defines the new name for the duplicated material
  87359. * @returns the cloned material
  87360. */
  87361. clone(name: string): Nullable<Material>;
  87362. /**
  87363. * Gets the meshes bound to the material
  87364. * @returns an array of meshes bound to the material
  87365. */
  87366. getBindedMeshes(): AbstractMesh[];
  87367. /**
  87368. * Force shader compilation
  87369. * @param mesh defines the mesh associated with this material
  87370. * @param onCompiled defines a function to execute once the material is compiled
  87371. * @param options defines the options to configure the compilation
  87372. */
  87373. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87374. clipPlane: boolean;
  87375. }>): void;
  87376. /**
  87377. * Force shader compilation
  87378. * @param mesh defines the mesh that will use this material
  87379. * @param options defines additional options for compiling the shaders
  87380. * @returns a promise that resolves when the compilation completes
  87381. */
  87382. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87383. clipPlane: boolean;
  87384. }>): Promise<void>;
  87385. private static readonly _AllDirtyCallBack;
  87386. private static readonly _ImageProcessingDirtyCallBack;
  87387. private static readonly _TextureDirtyCallBack;
  87388. private static readonly _FresnelDirtyCallBack;
  87389. private static readonly _MiscDirtyCallBack;
  87390. private static readonly _LightsDirtyCallBack;
  87391. private static readonly _AttributeDirtyCallBack;
  87392. private static _FresnelAndMiscDirtyCallBack;
  87393. private static _TextureAndMiscDirtyCallBack;
  87394. private static readonly _DirtyCallbackArray;
  87395. private static readonly _RunDirtyCallBacks;
  87396. /**
  87397. * Marks a define in the material to indicate that it needs to be re-computed
  87398. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87399. */
  87400. markAsDirty(flag: number): void;
  87401. /**
  87402. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87403. * @param func defines a function which checks material defines against the submeshes
  87404. */
  87405. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87406. /**
  87407. * Indicates that we need to re-calculated for all submeshes
  87408. */
  87409. protected _markAllSubMeshesAsAllDirty(): void;
  87410. /**
  87411. * Indicates that image processing needs to be re-calculated for all submeshes
  87412. */
  87413. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87414. /**
  87415. * Indicates that textures need to be re-calculated for all submeshes
  87416. */
  87417. protected _markAllSubMeshesAsTexturesDirty(): void;
  87418. /**
  87419. * Indicates that fresnel needs to be re-calculated for all submeshes
  87420. */
  87421. protected _markAllSubMeshesAsFresnelDirty(): void;
  87422. /**
  87423. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87424. */
  87425. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87426. /**
  87427. * Indicates that lights need to be re-calculated for all submeshes
  87428. */
  87429. protected _markAllSubMeshesAsLightsDirty(): void;
  87430. /**
  87431. * Indicates that attributes need to be re-calculated for all submeshes
  87432. */
  87433. protected _markAllSubMeshesAsAttributesDirty(): void;
  87434. /**
  87435. * Indicates that misc needs to be re-calculated for all submeshes
  87436. */
  87437. protected _markAllSubMeshesAsMiscDirty(): void;
  87438. /**
  87439. * Indicates that textures and misc need to be re-calculated for all submeshes
  87440. */
  87441. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87442. /**
  87443. * Disposes the material
  87444. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87445. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87446. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87447. */
  87448. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87449. /** @hidden */
  87450. private releaseVertexArrayObject;
  87451. /**
  87452. * Serializes this material
  87453. * @returns the serialized material object
  87454. */
  87455. serialize(): any;
  87456. /**
  87457. * Creates a material from parsed material data
  87458. * @param parsedMaterial defines parsed material data
  87459. * @param scene defines the hosting scene
  87460. * @param rootUrl defines the root URL to use to load textures
  87461. * @returns a new material
  87462. */
  87463. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87464. }
  87465. }
  87466. declare module BABYLON {
  87467. /**
  87468. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87469. * separate meshes. This can be use to improve performances.
  87470. * @see http://doc.babylonjs.com/how_to/multi_materials
  87471. */
  87472. export class MultiMaterial extends Material {
  87473. private _subMaterials;
  87474. /**
  87475. * Gets or Sets the list of Materials used within the multi material.
  87476. * They need to be ordered according to the submeshes order in the associated mesh
  87477. */
  87478. subMaterials: Nullable<Material>[];
  87479. /**
  87480. * Function used to align with Node.getChildren()
  87481. * @returns the list of Materials used within the multi material
  87482. */
  87483. getChildren(): Nullable<Material>[];
  87484. /**
  87485. * Instantiates a new Multi Material
  87486. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87487. * separate meshes. This can be use to improve performances.
  87488. * @see http://doc.babylonjs.com/how_to/multi_materials
  87489. * @param name Define the name in the scene
  87490. * @param scene Define the scene the material belongs to
  87491. */
  87492. constructor(name: string, scene: Scene);
  87493. private _hookArray;
  87494. /**
  87495. * Get one of the submaterial by its index in the submaterials array
  87496. * @param index The index to look the sub material at
  87497. * @returns The Material if the index has been defined
  87498. */
  87499. getSubMaterial(index: number): Nullable<Material>;
  87500. /**
  87501. * Get the list of active textures for the whole sub materials list.
  87502. * @returns All the textures that will be used during the rendering
  87503. */
  87504. getActiveTextures(): BaseTexture[];
  87505. /**
  87506. * Gets the current class name of the material e.g. "MultiMaterial"
  87507. * Mainly use in serialization.
  87508. * @returns the class name
  87509. */
  87510. getClassName(): string;
  87511. /**
  87512. * Checks if the material is ready to render the requested sub mesh
  87513. * @param mesh Define the mesh the submesh belongs to
  87514. * @param subMesh Define the sub mesh to look readyness for
  87515. * @param useInstances Define whether or not the material is used with instances
  87516. * @returns true if ready, otherwise false
  87517. */
  87518. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87519. /**
  87520. * Clones the current material and its related sub materials
  87521. * @param name Define the name of the newly cloned material
  87522. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87523. * @returns the cloned material
  87524. */
  87525. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87526. /**
  87527. * Serializes the materials into a JSON representation.
  87528. * @returns the JSON representation
  87529. */
  87530. serialize(): any;
  87531. /**
  87532. * Dispose the material and release its associated resources
  87533. * @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)
  87534. * @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)
  87535. * @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)
  87536. */
  87537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87538. /**
  87539. * Creates a MultiMaterial from parsed MultiMaterial data.
  87540. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87541. * @param scene defines the hosting scene
  87542. * @returns a new MultiMaterial
  87543. */
  87544. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87545. }
  87546. }
  87547. declare module BABYLON {
  87548. /**
  87549. * Base class for submeshes
  87550. */
  87551. export class BaseSubMesh {
  87552. /** @hidden */
  87553. _materialDefines: Nullable<MaterialDefines>;
  87554. /** @hidden */
  87555. _materialEffect: Nullable<Effect>;
  87556. /**
  87557. * Gets associated effect
  87558. */
  87559. readonly effect: Nullable<Effect>;
  87560. /**
  87561. * Sets associated effect (effect used to render this submesh)
  87562. * @param effect defines the effect to associate with
  87563. * @param defines defines the set of defines used to compile this effect
  87564. */
  87565. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87566. }
  87567. /**
  87568. * Defines a subdivision inside a mesh
  87569. */
  87570. export class SubMesh extends BaseSubMesh implements ICullable {
  87571. /** the material index to use */
  87572. materialIndex: number;
  87573. /** vertex index start */
  87574. verticesStart: number;
  87575. /** vertices count */
  87576. verticesCount: number;
  87577. /** index start */
  87578. indexStart: number;
  87579. /** indices count */
  87580. indexCount: number;
  87581. /** @hidden */
  87582. _linesIndexCount: number;
  87583. private _mesh;
  87584. private _renderingMesh;
  87585. private _boundingInfo;
  87586. private _linesIndexBuffer;
  87587. /** @hidden */
  87588. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87589. /** @hidden */
  87590. _trianglePlanes: Plane[];
  87591. /** @hidden */
  87592. _lastColliderTransformMatrix: Nullable<Matrix>;
  87593. /** @hidden */
  87594. _renderId: number;
  87595. /** @hidden */
  87596. _alphaIndex: number;
  87597. /** @hidden */
  87598. _distanceToCamera: number;
  87599. /** @hidden */
  87600. _id: number;
  87601. private _currentMaterial;
  87602. /**
  87603. * Add a new submesh to a mesh
  87604. * @param materialIndex defines the material index to use
  87605. * @param verticesStart defines vertex index start
  87606. * @param verticesCount defines vertices count
  87607. * @param indexStart defines index start
  87608. * @param indexCount defines indices count
  87609. * @param mesh defines the parent mesh
  87610. * @param renderingMesh defines an optional rendering mesh
  87611. * @param createBoundingBox defines if bounding box should be created for this submesh
  87612. * @returns the new submesh
  87613. */
  87614. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87615. /**
  87616. * Creates a new submesh
  87617. * @param materialIndex defines the material index to use
  87618. * @param verticesStart defines vertex index start
  87619. * @param verticesCount defines vertices count
  87620. * @param indexStart defines index start
  87621. * @param indexCount defines indices count
  87622. * @param mesh defines the parent mesh
  87623. * @param renderingMesh defines an optional rendering mesh
  87624. * @param createBoundingBox defines if bounding box should be created for this submesh
  87625. */
  87626. constructor(
  87627. /** the material index to use */
  87628. materialIndex: number,
  87629. /** vertex index start */
  87630. verticesStart: number,
  87631. /** vertices count */
  87632. verticesCount: number,
  87633. /** index start */
  87634. indexStart: number,
  87635. /** indices count */
  87636. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87637. /**
  87638. * Returns true if this submesh covers the entire parent mesh
  87639. * @ignorenaming
  87640. */
  87641. readonly IsGlobal: boolean;
  87642. /**
  87643. * Returns the submesh BoudingInfo object
  87644. * @returns current bounding info (or mesh's one if the submesh is global)
  87645. */
  87646. getBoundingInfo(): BoundingInfo;
  87647. /**
  87648. * Sets the submesh BoundingInfo
  87649. * @param boundingInfo defines the new bounding info to use
  87650. * @returns the SubMesh
  87651. */
  87652. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87653. /**
  87654. * Returns the mesh of the current submesh
  87655. * @return the parent mesh
  87656. */
  87657. getMesh(): AbstractMesh;
  87658. /**
  87659. * Returns the rendering mesh of the submesh
  87660. * @returns the rendering mesh (could be different from parent mesh)
  87661. */
  87662. getRenderingMesh(): Mesh;
  87663. /**
  87664. * Returns the submesh material
  87665. * @returns null or the current material
  87666. */
  87667. getMaterial(): Nullable<Material>;
  87668. /**
  87669. * Sets a new updated BoundingInfo object to the submesh
  87670. * @param data defines an optional position array to use to determine the bounding info
  87671. * @returns the SubMesh
  87672. */
  87673. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87674. /** @hidden */
  87675. _checkCollision(collider: Collider): boolean;
  87676. /**
  87677. * Updates the submesh BoundingInfo
  87678. * @param world defines the world matrix to use to update the bounding info
  87679. * @returns the submesh
  87680. */
  87681. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87682. /**
  87683. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87684. * @param frustumPlanes defines the frustum planes
  87685. * @returns true if the submesh is intersecting with the frustum
  87686. */
  87687. isInFrustum(frustumPlanes: Plane[]): boolean;
  87688. /**
  87689. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87690. * @param frustumPlanes defines the frustum planes
  87691. * @returns true if the submesh is inside the frustum
  87692. */
  87693. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87694. /**
  87695. * Renders the submesh
  87696. * @param enableAlphaMode defines if alpha needs to be used
  87697. * @returns the submesh
  87698. */
  87699. render(enableAlphaMode: boolean): SubMesh;
  87700. /**
  87701. * @hidden
  87702. */
  87703. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87704. /**
  87705. * Checks if the submesh intersects with a ray
  87706. * @param ray defines the ray to test
  87707. * @returns true is the passed ray intersects the submesh bounding box
  87708. */
  87709. canIntersects(ray: Ray): boolean;
  87710. /**
  87711. * Intersects current submesh with a ray
  87712. * @param ray defines the ray to test
  87713. * @param positions defines mesh's positions array
  87714. * @param indices defines mesh's indices array
  87715. * @param fastCheck defines if only bounding info should be used
  87716. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87717. * @returns intersection info or null if no intersection
  87718. */
  87719. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87720. /** @hidden */
  87721. private _intersectLines;
  87722. /** @hidden */
  87723. private _intersectUnIndexedLines;
  87724. /** @hidden */
  87725. private _intersectTriangles;
  87726. /** @hidden */
  87727. private _intersectUnIndexedTriangles;
  87728. /** @hidden */
  87729. _rebuild(): void;
  87730. /**
  87731. * Creates a new submesh from the passed mesh
  87732. * @param newMesh defines the new hosting mesh
  87733. * @param newRenderingMesh defines an optional rendering mesh
  87734. * @returns the new submesh
  87735. */
  87736. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87737. /**
  87738. * Release associated resources
  87739. */
  87740. dispose(): void;
  87741. /**
  87742. * Gets the class name
  87743. * @returns the string "SubMesh".
  87744. */
  87745. getClassName(): string;
  87746. /**
  87747. * Creates a new submesh from indices data
  87748. * @param materialIndex the index of the main mesh material
  87749. * @param startIndex the index where to start the copy in the mesh indices array
  87750. * @param indexCount the number of indices to copy then from the startIndex
  87751. * @param mesh the main mesh to create the submesh from
  87752. * @param renderingMesh the optional rendering mesh
  87753. * @returns a new submesh
  87754. */
  87755. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87756. }
  87757. }
  87758. declare module BABYLON {
  87759. /**
  87760. * Class used to represent data loading progression
  87761. */
  87762. export class SceneLoaderFlags {
  87763. private static _ForceFullSceneLoadingForIncremental;
  87764. private static _ShowLoadingScreen;
  87765. private static _CleanBoneMatrixWeights;
  87766. private static _loggingLevel;
  87767. /**
  87768. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87769. */
  87770. static ForceFullSceneLoadingForIncremental: boolean;
  87771. /**
  87772. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87773. */
  87774. static ShowLoadingScreen: boolean;
  87775. /**
  87776. * Defines the current logging level (while loading the scene)
  87777. * @ignorenaming
  87778. */
  87779. static loggingLevel: number;
  87780. /**
  87781. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87782. */
  87783. static CleanBoneMatrixWeights: boolean;
  87784. }
  87785. }
  87786. declare module BABYLON {
  87787. /**
  87788. * Class used to store geometry data (vertex buffers + index buffer)
  87789. */
  87790. export class Geometry implements IGetSetVerticesData {
  87791. /**
  87792. * Gets or sets the ID of the geometry
  87793. */
  87794. id: string;
  87795. /**
  87796. * Gets or sets the unique ID of the geometry
  87797. */
  87798. uniqueId: number;
  87799. /**
  87800. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87801. */
  87802. delayLoadState: number;
  87803. /**
  87804. * Gets the file containing the data to load when running in delay load state
  87805. */
  87806. delayLoadingFile: Nullable<string>;
  87807. /**
  87808. * Callback called when the geometry is updated
  87809. */
  87810. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87811. private _scene;
  87812. private _engine;
  87813. private _meshes;
  87814. private _totalVertices;
  87815. /** @hidden */
  87816. _indices: IndicesArray;
  87817. /** @hidden */
  87818. _vertexBuffers: {
  87819. [key: string]: VertexBuffer;
  87820. };
  87821. private _isDisposed;
  87822. private _extend;
  87823. private _boundingBias;
  87824. /** @hidden */
  87825. _delayInfo: Array<string>;
  87826. private _indexBuffer;
  87827. private _indexBufferIsUpdatable;
  87828. /** @hidden */
  87829. _boundingInfo: Nullable<BoundingInfo>;
  87830. /** @hidden */
  87831. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87832. /** @hidden */
  87833. _softwareSkinningFrameId: number;
  87834. private _vertexArrayObjects;
  87835. private _updatable;
  87836. /** @hidden */
  87837. _positions: Nullable<Vector3[]>;
  87838. /**
  87839. * 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
  87840. */
  87841. /**
  87842. * 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
  87843. */
  87844. boundingBias: Vector2;
  87845. /**
  87846. * Static function used to attach a new empty geometry to a mesh
  87847. * @param mesh defines the mesh to attach the geometry to
  87848. * @returns the new Geometry
  87849. */
  87850. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87851. /**
  87852. * Creates a new geometry
  87853. * @param id defines the unique ID
  87854. * @param scene defines the hosting scene
  87855. * @param vertexData defines the VertexData used to get geometry data
  87856. * @param updatable defines if geometry must be updatable (false by default)
  87857. * @param mesh defines the mesh that will be associated with the geometry
  87858. */
  87859. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87860. /**
  87861. * Gets the current extend of the geometry
  87862. */
  87863. readonly extend: {
  87864. minimum: Vector3;
  87865. maximum: Vector3;
  87866. };
  87867. /**
  87868. * Gets the hosting scene
  87869. * @returns the hosting Scene
  87870. */
  87871. getScene(): Scene;
  87872. /**
  87873. * Gets the hosting engine
  87874. * @returns the hosting Engine
  87875. */
  87876. getEngine(): Engine;
  87877. /**
  87878. * Defines if the geometry is ready to use
  87879. * @returns true if the geometry is ready to be used
  87880. */
  87881. isReady(): boolean;
  87882. /**
  87883. * Gets a value indicating that the geometry should not be serialized
  87884. */
  87885. readonly doNotSerialize: boolean;
  87886. /** @hidden */
  87887. _rebuild(): void;
  87888. /**
  87889. * Affects all geometry data in one call
  87890. * @param vertexData defines the geometry data
  87891. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87892. */
  87893. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87894. /**
  87895. * Set specific vertex data
  87896. * @param kind defines the data kind (Position, normal, etc...)
  87897. * @param data defines the vertex data to use
  87898. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87899. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87900. */
  87901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87902. /**
  87903. * Removes a specific vertex data
  87904. * @param kind defines the data kind (Position, normal, etc...)
  87905. */
  87906. removeVerticesData(kind: string): void;
  87907. /**
  87908. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87909. * @param buffer defines the vertex buffer to use
  87910. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87911. */
  87912. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87913. /**
  87914. * Update a specific vertex buffer
  87915. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87916. * It will do nothing if the buffer is not updatable
  87917. * @param kind defines the data kind (Position, normal, etc...)
  87918. * @param data defines the data to use
  87919. * @param offset defines the offset in the target buffer where to store the data
  87920. * @param useBytes set to true if the offset is in bytes
  87921. */
  87922. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87923. /**
  87924. * Update a specific vertex buffer
  87925. * This function will create a new buffer if the current one is not updatable
  87926. * @param kind defines the data kind (Position, normal, etc...)
  87927. * @param data defines the data to use
  87928. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87929. */
  87930. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87931. private _updateBoundingInfo;
  87932. /** @hidden */
  87933. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87934. /**
  87935. * Gets total number of vertices
  87936. * @returns the total number of vertices
  87937. */
  87938. getTotalVertices(): number;
  87939. /**
  87940. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87941. * @param kind defines the data kind (Position, normal, etc...)
  87942. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87943. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87944. * @returns a float array containing vertex data
  87945. */
  87946. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87947. /**
  87948. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87949. * @param kind defines the data kind (Position, normal, etc...)
  87950. * @returns true if the vertex buffer with the specified kind is updatable
  87951. */
  87952. isVertexBufferUpdatable(kind: string): boolean;
  87953. /**
  87954. * Gets a specific vertex buffer
  87955. * @param kind defines the data kind (Position, normal, etc...)
  87956. * @returns a VertexBuffer
  87957. */
  87958. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87959. /**
  87960. * Returns all vertex buffers
  87961. * @return an object holding all vertex buffers indexed by kind
  87962. */
  87963. getVertexBuffers(): Nullable<{
  87964. [key: string]: VertexBuffer;
  87965. }>;
  87966. /**
  87967. * Gets a boolean indicating if specific vertex buffer is present
  87968. * @param kind defines the data kind (Position, normal, etc...)
  87969. * @returns true if data is present
  87970. */
  87971. isVerticesDataPresent(kind: string): boolean;
  87972. /**
  87973. * Gets a list of all attached data kinds (Position, normal, etc...)
  87974. * @returns a list of string containing all kinds
  87975. */
  87976. getVerticesDataKinds(): string[];
  87977. /**
  87978. * Update index buffer
  87979. * @param indices defines the indices to store in the index buffer
  87980. * @param offset defines the offset in the target buffer where to store the data
  87981. * @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)
  87982. */
  87983. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87984. /**
  87985. * Creates a new index buffer
  87986. * @param indices defines the indices to store in the index buffer
  87987. * @param totalVertices defines the total number of vertices (could be null)
  87988. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87989. */
  87990. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87991. /**
  87992. * Return the total number of indices
  87993. * @returns the total number of indices
  87994. */
  87995. getTotalIndices(): number;
  87996. /**
  87997. * Gets the index buffer array
  87998. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87999. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88000. * @returns the index buffer array
  88001. */
  88002. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88003. /**
  88004. * Gets the index buffer
  88005. * @return the index buffer
  88006. */
  88007. getIndexBuffer(): Nullable<DataBuffer>;
  88008. /** @hidden */
  88009. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88010. /**
  88011. * Release the associated resources for a specific mesh
  88012. * @param mesh defines the source mesh
  88013. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88014. */
  88015. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88016. /**
  88017. * Apply current geometry to a given mesh
  88018. * @param mesh defines the mesh to apply geometry to
  88019. */
  88020. applyToMesh(mesh: Mesh): void;
  88021. private _updateExtend;
  88022. private _applyToMesh;
  88023. private notifyUpdate;
  88024. /**
  88025. * Load the geometry if it was flagged as delay loaded
  88026. * @param scene defines the hosting scene
  88027. * @param onLoaded defines a callback called when the geometry is loaded
  88028. */
  88029. load(scene: Scene, onLoaded?: () => void): void;
  88030. private _queueLoad;
  88031. /**
  88032. * Invert the geometry to move from a right handed system to a left handed one.
  88033. */
  88034. toLeftHanded(): void;
  88035. /** @hidden */
  88036. _resetPointsArrayCache(): void;
  88037. /** @hidden */
  88038. _generatePointsArray(): boolean;
  88039. /**
  88040. * Gets a value indicating if the geometry is disposed
  88041. * @returns true if the geometry was disposed
  88042. */
  88043. isDisposed(): boolean;
  88044. private _disposeVertexArrayObjects;
  88045. /**
  88046. * Free all associated resources
  88047. */
  88048. dispose(): void;
  88049. /**
  88050. * Clone the current geometry into a new geometry
  88051. * @param id defines the unique ID of the new geometry
  88052. * @returns a new geometry object
  88053. */
  88054. copy(id: string): Geometry;
  88055. /**
  88056. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88057. * @return a JSON representation of the current geometry data (without the vertices data)
  88058. */
  88059. serialize(): any;
  88060. private toNumberArray;
  88061. /**
  88062. * Serialize all vertices data into a JSON oject
  88063. * @returns a JSON representation of the current geometry data
  88064. */
  88065. serializeVerticeData(): any;
  88066. /**
  88067. * Extracts a clone of a mesh geometry
  88068. * @param mesh defines the source mesh
  88069. * @param id defines the unique ID of the new geometry object
  88070. * @returns the new geometry object
  88071. */
  88072. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88073. /**
  88074. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88075. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88076. * Be aware Math.random() could cause collisions, but:
  88077. * "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"
  88078. * @returns a string containing a new GUID
  88079. */
  88080. static RandomId(): string;
  88081. /** @hidden */
  88082. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88083. private static _CleanMatricesWeights;
  88084. /**
  88085. * Create a new geometry from persisted data (Using .babylon file format)
  88086. * @param parsedVertexData defines the persisted data
  88087. * @param scene defines the hosting scene
  88088. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88089. * @returns the new geometry object
  88090. */
  88091. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88092. }
  88093. }
  88094. declare module BABYLON {
  88095. /**
  88096. * Define an interface for all classes that will get and set the data on vertices
  88097. */
  88098. export interface IGetSetVerticesData {
  88099. /**
  88100. * Gets a boolean indicating if specific vertex data is present
  88101. * @param kind defines the vertex data kind to use
  88102. * @returns true is data kind is present
  88103. */
  88104. isVerticesDataPresent(kind: string): boolean;
  88105. /**
  88106. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88107. * @param kind defines the data kind (Position, normal, etc...)
  88108. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88110. * @returns a float array containing vertex data
  88111. */
  88112. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88113. /**
  88114. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88115. * @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.
  88116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88117. * @returns the indices array or an empty array if the mesh has no geometry
  88118. */
  88119. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88120. /**
  88121. * Set specific vertex data
  88122. * @param kind defines the data kind (Position, normal, etc...)
  88123. * @param data defines the vertex data to use
  88124. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88125. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88126. */
  88127. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88128. /**
  88129. * Update a specific associated vertex buffer
  88130. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88131. * - VertexBuffer.PositionKind
  88132. * - VertexBuffer.UVKind
  88133. * - VertexBuffer.UV2Kind
  88134. * - VertexBuffer.UV3Kind
  88135. * - VertexBuffer.UV4Kind
  88136. * - VertexBuffer.UV5Kind
  88137. * - VertexBuffer.UV6Kind
  88138. * - VertexBuffer.ColorKind
  88139. * - VertexBuffer.MatricesIndicesKind
  88140. * - VertexBuffer.MatricesIndicesExtraKind
  88141. * - VertexBuffer.MatricesWeightsKind
  88142. * - VertexBuffer.MatricesWeightsExtraKind
  88143. * @param data defines the data source
  88144. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88145. * @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)
  88146. */
  88147. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88148. /**
  88149. * Creates a new index buffer
  88150. * @param indices defines the indices to store in the index buffer
  88151. * @param totalVertices defines the total number of vertices (could be null)
  88152. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88153. */
  88154. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88155. }
  88156. /**
  88157. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88158. */
  88159. export class VertexData {
  88160. /**
  88161. * Mesh side orientation : usually the external or front surface
  88162. */
  88163. static readonly FRONTSIDE: number;
  88164. /**
  88165. * Mesh side orientation : usually the internal or back surface
  88166. */
  88167. static readonly BACKSIDE: number;
  88168. /**
  88169. * Mesh side orientation : both internal and external or front and back surfaces
  88170. */
  88171. static readonly DOUBLESIDE: number;
  88172. /**
  88173. * Mesh side orientation : by default, `FRONTSIDE`
  88174. */
  88175. static readonly DEFAULTSIDE: number;
  88176. /**
  88177. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88178. */
  88179. positions: Nullable<FloatArray>;
  88180. /**
  88181. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88182. */
  88183. normals: Nullable<FloatArray>;
  88184. /**
  88185. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88186. */
  88187. tangents: Nullable<FloatArray>;
  88188. /**
  88189. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88190. */
  88191. uvs: Nullable<FloatArray>;
  88192. /**
  88193. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88194. */
  88195. uvs2: Nullable<FloatArray>;
  88196. /**
  88197. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88198. */
  88199. uvs3: Nullable<FloatArray>;
  88200. /**
  88201. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88202. */
  88203. uvs4: Nullable<FloatArray>;
  88204. /**
  88205. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88206. */
  88207. uvs5: Nullable<FloatArray>;
  88208. /**
  88209. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88210. */
  88211. uvs6: Nullable<FloatArray>;
  88212. /**
  88213. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88214. */
  88215. colors: Nullable<FloatArray>;
  88216. /**
  88217. * 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).
  88218. */
  88219. matricesIndices: Nullable<FloatArray>;
  88220. /**
  88221. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88222. */
  88223. matricesWeights: Nullable<FloatArray>;
  88224. /**
  88225. * An array extending the number of possible indices
  88226. */
  88227. matricesIndicesExtra: Nullable<FloatArray>;
  88228. /**
  88229. * An array extending the number of possible weights when the number of indices is extended
  88230. */
  88231. matricesWeightsExtra: Nullable<FloatArray>;
  88232. /**
  88233. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88234. */
  88235. indices: Nullable<IndicesArray>;
  88236. /**
  88237. * Uses the passed data array to set the set the values for the specified kind of data
  88238. * @param data a linear array of floating numbers
  88239. * @param kind the type of data that is being set, eg positions, colors etc
  88240. */
  88241. set(data: FloatArray, kind: string): void;
  88242. /**
  88243. * Associates the vertexData to the passed Mesh.
  88244. * Sets it as updatable or not (default `false`)
  88245. * @param mesh the mesh the vertexData is applied to
  88246. * @param updatable when used and having the value true allows new data to update the vertexData
  88247. * @returns the VertexData
  88248. */
  88249. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88250. /**
  88251. * Associates the vertexData to the passed Geometry.
  88252. * Sets it as updatable or not (default `false`)
  88253. * @param geometry the geometry the vertexData is applied to
  88254. * @param updatable when used and having the value true allows new data to update the vertexData
  88255. * @returns VertexData
  88256. */
  88257. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88258. /**
  88259. * Updates the associated mesh
  88260. * @param mesh the mesh to be updated
  88261. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88262. * @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
  88263. * @returns VertexData
  88264. */
  88265. updateMesh(mesh: Mesh): VertexData;
  88266. /**
  88267. * Updates the associated geometry
  88268. * @param geometry the geometry to be updated
  88269. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88270. * @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
  88271. * @returns VertexData.
  88272. */
  88273. updateGeometry(geometry: Geometry): VertexData;
  88274. private _applyTo;
  88275. private _update;
  88276. /**
  88277. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88278. * @param matrix the transforming matrix
  88279. * @returns the VertexData
  88280. */
  88281. transform(matrix: Matrix): VertexData;
  88282. /**
  88283. * Merges the passed VertexData into the current one
  88284. * @param other the VertexData to be merged into the current one
  88285. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88286. * @returns the modified VertexData
  88287. */
  88288. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88289. private _mergeElement;
  88290. private _validate;
  88291. /**
  88292. * Serializes the VertexData
  88293. * @returns a serialized object
  88294. */
  88295. serialize(): any;
  88296. /**
  88297. * Extracts the vertexData from a mesh
  88298. * @param mesh the mesh from which to extract the VertexData
  88299. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88300. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88301. * @returns the object VertexData associated to the passed mesh
  88302. */
  88303. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88304. /**
  88305. * Extracts the vertexData from the geometry
  88306. * @param geometry the geometry from which to extract the VertexData
  88307. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88308. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88309. * @returns the object VertexData associated to the passed mesh
  88310. */
  88311. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88312. private static _ExtractFrom;
  88313. /**
  88314. * Creates the VertexData for a Ribbon
  88315. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88316. * * pathArray array of paths, each of which an array of successive Vector3
  88317. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88318. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88319. * * 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
  88320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88321. * * 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)
  88322. * * 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)
  88323. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88324. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88325. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88326. * @returns the VertexData of the ribbon
  88327. */
  88328. static CreateRibbon(options: {
  88329. pathArray: Vector3[][];
  88330. closeArray?: boolean;
  88331. closePath?: boolean;
  88332. offset?: number;
  88333. sideOrientation?: number;
  88334. frontUVs?: Vector4;
  88335. backUVs?: Vector4;
  88336. invertUV?: boolean;
  88337. uvs?: Vector2[];
  88338. colors?: Color4[];
  88339. }): VertexData;
  88340. /**
  88341. * Creates the VertexData for a box
  88342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88343. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88344. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88345. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88346. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88347. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88348. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88350. * * 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)
  88351. * * 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)
  88352. * @returns the VertexData of the box
  88353. */
  88354. static CreateBox(options: {
  88355. size?: number;
  88356. width?: number;
  88357. height?: number;
  88358. depth?: number;
  88359. faceUV?: Vector4[];
  88360. faceColors?: Color4[];
  88361. sideOrientation?: number;
  88362. frontUVs?: Vector4;
  88363. backUVs?: Vector4;
  88364. }): VertexData;
  88365. /**
  88366. * Creates the VertexData for a tiled box
  88367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88368. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88369. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88370. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88372. * @returns the VertexData of the box
  88373. */
  88374. static CreateTiledBox(options: {
  88375. pattern?: number;
  88376. width?: number;
  88377. height?: number;
  88378. depth?: number;
  88379. tileSize?: number;
  88380. tileWidth?: number;
  88381. tileHeight?: number;
  88382. alignHorizontal?: number;
  88383. alignVertical?: number;
  88384. faceUV?: Vector4[];
  88385. faceColors?: Color4[];
  88386. sideOrientation?: number;
  88387. }): VertexData;
  88388. /**
  88389. * Creates the VertexData for a tiled plane
  88390. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88391. * * pattern a limited pattern arrangement depending on the number
  88392. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88393. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88394. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88396. * * 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)
  88397. * * 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)
  88398. * @returns the VertexData of the tiled plane
  88399. */
  88400. static CreateTiledPlane(options: {
  88401. pattern?: number;
  88402. tileSize?: number;
  88403. tileWidth?: number;
  88404. tileHeight?: number;
  88405. size?: number;
  88406. width?: number;
  88407. height?: number;
  88408. alignHorizontal?: number;
  88409. alignVertical?: number;
  88410. sideOrientation?: number;
  88411. frontUVs?: Vector4;
  88412. backUVs?: Vector4;
  88413. }): VertexData;
  88414. /**
  88415. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88416. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88417. * * segments sets the number of horizontal strips optional, default 32
  88418. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88419. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88420. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88421. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88422. * * 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
  88423. * * 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
  88424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88425. * * 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)
  88426. * * 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)
  88427. * @returns the VertexData of the ellipsoid
  88428. */
  88429. static CreateSphere(options: {
  88430. segments?: number;
  88431. diameter?: number;
  88432. diameterX?: number;
  88433. diameterY?: number;
  88434. diameterZ?: number;
  88435. arc?: number;
  88436. slice?: number;
  88437. sideOrientation?: number;
  88438. frontUVs?: Vector4;
  88439. backUVs?: Vector4;
  88440. }): VertexData;
  88441. /**
  88442. * Creates the VertexData for a cylinder, cone or prism
  88443. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88444. * * height sets the height (y direction) of the cylinder, optional, default 2
  88445. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88446. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88447. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88448. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88449. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88450. * * 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
  88451. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88452. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88453. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88454. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88455. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88456. * * 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)
  88457. * * 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)
  88458. * @returns the VertexData of the cylinder, cone or prism
  88459. */
  88460. static CreateCylinder(options: {
  88461. height?: number;
  88462. diameterTop?: number;
  88463. diameterBottom?: number;
  88464. diameter?: number;
  88465. tessellation?: number;
  88466. subdivisions?: number;
  88467. arc?: number;
  88468. faceColors?: Color4[];
  88469. faceUV?: Vector4[];
  88470. hasRings?: boolean;
  88471. enclose?: boolean;
  88472. sideOrientation?: number;
  88473. frontUVs?: Vector4;
  88474. backUVs?: Vector4;
  88475. }): VertexData;
  88476. /**
  88477. * Creates the VertexData for a torus
  88478. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88479. * * diameter the diameter of the torus, optional default 1
  88480. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88481. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88483. * * 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)
  88484. * * 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)
  88485. * @returns the VertexData of the torus
  88486. */
  88487. static CreateTorus(options: {
  88488. diameter?: number;
  88489. thickness?: number;
  88490. tessellation?: number;
  88491. sideOrientation?: number;
  88492. frontUVs?: Vector4;
  88493. backUVs?: Vector4;
  88494. }): VertexData;
  88495. /**
  88496. * Creates the VertexData of the LineSystem
  88497. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88498. * - lines an array of lines, each line being an array of successive Vector3
  88499. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88500. * @returns the VertexData of the LineSystem
  88501. */
  88502. static CreateLineSystem(options: {
  88503. lines: Vector3[][];
  88504. colors?: Nullable<Color4[][]>;
  88505. }): VertexData;
  88506. /**
  88507. * Create the VertexData for a DashedLines
  88508. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88509. * - points an array successive Vector3
  88510. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88511. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88512. * - dashNb the intended total number of dashes, optional, default 200
  88513. * @returns the VertexData for the DashedLines
  88514. */
  88515. static CreateDashedLines(options: {
  88516. points: Vector3[];
  88517. dashSize?: number;
  88518. gapSize?: number;
  88519. dashNb?: number;
  88520. }): VertexData;
  88521. /**
  88522. * Creates the VertexData for a Ground
  88523. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88524. * - width the width (x direction) of the ground, optional, default 1
  88525. * - height the height (z direction) of the ground, optional, default 1
  88526. * - subdivisions the number of subdivisions per side, optional, default 1
  88527. * @returns the VertexData of the Ground
  88528. */
  88529. static CreateGround(options: {
  88530. width?: number;
  88531. height?: number;
  88532. subdivisions?: number;
  88533. subdivisionsX?: number;
  88534. subdivisionsY?: number;
  88535. }): VertexData;
  88536. /**
  88537. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88538. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88539. * * xmin the ground minimum X coordinate, optional, default -1
  88540. * * zmin the ground minimum Z coordinate, optional, default -1
  88541. * * xmax the ground maximum X coordinate, optional, default 1
  88542. * * zmax the ground maximum Z coordinate, optional, default 1
  88543. * * 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}
  88544. * * 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}
  88545. * @returns the VertexData of the TiledGround
  88546. */
  88547. static CreateTiledGround(options: {
  88548. xmin: number;
  88549. zmin: number;
  88550. xmax: number;
  88551. zmax: number;
  88552. subdivisions?: {
  88553. w: number;
  88554. h: number;
  88555. };
  88556. precision?: {
  88557. w: number;
  88558. h: number;
  88559. };
  88560. }): VertexData;
  88561. /**
  88562. * Creates the VertexData of the Ground designed from a heightmap
  88563. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88564. * * width the width (x direction) of the ground
  88565. * * height the height (z direction) of the ground
  88566. * * subdivisions the number of subdivisions per side
  88567. * * minHeight the minimum altitude on the ground, optional, default 0
  88568. * * maxHeight the maximum altitude on the ground, optional default 1
  88569. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88570. * * buffer the array holding the image color data
  88571. * * bufferWidth the width of image
  88572. * * bufferHeight the height of image
  88573. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88574. * @returns the VertexData of the Ground designed from a heightmap
  88575. */
  88576. static CreateGroundFromHeightMap(options: {
  88577. width: number;
  88578. height: number;
  88579. subdivisions: number;
  88580. minHeight: number;
  88581. maxHeight: number;
  88582. colorFilter: Color3;
  88583. buffer: Uint8Array;
  88584. bufferWidth: number;
  88585. bufferHeight: number;
  88586. alphaFilter: number;
  88587. }): VertexData;
  88588. /**
  88589. * Creates the VertexData for a Plane
  88590. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88591. * * size sets the width and height of the plane to the value of size, optional default 1
  88592. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88593. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88595. * * 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)
  88596. * * 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)
  88597. * @returns the VertexData of the box
  88598. */
  88599. static CreatePlane(options: {
  88600. size?: number;
  88601. width?: number;
  88602. height?: number;
  88603. sideOrientation?: number;
  88604. frontUVs?: Vector4;
  88605. backUVs?: Vector4;
  88606. }): VertexData;
  88607. /**
  88608. * Creates the VertexData of the Disc or regular Polygon
  88609. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88610. * * radius the radius of the disc, optional default 0.5
  88611. * * tessellation the number of polygon sides, optional, default 64
  88612. * * 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
  88613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88614. * * 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)
  88615. * * 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)
  88616. * @returns the VertexData of the box
  88617. */
  88618. static CreateDisc(options: {
  88619. radius?: number;
  88620. tessellation?: number;
  88621. arc?: number;
  88622. sideOrientation?: number;
  88623. frontUVs?: Vector4;
  88624. backUVs?: Vector4;
  88625. }): VertexData;
  88626. /**
  88627. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88628. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88629. * @param polygon a mesh built from polygonTriangulation.build()
  88630. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88631. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88632. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88633. * @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)
  88634. * @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)
  88635. * @returns the VertexData of the Polygon
  88636. */
  88637. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88638. /**
  88639. * Creates the VertexData of the IcoSphere
  88640. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88641. * * radius the radius of the IcoSphere, optional default 1
  88642. * * radiusX allows stretching in the x direction, optional, default radius
  88643. * * radiusY allows stretching in the y direction, optional, default radius
  88644. * * radiusZ allows stretching in the z direction, optional, default radius
  88645. * * flat when true creates a flat shaded mesh, optional, default true
  88646. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88647. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88648. * * 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)
  88649. * * 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)
  88650. * @returns the VertexData of the IcoSphere
  88651. */
  88652. static CreateIcoSphere(options: {
  88653. radius?: number;
  88654. radiusX?: number;
  88655. radiusY?: number;
  88656. radiusZ?: number;
  88657. flat?: boolean;
  88658. subdivisions?: number;
  88659. sideOrientation?: number;
  88660. frontUVs?: Vector4;
  88661. backUVs?: Vector4;
  88662. }): VertexData;
  88663. /**
  88664. * Creates the VertexData for a Polyhedron
  88665. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88666. * * type provided types are:
  88667. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88668. * * 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)
  88669. * * size the size of the IcoSphere, optional default 1
  88670. * * sizeX allows stretching in the x direction, optional, default size
  88671. * * sizeY allows stretching in the y direction, optional, default size
  88672. * * sizeZ allows stretching in the z direction, optional, default size
  88673. * * 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
  88674. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88675. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88676. * * flat when true creates a flat shaded mesh, optional, default true
  88677. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88679. * * 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)
  88680. * * 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)
  88681. * @returns the VertexData of the Polyhedron
  88682. */
  88683. static CreatePolyhedron(options: {
  88684. type?: number;
  88685. size?: number;
  88686. sizeX?: number;
  88687. sizeY?: number;
  88688. sizeZ?: number;
  88689. custom?: any;
  88690. faceUV?: Vector4[];
  88691. faceColors?: Color4[];
  88692. flat?: boolean;
  88693. sideOrientation?: number;
  88694. frontUVs?: Vector4;
  88695. backUVs?: Vector4;
  88696. }): VertexData;
  88697. /**
  88698. * Creates the VertexData for a TorusKnot
  88699. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88700. * * radius the radius of the torus knot, optional, default 2
  88701. * * tube the thickness of the tube, optional, default 0.5
  88702. * * radialSegments the number of sides on each tube segments, optional, default 32
  88703. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88704. * * p the number of windings around the z axis, optional, default 2
  88705. * * q the number of windings around the x axis, optional, default 3
  88706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88707. * * 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)
  88708. * * 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)
  88709. * @returns the VertexData of the Torus Knot
  88710. */
  88711. static CreateTorusKnot(options: {
  88712. radius?: number;
  88713. tube?: number;
  88714. radialSegments?: number;
  88715. tubularSegments?: number;
  88716. p?: number;
  88717. q?: number;
  88718. sideOrientation?: number;
  88719. frontUVs?: Vector4;
  88720. backUVs?: Vector4;
  88721. }): VertexData;
  88722. /**
  88723. * Compute normals for given positions and indices
  88724. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88725. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88726. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88727. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88728. * * facetNormals : optional array of facet normals (vector3)
  88729. * * facetPositions : optional array of facet positions (vector3)
  88730. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88731. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88732. * * bInfo : optional bounding info, required for facetPartitioning computation
  88733. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88734. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88735. * * useRightHandedSystem: optional boolean to for right handed system computation
  88736. * * depthSort : optional boolean to enable the facet depth sort computation
  88737. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88738. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88739. */
  88740. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88741. facetNormals?: any;
  88742. facetPositions?: any;
  88743. facetPartitioning?: any;
  88744. ratio?: number;
  88745. bInfo?: any;
  88746. bbSize?: Vector3;
  88747. subDiv?: any;
  88748. useRightHandedSystem?: boolean;
  88749. depthSort?: boolean;
  88750. distanceTo?: Vector3;
  88751. depthSortedFacets?: any;
  88752. }): void;
  88753. /** @hidden */
  88754. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88755. /**
  88756. * Applies VertexData created from the imported parameters to the geometry
  88757. * @param parsedVertexData the parsed data from an imported file
  88758. * @param geometry the geometry to apply the VertexData to
  88759. */
  88760. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88761. }
  88762. }
  88763. declare module BABYLON {
  88764. /**
  88765. * Defines a target to use with MorphTargetManager
  88766. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88767. */
  88768. export class MorphTarget implements IAnimatable {
  88769. /** defines the name of the target */
  88770. name: string;
  88771. /**
  88772. * Gets or sets the list of animations
  88773. */
  88774. animations: Animation[];
  88775. private _scene;
  88776. private _positions;
  88777. private _normals;
  88778. private _tangents;
  88779. private _uvs;
  88780. private _influence;
  88781. /**
  88782. * Observable raised when the influence changes
  88783. */
  88784. onInfluenceChanged: Observable<boolean>;
  88785. /** @hidden */
  88786. _onDataLayoutChanged: Observable<void>;
  88787. /**
  88788. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88789. */
  88790. influence: number;
  88791. /**
  88792. * Gets or sets the id of the morph Target
  88793. */
  88794. id: string;
  88795. private _animationPropertiesOverride;
  88796. /**
  88797. * Gets or sets the animation properties override
  88798. */
  88799. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88800. /**
  88801. * Creates a new MorphTarget
  88802. * @param name defines the name of the target
  88803. * @param influence defines the influence to use
  88804. * @param scene defines the scene the morphtarget belongs to
  88805. */
  88806. constructor(
  88807. /** defines the name of the target */
  88808. name: string, influence?: number, scene?: Nullable<Scene>);
  88809. /**
  88810. * Gets a boolean defining if the target contains position data
  88811. */
  88812. readonly hasPositions: boolean;
  88813. /**
  88814. * Gets a boolean defining if the target contains normal data
  88815. */
  88816. readonly hasNormals: boolean;
  88817. /**
  88818. * Gets a boolean defining if the target contains tangent data
  88819. */
  88820. readonly hasTangents: boolean;
  88821. /**
  88822. * Gets a boolean defining if the target contains texture coordinates data
  88823. */
  88824. readonly hasUVs: boolean;
  88825. /**
  88826. * Affects position data to this target
  88827. * @param data defines the position data to use
  88828. */
  88829. setPositions(data: Nullable<FloatArray>): void;
  88830. /**
  88831. * Gets the position data stored in this target
  88832. * @returns a FloatArray containing the position data (or null if not present)
  88833. */
  88834. getPositions(): Nullable<FloatArray>;
  88835. /**
  88836. * Affects normal data to this target
  88837. * @param data defines the normal data to use
  88838. */
  88839. setNormals(data: Nullable<FloatArray>): void;
  88840. /**
  88841. * Gets the normal data stored in this target
  88842. * @returns a FloatArray containing the normal data (or null if not present)
  88843. */
  88844. getNormals(): Nullable<FloatArray>;
  88845. /**
  88846. * Affects tangent data to this target
  88847. * @param data defines the tangent data to use
  88848. */
  88849. setTangents(data: Nullable<FloatArray>): void;
  88850. /**
  88851. * Gets the tangent data stored in this target
  88852. * @returns a FloatArray containing the tangent data (or null if not present)
  88853. */
  88854. getTangents(): Nullable<FloatArray>;
  88855. /**
  88856. * Affects texture coordinates data to this target
  88857. * @param data defines the texture coordinates data to use
  88858. */
  88859. setUVs(data: Nullable<FloatArray>): void;
  88860. /**
  88861. * Gets the texture coordinates data stored in this target
  88862. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88863. */
  88864. getUVs(): Nullable<FloatArray>;
  88865. /**
  88866. * Serializes the current target into a Serialization object
  88867. * @returns the serialized object
  88868. */
  88869. serialize(): any;
  88870. /**
  88871. * Returns the string "MorphTarget"
  88872. * @returns "MorphTarget"
  88873. */
  88874. getClassName(): string;
  88875. /**
  88876. * Creates a new target from serialized data
  88877. * @param serializationObject defines the serialized data to use
  88878. * @returns a new MorphTarget
  88879. */
  88880. static Parse(serializationObject: any): MorphTarget;
  88881. /**
  88882. * Creates a MorphTarget from mesh data
  88883. * @param mesh defines the source mesh
  88884. * @param name defines the name to use for the new target
  88885. * @param influence defines the influence to attach to the target
  88886. * @returns a new MorphTarget
  88887. */
  88888. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88889. }
  88890. }
  88891. declare module BABYLON {
  88892. /**
  88893. * This class is used to deform meshes using morphing between different targets
  88894. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88895. */
  88896. export class MorphTargetManager {
  88897. private _targets;
  88898. private _targetInfluenceChangedObservers;
  88899. private _targetDataLayoutChangedObservers;
  88900. private _activeTargets;
  88901. private _scene;
  88902. private _influences;
  88903. private _supportsNormals;
  88904. private _supportsTangents;
  88905. private _supportsUVs;
  88906. private _vertexCount;
  88907. private _uniqueId;
  88908. private _tempInfluences;
  88909. /**
  88910. * Gets or sets a boolean indicating if normals must be morphed
  88911. */
  88912. enableNormalMorphing: boolean;
  88913. /**
  88914. * Gets or sets a boolean indicating if tangents must be morphed
  88915. */
  88916. enableTangentMorphing: boolean;
  88917. /**
  88918. * Gets or sets a boolean indicating if UV must be morphed
  88919. */
  88920. enableUVMorphing: boolean;
  88921. /**
  88922. * Creates a new MorphTargetManager
  88923. * @param scene defines the current scene
  88924. */
  88925. constructor(scene?: Nullable<Scene>);
  88926. /**
  88927. * Gets the unique ID of this manager
  88928. */
  88929. readonly uniqueId: number;
  88930. /**
  88931. * Gets the number of vertices handled by this manager
  88932. */
  88933. readonly vertexCount: number;
  88934. /**
  88935. * Gets a boolean indicating if this manager supports morphing of normals
  88936. */
  88937. readonly supportsNormals: boolean;
  88938. /**
  88939. * Gets a boolean indicating if this manager supports morphing of tangents
  88940. */
  88941. readonly supportsTangents: boolean;
  88942. /**
  88943. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88944. */
  88945. readonly supportsUVs: boolean;
  88946. /**
  88947. * Gets the number of targets stored in this manager
  88948. */
  88949. readonly numTargets: number;
  88950. /**
  88951. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88952. */
  88953. readonly numInfluencers: number;
  88954. /**
  88955. * Gets the list of influences (one per target)
  88956. */
  88957. readonly influences: Float32Array;
  88958. /**
  88959. * Gets the active target at specified index. An active target is a target with an influence > 0
  88960. * @param index defines the index to check
  88961. * @returns the requested target
  88962. */
  88963. getActiveTarget(index: number): MorphTarget;
  88964. /**
  88965. * Gets the target at specified index
  88966. * @param index defines the index to check
  88967. * @returns the requested target
  88968. */
  88969. getTarget(index: number): MorphTarget;
  88970. /**
  88971. * Add a new target to this manager
  88972. * @param target defines the target to add
  88973. */
  88974. addTarget(target: MorphTarget): void;
  88975. /**
  88976. * Removes a target from the manager
  88977. * @param target defines the target to remove
  88978. */
  88979. removeTarget(target: MorphTarget): void;
  88980. /**
  88981. * Serializes the current manager into a Serialization object
  88982. * @returns the serialized object
  88983. */
  88984. serialize(): any;
  88985. private _syncActiveTargets;
  88986. /**
  88987. * Syncrhonize the targets with all the meshes using this morph target manager
  88988. */
  88989. synchronize(): void;
  88990. /**
  88991. * Creates a new MorphTargetManager from serialized data
  88992. * @param serializationObject defines the serialized data
  88993. * @param scene defines the hosting scene
  88994. * @returns the new MorphTargetManager
  88995. */
  88996. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88997. }
  88998. }
  88999. declare module BABYLON {
  89000. /**
  89001. * Class used to represent a specific level of detail of a mesh
  89002. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89003. */
  89004. export class MeshLODLevel {
  89005. /** Defines the distance where this level should start being displayed */
  89006. distance: number;
  89007. /** Defines the mesh to use to render this level */
  89008. mesh: Nullable<Mesh>;
  89009. /**
  89010. * Creates a new LOD level
  89011. * @param distance defines the distance where this level should star being displayed
  89012. * @param mesh defines the mesh to use to render this level
  89013. */
  89014. constructor(
  89015. /** Defines the distance where this level should start being displayed */
  89016. distance: number,
  89017. /** Defines the mesh to use to render this level */
  89018. mesh: Nullable<Mesh>);
  89019. }
  89020. }
  89021. declare module BABYLON {
  89022. /**
  89023. * Mesh representing the gorund
  89024. */
  89025. export class GroundMesh extends Mesh {
  89026. /** If octree should be generated */
  89027. generateOctree: boolean;
  89028. private _heightQuads;
  89029. /** @hidden */
  89030. _subdivisionsX: number;
  89031. /** @hidden */
  89032. _subdivisionsY: number;
  89033. /** @hidden */
  89034. _width: number;
  89035. /** @hidden */
  89036. _height: number;
  89037. /** @hidden */
  89038. _minX: number;
  89039. /** @hidden */
  89040. _maxX: number;
  89041. /** @hidden */
  89042. _minZ: number;
  89043. /** @hidden */
  89044. _maxZ: number;
  89045. constructor(name: string, scene: Scene);
  89046. /**
  89047. * "GroundMesh"
  89048. * @returns "GroundMesh"
  89049. */
  89050. getClassName(): string;
  89051. /**
  89052. * The minimum of x and y subdivisions
  89053. */
  89054. readonly subdivisions: number;
  89055. /**
  89056. * X subdivisions
  89057. */
  89058. readonly subdivisionsX: number;
  89059. /**
  89060. * Y subdivisions
  89061. */
  89062. readonly subdivisionsY: number;
  89063. /**
  89064. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89065. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89066. * @param chunksCount the number of subdivisions for x and y
  89067. * @param octreeBlocksSize (Default: 32)
  89068. */
  89069. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89070. /**
  89071. * Returns a height (y) value in the Worl system :
  89072. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89073. * @param x x coordinate
  89074. * @param z z coordinate
  89075. * @returns the ground y position if (x, z) are outside the ground surface.
  89076. */
  89077. getHeightAtCoordinates(x: number, z: number): number;
  89078. /**
  89079. * Returns a normalized vector (Vector3) orthogonal to the ground
  89080. * at the ground coordinates (x, z) expressed in the World system.
  89081. * @param x x coordinate
  89082. * @param z z coordinate
  89083. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89084. */
  89085. getNormalAtCoordinates(x: number, z: number): Vector3;
  89086. /**
  89087. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89088. * at the ground coordinates (x, z) expressed in the World system.
  89089. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89090. * @param x x coordinate
  89091. * @param z z coordinate
  89092. * @param ref vector to store the result
  89093. * @returns the GroundMesh.
  89094. */
  89095. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89096. /**
  89097. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89098. * if the ground has been updated.
  89099. * This can be used in the render loop.
  89100. * @returns the GroundMesh.
  89101. */
  89102. updateCoordinateHeights(): GroundMesh;
  89103. private _getFacetAt;
  89104. private _initHeightQuads;
  89105. private _computeHeightQuads;
  89106. /**
  89107. * Serializes this ground mesh
  89108. * @param serializationObject object to write serialization to
  89109. */
  89110. serialize(serializationObject: any): void;
  89111. /**
  89112. * Parses a serialized ground mesh
  89113. * @param parsedMesh the serialized mesh
  89114. * @param scene the scene to create the ground mesh in
  89115. * @returns the created ground mesh
  89116. */
  89117. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89118. }
  89119. }
  89120. declare module BABYLON {
  89121. /**
  89122. * Interface for Physics-Joint data
  89123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89124. */
  89125. export interface PhysicsJointData {
  89126. /**
  89127. * The main pivot of the joint
  89128. */
  89129. mainPivot?: Vector3;
  89130. /**
  89131. * The connected pivot of the joint
  89132. */
  89133. connectedPivot?: Vector3;
  89134. /**
  89135. * The main axis of the joint
  89136. */
  89137. mainAxis?: Vector3;
  89138. /**
  89139. * The connected axis of the joint
  89140. */
  89141. connectedAxis?: Vector3;
  89142. /**
  89143. * The collision of the joint
  89144. */
  89145. collision?: boolean;
  89146. /**
  89147. * Native Oimo/Cannon/Energy data
  89148. */
  89149. nativeParams?: any;
  89150. }
  89151. /**
  89152. * This is a holder class for the physics joint created by the physics plugin
  89153. * It holds a set of functions to control the underlying joint
  89154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89155. */
  89156. export class PhysicsJoint {
  89157. /**
  89158. * The type of the physics joint
  89159. */
  89160. type: number;
  89161. /**
  89162. * The data for the physics joint
  89163. */
  89164. jointData: PhysicsJointData;
  89165. private _physicsJoint;
  89166. protected _physicsPlugin: IPhysicsEnginePlugin;
  89167. /**
  89168. * Initializes the physics joint
  89169. * @param type The type of the physics joint
  89170. * @param jointData The data for the physics joint
  89171. */
  89172. constructor(
  89173. /**
  89174. * The type of the physics joint
  89175. */
  89176. type: number,
  89177. /**
  89178. * The data for the physics joint
  89179. */
  89180. jointData: PhysicsJointData);
  89181. /**
  89182. * Gets the physics joint
  89183. */
  89184. /**
  89185. * Sets the physics joint
  89186. */
  89187. physicsJoint: any;
  89188. /**
  89189. * Sets the physics plugin
  89190. */
  89191. physicsPlugin: IPhysicsEnginePlugin;
  89192. /**
  89193. * Execute a function that is physics-plugin specific.
  89194. * @param {Function} func the function that will be executed.
  89195. * It accepts two parameters: the physics world and the physics joint
  89196. */
  89197. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89198. /**
  89199. * Distance-Joint type
  89200. */
  89201. static DistanceJoint: number;
  89202. /**
  89203. * Hinge-Joint type
  89204. */
  89205. static HingeJoint: number;
  89206. /**
  89207. * Ball-and-Socket joint type
  89208. */
  89209. static BallAndSocketJoint: number;
  89210. /**
  89211. * Wheel-Joint type
  89212. */
  89213. static WheelJoint: number;
  89214. /**
  89215. * Slider-Joint type
  89216. */
  89217. static SliderJoint: number;
  89218. /**
  89219. * Prismatic-Joint type
  89220. */
  89221. static PrismaticJoint: number;
  89222. /**
  89223. * Universal-Joint type
  89224. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89225. */
  89226. static UniversalJoint: number;
  89227. /**
  89228. * Hinge-Joint 2 type
  89229. */
  89230. static Hinge2Joint: number;
  89231. /**
  89232. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89233. */
  89234. static PointToPointJoint: number;
  89235. /**
  89236. * Spring-Joint type
  89237. */
  89238. static SpringJoint: number;
  89239. /**
  89240. * Lock-Joint type
  89241. */
  89242. static LockJoint: number;
  89243. }
  89244. /**
  89245. * A class representing a physics distance joint
  89246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89247. */
  89248. export class DistanceJoint extends PhysicsJoint {
  89249. /**
  89250. *
  89251. * @param jointData The data for the Distance-Joint
  89252. */
  89253. constructor(jointData: DistanceJointData);
  89254. /**
  89255. * Update the predefined distance.
  89256. * @param maxDistance The maximum preferred distance
  89257. * @param minDistance The minimum preferred distance
  89258. */
  89259. updateDistance(maxDistance: number, minDistance?: number): void;
  89260. }
  89261. /**
  89262. * Represents a Motor-Enabled Joint
  89263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89264. */
  89265. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89266. /**
  89267. * Initializes the Motor-Enabled Joint
  89268. * @param type The type of the joint
  89269. * @param jointData The physica joint data for the joint
  89270. */
  89271. constructor(type: number, jointData: PhysicsJointData);
  89272. /**
  89273. * Set the motor values.
  89274. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89275. * @param force the force to apply
  89276. * @param maxForce max force for this motor.
  89277. */
  89278. setMotor(force?: number, maxForce?: number): void;
  89279. /**
  89280. * Set the motor's limits.
  89281. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89282. * @param upperLimit The upper limit of the motor
  89283. * @param lowerLimit The lower limit of the motor
  89284. */
  89285. setLimit(upperLimit: number, lowerLimit?: number): void;
  89286. }
  89287. /**
  89288. * This class represents a single physics Hinge-Joint
  89289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89290. */
  89291. export class HingeJoint extends MotorEnabledJoint {
  89292. /**
  89293. * Initializes the Hinge-Joint
  89294. * @param jointData The joint data for the Hinge-Joint
  89295. */
  89296. constructor(jointData: PhysicsJointData);
  89297. /**
  89298. * Set the motor values.
  89299. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89300. * @param {number} force the force to apply
  89301. * @param {number} maxForce max force for this motor.
  89302. */
  89303. setMotor(force?: number, maxForce?: number): void;
  89304. /**
  89305. * Set the motor's limits.
  89306. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89307. * @param upperLimit The upper limit of the motor
  89308. * @param lowerLimit The lower limit of the motor
  89309. */
  89310. setLimit(upperLimit: number, lowerLimit?: number): void;
  89311. }
  89312. /**
  89313. * This class represents a dual hinge physics joint (same as wheel joint)
  89314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89315. */
  89316. export class Hinge2Joint extends MotorEnabledJoint {
  89317. /**
  89318. * Initializes the Hinge2-Joint
  89319. * @param jointData The joint data for the Hinge2-Joint
  89320. */
  89321. constructor(jointData: PhysicsJointData);
  89322. /**
  89323. * Set the motor values.
  89324. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89325. * @param {number} targetSpeed the speed the motor is to reach
  89326. * @param {number} maxForce max force for this motor.
  89327. * @param {motorIndex} the motor's index, 0 or 1.
  89328. */
  89329. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89330. /**
  89331. * Set the motor limits.
  89332. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89333. * @param {number} upperLimit the upper limit
  89334. * @param {number} lowerLimit lower limit
  89335. * @param {motorIndex} the motor's index, 0 or 1.
  89336. */
  89337. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89338. }
  89339. /**
  89340. * Interface for a motor enabled joint
  89341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89342. */
  89343. export interface IMotorEnabledJoint {
  89344. /**
  89345. * Physics joint
  89346. */
  89347. physicsJoint: any;
  89348. /**
  89349. * Sets the motor of the motor-enabled joint
  89350. * @param force The force of the motor
  89351. * @param maxForce The maximum force of the motor
  89352. * @param motorIndex The index of the motor
  89353. */
  89354. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89355. /**
  89356. * Sets the limit of the motor
  89357. * @param upperLimit The upper limit of the motor
  89358. * @param lowerLimit The lower limit of the motor
  89359. * @param motorIndex The index of the motor
  89360. */
  89361. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89362. }
  89363. /**
  89364. * Joint data for a Distance-Joint
  89365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89366. */
  89367. export interface DistanceJointData extends PhysicsJointData {
  89368. /**
  89369. * Max distance the 2 joint objects can be apart
  89370. */
  89371. maxDistance: number;
  89372. }
  89373. /**
  89374. * Joint data from a spring joint
  89375. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89376. */
  89377. export interface SpringJointData extends PhysicsJointData {
  89378. /**
  89379. * Length of the spring
  89380. */
  89381. length: number;
  89382. /**
  89383. * Stiffness of the spring
  89384. */
  89385. stiffness: number;
  89386. /**
  89387. * Damping of the spring
  89388. */
  89389. damping: number;
  89390. /** this callback will be called when applying the force to the impostors. */
  89391. forceApplicationCallback: () => void;
  89392. }
  89393. }
  89394. declare module BABYLON {
  89395. /**
  89396. * Holds the data for the raycast result
  89397. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89398. */
  89399. export class PhysicsRaycastResult {
  89400. private _hasHit;
  89401. private _hitDistance;
  89402. private _hitNormalWorld;
  89403. private _hitPointWorld;
  89404. private _rayFromWorld;
  89405. private _rayToWorld;
  89406. /**
  89407. * Gets if there was a hit
  89408. */
  89409. readonly hasHit: boolean;
  89410. /**
  89411. * Gets the distance from the hit
  89412. */
  89413. readonly hitDistance: number;
  89414. /**
  89415. * Gets the hit normal/direction in the world
  89416. */
  89417. readonly hitNormalWorld: Vector3;
  89418. /**
  89419. * Gets the hit point in the world
  89420. */
  89421. readonly hitPointWorld: Vector3;
  89422. /**
  89423. * Gets the ray "start point" of the ray in the world
  89424. */
  89425. readonly rayFromWorld: Vector3;
  89426. /**
  89427. * Gets the ray "end point" of the ray in the world
  89428. */
  89429. readonly rayToWorld: Vector3;
  89430. /**
  89431. * Sets the hit data (normal & point in world space)
  89432. * @param hitNormalWorld defines the normal in world space
  89433. * @param hitPointWorld defines the point in world space
  89434. */
  89435. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89436. /**
  89437. * Sets the distance from the start point to the hit point
  89438. * @param distance
  89439. */
  89440. setHitDistance(distance: number): void;
  89441. /**
  89442. * Calculates the distance manually
  89443. */
  89444. calculateHitDistance(): void;
  89445. /**
  89446. * Resets all the values to default
  89447. * @param from The from point on world space
  89448. * @param to The to point on world space
  89449. */
  89450. reset(from?: Vector3, to?: Vector3): void;
  89451. }
  89452. /**
  89453. * Interface for the size containing width and height
  89454. */
  89455. interface IXYZ {
  89456. /**
  89457. * X
  89458. */
  89459. x: number;
  89460. /**
  89461. * Y
  89462. */
  89463. y: number;
  89464. /**
  89465. * Z
  89466. */
  89467. z: number;
  89468. }
  89469. }
  89470. declare module BABYLON {
  89471. /**
  89472. * Interface used to describe a physics joint
  89473. */
  89474. export interface PhysicsImpostorJoint {
  89475. /** Defines the main impostor to which the joint is linked */
  89476. mainImpostor: PhysicsImpostor;
  89477. /** Defines the impostor that is connected to the main impostor using this joint */
  89478. connectedImpostor: PhysicsImpostor;
  89479. /** Defines the joint itself */
  89480. joint: PhysicsJoint;
  89481. }
  89482. /** @hidden */
  89483. export interface IPhysicsEnginePlugin {
  89484. world: any;
  89485. name: string;
  89486. setGravity(gravity: Vector3): void;
  89487. setTimeStep(timeStep: number): void;
  89488. getTimeStep(): number;
  89489. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89490. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89491. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89492. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89493. removePhysicsBody(impostor: PhysicsImpostor): void;
  89494. generateJoint(joint: PhysicsImpostorJoint): void;
  89495. removeJoint(joint: PhysicsImpostorJoint): void;
  89496. isSupported(): boolean;
  89497. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89498. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89499. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89500. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89501. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89502. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89503. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89504. getBodyMass(impostor: PhysicsImpostor): number;
  89505. getBodyFriction(impostor: PhysicsImpostor): number;
  89506. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89507. getBodyRestitution(impostor: PhysicsImpostor): number;
  89508. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89509. getBodyPressure?(impostor: PhysicsImpostor): number;
  89510. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89511. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89512. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89513. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89514. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89515. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89516. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89517. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89518. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89519. sleepBody(impostor: PhysicsImpostor): void;
  89520. wakeUpBody(impostor: PhysicsImpostor): void;
  89521. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89522. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89523. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89524. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89525. getRadius(impostor: PhysicsImpostor): number;
  89526. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89527. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89528. dispose(): void;
  89529. }
  89530. /**
  89531. * Interface used to define a physics engine
  89532. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89533. */
  89534. export interface IPhysicsEngine {
  89535. /**
  89536. * Gets the gravity vector used by the simulation
  89537. */
  89538. gravity: Vector3;
  89539. /**
  89540. * Sets the gravity vector used by the simulation
  89541. * @param gravity defines the gravity vector to use
  89542. */
  89543. setGravity(gravity: Vector3): void;
  89544. /**
  89545. * Set the time step of the physics engine.
  89546. * Default is 1/60.
  89547. * To slow it down, enter 1/600 for example.
  89548. * To speed it up, 1/30
  89549. * @param newTimeStep the new timestep to apply to this world.
  89550. */
  89551. setTimeStep(newTimeStep: number): void;
  89552. /**
  89553. * Get the time step of the physics engine.
  89554. * @returns the current time step
  89555. */
  89556. getTimeStep(): number;
  89557. /**
  89558. * Release all resources
  89559. */
  89560. dispose(): void;
  89561. /**
  89562. * Gets the name of the current physics plugin
  89563. * @returns the name of the plugin
  89564. */
  89565. getPhysicsPluginName(): string;
  89566. /**
  89567. * Adding a new impostor for the impostor tracking.
  89568. * This will be done by the impostor itself.
  89569. * @param impostor the impostor to add
  89570. */
  89571. addImpostor(impostor: PhysicsImpostor): void;
  89572. /**
  89573. * Remove an impostor from the engine.
  89574. * This impostor and its mesh will not longer be updated by the physics engine.
  89575. * @param impostor the impostor to remove
  89576. */
  89577. removeImpostor(impostor: PhysicsImpostor): void;
  89578. /**
  89579. * Add a joint to the physics engine
  89580. * @param mainImpostor defines the main impostor to which the joint is added.
  89581. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89582. * @param joint defines the joint that will connect both impostors.
  89583. */
  89584. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89585. /**
  89586. * Removes a joint from the simulation
  89587. * @param mainImpostor defines the impostor used with the joint
  89588. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89589. * @param joint defines the joint to remove
  89590. */
  89591. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89592. /**
  89593. * Gets the current plugin used to run the simulation
  89594. * @returns current plugin
  89595. */
  89596. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89597. /**
  89598. * Gets the list of physic impostors
  89599. * @returns an array of PhysicsImpostor
  89600. */
  89601. getImpostors(): Array<PhysicsImpostor>;
  89602. /**
  89603. * Gets the impostor for a physics enabled object
  89604. * @param object defines the object impersonated by the impostor
  89605. * @returns the PhysicsImpostor or null if not found
  89606. */
  89607. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89608. /**
  89609. * Gets the impostor for a physics body object
  89610. * @param body defines physics body used by the impostor
  89611. * @returns the PhysicsImpostor or null if not found
  89612. */
  89613. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89614. /**
  89615. * Does a raycast in the physics world
  89616. * @param from when should the ray start?
  89617. * @param to when should the ray end?
  89618. * @returns PhysicsRaycastResult
  89619. */
  89620. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89621. /**
  89622. * Called by the scene. No need to call it.
  89623. * @param delta defines the timespam between frames
  89624. */
  89625. _step(delta: number): void;
  89626. }
  89627. }
  89628. declare module BABYLON {
  89629. /**
  89630. * The interface for the physics imposter parameters
  89631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89632. */
  89633. export interface PhysicsImpostorParameters {
  89634. /**
  89635. * The mass of the physics imposter
  89636. */
  89637. mass: number;
  89638. /**
  89639. * The friction of the physics imposter
  89640. */
  89641. friction?: number;
  89642. /**
  89643. * The coefficient of restitution of the physics imposter
  89644. */
  89645. restitution?: number;
  89646. /**
  89647. * The native options of the physics imposter
  89648. */
  89649. nativeOptions?: any;
  89650. /**
  89651. * Specifies if the parent should be ignored
  89652. */
  89653. ignoreParent?: boolean;
  89654. /**
  89655. * Specifies if bi-directional transformations should be disabled
  89656. */
  89657. disableBidirectionalTransformation?: boolean;
  89658. /**
  89659. * The pressure inside the physics imposter, soft object only
  89660. */
  89661. pressure?: number;
  89662. /**
  89663. * The stiffness the physics imposter, soft object only
  89664. */
  89665. stiffness?: number;
  89666. /**
  89667. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89668. */
  89669. velocityIterations?: number;
  89670. /**
  89671. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89672. */
  89673. positionIterations?: number;
  89674. /**
  89675. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89676. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89677. * Add to fix multiple points
  89678. */
  89679. fixedPoints?: number;
  89680. /**
  89681. * The collision margin around a soft object
  89682. */
  89683. margin?: number;
  89684. /**
  89685. * The collision margin around a soft object
  89686. */
  89687. damping?: number;
  89688. /**
  89689. * The path for a rope based on an extrusion
  89690. */
  89691. path?: any;
  89692. /**
  89693. * The shape of an extrusion used for a rope based on an extrusion
  89694. */
  89695. shape?: any;
  89696. }
  89697. /**
  89698. * Interface for a physics-enabled object
  89699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89700. */
  89701. export interface IPhysicsEnabledObject {
  89702. /**
  89703. * The position of the physics-enabled object
  89704. */
  89705. position: Vector3;
  89706. /**
  89707. * The rotation of the physics-enabled object
  89708. */
  89709. rotationQuaternion: Nullable<Quaternion>;
  89710. /**
  89711. * The scale of the physics-enabled object
  89712. */
  89713. scaling: Vector3;
  89714. /**
  89715. * The rotation of the physics-enabled object
  89716. */
  89717. rotation?: Vector3;
  89718. /**
  89719. * The parent of the physics-enabled object
  89720. */
  89721. parent?: any;
  89722. /**
  89723. * The bounding info of the physics-enabled object
  89724. * @returns The bounding info of the physics-enabled object
  89725. */
  89726. getBoundingInfo(): BoundingInfo;
  89727. /**
  89728. * Computes the world matrix
  89729. * @param force Specifies if the world matrix should be computed by force
  89730. * @returns A world matrix
  89731. */
  89732. computeWorldMatrix(force: boolean): Matrix;
  89733. /**
  89734. * Gets the world matrix
  89735. * @returns A world matrix
  89736. */
  89737. getWorldMatrix?(): Matrix;
  89738. /**
  89739. * Gets the child meshes
  89740. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89741. * @returns An array of abstract meshes
  89742. */
  89743. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89744. /**
  89745. * Gets the vertex data
  89746. * @param kind The type of vertex data
  89747. * @returns A nullable array of numbers, or a float32 array
  89748. */
  89749. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89750. /**
  89751. * Gets the indices from the mesh
  89752. * @returns A nullable array of index arrays
  89753. */
  89754. getIndices?(): Nullable<IndicesArray>;
  89755. /**
  89756. * Gets the scene from the mesh
  89757. * @returns the indices array or null
  89758. */
  89759. getScene?(): Scene;
  89760. /**
  89761. * Gets the absolute position from the mesh
  89762. * @returns the absolute position
  89763. */
  89764. getAbsolutePosition(): Vector3;
  89765. /**
  89766. * Gets the absolute pivot point from the mesh
  89767. * @returns the absolute pivot point
  89768. */
  89769. getAbsolutePivotPoint(): Vector3;
  89770. /**
  89771. * Rotates the mesh
  89772. * @param axis The axis of rotation
  89773. * @param amount The amount of rotation
  89774. * @param space The space of the rotation
  89775. * @returns The rotation transform node
  89776. */
  89777. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89778. /**
  89779. * Translates the mesh
  89780. * @param axis The axis of translation
  89781. * @param distance The distance of translation
  89782. * @param space The space of the translation
  89783. * @returns The transform node
  89784. */
  89785. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89786. /**
  89787. * Sets the absolute position of the mesh
  89788. * @param absolutePosition The absolute position of the mesh
  89789. * @returns The transform node
  89790. */
  89791. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89792. /**
  89793. * Gets the class name of the mesh
  89794. * @returns The class name
  89795. */
  89796. getClassName(): string;
  89797. }
  89798. /**
  89799. * Represents a physics imposter
  89800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89801. */
  89802. export class PhysicsImpostor {
  89803. /**
  89804. * The physics-enabled object used as the physics imposter
  89805. */
  89806. object: IPhysicsEnabledObject;
  89807. /**
  89808. * The type of the physics imposter
  89809. */
  89810. type: number;
  89811. private _options;
  89812. private _scene?;
  89813. /**
  89814. * The default object size of the imposter
  89815. */
  89816. static DEFAULT_OBJECT_SIZE: Vector3;
  89817. /**
  89818. * The identity quaternion of the imposter
  89819. */
  89820. static IDENTITY_QUATERNION: Quaternion;
  89821. /** @hidden */
  89822. _pluginData: any;
  89823. private _physicsEngine;
  89824. private _physicsBody;
  89825. private _bodyUpdateRequired;
  89826. private _onBeforePhysicsStepCallbacks;
  89827. private _onAfterPhysicsStepCallbacks;
  89828. /** @hidden */
  89829. _onPhysicsCollideCallbacks: Array<{
  89830. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89831. otherImpostors: Array<PhysicsImpostor>;
  89832. }>;
  89833. private _deltaPosition;
  89834. private _deltaRotation;
  89835. private _deltaRotationConjugated;
  89836. /** @hidden */
  89837. _isFromLine: boolean;
  89838. private _parent;
  89839. private _isDisposed;
  89840. private static _tmpVecs;
  89841. private static _tmpQuat;
  89842. /**
  89843. * Specifies if the physics imposter is disposed
  89844. */
  89845. readonly isDisposed: boolean;
  89846. /**
  89847. * Gets the mass of the physics imposter
  89848. */
  89849. mass: number;
  89850. /**
  89851. * Gets the coefficient of friction
  89852. */
  89853. /**
  89854. * Sets the coefficient of friction
  89855. */
  89856. friction: number;
  89857. /**
  89858. * Gets the coefficient of restitution
  89859. */
  89860. /**
  89861. * Sets the coefficient of restitution
  89862. */
  89863. restitution: number;
  89864. /**
  89865. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89866. */
  89867. /**
  89868. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89869. */
  89870. pressure: number;
  89871. /**
  89872. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89873. */
  89874. /**
  89875. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89876. */
  89877. stiffness: number;
  89878. /**
  89879. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89880. */
  89881. /**
  89882. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89883. */
  89884. velocityIterations: number;
  89885. /**
  89886. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89887. */
  89888. /**
  89889. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89890. */
  89891. positionIterations: number;
  89892. /**
  89893. * The unique id of the physics imposter
  89894. * set by the physics engine when adding this impostor to the array
  89895. */
  89896. uniqueId: number;
  89897. /**
  89898. * @hidden
  89899. */
  89900. soft: boolean;
  89901. /**
  89902. * @hidden
  89903. */
  89904. segments: number;
  89905. private _joints;
  89906. /**
  89907. * Initializes the physics imposter
  89908. * @param object The physics-enabled object used as the physics imposter
  89909. * @param type The type of the physics imposter
  89910. * @param _options The options for the physics imposter
  89911. * @param _scene The Babylon scene
  89912. */
  89913. constructor(
  89914. /**
  89915. * The physics-enabled object used as the physics imposter
  89916. */
  89917. object: IPhysicsEnabledObject,
  89918. /**
  89919. * The type of the physics imposter
  89920. */
  89921. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89922. /**
  89923. * This function will completly initialize this impostor.
  89924. * It will create a new body - but only if this mesh has no parent.
  89925. * If it has, this impostor will not be used other than to define the impostor
  89926. * of the child mesh.
  89927. * @hidden
  89928. */
  89929. _init(): void;
  89930. private _getPhysicsParent;
  89931. /**
  89932. * Should a new body be generated.
  89933. * @returns boolean specifying if body initialization is required
  89934. */
  89935. isBodyInitRequired(): boolean;
  89936. /**
  89937. * Sets the updated scaling
  89938. * @param updated Specifies if the scaling is updated
  89939. */
  89940. setScalingUpdated(): void;
  89941. /**
  89942. * Force a regeneration of this or the parent's impostor's body.
  89943. * Use under cautious - This will remove all joints already implemented.
  89944. */
  89945. forceUpdate(): void;
  89946. /**
  89947. * Gets the body that holds this impostor. Either its own, or its parent.
  89948. */
  89949. /**
  89950. * Set the physics body. Used mainly by the physics engine/plugin
  89951. */
  89952. physicsBody: any;
  89953. /**
  89954. * Get the parent of the physics imposter
  89955. * @returns Physics imposter or null
  89956. */
  89957. /**
  89958. * Sets the parent of the physics imposter
  89959. */
  89960. parent: Nullable<PhysicsImpostor>;
  89961. /**
  89962. * Resets the update flags
  89963. */
  89964. resetUpdateFlags(): void;
  89965. /**
  89966. * Gets the object extend size
  89967. * @returns the object extend size
  89968. */
  89969. getObjectExtendSize(): Vector3;
  89970. /**
  89971. * Gets the object center
  89972. * @returns The object center
  89973. */
  89974. getObjectCenter(): Vector3;
  89975. /**
  89976. * Get a specific parametes from the options parameter
  89977. * @param paramName The object parameter name
  89978. * @returns The object parameter
  89979. */
  89980. getParam(paramName: string): any;
  89981. /**
  89982. * Sets a specific parameter in the options given to the physics plugin
  89983. * @param paramName The parameter name
  89984. * @param value The value of the parameter
  89985. */
  89986. setParam(paramName: string, value: number): void;
  89987. /**
  89988. * Specifically change the body's mass option. Won't recreate the physics body object
  89989. * @param mass The mass of the physics imposter
  89990. */
  89991. setMass(mass: number): void;
  89992. /**
  89993. * Gets the linear velocity
  89994. * @returns linear velocity or null
  89995. */
  89996. getLinearVelocity(): Nullable<Vector3>;
  89997. /**
  89998. * Sets the linear velocity
  89999. * @param velocity linear velocity or null
  90000. */
  90001. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90002. /**
  90003. * Gets the angular velocity
  90004. * @returns angular velocity or null
  90005. */
  90006. getAngularVelocity(): Nullable<Vector3>;
  90007. /**
  90008. * Sets the angular velocity
  90009. * @param velocity The velocity or null
  90010. */
  90011. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90012. /**
  90013. * Execute a function with the physics plugin native code
  90014. * Provide a function the will have two variables - the world object and the physics body object
  90015. * @param func The function to execute with the physics plugin native code
  90016. */
  90017. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90018. /**
  90019. * Register a function that will be executed before the physics world is stepping forward
  90020. * @param func The function to execute before the physics world is stepped forward
  90021. */
  90022. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90023. /**
  90024. * Unregister 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. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90028. /**
  90029. * Register a function that will be executed after the physics step
  90030. * @param func The function to execute after physics step
  90031. */
  90032. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90033. /**
  90034. * Unregisters a function that will be executed after the physics step
  90035. * @param func The function to execute after physics step
  90036. */
  90037. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90038. /**
  90039. * register a function that will be executed when this impostor collides against a different body
  90040. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90041. * @param func Callback that is executed on collision
  90042. */
  90043. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90044. /**
  90045. * Unregisters the physics imposter on contact
  90046. * @param collideAgainst The physics object to collide against
  90047. * @param func Callback to execute on collision
  90048. */
  90049. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90050. private _tmpQuat;
  90051. private _tmpQuat2;
  90052. /**
  90053. * Get the parent rotation
  90054. * @returns The parent rotation
  90055. */
  90056. getParentsRotation(): Quaternion;
  90057. /**
  90058. * this function is executed by the physics engine.
  90059. */
  90060. beforeStep: () => void;
  90061. /**
  90062. * this function is executed by the physics engine
  90063. */
  90064. afterStep: () => void;
  90065. /**
  90066. * Legacy collision detection event support
  90067. */
  90068. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90069. /**
  90070. * event and body object due to cannon's event-based architecture.
  90071. */
  90072. onCollide: (e: {
  90073. body: any;
  90074. }) => void;
  90075. /**
  90076. * Apply a force
  90077. * @param force The force to apply
  90078. * @param contactPoint The contact point for the force
  90079. * @returns The physics imposter
  90080. */
  90081. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90082. /**
  90083. * Apply an impulse
  90084. * @param force The impulse force
  90085. * @param contactPoint The contact point for the impulse force
  90086. * @returns The physics imposter
  90087. */
  90088. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90089. /**
  90090. * A help function to create a joint
  90091. * @param otherImpostor A physics imposter used to create a joint
  90092. * @param jointType The type of joint
  90093. * @param jointData The data for the joint
  90094. * @returns The physics imposter
  90095. */
  90096. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90097. /**
  90098. * Add a joint to this impostor with a different impostor
  90099. * @param otherImpostor A physics imposter used to add a joint
  90100. * @param joint The joint to add
  90101. * @returns The physics imposter
  90102. */
  90103. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90104. /**
  90105. * Add an anchor to a cloth impostor
  90106. * @param otherImpostor rigid impostor to anchor to
  90107. * @param width ratio across width from 0 to 1
  90108. * @param height ratio up height from 0 to 1
  90109. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90110. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90111. * @returns impostor the soft imposter
  90112. */
  90113. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90114. /**
  90115. * Add a hook to a rope impostor
  90116. * @param otherImpostor rigid impostor to anchor to
  90117. * @param length ratio across rope from 0 to 1
  90118. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90119. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90120. * @returns impostor the rope imposter
  90121. */
  90122. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90123. /**
  90124. * Will keep this body still, in a sleep mode.
  90125. * @returns the physics imposter
  90126. */
  90127. sleep(): PhysicsImpostor;
  90128. /**
  90129. * Wake the body up.
  90130. * @returns The physics imposter
  90131. */
  90132. wakeUp(): PhysicsImpostor;
  90133. /**
  90134. * Clones the physics imposter
  90135. * @param newObject The physics imposter clones to this physics-enabled object
  90136. * @returns A nullable physics imposter
  90137. */
  90138. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90139. /**
  90140. * Disposes the physics imposter
  90141. */
  90142. dispose(): void;
  90143. /**
  90144. * Sets the delta position
  90145. * @param position The delta position amount
  90146. */
  90147. setDeltaPosition(position: Vector3): void;
  90148. /**
  90149. * Sets the delta rotation
  90150. * @param rotation The delta rotation amount
  90151. */
  90152. setDeltaRotation(rotation: Quaternion): void;
  90153. /**
  90154. * Gets the box size of the physics imposter and stores the result in the input parameter
  90155. * @param result Stores the box size
  90156. * @returns The physics imposter
  90157. */
  90158. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90159. /**
  90160. * Gets the radius of the physics imposter
  90161. * @returns Radius of the physics imposter
  90162. */
  90163. getRadius(): number;
  90164. /**
  90165. * Sync a bone with this impostor
  90166. * @param bone The bone to sync to the impostor.
  90167. * @param boneMesh The mesh that the bone is influencing.
  90168. * @param jointPivot The pivot of the joint / bone in local space.
  90169. * @param distToJoint Optional distance from the impostor to the joint.
  90170. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90171. */
  90172. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90173. /**
  90174. * Sync impostor to a bone
  90175. * @param bone The bone that the impostor will be synced to.
  90176. * @param boneMesh The mesh that the bone is influencing.
  90177. * @param jointPivot The pivot of the joint / bone in local space.
  90178. * @param distToJoint Optional distance from the impostor to the joint.
  90179. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90180. * @param boneAxis Optional vector3 axis the bone is aligned with
  90181. */
  90182. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90183. /**
  90184. * No-Imposter type
  90185. */
  90186. static NoImpostor: number;
  90187. /**
  90188. * Sphere-Imposter type
  90189. */
  90190. static SphereImpostor: number;
  90191. /**
  90192. * Box-Imposter type
  90193. */
  90194. static BoxImpostor: number;
  90195. /**
  90196. * Plane-Imposter type
  90197. */
  90198. static PlaneImpostor: number;
  90199. /**
  90200. * Mesh-imposter type
  90201. */
  90202. static MeshImpostor: number;
  90203. /**
  90204. * Capsule-Impostor type (Ammo.js plugin only)
  90205. */
  90206. static CapsuleImpostor: number;
  90207. /**
  90208. * Cylinder-Imposter type
  90209. */
  90210. static CylinderImpostor: number;
  90211. /**
  90212. * Particle-Imposter type
  90213. */
  90214. static ParticleImpostor: number;
  90215. /**
  90216. * Heightmap-Imposter type
  90217. */
  90218. static HeightmapImpostor: number;
  90219. /**
  90220. * ConvexHull-Impostor type (Ammo.js plugin only)
  90221. */
  90222. static ConvexHullImpostor: number;
  90223. /**
  90224. * Rope-Imposter type
  90225. */
  90226. static RopeImpostor: number;
  90227. /**
  90228. * Cloth-Imposter type
  90229. */
  90230. static ClothImpostor: number;
  90231. /**
  90232. * Softbody-Imposter type
  90233. */
  90234. static SoftbodyImpostor: number;
  90235. }
  90236. }
  90237. declare module BABYLON {
  90238. /**
  90239. * @hidden
  90240. **/
  90241. export class _CreationDataStorage {
  90242. closePath?: boolean;
  90243. closeArray?: boolean;
  90244. idx: number[];
  90245. dashSize: number;
  90246. gapSize: number;
  90247. path3D: Path3D;
  90248. pathArray: Vector3[][];
  90249. arc: number;
  90250. radius: number;
  90251. cap: number;
  90252. tessellation: number;
  90253. }
  90254. /**
  90255. * @hidden
  90256. **/
  90257. class _InstanceDataStorage {
  90258. visibleInstances: any;
  90259. batchCache: _InstancesBatch;
  90260. instancesBufferSize: number;
  90261. instancesBuffer: Nullable<Buffer>;
  90262. instancesData: Float32Array;
  90263. overridenInstanceCount: number;
  90264. isFrozen: boolean;
  90265. previousBatch: Nullable<_InstancesBatch>;
  90266. hardwareInstancedRendering: boolean;
  90267. sideOrientation: number;
  90268. }
  90269. /**
  90270. * @hidden
  90271. **/
  90272. export class _InstancesBatch {
  90273. mustReturn: boolean;
  90274. visibleInstances: Nullable<InstancedMesh[]>[];
  90275. renderSelf: boolean[];
  90276. hardwareInstancedRendering: boolean[];
  90277. }
  90278. /**
  90279. * Class used to represent renderable models
  90280. */
  90281. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90282. /**
  90283. * Mesh side orientation : usually the external or front surface
  90284. */
  90285. static readonly FRONTSIDE: number;
  90286. /**
  90287. * Mesh side orientation : usually the internal or back surface
  90288. */
  90289. static readonly BACKSIDE: number;
  90290. /**
  90291. * Mesh side orientation : both internal and external or front and back surfaces
  90292. */
  90293. static readonly DOUBLESIDE: number;
  90294. /**
  90295. * Mesh side orientation : by default, `FRONTSIDE`
  90296. */
  90297. static readonly DEFAULTSIDE: number;
  90298. /**
  90299. * Mesh cap setting : no cap
  90300. */
  90301. static readonly NO_CAP: number;
  90302. /**
  90303. * Mesh cap setting : one cap at the beginning of the mesh
  90304. */
  90305. static readonly CAP_START: number;
  90306. /**
  90307. * Mesh cap setting : one cap at the end of the mesh
  90308. */
  90309. static readonly CAP_END: number;
  90310. /**
  90311. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90312. */
  90313. static readonly CAP_ALL: number;
  90314. /**
  90315. * Mesh pattern setting : no flip or rotate
  90316. */
  90317. static readonly NO_FLIP: number;
  90318. /**
  90319. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90320. */
  90321. static readonly FLIP_TILE: number;
  90322. /**
  90323. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90324. */
  90325. static readonly ROTATE_TILE: number;
  90326. /**
  90327. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90328. */
  90329. static readonly FLIP_ROW: number;
  90330. /**
  90331. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90332. */
  90333. static readonly ROTATE_ROW: number;
  90334. /**
  90335. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90336. */
  90337. static readonly FLIP_N_ROTATE_TILE: number;
  90338. /**
  90339. * Mesh pattern setting : rotate pattern and rotate
  90340. */
  90341. static readonly FLIP_N_ROTATE_ROW: number;
  90342. /**
  90343. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90344. */
  90345. static readonly CENTER: number;
  90346. /**
  90347. * Mesh tile positioning : part tiles on left
  90348. */
  90349. static readonly LEFT: number;
  90350. /**
  90351. * Mesh tile positioning : part tiles on right
  90352. */
  90353. static readonly RIGHT: number;
  90354. /**
  90355. * Mesh tile positioning : part tiles on top
  90356. */
  90357. static readonly TOP: number;
  90358. /**
  90359. * Mesh tile positioning : part tiles on bottom
  90360. */
  90361. static readonly BOTTOM: number;
  90362. /**
  90363. * Gets the default side orientation.
  90364. * @param orientation the orientation to value to attempt to get
  90365. * @returns the default orientation
  90366. * @hidden
  90367. */
  90368. static _GetDefaultSideOrientation(orientation?: number): number;
  90369. private _internalMeshDataInfo;
  90370. /**
  90371. * An event triggered before rendering the mesh
  90372. */
  90373. readonly onBeforeRenderObservable: Observable<Mesh>;
  90374. /**
  90375. * An event triggered before binding the mesh
  90376. */
  90377. readonly onBeforeBindObservable: Observable<Mesh>;
  90378. /**
  90379. * An event triggered after rendering the mesh
  90380. */
  90381. readonly onAfterRenderObservable: Observable<Mesh>;
  90382. /**
  90383. * An event triggered before drawing the mesh
  90384. */
  90385. readonly onBeforeDrawObservable: Observable<Mesh>;
  90386. private _onBeforeDrawObserver;
  90387. /**
  90388. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90389. */
  90390. onBeforeDraw: () => void;
  90391. readonly hasInstances: boolean;
  90392. /**
  90393. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90394. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90395. */
  90396. delayLoadState: number;
  90397. /**
  90398. * Gets the list of instances created from this mesh
  90399. * it is not supposed to be modified manually.
  90400. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90401. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90402. */
  90403. instances: InstancedMesh[];
  90404. /**
  90405. * Gets the file containing delay loading data for this mesh
  90406. */
  90407. delayLoadingFile: string;
  90408. /** @hidden */
  90409. _binaryInfo: any;
  90410. /**
  90411. * User defined function used to change how LOD level selection is done
  90412. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90413. */
  90414. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90415. /**
  90416. * Gets or sets the morph target manager
  90417. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90418. */
  90419. morphTargetManager: Nullable<MorphTargetManager>;
  90420. /** @hidden */
  90421. _creationDataStorage: Nullable<_CreationDataStorage>;
  90422. /** @hidden */
  90423. _geometry: Nullable<Geometry>;
  90424. /** @hidden */
  90425. _delayInfo: Array<string>;
  90426. /** @hidden */
  90427. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90428. /** @hidden */
  90429. _instanceDataStorage: _InstanceDataStorage;
  90430. private _effectiveMaterial;
  90431. /** @hidden */
  90432. _shouldGenerateFlatShading: boolean;
  90433. /** @hidden */
  90434. _originalBuilderSideOrientation: number;
  90435. /**
  90436. * Use this property to change the original side orientation defined at construction time
  90437. */
  90438. overrideMaterialSideOrientation: Nullable<number>;
  90439. /**
  90440. * Gets the source mesh (the one used to clone this one from)
  90441. */
  90442. readonly source: Nullable<Mesh>;
  90443. /**
  90444. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90445. */
  90446. isUnIndexed: boolean;
  90447. /**
  90448. * @constructor
  90449. * @param name The value used by scene.getMeshByName() to do a lookup.
  90450. * @param scene The scene to add this mesh to.
  90451. * @param parent The parent of this mesh, if it has one
  90452. * @param source An optional Mesh from which geometry is shared, cloned.
  90453. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90454. * When false, achieved by calling a clone(), also passing False.
  90455. * This will make creation of children, recursive.
  90456. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90457. */
  90458. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90459. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90460. /**
  90461. * Gets the class name
  90462. * @returns the string "Mesh".
  90463. */
  90464. getClassName(): string;
  90465. /** @hidden */
  90466. readonly _isMesh: boolean;
  90467. /**
  90468. * Returns a description of this mesh
  90469. * @param fullDetails define if full details about this mesh must be used
  90470. * @returns a descriptive string representing this mesh
  90471. */
  90472. toString(fullDetails?: boolean): string;
  90473. /** @hidden */
  90474. _unBindEffect(): void;
  90475. /**
  90476. * Gets a boolean indicating if this mesh has LOD
  90477. */
  90478. readonly hasLODLevels: boolean;
  90479. /**
  90480. * Gets the list of MeshLODLevel associated with the current mesh
  90481. * @returns an array of MeshLODLevel
  90482. */
  90483. getLODLevels(): MeshLODLevel[];
  90484. private _sortLODLevels;
  90485. /**
  90486. * Add a mesh as LOD level triggered at the given distance.
  90487. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90488. * @param distance The distance from the center of the object to show this level
  90489. * @param mesh The mesh to be added as LOD level (can be null)
  90490. * @return This mesh (for chaining)
  90491. */
  90492. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90493. /**
  90494. * Returns the LOD level mesh at the passed distance or null if not found.
  90495. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90496. * @param distance The distance from the center of the object to show this level
  90497. * @returns a Mesh or `null`
  90498. */
  90499. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90500. /**
  90501. * Remove a mesh from the LOD array
  90502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90503. * @param mesh defines the mesh to be removed
  90504. * @return This mesh (for chaining)
  90505. */
  90506. removeLODLevel(mesh: Mesh): Mesh;
  90507. /**
  90508. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90509. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90510. * @param camera defines the camera to use to compute distance
  90511. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90512. * @return This mesh (for chaining)
  90513. */
  90514. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90515. /**
  90516. * Gets the mesh internal Geometry object
  90517. */
  90518. readonly geometry: Nullable<Geometry>;
  90519. /**
  90520. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90521. * @returns the total number of vertices
  90522. */
  90523. getTotalVertices(): number;
  90524. /**
  90525. * Returns the content of an associated vertex buffer
  90526. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90527. * - VertexBuffer.PositionKind
  90528. * - VertexBuffer.UVKind
  90529. * - VertexBuffer.UV2Kind
  90530. * - VertexBuffer.UV3Kind
  90531. * - VertexBuffer.UV4Kind
  90532. * - VertexBuffer.UV5Kind
  90533. * - VertexBuffer.UV6Kind
  90534. * - VertexBuffer.ColorKind
  90535. * - VertexBuffer.MatricesIndicesKind
  90536. * - VertexBuffer.MatricesIndicesExtraKind
  90537. * - VertexBuffer.MatricesWeightsKind
  90538. * - VertexBuffer.MatricesWeightsExtraKind
  90539. * @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
  90540. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90541. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90542. */
  90543. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90544. /**
  90545. * Returns the mesh VertexBuffer object from the requested `kind`
  90546. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90547. * - VertexBuffer.PositionKind
  90548. * - VertexBuffer.NormalKind
  90549. * - VertexBuffer.UVKind
  90550. * - VertexBuffer.UV2Kind
  90551. * - VertexBuffer.UV3Kind
  90552. * - VertexBuffer.UV4Kind
  90553. * - VertexBuffer.UV5Kind
  90554. * - VertexBuffer.UV6Kind
  90555. * - VertexBuffer.ColorKind
  90556. * - VertexBuffer.MatricesIndicesKind
  90557. * - VertexBuffer.MatricesIndicesExtraKind
  90558. * - VertexBuffer.MatricesWeightsKind
  90559. * - VertexBuffer.MatricesWeightsExtraKind
  90560. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90561. */
  90562. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90563. /**
  90564. * Tests if a specific vertex buffer is associated with this mesh
  90565. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90566. * - VertexBuffer.PositionKind
  90567. * - VertexBuffer.NormalKind
  90568. * - VertexBuffer.UVKind
  90569. * - VertexBuffer.UV2Kind
  90570. * - VertexBuffer.UV3Kind
  90571. * - VertexBuffer.UV4Kind
  90572. * - VertexBuffer.UV5Kind
  90573. * - VertexBuffer.UV6Kind
  90574. * - VertexBuffer.ColorKind
  90575. * - VertexBuffer.MatricesIndicesKind
  90576. * - VertexBuffer.MatricesIndicesExtraKind
  90577. * - VertexBuffer.MatricesWeightsKind
  90578. * - VertexBuffer.MatricesWeightsExtraKind
  90579. * @returns a boolean
  90580. */
  90581. isVerticesDataPresent(kind: string): boolean;
  90582. /**
  90583. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90584. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90585. * - VertexBuffer.PositionKind
  90586. * - VertexBuffer.UVKind
  90587. * - VertexBuffer.UV2Kind
  90588. * - VertexBuffer.UV3Kind
  90589. * - VertexBuffer.UV4Kind
  90590. * - VertexBuffer.UV5Kind
  90591. * - VertexBuffer.UV6Kind
  90592. * - VertexBuffer.ColorKind
  90593. * - VertexBuffer.MatricesIndicesKind
  90594. * - VertexBuffer.MatricesIndicesExtraKind
  90595. * - VertexBuffer.MatricesWeightsKind
  90596. * - VertexBuffer.MatricesWeightsExtraKind
  90597. * @returns a boolean
  90598. */
  90599. isVertexBufferUpdatable(kind: string): boolean;
  90600. /**
  90601. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90602. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90603. * - VertexBuffer.PositionKind
  90604. * - VertexBuffer.NormalKind
  90605. * - VertexBuffer.UVKind
  90606. * - VertexBuffer.UV2Kind
  90607. * - VertexBuffer.UV3Kind
  90608. * - VertexBuffer.UV4Kind
  90609. * - VertexBuffer.UV5Kind
  90610. * - VertexBuffer.UV6Kind
  90611. * - VertexBuffer.ColorKind
  90612. * - VertexBuffer.MatricesIndicesKind
  90613. * - VertexBuffer.MatricesIndicesExtraKind
  90614. * - VertexBuffer.MatricesWeightsKind
  90615. * - VertexBuffer.MatricesWeightsExtraKind
  90616. * @returns an array of strings
  90617. */
  90618. getVerticesDataKinds(): string[];
  90619. /**
  90620. * Returns a positive integer : the total number of indices in this mesh geometry.
  90621. * @returns the numner of indices or zero if the mesh has no geometry.
  90622. */
  90623. getTotalIndices(): number;
  90624. /**
  90625. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90626. * @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.
  90627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90628. * @returns the indices array or an empty array if the mesh has no geometry
  90629. */
  90630. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90631. readonly isBlocked: boolean;
  90632. /**
  90633. * Determine if the current mesh is ready to be rendered
  90634. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90635. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90636. * @returns true if all associated assets are ready (material, textures, shaders)
  90637. */
  90638. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90639. /**
  90640. * 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.
  90641. */
  90642. readonly areNormalsFrozen: boolean;
  90643. /**
  90644. * 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.
  90645. * @returns the current mesh
  90646. */
  90647. freezeNormals(): Mesh;
  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 reactivates the mesh normals computation if it was previously frozen
  90650. * @returns the current mesh
  90651. */
  90652. unfreezeNormals(): Mesh;
  90653. /**
  90654. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90655. */
  90656. overridenInstanceCount: number;
  90657. /** @hidden */
  90658. _preActivate(): Mesh;
  90659. /** @hidden */
  90660. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90661. /** @hidden */
  90662. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90663. /**
  90664. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90665. * This means the mesh underlying bounding box and sphere are recomputed.
  90666. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90667. * @returns the current mesh
  90668. */
  90669. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90670. /** @hidden */
  90671. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90672. /**
  90673. * This function will subdivide the mesh into multiple submeshes
  90674. * @param count defines the expected number of submeshes
  90675. */
  90676. subdivide(count: number): void;
  90677. /**
  90678. * Copy a FloatArray into a specific associated vertex buffer
  90679. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90680. * - VertexBuffer.PositionKind
  90681. * - VertexBuffer.UVKind
  90682. * - VertexBuffer.UV2Kind
  90683. * - VertexBuffer.UV3Kind
  90684. * - VertexBuffer.UV4Kind
  90685. * - VertexBuffer.UV5Kind
  90686. * - VertexBuffer.UV6Kind
  90687. * - VertexBuffer.ColorKind
  90688. * - VertexBuffer.MatricesIndicesKind
  90689. * - VertexBuffer.MatricesIndicesExtraKind
  90690. * - VertexBuffer.MatricesWeightsKind
  90691. * - VertexBuffer.MatricesWeightsExtraKind
  90692. * @param data defines the data source
  90693. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90694. * @param stride defines the data stride size (can be null)
  90695. * @returns the current mesh
  90696. */
  90697. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90698. /**
  90699. * Flags an associated vertex buffer as updatable
  90700. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90701. * - VertexBuffer.PositionKind
  90702. * - VertexBuffer.UVKind
  90703. * - VertexBuffer.UV2Kind
  90704. * - VertexBuffer.UV3Kind
  90705. * - VertexBuffer.UV4Kind
  90706. * - VertexBuffer.UV5Kind
  90707. * - VertexBuffer.UV6Kind
  90708. * - VertexBuffer.ColorKind
  90709. * - VertexBuffer.MatricesIndicesKind
  90710. * - VertexBuffer.MatricesIndicesExtraKind
  90711. * - VertexBuffer.MatricesWeightsKind
  90712. * - VertexBuffer.MatricesWeightsExtraKind
  90713. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90714. */
  90715. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90716. /**
  90717. * Sets the mesh global Vertex Buffer
  90718. * @param buffer defines the buffer to use
  90719. * @returns the current mesh
  90720. */
  90721. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90722. /**
  90723. * Update a specific associated vertex buffer
  90724. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90725. * - VertexBuffer.PositionKind
  90726. * - VertexBuffer.UVKind
  90727. * - VertexBuffer.UV2Kind
  90728. * - VertexBuffer.UV3Kind
  90729. * - VertexBuffer.UV4Kind
  90730. * - VertexBuffer.UV5Kind
  90731. * - VertexBuffer.UV6Kind
  90732. * - VertexBuffer.ColorKind
  90733. * - VertexBuffer.MatricesIndicesKind
  90734. * - VertexBuffer.MatricesIndicesExtraKind
  90735. * - VertexBuffer.MatricesWeightsKind
  90736. * - VertexBuffer.MatricesWeightsExtraKind
  90737. * @param data defines the data source
  90738. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90739. * @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)
  90740. * @returns the current mesh
  90741. */
  90742. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90743. /**
  90744. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90745. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90746. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90747. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90748. * @returns the current mesh
  90749. */
  90750. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90751. /**
  90752. * Creates a un-shared specific occurence of the geometry for the mesh.
  90753. * @returns the current mesh
  90754. */
  90755. makeGeometryUnique(): Mesh;
  90756. /**
  90757. * Set the index buffer of this mesh
  90758. * @param indices defines the source data
  90759. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90760. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90761. * @returns the current mesh
  90762. */
  90763. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90764. /**
  90765. * Update the current index buffer
  90766. * @param indices defines the source data
  90767. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90768. * @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)
  90769. * @returns the current mesh
  90770. */
  90771. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90772. /**
  90773. * Invert the geometry to move from a right handed system to a left handed one.
  90774. * @returns the current mesh
  90775. */
  90776. toLeftHanded(): Mesh;
  90777. /** @hidden */
  90778. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90779. /** @hidden */
  90780. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90781. /**
  90782. * Registers for this mesh a javascript function called just before the rendering process
  90783. * @param func defines the function to call before rendering this mesh
  90784. * @returns the current mesh
  90785. */
  90786. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90787. /**
  90788. * Disposes a previously registered javascript function called before the rendering
  90789. * @param func defines the function to remove
  90790. * @returns the current mesh
  90791. */
  90792. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90793. /**
  90794. * Registers for this mesh a javascript function called just after the rendering is complete
  90795. * @param func defines the function to call after rendering this mesh
  90796. * @returns the current mesh
  90797. */
  90798. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90799. /**
  90800. * Disposes a previously registered javascript function called after the rendering.
  90801. * @param func defines the function to remove
  90802. * @returns the current mesh
  90803. */
  90804. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90805. /** @hidden */
  90806. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90807. /** @hidden */
  90808. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90809. /** @hidden */
  90810. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90811. /** @hidden */
  90812. _rebuild(): void;
  90813. /** @hidden */
  90814. _freeze(): void;
  90815. /** @hidden */
  90816. _unFreeze(): void;
  90817. /**
  90818. * 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
  90819. * @param subMesh defines the subMesh to render
  90820. * @param enableAlphaMode defines if alpha mode can be changed
  90821. * @returns the current mesh
  90822. */
  90823. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90824. private _onBeforeDraw;
  90825. /**
  90826. * Renormalize the mesh and patch it up if there are no weights
  90827. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90828. * However in the case of zero weights then we set just a single influence to 1.
  90829. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90830. */
  90831. cleanMatrixWeights(): void;
  90832. private normalizeSkinFourWeights;
  90833. private normalizeSkinWeightsAndExtra;
  90834. /**
  90835. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90836. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90837. * the user know there was an issue with importing the mesh
  90838. * @returns a validation object with skinned, valid and report string
  90839. */
  90840. validateSkinning(): {
  90841. skinned: boolean;
  90842. valid: boolean;
  90843. report: string;
  90844. };
  90845. /** @hidden */
  90846. _checkDelayState(): Mesh;
  90847. private _queueLoad;
  90848. /**
  90849. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90850. * A mesh is in the frustum if its bounding box intersects the frustum
  90851. * @param frustumPlanes defines the frustum to test
  90852. * @returns true if the mesh is in the frustum planes
  90853. */
  90854. isInFrustum(frustumPlanes: Plane[]): boolean;
  90855. /**
  90856. * Sets the mesh material by the material or multiMaterial `id` property
  90857. * @param id is a string identifying the material or the multiMaterial
  90858. * @returns the current mesh
  90859. */
  90860. setMaterialByID(id: string): Mesh;
  90861. /**
  90862. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90863. * @returns an array of IAnimatable
  90864. */
  90865. getAnimatables(): IAnimatable[];
  90866. /**
  90867. * Modifies the mesh geometry according to the passed transformation matrix.
  90868. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90869. * The mesh normals are modified using the same transformation.
  90870. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90871. * @param transform defines the transform matrix to use
  90872. * @see http://doc.babylonjs.com/resources/baking_transformations
  90873. * @returns the current mesh
  90874. */
  90875. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90876. /**
  90877. * Modifies the mesh geometry according to its own current World Matrix.
  90878. * The mesh World Matrix is then reset.
  90879. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90880. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90881. * @see http://doc.babylonjs.com/resources/baking_transformations
  90882. * @returns the current mesh
  90883. */
  90884. bakeCurrentTransformIntoVertices(): Mesh;
  90885. /** @hidden */
  90886. readonly _positions: Nullable<Vector3[]>;
  90887. /** @hidden */
  90888. _resetPointsArrayCache(): Mesh;
  90889. /** @hidden */
  90890. _generatePointsArray(): boolean;
  90891. /**
  90892. * Returns a new Mesh object generated from the current mesh properties.
  90893. * This method must not get confused with createInstance()
  90894. * @param name is a string, the name given to the new mesh
  90895. * @param newParent can be any Node object (default `null`)
  90896. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90897. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90898. * @returns a new mesh
  90899. */
  90900. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90901. /**
  90902. * Releases resources associated with this mesh.
  90903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90905. */
  90906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90907. /**
  90908. * Modifies the mesh geometry according to a displacement map.
  90909. * 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.
  90910. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90911. * @param url is a string, the URL from the image file is to be downloaded.
  90912. * @param minHeight is the lower limit of the displacement.
  90913. * @param maxHeight is the upper limit of the displacement.
  90914. * @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.
  90915. * @param uvOffset is an optional vector2 used to offset UV.
  90916. * @param uvScale is an optional vector2 used to scale UV.
  90917. * @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.
  90918. * @returns the Mesh.
  90919. */
  90920. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90921. /**
  90922. * Modifies the mesh geometry according to a displacementMap buffer.
  90923. * 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.
  90924. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90925. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90926. * @param heightMapWidth is the width of the buffer image.
  90927. * @param heightMapHeight is the height of the buffer image.
  90928. * @param minHeight is the lower limit of the displacement.
  90929. * @param maxHeight is the upper limit of the displacement.
  90930. * @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.
  90931. * @param uvOffset is an optional vector2 used to offset UV.
  90932. * @param uvScale is an optional vector2 used to scale UV.
  90933. * @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.
  90934. * @returns the Mesh.
  90935. */
  90936. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90937. /**
  90938. * Modify the mesh to get a flat shading rendering.
  90939. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90940. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90941. * @returns current mesh
  90942. */
  90943. convertToFlatShadedMesh(): Mesh;
  90944. /**
  90945. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90946. * In other words, more vertices, no more indices and a single bigger VBO.
  90947. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90948. * @returns current mesh
  90949. */
  90950. convertToUnIndexedMesh(): Mesh;
  90951. /**
  90952. * Inverses facet orientations.
  90953. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90954. * @param flipNormals will also inverts the normals
  90955. * @returns current mesh
  90956. */
  90957. flipFaces(flipNormals?: boolean): Mesh;
  90958. /**
  90959. * Increase the number of facets and hence vertices in a mesh
  90960. * Vertex normals are interpolated from existing vertex normals
  90961. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90962. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90963. */
  90964. increaseVertices(numberPerEdge: number): void;
  90965. /**
  90966. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90967. * This will undo any application of covertToFlatShadedMesh
  90968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90969. */
  90970. forceSharedVertices(): void;
  90971. /** @hidden */
  90972. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90973. /** @hidden */
  90974. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90975. /**
  90976. * Creates a new InstancedMesh object from the mesh model.
  90977. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90978. * @param name defines the name of the new instance
  90979. * @returns a new InstancedMesh
  90980. */
  90981. createInstance(name: string): InstancedMesh;
  90982. /**
  90983. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90984. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90985. * @returns the current mesh
  90986. */
  90987. synchronizeInstances(): Mesh;
  90988. /**
  90989. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90990. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90991. * This should be used together with the simplification to avoid disappearing triangles.
  90992. * @param successCallback an optional success callback to be called after the optimization finished.
  90993. * @returns the current mesh
  90994. */
  90995. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90996. /**
  90997. * Serialize current mesh
  90998. * @param serializationObject defines the object which will receive the serialization data
  90999. */
  91000. serialize(serializationObject: any): void;
  91001. /** @hidden */
  91002. _syncGeometryWithMorphTargetManager(): void;
  91003. /** @hidden */
  91004. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91005. /**
  91006. * Returns a new Mesh object parsed from the source provided.
  91007. * @param parsedMesh is the source
  91008. * @param scene defines the hosting scene
  91009. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91010. * @returns a new Mesh
  91011. */
  91012. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91013. /**
  91014. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91015. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91016. * @param name defines the name of the mesh to create
  91017. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91018. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91019. * @param closePath creates a seam between the first and the last points of each path of the path array
  91020. * @param offset is taken in account only if the `pathArray` is containing a single path
  91021. * @param scene defines the hosting scene
  91022. * @param updatable defines if the mesh must be flagged as updatable
  91023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91024. * @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)
  91025. * @returns a new Mesh
  91026. */
  91027. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91028. /**
  91029. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91030. * @param name defines the name of the mesh to create
  91031. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91032. * @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
  91033. * @param scene defines the hosting scene
  91034. * @param updatable defines if the mesh must be flagged as updatable
  91035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91036. * @returns a new Mesh
  91037. */
  91038. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91039. /**
  91040. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91041. * @param name defines the name of the mesh to create
  91042. * @param size sets the size (float) of each box side (default 1)
  91043. * @param scene defines the hosting scene
  91044. * @param updatable defines if the mesh must be flagged as updatable
  91045. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91046. * @returns a new Mesh
  91047. */
  91048. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91049. /**
  91050. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91051. * @param name defines the name of the mesh to create
  91052. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91053. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91054. * @param scene defines the hosting scene
  91055. * @param updatable defines if the mesh must be flagged as updatable
  91056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91057. * @returns a new Mesh
  91058. */
  91059. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91060. /**
  91061. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91062. * @param name defines the name of the mesh to create
  91063. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91064. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91065. * @param scene defines the hosting scene
  91066. * @returns a new Mesh
  91067. */
  91068. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91069. /**
  91070. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91071. * @param name defines the name of the mesh to create
  91072. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91073. * @param diameterTop set the top cap diameter (floats, default 1)
  91074. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91075. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91076. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91077. * @param scene defines the hosting scene
  91078. * @param updatable defines if the mesh must be flagged as updatable
  91079. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91080. * @returns a new Mesh
  91081. */
  91082. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91083. /**
  91084. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91085. * @param name defines the name of the mesh to create
  91086. * @param diameter sets the diameter size (float) of the torus (default 1)
  91087. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91088. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91089. * @param scene defines the hosting scene
  91090. * @param updatable defines if the mesh must be flagged as updatable
  91091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91092. * @returns a new Mesh
  91093. */
  91094. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91095. /**
  91096. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91097. * @param name defines the name of the mesh to create
  91098. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91099. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91100. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91101. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91102. * @param p the number of windings on X axis (positive integers, default 2)
  91103. * @param q the number of windings on Y axis (positive integers, default 3)
  91104. * @param scene defines the hosting scene
  91105. * @param updatable defines if the mesh must be flagged as updatable
  91106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91107. * @returns a new Mesh
  91108. */
  91109. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91110. /**
  91111. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91112. * @param name defines the name of the mesh to create
  91113. * @param points is an array successive Vector3
  91114. * @param scene defines the hosting scene
  91115. * @param updatable defines if the mesh must be flagged as updatable
  91116. * @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).
  91117. * @returns a new Mesh
  91118. */
  91119. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91120. /**
  91121. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91122. * @param name defines the name of the mesh to create
  91123. * @param points is an array successive Vector3
  91124. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91125. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91126. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91127. * @param scene defines the hosting scene
  91128. * @param updatable defines if the mesh must be flagged as updatable
  91129. * @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)
  91130. * @returns a new Mesh
  91131. */
  91132. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91133. /**
  91134. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91135. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91136. * 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.
  91137. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91138. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91139. * Remember you can only change the shape positions, not their number when updating a polygon.
  91140. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91141. * @param name defines the name of the mesh to create
  91142. * @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
  91143. * @param scene defines the hosting scene
  91144. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91145. * @param updatable defines if the mesh must be flagged as updatable
  91146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91147. * @param earcutInjection can be used to inject your own earcut reference
  91148. * @returns a new Mesh
  91149. */
  91150. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91151. /**
  91152. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91153. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91154. * @param name defines the name of the mesh to create
  91155. * @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
  91156. * @param depth defines the height of extrusion
  91157. * @param scene defines the hosting scene
  91158. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91159. * @param updatable defines if the mesh must be flagged as updatable
  91160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91161. * @param earcutInjection can be used to inject your own earcut reference
  91162. * @returns a new Mesh
  91163. */
  91164. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91165. /**
  91166. * Creates an extruded shape mesh.
  91167. * 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
  91168. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91169. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91170. * @param name defines the name of the mesh to create
  91171. * @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
  91172. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91173. * @param scale is the value to scale the shape
  91174. * @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
  91175. * @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
  91176. * @param scene defines the hosting scene
  91177. * @param updatable defines if the mesh must be flagged as updatable
  91178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91179. * @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)
  91180. * @returns a new Mesh
  91181. */
  91182. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91183. /**
  91184. * Creates an custom extruded shape mesh.
  91185. * The custom extrusion is a parametric shape.
  91186. * It has no predefined shape. Its final shape will depend on the input parameters.
  91187. * Please consider using the same method from the MeshBuilder class instead
  91188. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91189. * @param name defines the name of the mesh to create
  91190. * @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
  91191. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91192. * @param scaleFunction is a custom Javascript function called on each path point
  91193. * @param rotationFunction is a custom Javascript function called on each path point
  91194. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91195. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91196. * @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
  91197. * @param scene defines the hosting scene
  91198. * @param updatable defines if the mesh must be flagged as updatable
  91199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91200. * @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)
  91201. * @returns a new Mesh
  91202. */
  91203. 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;
  91204. /**
  91205. * Creates lathe mesh.
  91206. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91207. * Please consider using the same method from the MeshBuilder class instead
  91208. * @param name defines the name of the mesh to create
  91209. * @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
  91210. * @param radius is the radius value of the lathe
  91211. * @param tessellation is the side number of the lathe.
  91212. * @param scene defines the hosting scene
  91213. * @param updatable defines if the mesh must be flagged as updatable
  91214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91215. * @returns a new Mesh
  91216. */
  91217. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91218. /**
  91219. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91220. * @param name defines the name of the mesh to create
  91221. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91222. * @param scene defines the hosting scene
  91223. * @param updatable defines if the mesh must be flagged as updatable
  91224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91225. * @returns a new Mesh
  91226. */
  91227. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91228. /**
  91229. * Creates a ground mesh.
  91230. * Please consider using the same method from the MeshBuilder class instead
  91231. * @param name defines the name of the mesh to create
  91232. * @param width set the width of the ground
  91233. * @param height set the height of the ground
  91234. * @param subdivisions sets the number of subdivisions per side
  91235. * @param scene defines the hosting scene
  91236. * @param updatable defines if the mesh must be flagged as updatable
  91237. * @returns a new Mesh
  91238. */
  91239. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91240. /**
  91241. * Creates a tiled ground mesh.
  91242. * Please consider using the same method from the MeshBuilder class instead
  91243. * @param name defines the name of the mesh to create
  91244. * @param xmin set the ground minimum X coordinate
  91245. * @param zmin set the ground minimum Y coordinate
  91246. * @param xmax set the ground maximum X coordinate
  91247. * @param zmax set the ground maximum Z coordinate
  91248. * @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
  91249. * @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
  91250. * @param scene defines the hosting scene
  91251. * @param updatable defines if the mesh must be flagged as updatable
  91252. * @returns a new Mesh
  91253. */
  91254. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91255. w: number;
  91256. h: number;
  91257. }, precision: {
  91258. w: number;
  91259. h: number;
  91260. }, scene: Scene, updatable?: boolean): Mesh;
  91261. /**
  91262. * Creates a ground mesh from a height map.
  91263. * Please consider using the same method from the MeshBuilder class instead
  91264. * @see http://doc.babylonjs.com/babylon101/height_map
  91265. * @param name defines the name of the mesh to create
  91266. * @param url sets the URL of the height map image resource
  91267. * @param width set the ground width size
  91268. * @param height set the ground height size
  91269. * @param subdivisions sets the number of subdivision per side
  91270. * @param minHeight is the minimum altitude on the ground
  91271. * @param maxHeight is the maximum altitude on the ground
  91272. * @param scene defines the hosting scene
  91273. * @param updatable defines if the mesh must be flagged as updatable
  91274. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91275. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91276. * @returns a new Mesh
  91277. */
  91278. 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;
  91279. /**
  91280. * Creates a tube mesh.
  91281. * The tube is a parametric shape.
  91282. * It has no predefined shape. Its final shape will depend on the input parameters.
  91283. * Please consider using the same method from the MeshBuilder class instead
  91284. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91285. * @param name defines the name of the mesh to create
  91286. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91287. * @param radius sets the tube radius size
  91288. * @param tessellation is the number of sides on the tubular surface
  91289. * @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
  91290. * @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
  91291. * @param scene defines the hosting scene
  91292. * @param updatable defines if the mesh must be flagged as updatable
  91293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91294. * @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)
  91295. * @returns a new Mesh
  91296. */
  91297. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91298. (i: number, distance: number): number;
  91299. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91300. /**
  91301. * Creates a polyhedron mesh.
  91302. * Please consider using the same method from the MeshBuilder class instead.
  91303. * * 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
  91304. * * The parameter `size` (positive float, default 1) sets the polygon size
  91305. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91306. * * 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`
  91307. * * 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
  91308. * * 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)`)
  91309. * * 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
  91310. * * 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
  91311. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91312. * * If you create a double-sided mesh, you can choose what parts of 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
  91313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91314. * @param name defines the name of the mesh to create
  91315. * @param options defines the options used to create the mesh
  91316. * @param scene defines the hosting scene
  91317. * @returns a new Mesh
  91318. */
  91319. static CreatePolyhedron(name: string, options: {
  91320. type?: number;
  91321. size?: number;
  91322. sizeX?: number;
  91323. sizeY?: number;
  91324. sizeZ?: number;
  91325. custom?: any;
  91326. faceUV?: Vector4[];
  91327. faceColors?: Color4[];
  91328. updatable?: boolean;
  91329. sideOrientation?: number;
  91330. }, scene: Scene): Mesh;
  91331. /**
  91332. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91333. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91334. * * 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`)
  91335. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91336. * * 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
  91337. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91338. * * If you create a double-sided mesh, you can choose what parts of 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
  91339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91340. * @param name defines the name of the mesh
  91341. * @param options defines the options used to create the mesh
  91342. * @param scene defines the hosting scene
  91343. * @returns a new Mesh
  91344. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91345. */
  91346. static CreateIcoSphere(name: string, options: {
  91347. radius?: number;
  91348. flat?: boolean;
  91349. subdivisions?: number;
  91350. sideOrientation?: number;
  91351. updatable?: boolean;
  91352. }, scene: Scene): Mesh;
  91353. /**
  91354. * Creates a decal mesh.
  91355. * Please consider using the same method from the MeshBuilder class instead.
  91356. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91357. * @param name defines the name of the mesh
  91358. * @param sourceMesh defines the mesh receiving the decal
  91359. * @param position sets the position of the decal in world coordinates
  91360. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91361. * @param size sets the decal scaling
  91362. * @param angle sets the angle to rotate the decal
  91363. * @returns a new Mesh
  91364. */
  91365. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91366. /**
  91367. * Prepare internal position array for software CPU skinning
  91368. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91369. */
  91370. setPositionsForCPUSkinning(): Float32Array;
  91371. /**
  91372. * Prepare internal normal array for software CPU skinning
  91373. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91374. */
  91375. setNormalsForCPUSkinning(): Float32Array;
  91376. /**
  91377. * Updates the vertex buffer by applying transformation from the bones
  91378. * @param skeleton defines the skeleton to apply to current mesh
  91379. * @returns the current mesh
  91380. */
  91381. applySkeleton(skeleton: Skeleton): Mesh;
  91382. /**
  91383. * 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
  91384. * @param meshes defines the list of meshes to scan
  91385. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91386. */
  91387. static MinMax(meshes: AbstractMesh[]): {
  91388. min: Vector3;
  91389. max: Vector3;
  91390. };
  91391. /**
  91392. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91393. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91394. * @returns a vector3
  91395. */
  91396. static Center(meshesOrMinMaxVector: {
  91397. min: Vector3;
  91398. max: Vector3;
  91399. } | AbstractMesh[]): Vector3;
  91400. /**
  91401. * Merge the array of meshes into a single mesh for performance reasons.
  91402. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91403. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91404. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91405. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91406. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91407. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91408. * @returns a new mesh
  91409. */
  91410. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91411. /** @hidden */
  91412. addInstance(instance: InstancedMesh): void;
  91413. /** @hidden */
  91414. removeInstance(instance: InstancedMesh): void;
  91415. }
  91416. }
  91417. declare module BABYLON {
  91418. /**
  91419. * This is the base class of all the camera used in the application.
  91420. * @see http://doc.babylonjs.com/features/cameras
  91421. */
  91422. export class Camera extends Node {
  91423. /** @hidden */
  91424. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91425. /**
  91426. * This is the default projection mode used by the cameras.
  91427. * It helps recreating a feeling of perspective and better appreciate depth.
  91428. * This is the best way to simulate real life cameras.
  91429. */
  91430. static readonly PERSPECTIVE_CAMERA: number;
  91431. /**
  91432. * This helps creating camera with an orthographic mode.
  91433. * 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.
  91434. */
  91435. static readonly ORTHOGRAPHIC_CAMERA: number;
  91436. /**
  91437. * This is the default FOV mode for perspective cameras.
  91438. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91439. */
  91440. static readonly FOVMODE_VERTICAL_FIXED: number;
  91441. /**
  91442. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91443. */
  91444. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91445. /**
  91446. * This specifies ther is no need for a camera rig.
  91447. * Basically only one eye is rendered corresponding to the camera.
  91448. */
  91449. static readonly RIG_MODE_NONE: number;
  91450. /**
  91451. * Simulates a camera Rig with one blue eye and one red eye.
  91452. * This can be use with 3d blue and red glasses.
  91453. */
  91454. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91455. /**
  91456. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91457. */
  91458. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91459. /**
  91460. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91461. */
  91462. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91463. /**
  91464. * Defines that both eyes of the camera will be rendered over under each other.
  91465. */
  91466. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91467. /**
  91468. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91469. */
  91470. static readonly RIG_MODE_VR: number;
  91471. /**
  91472. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91473. */
  91474. static readonly RIG_MODE_WEBVR: number;
  91475. /**
  91476. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91477. */
  91478. static readonly RIG_MODE_CUSTOM: number;
  91479. /**
  91480. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91481. */
  91482. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91483. /**
  91484. * Define the input manager associated with the camera.
  91485. */
  91486. inputs: CameraInputsManager<Camera>;
  91487. /** @hidden */
  91488. _position: Vector3;
  91489. /**
  91490. * Define the current local position of the camera in the scene
  91491. */
  91492. position: Vector3;
  91493. /**
  91494. * The vector the camera should consider as up.
  91495. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91496. */
  91497. upVector: Vector3;
  91498. /**
  91499. * Define the current limit on the left side for an orthographic camera
  91500. * In scene unit
  91501. */
  91502. orthoLeft: Nullable<number>;
  91503. /**
  91504. * Define the current limit on the right side for an orthographic camera
  91505. * In scene unit
  91506. */
  91507. orthoRight: Nullable<number>;
  91508. /**
  91509. * Define the current limit on the bottom side for an orthographic camera
  91510. * In scene unit
  91511. */
  91512. orthoBottom: Nullable<number>;
  91513. /**
  91514. * Define the current limit on the top side for an orthographic camera
  91515. * In scene unit
  91516. */
  91517. orthoTop: Nullable<number>;
  91518. /**
  91519. * Field Of View is set in Radians. (default is 0.8)
  91520. */
  91521. fov: number;
  91522. /**
  91523. * Define the minimum distance the camera can see from.
  91524. * This is important to note that the depth buffer are not infinite and the closer it starts
  91525. * the more your scene might encounter depth fighting issue.
  91526. */
  91527. minZ: number;
  91528. /**
  91529. * Define the maximum distance the camera can see to.
  91530. * This is important to note that the depth buffer are not infinite and the further it end
  91531. * the more your scene might encounter depth fighting issue.
  91532. */
  91533. maxZ: number;
  91534. /**
  91535. * Define the default inertia of the camera.
  91536. * This helps giving a smooth feeling to the camera movement.
  91537. */
  91538. inertia: number;
  91539. /**
  91540. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91541. */
  91542. mode: number;
  91543. /**
  91544. * Define wether the camera is intermediate.
  91545. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91546. */
  91547. isIntermediate: boolean;
  91548. /**
  91549. * Define the viewport of the camera.
  91550. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91551. */
  91552. viewport: Viewport;
  91553. /**
  91554. * Restricts the camera to viewing objects with the same layerMask.
  91555. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91556. */
  91557. layerMask: number;
  91558. /**
  91559. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91560. */
  91561. fovMode: number;
  91562. /**
  91563. * Rig mode of the camera.
  91564. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91565. * This is normally controlled byt the camera themselves as internal use.
  91566. */
  91567. cameraRigMode: number;
  91568. /**
  91569. * Defines the distance between both "eyes" in case of a RIG
  91570. */
  91571. interaxialDistance: number;
  91572. /**
  91573. * Defines if stereoscopic rendering is done side by side or over under.
  91574. */
  91575. isStereoscopicSideBySide: boolean;
  91576. /**
  91577. * 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
  91578. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91579. * else in the scene. (Eg. security camera)
  91580. *
  91581. * 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)
  91582. */
  91583. customRenderTargets: RenderTargetTexture[];
  91584. /**
  91585. * When set, the camera will render to this render target instead of the default canvas
  91586. *
  91587. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91588. */
  91589. outputRenderTarget: Nullable<RenderTargetTexture>;
  91590. /**
  91591. * Observable triggered when the camera view matrix has changed.
  91592. */
  91593. onViewMatrixChangedObservable: Observable<Camera>;
  91594. /**
  91595. * Observable triggered when the camera Projection matrix has changed.
  91596. */
  91597. onProjectionMatrixChangedObservable: Observable<Camera>;
  91598. /**
  91599. * Observable triggered when the inputs have been processed.
  91600. */
  91601. onAfterCheckInputsObservable: Observable<Camera>;
  91602. /**
  91603. * Observable triggered when reset has been called and applied to the camera.
  91604. */
  91605. onRestoreStateObservable: Observable<Camera>;
  91606. /** @hidden */
  91607. _cameraRigParams: any;
  91608. /** @hidden */
  91609. _rigCameras: Camera[];
  91610. /** @hidden */
  91611. _rigPostProcess: Nullable<PostProcess>;
  91612. protected _webvrViewMatrix: Matrix;
  91613. /** @hidden */
  91614. _skipRendering: boolean;
  91615. /** @hidden */
  91616. _projectionMatrix: Matrix;
  91617. /** @hidden */
  91618. _postProcesses: Nullable<PostProcess>[];
  91619. /** @hidden */
  91620. _activeMeshes: SmartArray<AbstractMesh>;
  91621. protected _globalPosition: Vector3;
  91622. /** @hidden */
  91623. _computedViewMatrix: Matrix;
  91624. private _doNotComputeProjectionMatrix;
  91625. private _transformMatrix;
  91626. private _frustumPlanes;
  91627. private _refreshFrustumPlanes;
  91628. private _storedFov;
  91629. private _stateStored;
  91630. /**
  91631. * Instantiates a new camera object.
  91632. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91633. * @see http://doc.babylonjs.com/features/cameras
  91634. * @param name Defines the name of the camera in the scene
  91635. * @param position Defines the position of the camera
  91636. * @param scene Defines the scene the camera belongs too
  91637. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91638. */
  91639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91640. /**
  91641. * Store current camera state (fov, position, etc..)
  91642. * @returns the camera
  91643. */
  91644. storeState(): Camera;
  91645. /**
  91646. * Restores the camera state values if it has been stored. You must call storeState() first
  91647. */
  91648. protected _restoreStateValues(): boolean;
  91649. /**
  91650. * Restored camera state. You must call storeState() first.
  91651. * @returns true if restored and false otherwise
  91652. */
  91653. restoreState(): boolean;
  91654. /**
  91655. * Gets the class name of the camera.
  91656. * @returns the class name
  91657. */
  91658. getClassName(): string;
  91659. /** @hidden */
  91660. readonly _isCamera: boolean;
  91661. /**
  91662. * Gets a string representation of the camera useful for debug purpose.
  91663. * @param fullDetails Defines that a more verboe level of logging is required
  91664. * @returns the string representation
  91665. */
  91666. toString(fullDetails?: boolean): string;
  91667. /**
  91668. * Gets the current world space position of the camera.
  91669. */
  91670. readonly globalPosition: Vector3;
  91671. /**
  91672. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91673. * @returns the active meshe list
  91674. */
  91675. getActiveMeshes(): SmartArray<AbstractMesh>;
  91676. /**
  91677. * Check wether a mesh is part of the current active mesh list of the camera
  91678. * @param mesh Defines the mesh to check
  91679. * @returns true if active, false otherwise
  91680. */
  91681. isActiveMesh(mesh: Mesh): boolean;
  91682. /**
  91683. * Is this camera ready to be used/rendered
  91684. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91685. * @return true if the camera is ready
  91686. */
  91687. isReady(completeCheck?: boolean): boolean;
  91688. /** @hidden */
  91689. _initCache(): void;
  91690. /** @hidden */
  91691. _updateCache(ignoreParentClass?: boolean): void;
  91692. /** @hidden */
  91693. _isSynchronized(): boolean;
  91694. /** @hidden */
  91695. _isSynchronizedViewMatrix(): boolean;
  91696. /** @hidden */
  91697. _isSynchronizedProjectionMatrix(): boolean;
  91698. /**
  91699. * Attach the input controls to a specific dom element to get the input from.
  91700. * @param element Defines the element the controls should be listened from
  91701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91702. */
  91703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91704. /**
  91705. * Detach the current controls from the specified dom element.
  91706. * @param element Defines the element to stop listening the inputs from
  91707. */
  91708. detachControl(element: HTMLElement): void;
  91709. /**
  91710. * Update the camera state according to the different inputs gathered during the frame.
  91711. */
  91712. update(): void;
  91713. /** @hidden */
  91714. _checkInputs(): void;
  91715. /** @hidden */
  91716. readonly rigCameras: Camera[];
  91717. /**
  91718. * Gets the post process used by the rig cameras
  91719. */
  91720. readonly rigPostProcess: Nullable<PostProcess>;
  91721. /**
  91722. * Internal, gets the first post proces.
  91723. * @returns the first post process to be run on this camera.
  91724. */
  91725. _getFirstPostProcess(): Nullable<PostProcess>;
  91726. private _cascadePostProcessesToRigCams;
  91727. /**
  91728. * Attach a post process to the camera.
  91729. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91730. * @param postProcess The post process to attach to the camera
  91731. * @param insertAt The position of the post process in case several of them are in use in the scene
  91732. * @returns the position the post process has been inserted at
  91733. */
  91734. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91735. /**
  91736. * Detach a post process to the camera.
  91737. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91738. * @param postProcess The post process to detach from the camera
  91739. */
  91740. detachPostProcess(postProcess: PostProcess): void;
  91741. /**
  91742. * Gets the current world matrix of the camera
  91743. */
  91744. getWorldMatrix(): Matrix;
  91745. /** @hidden */
  91746. _getViewMatrix(): Matrix;
  91747. /**
  91748. * Gets the current view matrix of the camera.
  91749. * @param force forces the camera to recompute the matrix without looking at the cached state
  91750. * @returns the view matrix
  91751. */
  91752. getViewMatrix(force?: boolean): Matrix;
  91753. /**
  91754. * Freeze the projection matrix.
  91755. * It will prevent the cache check of the camera projection compute and can speed up perf
  91756. * if no parameter of the camera are meant to change
  91757. * @param projection Defines manually a projection if necessary
  91758. */
  91759. freezeProjectionMatrix(projection?: Matrix): void;
  91760. /**
  91761. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91762. */
  91763. unfreezeProjectionMatrix(): void;
  91764. /**
  91765. * Gets the current projection matrix of the camera.
  91766. * @param force forces the camera to recompute the matrix without looking at the cached state
  91767. * @returns the projection matrix
  91768. */
  91769. getProjectionMatrix(force?: boolean): Matrix;
  91770. /**
  91771. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91772. * @returns a Matrix
  91773. */
  91774. getTransformationMatrix(): Matrix;
  91775. private _updateFrustumPlanes;
  91776. /**
  91777. * Checks if a cullable object (mesh...) is in the camera frustum
  91778. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91779. * @param target The object to check
  91780. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91781. * @returns true if the object is in frustum otherwise false
  91782. */
  91783. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91784. /**
  91785. * Checks if a cullable object (mesh...) is in the camera frustum
  91786. * Unlike isInFrustum this cheks the full bounding box
  91787. * @param target The object to check
  91788. * @returns true if the object is in frustum otherwise false
  91789. */
  91790. isCompletelyInFrustum(target: ICullable): boolean;
  91791. /**
  91792. * Gets a ray in the forward direction from the camera.
  91793. * @param length Defines the length of the ray to create
  91794. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91795. * @param origin Defines the start point of the ray which defaults to the camera position
  91796. * @returns the forward ray
  91797. */
  91798. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91799. /**
  91800. * Releases resources associated with this node.
  91801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91803. */
  91804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91805. /** @hidden */
  91806. _isLeftCamera: boolean;
  91807. /**
  91808. * Gets the left camera of a rig setup in case of Rigged Camera
  91809. */
  91810. readonly isLeftCamera: boolean;
  91811. /** @hidden */
  91812. _isRightCamera: boolean;
  91813. /**
  91814. * Gets the right camera of a rig setup in case of Rigged Camera
  91815. */
  91816. readonly isRightCamera: boolean;
  91817. /**
  91818. * Gets the left camera of a rig setup in case of Rigged Camera
  91819. */
  91820. readonly leftCamera: Nullable<FreeCamera>;
  91821. /**
  91822. * Gets the right camera of a rig setup in case of Rigged Camera
  91823. */
  91824. readonly rightCamera: Nullable<FreeCamera>;
  91825. /**
  91826. * Gets the left camera target of a rig setup in case of Rigged Camera
  91827. * @returns the target position
  91828. */
  91829. getLeftTarget(): Nullable<Vector3>;
  91830. /**
  91831. * Gets the right camera target of a rig setup in case of Rigged Camera
  91832. * @returns the target position
  91833. */
  91834. getRightTarget(): Nullable<Vector3>;
  91835. /**
  91836. * @hidden
  91837. */
  91838. setCameraRigMode(mode: number, rigParams: any): void;
  91839. /** @hidden */
  91840. static _setStereoscopicRigMode(camera: Camera): void;
  91841. /** @hidden */
  91842. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91843. /** @hidden */
  91844. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91845. /** @hidden */
  91846. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91847. /** @hidden */
  91848. _getVRProjectionMatrix(): Matrix;
  91849. protected _updateCameraRotationMatrix(): void;
  91850. protected _updateWebVRCameraRotationMatrix(): void;
  91851. /**
  91852. * This function MUST be overwritten by the different WebVR cameras available.
  91853. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91854. * @hidden
  91855. */
  91856. _getWebVRProjectionMatrix(): Matrix;
  91857. /**
  91858. * This function MUST be overwritten by the different WebVR cameras available.
  91859. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91860. * @hidden
  91861. */
  91862. _getWebVRViewMatrix(): Matrix;
  91863. /** @hidden */
  91864. setCameraRigParameter(name: string, value: any): void;
  91865. /**
  91866. * needs to be overridden by children so sub has required properties to be copied
  91867. * @hidden
  91868. */
  91869. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91870. /**
  91871. * May need to be overridden by children
  91872. * @hidden
  91873. */
  91874. _updateRigCameras(): void;
  91875. /** @hidden */
  91876. _setupInputs(): void;
  91877. /**
  91878. * Serialiaze the camera setup to a json represention
  91879. * @returns the JSON representation
  91880. */
  91881. serialize(): any;
  91882. /**
  91883. * Clones the current camera.
  91884. * @param name The cloned camera name
  91885. * @returns the cloned camera
  91886. */
  91887. clone(name: string): Camera;
  91888. /**
  91889. * Gets the direction of the camera relative to a given local axis.
  91890. * @param localAxis Defines the reference axis to provide a relative direction.
  91891. * @return the direction
  91892. */
  91893. getDirection(localAxis: Vector3): Vector3;
  91894. /**
  91895. * Returns the current camera absolute rotation
  91896. */
  91897. readonly absoluteRotation: Quaternion;
  91898. /**
  91899. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91900. * @param localAxis Defines the reference axis to provide a relative direction.
  91901. * @param result Defines the vector to store the result in
  91902. */
  91903. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91904. /**
  91905. * Gets a camera constructor for a given camera type
  91906. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91907. * @param name The name of the camera the result will be able to instantiate
  91908. * @param scene The scene the result will construct the camera in
  91909. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91910. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91911. * @returns a factory method to construc the camera
  91912. */
  91913. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91914. /**
  91915. * Compute the world matrix of the camera.
  91916. * @returns the camera workd matrix
  91917. */
  91918. computeWorldMatrix(): Matrix;
  91919. /**
  91920. * Parse a JSON and creates the camera from the parsed information
  91921. * @param parsedCamera The JSON to parse
  91922. * @param scene The scene to instantiate the camera in
  91923. * @returns the newly constructed camera
  91924. */
  91925. static Parse(parsedCamera: any, scene: Scene): Camera;
  91926. }
  91927. }
  91928. declare module BABYLON {
  91929. /**
  91930. * Class containing static functions to help procedurally build meshes
  91931. */
  91932. export class DiscBuilder {
  91933. /**
  91934. * Creates a plane polygonal mesh. By default, this is a disc
  91935. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91936. * * 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
  91937. * * 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
  91938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91941. * @param name defines the name of the mesh
  91942. * @param options defines the options used to create the mesh
  91943. * @param scene defines the hosting scene
  91944. * @returns the plane polygonal mesh
  91945. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91946. */
  91947. static CreateDisc(name: string, options: {
  91948. radius?: number;
  91949. tessellation?: number;
  91950. arc?: number;
  91951. updatable?: boolean;
  91952. sideOrientation?: number;
  91953. frontUVs?: Vector4;
  91954. backUVs?: Vector4;
  91955. }, scene?: Nullable<Scene>): Mesh;
  91956. }
  91957. }
  91958. declare module BABYLON {
  91959. /**
  91960. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91961. *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.
  91962. * The SPS is also a particle system. It provides some methods to manage the particles.
  91963. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91964. *
  91965. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91966. */
  91967. export class SolidParticleSystem implements IDisposable {
  91968. /**
  91969. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91970. * Example : var p = SPS.particles[i];
  91971. */
  91972. particles: SolidParticle[];
  91973. /**
  91974. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91975. */
  91976. nbParticles: number;
  91977. /**
  91978. * If the particles must ever face the camera (default false). Useful for planar particles.
  91979. */
  91980. billboard: boolean;
  91981. /**
  91982. * Recompute normals when adding a shape
  91983. */
  91984. recomputeNormals: boolean;
  91985. /**
  91986. * This a counter ofr your own usage. It's not set by any SPS functions.
  91987. */
  91988. counter: number;
  91989. /**
  91990. * The SPS name. This name is also given to the underlying mesh.
  91991. */
  91992. name: string;
  91993. /**
  91994. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91995. */
  91996. mesh: Mesh;
  91997. /**
  91998. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91999. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92000. */
  92001. vars: any;
  92002. /**
  92003. * This array is populated when the SPS is set as 'pickable'.
  92004. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92005. * Each element of this array is an object `{idx: int, faceId: int}`.
  92006. * `idx` is the picked particle index in the `SPS.particles` array
  92007. * `faceId` is the picked face index counted within this particle.
  92008. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92009. */
  92010. pickedParticles: {
  92011. idx: number;
  92012. faceId: number;
  92013. }[];
  92014. /**
  92015. * This array is populated when `enableDepthSort` is set to true.
  92016. * Each element of this array is an instance of the class DepthSortedParticle.
  92017. */
  92018. depthSortedParticles: DepthSortedParticle[];
  92019. /**
  92020. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92021. * @hidden
  92022. */
  92023. _bSphereOnly: boolean;
  92024. /**
  92025. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92026. * @hidden
  92027. */
  92028. _bSphereRadiusFactor: number;
  92029. private _scene;
  92030. private _positions;
  92031. private _indices;
  92032. private _normals;
  92033. private _colors;
  92034. private _uvs;
  92035. private _indices32;
  92036. private _positions32;
  92037. private _normals32;
  92038. private _fixedNormal32;
  92039. private _colors32;
  92040. private _uvs32;
  92041. private _index;
  92042. private _updatable;
  92043. private _pickable;
  92044. private _isVisibilityBoxLocked;
  92045. private _alwaysVisible;
  92046. private _depthSort;
  92047. private _shapeCounter;
  92048. private _copy;
  92049. private _color;
  92050. private _computeParticleColor;
  92051. private _computeParticleTexture;
  92052. private _computeParticleRotation;
  92053. private _computeParticleVertex;
  92054. private _computeBoundingBox;
  92055. private _depthSortParticles;
  92056. private _camera;
  92057. private _mustUnrotateFixedNormals;
  92058. private _particlesIntersect;
  92059. private _needs32Bits;
  92060. /**
  92061. * Creates a SPS (Solid Particle System) object.
  92062. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92063. * @param scene (Scene) is the scene in which the SPS is added.
  92064. * @param options defines the options of the sps e.g.
  92065. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92066. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92067. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92068. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92069. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92070. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92071. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92072. */
  92073. constructor(name: string, scene: Scene, options?: {
  92074. updatable?: boolean;
  92075. isPickable?: boolean;
  92076. enableDepthSort?: boolean;
  92077. particleIntersection?: boolean;
  92078. boundingSphereOnly?: boolean;
  92079. bSphereRadiusFactor?: number;
  92080. });
  92081. /**
  92082. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92083. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92084. * @returns the created mesh
  92085. */
  92086. buildMesh(): Mesh;
  92087. /**
  92088. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92089. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92090. * Thus the particles generated from `digest()` have their property `position` set yet.
  92091. * @param mesh ( Mesh ) is the mesh to be digested
  92092. * @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
  92093. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92094. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92095. * @returns the current SPS
  92096. */
  92097. digest(mesh: Mesh, options?: {
  92098. facetNb?: number;
  92099. number?: number;
  92100. delta?: number;
  92101. }): SolidParticleSystem;
  92102. private _unrotateFixedNormals;
  92103. private _resetCopy;
  92104. private _meshBuilder;
  92105. private _posToShape;
  92106. private _uvsToShapeUV;
  92107. private _addParticle;
  92108. /**
  92109. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92110. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92111. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92112. * @param nb (positive integer) the number of particles to be created from this model
  92113. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92114. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92115. * @returns the number of shapes in the system
  92116. */
  92117. addShape(mesh: Mesh, nb: number, options?: {
  92118. positionFunction?: any;
  92119. vertexFunction?: any;
  92120. }): number;
  92121. private _rebuildParticle;
  92122. /**
  92123. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92124. * @returns the SPS.
  92125. */
  92126. rebuildMesh(): SolidParticleSystem;
  92127. /**
  92128. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92129. * This method calls `updateParticle()` for each particle of the SPS.
  92130. * For an animated SPS, it is usually called within the render loop.
  92131. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92132. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92133. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92134. * @returns the SPS.
  92135. */
  92136. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92137. /**
  92138. * Disposes the SPS.
  92139. */
  92140. dispose(): void;
  92141. /**
  92142. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92143. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92144. * @returns the SPS.
  92145. */
  92146. refreshVisibleSize(): SolidParticleSystem;
  92147. /**
  92148. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92149. * @param size the size (float) of the visibility box
  92150. * note : this doesn't lock the SPS mesh bounding box.
  92151. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92152. */
  92153. setVisibilityBox(size: number): void;
  92154. /**
  92155. * Gets whether the SPS as always visible or not
  92156. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92157. */
  92158. /**
  92159. * Sets the SPS as always visible or not
  92160. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92161. */
  92162. isAlwaysVisible: boolean;
  92163. /**
  92164. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92165. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92166. */
  92167. /**
  92168. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92169. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92170. */
  92171. isVisibilityBoxLocked: boolean;
  92172. /**
  92173. * Tells to `setParticles()` to compute the particle rotations or not.
  92174. * Default value : true. The SPS is faster when it's set to false.
  92175. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92176. */
  92177. /**
  92178. * Gets if `setParticles()` computes 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. computeParticleRotation: boolean;
  92183. /**
  92184. * Tells to `setParticles()` to compute the particle colors or not.
  92185. * Default value : true. The SPS is faster when it's set to false.
  92186. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92187. */
  92188. /**
  92189. * Gets if `setParticles()` computes 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. computeParticleColor: boolean;
  92194. /**
  92195. * Gets if `setParticles()` computes the particle textures or not.
  92196. * Default value : true. The SPS is faster when it's set to false.
  92197. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92198. */
  92199. computeParticleTexture: boolean;
  92200. /**
  92201. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92202. * Default value : false. The SPS is faster when it's set to false.
  92203. * Note : the particle custom vertex positions aren't stored values.
  92204. */
  92205. /**
  92206. * Gets if `setParticles()` calls 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. computeParticleVertex: boolean;
  92211. /**
  92212. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92213. */
  92214. /**
  92215. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92216. */
  92217. computeBoundingBox: boolean;
  92218. /**
  92219. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92220. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92221. * Default : `true`
  92222. */
  92223. /**
  92224. * Gets if `setParticles()` sorts 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. depthSortParticles: boolean;
  92229. /**
  92230. * This function does nothing. It may be overwritten to set all the particle first values.
  92231. * The SPS doesn't call this function, you may have to call it by your own.
  92232. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92233. */
  92234. initParticles(): void;
  92235. /**
  92236. * This function does nothing. It may be overwritten to recycle a particle.
  92237. * The SPS doesn't call this function, you may have to call it by your own.
  92238. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92239. * @param particle The particle to recycle
  92240. * @returns the recycled particle
  92241. */
  92242. recycleParticle(particle: SolidParticle): SolidParticle;
  92243. /**
  92244. * Updates a particle : this function should be overwritten by the user.
  92245. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92247. * @example : just set a particle position or velocity and recycle conditions
  92248. * @param particle The particle to update
  92249. * @returns the updated particle
  92250. */
  92251. updateParticle(particle: SolidParticle): SolidParticle;
  92252. /**
  92253. * Updates a vertex of a particle : it can be overwritten by the user.
  92254. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92255. * @param particle the current particle
  92256. * @param vertex the current index of the current particle
  92257. * @param pt the index of the current vertex in the particle shape
  92258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92259. * @example : just set a vertex particle position
  92260. * @returns the updated vertex
  92261. */
  92262. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92263. /**
  92264. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92265. * This does nothing and may be overwritten by the user.
  92266. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92267. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92268. * @param update the boolean update value actually passed to setParticles()
  92269. */
  92270. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92271. /**
  92272. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92273. * This will be passed three parameters.
  92274. * This does nothing and may be overwritten by the user.
  92275. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92276. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92277. * @param update the boolean update value actually passed to setParticles()
  92278. */
  92279. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92280. }
  92281. }
  92282. declare module BABYLON {
  92283. /**
  92284. * Represents one particle of a solid particle system.
  92285. */
  92286. export class SolidParticle {
  92287. /**
  92288. * particle global index
  92289. */
  92290. idx: number;
  92291. /**
  92292. * The color of the particle
  92293. */
  92294. color: Nullable<Color4>;
  92295. /**
  92296. * The world space position of the particle.
  92297. */
  92298. position: Vector3;
  92299. /**
  92300. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92301. */
  92302. rotation: Vector3;
  92303. /**
  92304. * The world space rotation quaternion of the particle.
  92305. */
  92306. rotationQuaternion: Nullable<Quaternion>;
  92307. /**
  92308. * The scaling of the particle.
  92309. */
  92310. scaling: Vector3;
  92311. /**
  92312. * The uvs of the particle.
  92313. */
  92314. uvs: Vector4;
  92315. /**
  92316. * The current speed of the particle.
  92317. */
  92318. velocity: Vector3;
  92319. /**
  92320. * The pivot point in the particle local space.
  92321. */
  92322. pivot: Vector3;
  92323. /**
  92324. * Must the particle be translated from its pivot point in its local space ?
  92325. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92326. * Default : false
  92327. */
  92328. translateFromPivot: boolean;
  92329. /**
  92330. * Is the particle active or not ?
  92331. */
  92332. alive: boolean;
  92333. /**
  92334. * Is the particle visible or not ?
  92335. */
  92336. isVisible: boolean;
  92337. /**
  92338. * Index of this particle in the global "positions" array (Internal use)
  92339. * @hidden
  92340. */
  92341. _pos: number;
  92342. /**
  92343. * @hidden Index of this particle in the global "indices" array (Internal use)
  92344. */
  92345. _ind: number;
  92346. /**
  92347. * @hidden ModelShape of this particle (Internal use)
  92348. */
  92349. _model: ModelShape;
  92350. /**
  92351. * ModelShape id of this particle
  92352. */
  92353. shapeId: number;
  92354. /**
  92355. * Index of the particle in its shape id
  92356. */
  92357. idxInShape: number;
  92358. /**
  92359. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92360. */
  92361. _modelBoundingInfo: BoundingInfo;
  92362. /**
  92363. * @hidden Particle BoundingInfo object (Internal use)
  92364. */
  92365. _boundingInfo: BoundingInfo;
  92366. /**
  92367. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92368. */
  92369. _sps: SolidParticleSystem;
  92370. /**
  92371. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92372. */
  92373. _stillInvisible: boolean;
  92374. /**
  92375. * @hidden Last computed particle rotation matrix
  92376. */
  92377. _rotationMatrix: number[];
  92378. /**
  92379. * Parent particle Id, if any.
  92380. * Default null.
  92381. */
  92382. parentId: Nullable<number>;
  92383. /**
  92384. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92385. * The possible values are :
  92386. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92387. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92388. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92389. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92390. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92391. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92392. * */
  92393. cullingStrategy: number;
  92394. /**
  92395. * @hidden Internal global position in the SPS.
  92396. */
  92397. _globalPosition: Vector3;
  92398. /**
  92399. * Creates a Solid Particle object.
  92400. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92401. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92402. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92403. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92404. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92405. * @param shapeId (integer) is the model shape identifier in the SPS.
  92406. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92407. * @param sps defines the sps it is associated to
  92408. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92409. */
  92410. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92411. /**
  92412. * Legacy support, changed scale to scaling
  92413. */
  92414. /**
  92415. * Legacy support, changed scale to scaling
  92416. */
  92417. scale: Vector3;
  92418. /**
  92419. * Legacy support, changed quaternion to rotationQuaternion
  92420. */
  92421. /**
  92422. * Legacy support, changed quaternion to rotationQuaternion
  92423. */
  92424. quaternion: Nullable<Quaternion>;
  92425. /**
  92426. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92427. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92428. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92429. * @returns true if it intersects
  92430. */
  92431. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92432. /**
  92433. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92434. * A particle is in the frustum if its bounding box intersects the frustum
  92435. * @param frustumPlanes defines the frustum to test
  92436. * @returns true if the particle is in the frustum planes
  92437. */
  92438. isInFrustum(frustumPlanes: Plane[]): boolean;
  92439. /**
  92440. * get the rotation matrix of the particle
  92441. * @hidden
  92442. */
  92443. getRotationMatrix(m: Matrix): void;
  92444. }
  92445. /**
  92446. * Represents the shape of the model used by one particle of a solid particle system.
  92447. * SPS internal tool, don't use it manually.
  92448. */
  92449. export class ModelShape {
  92450. /**
  92451. * The shape id
  92452. * @hidden
  92453. */
  92454. shapeID: number;
  92455. /**
  92456. * flat array of model positions (internal use)
  92457. * @hidden
  92458. */
  92459. _shape: Vector3[];
  92460. /**
  92461. * flat array of model UVs (internal use)
  92462. * @hidden
  92463. */
  92464. _shapeUV: number[];
  92465. /**
  92466. * length of the shape in the model indices array (internal use)
  92467. * @hidden
  92468. */
  92469. _indicesLength: number;
  92470. /**
  92471. * Custom position function (internal use)
  92472. * @hidden
  92473. */
  92474. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92475. /**
  92476. * Custom vertex function (internal use)
  92477. * @hidden
  92478. */
  92479. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92480. /**
  92481. * 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.
  92482. * SPS internal tool, don't use it manually.
  92483. * @hidden
  92484. */
  92485. 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>);
  92486. }
  92487. /**
  92488. * Represents a Depth Sorted Particle in the solid particle system.
  92489. */
  92490. export class DepthSortedParticle {
  92491. /**
  92492. * Index of the particle in the "indices" array
  92493. */
  92494. ind: number;
  92495. /**
  92496. * Length of the particle shape in the "indices" array
  92497. */
  92498. indicesLength: number;
  92499. /**
  92500. * Squared distance from the particle to the camera
  92501. */
  92502. sqDistance: number;
  92503. }
  92504. }
  92505. declare module BABYLON {
  92506. /**
  92507. * @hidden
  92508. */
  92509. export class _MeshCollisionData {
  92510. _checkCollisions: boolean;
  92511. _collisionMask: number;
  92512. _collisionGroup: number;
  92513. _collider: Nullable<Collider>;
  92514. _oldPositionForCollisions: Vector3;
  92515. _diffPositionForCollisions: Vector3;
  92516. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92517. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92518. }
  92519. }
  92520. declare module BABYLON {
  92521. /** @hidden */
  92522. class _FacetDataStorage {
  92523. facetPositions: Vector3[];
  92524. facetNormals: Vector3[];
  92525. facetPartitioning: number[][];
  92526. facetNb: number;
  92527. partitioningSubdivisions: number;
  92528. partitioningBBoxRatio: number;
  92529. facetDataEnabled: boolean;
  92530. facetParameters: any;
  92531. bbSize: Vector3;
  92532. subDiv: {
  92533. max: number;
  92534. X: number;
  92535. Y: number;
  92536. Z: number;
  92537. };
  92538. facetDepthSort: boolean;
  92539. facetDepthSortEnabled: boolean;
  92540. depthSortedIndices: IndicesArray;
  92541. depthSortedFacets: {
  92542. ind: number;
  92543. sqDistance: number;
  92544. }[];
  92545. facetDepthSortFunction: (f1: {
  92546. ind: number;
  92547. sqDistance: number;
  92548. }, f2: {
  92549. ind: number;
  92550. sqDistance: number;
  92551. }) => number;
  92552. facetDepthSortFrom: Vector3;
  92553. facetDepthSortOrigin: Vector3;
  92554. invertedMatrix: Matrix;
  92555. }
  92556. /**
  92557. * @hidden
  92558. **/
  92559. class _InternalAbstractMeshDataInfo {
  92560. _hasVertexAlpha: boolean;
  92561. _useVertexColors: boolean;
  92562. _numBoneInfluencers: number;
  92563. _applyFog: boolean;
  92564. _receiveShadows: boolean;
  92565. _facetData: _FacetDataStorage;
  92566. _visibility: number;
  92567. _skeleton: Nullable<Skeleton>;
  92568. _layerMask: number;
  92569. _computeBonesUsingShaders: boolean;
  92570. _isActive: boolean;
  92571. _onlyForInstances: boolean;
  92572. _isActiveIntermediate: boolean;
  92573. _onlyForInstancesIntermediate: boolean;
  92574. }
  92575. /**
  92576. * Class used to store all common mesh properties
  92577. */
  92578. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92579. /** No occlusion */
  92580. static OCCLUSION_TYPE_NONE: number;
  92581. /** Occlusion set to optimisitic */
  92582. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92583. /** Occlusion set to strict */
  92584. static OCCLUSION_TYPE_STRICT: number;
  92585. /** Use an accurante occlusion algorithm */
  92586. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92587. /** Use a conservative occlusion algorithm */
  92588. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92589. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92590. * Test order :
  92591. * Is the bounding sphere outside the frustum ?
  92592. * If not, are the bounding box vertices outside the frustum ?
  92593. * It not, then the cullable object is in the frustum.
  92594. */
  92595. static readonly CULLINGSTRATEGY_STANDARD: number;
  92596. /** Culling strategy : Bounding Sphere Only.
  92597. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92598. * It's also less accurate than the standard because some not visible objects can still be selected.
  92599. * Test : is the bounding sphere outside the frustum ?
  92600. * If not, then the cullable object is in the frustum.
  92601. */
  92602. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92603. /** Culling strategy : Optimistic Inclusion.
  92604. * This in an inclusion test first, then the standard exclusion test.
  92605. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92606. * 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.
  92607. * Anyway, it's as accurate as the standard strategy.
  92608. * Test :
  92609. * Is the cullable object bounding sphere center in the frustum ?
  92610. * If not, apply the default culling strategy.
  92611. */
  92612. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92613. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92614. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92615. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92616. * 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.
  92617. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92618. * Test :
  92619. * Is the cullable object bounding sphere center in the frustum ?
  92620. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92621. */
  92622. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92623. /**
  92624. * No billboard
  92625. */
  92626. static readonly BILLBOARDMODE_NONE: number;
  92627. /** Billboard on X axis */
  92628. static readonly BILLBOARDMODE_X: number;
  92629. /** Billboard on Y axis */
  92630. static readonly BILLBOARDMODE_Y: number;
  92631. /** Billboard on Z axis */
  92632. static readonly BILLBOARDMODE_Z: number;
  92633. /** Billboard on all axes */
  92634. static readonly BILLBOARDMODE_ALL: number;
  92635. /** Billboard on using position instead of orientation */
  92636. static readonly BILLBOARDMODE_USE_POSITION: number;
  92637. /** @hidden */
  92638. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92639. /**
  92640. * The culling strategy to use to check whether the mesh must be rendered or not.
  92641. * This value can be changed at any time and will be used on the next render mesh selection.
  92642. * The possible values are :
  92643. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92644. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92645. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92646. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92647. * Please read each static variable documentation to get details about the culling process.
  92648. * */
  92649. cullingStrategy: number;
  92650. /**
  92651. * Gets the number of facets in the mesh
  92652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92653. */
  92654. readonly facetNb: number;
  92655. /**
  92656. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92658. */
  92659. partitioningSubdivisions: number;
  92660. /**
  92661. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92662. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92664. */
  92665. partitioningBBoxRatio: number;
  92666. /**
  92667. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92668. * Works only for updatable meshes.
  92669. * Doesn't work with multi-materials
  92670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92671. */
  92672. mustDepthSortFacets: boolean;
  92673. /**
  92674. * The location (Vector3) where the facet depth sort must be computed from.
  92675. * By default, the active camera position.
  92676. * Used only when facet depth sort is enabled
  92677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92678. */
  92679. facetDepthSortFrom: Vector3;
  92680. /**
  92681. * gets a boolean indicating if facetData is enabled
  92682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92683. */
  92684. readonly isFacetDataEnabled: boolean;
  92685. /** @hidden */
  92686. _updateNonUniformScalingState(value: boolean): boolean;
  92687. /**
  92688. * An event triggered when this mesh collides with another one
  92689. */
  92690. onCollideObservable: Observable<AbstractMesh>;
  92691. /** Set a function to call when this mesh collides with another one */
  92692. onCollide: () => void;
  92693. /**
  92694. * An event triggered when the collision's position changes
  92695. */
  92696. onCollisionPositionChangeObservable: Observable<Vector3>;
  92697. /** Set a function to call when the collision's position changes */
  92698. onCollisionPositionChange: () => void;
  92699. /**
  92700. * An event triggered when material is changed
  92701. */
  92702. onMaterialChangedObservable: Observable<AbstractMesh>;
  92703. /**
  92704. * Gets or sets the orientation for POV movement & rotation
  92705. */
  92706. definedFacingForward: boolean;
  92707. /** @hidden */
  92708. _occlusionQuery: Nullable<WebGLQuery>;
  92709. /** @hidden */
  92710. _renderingGroup: Nullable<RenderingGroup>;
  92711. /**
  92712. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92713. */
  92714. /**
  92715. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92716. */
  92717. visibility: number;
  92718. /** Gets or sets the alpha index used to sort transparent meshes
  92719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92720. */
  92721. alphaIndex: number;
  92722. /**
  92723. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92724. */
  92725. isVisible: boolean;
  92726. /**
  92727. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92728. */
  92729. isPickable: boolean;
  92730. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92731. showSubMeshesBoundingBox: boolean;
  92732. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92733. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92734. */
  92735. isBlocker: boolean;
  92736. /**
  92737. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92738. */
  92739. enablePointerMoveEvents: boolean;
  92740. /**
  92741. * Specifies the rendering group id for this mesh (0 by default)
  92742. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92743. */
  92744. renderingGroupId: number;
  92745. private _material;
  92746. /** Gets or sets current material */
  92747. material: Nullable<Material>;
  92748. /**
  92749. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92750. * @see http://doc.babylonjs.com/babylon101/shadows
  92751. */
  92752. receiveShadows: boolean;
  92753. /** Defines color to use when rendering outline */
  92754. outlineColor: Color3;
  92755. /** Define width to use when rendering outline */
  92756. outlineWidth: number;
  92757. /** Defines color to use when rendering overlay */
  92758. overlayColor: Color3;
  92759. /** Defines alpha to use when rendering overlay */
  92760. overlayAlpha: number;
  92761. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92762. hasVertexAlpha: boolean;
  92763. /** 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) */
  92764. useVertexColors: boolean;
  92765. /**
  92766. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92767. */
  92768. computeBonesUsingShaders: boolean;
  92769. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92770. numBoneInfluencers: number;
  92771. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92772. applyFog: boolean;
  92773. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92774. useOctreeForRenderingSelection: boolean;
  92775. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92776. useOctreeForPicking: boolean;
  92777. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92778. useOctreeForCollisions: boolean;
  92779. /**
  92780. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92781. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92782. */
  92783. layerMask: number;
  92784. /**
  92785. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92786. */
  92787. alwaysSelectAsActiveMesh: boolean;
  92788. /**
  92789. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92790. */
  92791. doNotSyncBoundingInfo: boolean;
  92792. /**
  92793. * Gets or sets the current action manager
  92794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92795. */
  92796. actionManager: Nullable<AbstractActionManager>;
  92797. private _meshCollisionData;
  92798. /**
  92799. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92801. */
  92802. ellipsoid: Vector3;
  92803. /**
  92804. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92806. */
  92807. ellipsoidOffset: Vector3;
  92808. /**
  92809. * Gets or sets a collision mask used to mask collisions (default is -1).
  92810. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92811. */
  92812. collisionMask: number;
  92813. /**
  92814. * Gets or sets the current collision group mask (-1 by default).
  92815. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92816. */
  92817. collisionGroup: number;
  92818. /**
  92819. * Defines edge width used when edgesRenderer is enabled
  92820. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92821. */
  92822. edgesWidth: number;
  92823. /**
  92824. * Defines edge color used when edgesRenderer is enabled
  92825. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92826. */
  92827. edgesColor: Color4;
  92828. /** @hidden */
  92829. _edgesRenderer: Nullable<IEdgesRenderer>;
  92830. /** @hidden */
  92831. _masterMesh: Nullable<AbstractMesh>;
  92832. /** @hidden */
  92833. _boundingInfo: Nullable<BoundingInfo>;
  92834. /** @hidden */
  92835. _renderId: number;
  92836. /**
  92837. * Gets or sets the list of subMeshes
  92838. * @see http://doc.babylonjs.com/how_to/multi_materials
  92839. */
  92840. subMeshes: SubMesh[];
  92841. /** @hidden */
  92842. _intersectionsInProgress: AbstractMesh[];
  92843. /** @hidden */
  92844. _unIndexed: boolean;
  92845. /** @hidden */
  92846. _lightSources: Light[];
  92847. /** Gets the list of lights affecting that mesh */
  92848. readonly lightSources: Light[];
  92849. /** @hidden */
  92850. readonly _positions: Nullable<Vector3[]>;
  92851. /** @hidden */
  92852. _waitingData: {
  92853. lods: Nullable<any>;
  92854. actions: Nullable<any>;
  92855. freezeWorldMatrix: Nullable<boolean>;
  92856. };
  92857. /** @hidden */
  92858. _bonesTransformMatrices: Nullable<Float32Array>;
  92859. /** @hidden */
  92860. _transformMatrixTexture: Nullable<RawTexture>;
  92861. /**
  92862. * Gets or sets a skeleton to apply skining transformations
  92863. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92864. */
  92865. skeleton: Nullable<Skeleton>;
  92866. /**
  92867. * An event triggered when the mesh is rebuilt.
  92868. */
  92869. onRebuildObservable: Observable<AbstractMesh>;
  92870. /**
  92871. * Creates a new AbstractMesh
  92872. * @param name defines the name of the mesh
  92873. * @param scene defines the hosting scene
  92874. */
  92875. constructor(name: string, scene?: Nullable<Scene>);
  92876. /**
  92877. * Returns the string "AbstractMesh"
  92878. * @returns "AbstractMesh"
  92879. */
  92880. getClassName(): string;
  92881. /**
  92882. * Gets a string representation of the current mesh
  92883. * @param fullDetails defines a boolean indicating if full details must be included
  92884. * @returns a string representation of the current mesh
  92885. */
  92886. toString(fullDetails?: boolean): string;
  92887. /**
  92888. * @hidden
  92889. */
  92890. protected _getEffectiveParent(): Nullable<Node>;
  92891. /** @hidden */
  92892. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92893. /** @hidden */
  92894. _rebuild(): void;
  92895. /** @hidden */
  92896. _resyncLightSources(): void;
  92897. /** @hidden */
  92898. _resyncLighSource(light: Light): void;
  92899. /** @hidden */
  92900. _unBindEffect(): void;
  92901. /** @hidden */
  92902. _removeLightSource(light: Light, dispose: boolean): void;
  92903. private _markSubMeshesAsDirty;
  92904. /** @hidden */
  92905. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92906. /** @hidden */
  92907. _markSubMeshesAsAttributesDirty(): void;
  92908. /** @hidden */
  92909. _markSubMeshesAsMiscDirty(): void;
  92910. /**
  92911. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92912. */
  92913. scaling: Vector3;
  92914. /**
  92915. * Returns true if the mesh is blocked. Implemented by child classes
  92916. */
  92917. readonly isBlocked: boolean;
  92918. /**
  92919. * Returns the mesh itself by default. Implemented by child classes
  92920. * @param camera defines the camera to use to pick the right LOD level
  92921. * @returns the currentAbstractMesh
  92922. */
  92923. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92924. /**
  92925. * Returns 0 by default. Implemented by child classes
  92926. * @returns an integer
  92927. */
  92928. getTotalVertices(): number;
  92929. /**
  92930. * Returns a positive integer : the total number of indices in this mesh geometry.
  92931. * @returns the numner of indices or zero if the mesh has no geometry.
  92932. */
  92933. getTotalIndices(): number;
  92934. /**
  92935. * Returns null by default. Implemented by child classes
  92936. * @returns null
  92937. */
  92938. getIndices(): Nullable<IndicesArray>;
  92939. /**
  92940. * Returns the array of the requested vertex data kind. Implemented by child classes
  92941. * @param kind defines the vertex data kind to use
  92942. * @returns null
  92943. */
  92944. getVerticesData(kind: string): Nullable<FloatArray>;
  92945. /**
  92946. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92947. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92948. * Note that a new underlying VertexBuffer object is created each call.
  92949. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92950. * @param kind defines vertex data kind:
  92951. * * VertexBuffer.PositionKind
  92952. * * VertexBuffer.UVKind
  92953. * * VertexBuffer.UV2Kind
  92954. * * VertexBuffer.UV3Kind
  92955. * * VertexBuffer.UV4Kind
  92956. * * VertexBuffer.UV5Kind
  92957. * * VertexBuffer.UV6Kind
  92958. * * VertexBuffer.ColorKind
  92959. * * VertexBuffer.MatricesIndicesKind
  92960. * * VertexBuffer.MatricesIndicesExtraKind
  92961. * * VertexBuffer.MatricesWeightsKind
  92962. * * VertexBuffer.MatricesWeightsExtraKind
  92963. * @param data defines the data source
  92964. * @param updatable defines if the data must be flagged as updatable (or static)
  92965. * @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
  92966. * @returns the current mesh
  92967. */
  92968. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92969. /**
  92970. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92971. * If the mesh has no geometry, it is simply returned as it is.
  92972. * @param kind defines vertex data kind:
  92973. * * VertexBuffer.PositionKind
  92974. * * VertexBuffer.UVKind
  92975. * * VertexBuffer.UV2Kind
  92976. * * VertexBuffer.UV3Kind
  92977. * * VertexBuffer.UV4Kind
  92978. * * VertexBuffer.UV5Kind
  92979. * * VertexBuffer.UV6Kind
  92980. * * VertexBuffer.ColorKind
  92981. * * VertexBuffer.MatricesIndicesKind
  92982. * * VertexBuffer.MatricesIndicesExtraKind
  92983. * * VertexBuffer.MatricesWeightsKind
  92984. * * VertexBuffer.MatricesWeightsExtraKind
  92985. * @param data defines the data source
  92986. * @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
  92987. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92988. * @returns the current mesh
  92989. */
  92990. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92991. /**
  92992. * Sets the mesh indices,
  92993. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92994. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92995. * @param totalVertices Defines the total number of vertices
  92996. * @returns the current mesh
  92997. */
  92998. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92999. /**
  93000. * Gets a boolean indicating if specific vertex data is present
  93001. * @param kind defines the vertex data kind to use
  93002. * @returns true is data kind is present
  93003. */
  93004. isVerticesDataPresent(kind: string): boolean;
  93005. /**
  93006. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93007. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93008. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93009. * @returns a BoundingInfo
  93010. */
  93011. getBoundingInfo(): BoundingInfo;
  93012. /**
  93013. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93014. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93015. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93016. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93017. * @returns the current mesh
  93018. */
  93019. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93020. /**
  93021. * Overwrite the current bounding info
  93022. * @param boundingInfo defines the new bounding info
  93023. * @returns the current mesh
  93024. */
  93025. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93026. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93027. readonly useBones: boolean;
  93028. /** @hidden */
  93029. _preActivate(): void;
  93030. /** @hidden */
  93031. _preActivateForIntermediateRendering(renderId: number): void;
  93032. /** @hidden */
  93033. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93034. /** @hidden */
  93035. _postActivate(): void;
  93036. /** @hidden */
  93037. _freeze(): void;
  93038. /** @hidden */
  93039. _unFreeze(): void;
  93040. /**
  93041. * Gets the current world matrix
  93042. * @returns a Matrix
  93043. */
  93044. getWorldMatrix(): Matrix;
  93045. /** @hidden */
  93046. _getWorldMatrixDeterminant(): number;
  93047. /**
  93048. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93049. */
  93050. readonly isAnInstance: boolean;
  93051. /**
  93052. * Gets a boolean indicating if this mesh has instances
  93053. */
  93054. readonly hasInstances: boolean;
  93055. /**
  93056. * Perform relative position change from the point of view of behind the front of the mesh.
  93057. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93058. * Supports definition of mesh facing forward or backward
  93059. * @param amountRight defines the distance on the right axis
  93060. * @param amountUp defines the distance on the up axis
  93061. * @param amountForward defines the distance on the forward axis
  93062. * @returns the current mesh
  93063. */
  93064. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93065. /**
  93066. * Calculate relative position change from the point of view of behind the front of the mesh.
  93067. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93068. * Supports definition of mesh facing forward or backward
  93069. * @param amountRight defines the distance on the right axis
  93070. * @param amountUp defines the distance on the up axis
  93071. * @param amountForward defines the distance on the forward axis
  93072. * @returns the new displacement vector
  93073. */
  93074. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93075. /**
  93076. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93077. * Supports definition of mesh facing forward or backward
  93078. * @param flipBack defines the flip
  93079. * @param twirlClockwise defines the twirl
  93080. * @param tiltRight defines the tilt
  93081. * @returns the current mesh
  93082. */
  93083. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93084. /**
  93085. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93086. * Supports definition of mesh facing forward or backward.
  93087. * @param flipBack defines the flip
  93088. * @param twirlClockwise defines the twirl
  93089. * @param tiltRight defines the tilt
  93090. * @returns the new rotation vector
  93091. */
  93092. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93093. /**
  93094. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93095. * This means the mesh underlying bounding box and sphere are recomputed.
  93096. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93097. * @returns the current mesh
  93098. */
  93099. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93100. /** @hidden */
  93101. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93102. /** @hidden */
  93103. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93104. /** @hidden */
  93105. _updateBoundingInfo(): AbstractMesh;
  93106. /** @hidden */
  93107. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93108. /** @hidden */
  93109. protected _afterComputeWorldMatrix(): void;
  93110. /** @hidden */
  93111. readonly _effectiveMesh: AbstractMesh;
  93112. /**
  93113. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93114. * A mesh is in the frustum if its bounding box intersects the frustum
  93115. * @param frustumPlanes defines the frustum to test
  93116. * @returns true if the mesh is in the frustum planes
  93117. */
  93118. isInFrustum(frustumPlanes: Plane[]): boolean;
  93119. /**
  93120. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93121. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93122. * @param frustumPlanes defines the frustum to test
  93123. * @returns true if the mesh is completely in the frustum planes
  93124. */
  93125. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93126. /**
  93127. * True if the mesh intersects another mesh or a SolidParticle object
  93128. * @param mesh defines a target mesh or SolidParticle to test
  93129. * @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)
  93130. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93131. * @returns true if there is an intersection
  93132. */
  93133. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93134. /**
  93135. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93136. * @param point defines the point to test
  93137. * @returns true if there is an intersection
  93138. */
  93139. intersectsPoint(point: Vector3): boolean;
  93140. /**
  93141. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93143. */
  93144. checkCollisions: boolean;
  93145. /**
  93146. * Gets Collider object used to compute collisions (not physics)
  93147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93148. */
  93149. readonly collider: Nullable<Collider>;
  93150. /**
  93151. * Move the mesh using collision engine
  93152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93153. * @param displacement defines the requested displacement vector
  93154. * @returns the current mesh
  93155. */
  93156. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93157. private _onCollisionPositionChange;
  93158. /** @hidden */
  93159. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93160. /** @hidden */
  93161. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93162. /** @hidden */
  93163. _checkCollision(collider: Collider): AbstractMesh;
  93164. /** @hidden */
  93165. _generatePointsArray(): boolean;
  93166. /**
  93167. * Checks if the passed Ray intersects with the mesh
  93168. * @param ray defines the ray to use
  93169. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93170. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93171. * @returns the picking info
  93172. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93173. */
  93174. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93175. /**
  93176. * Clones the current mesh
  93177. * @param name defines the mesh name
  93178. * @param newParent defines the new mesh parent
  93179. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93180. * @returns the new mesh
  93181. */
  93182. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93183. /**
  93184. * Disposes all the submeshes of the current meshnp
  93185. * @returns the current mesh
  93186. */
  93187. releaseSubMeshes(): AbstractMesh;
  93188. /**
  93189. * Releases resources associated with this abstract mesh.
  93190. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93191. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93192. */
  93193. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93194. /**
  93195. * Adds the passed mesh as a child to the current mesh
  93196. * @param mesh defines the child mesh
  93197. * @returns the current mesh
  93198. */
  93199. addChild(mesh: AbstractMesh): AbstractMesh;
  93200. /**
  93201. * Removes the passed mesh from the current mesh children list
  93202. * @param mesh defines the child mesh
  93203. * @returns the current mesh
  93204. */
  93205. removeChild(mesh: AbstractMesh): AbstractMesh;
  93206. /** @hidden */
  93207. private _initFacetData;
  93208. /**
  93209. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93210. * This method can be called within the render loop.
  93211. * 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
  93212. * @returns the current mesh
  93213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93214. */
  93215. updateFacetData(): AbstractMesh;
  93216. /**
  93217. * Returns the facetLocalNormals array.
  93218. * The normals are expressed in the mesh local spac
  93219. * @returns an array of Vector3
  93220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93221. */
  93222. getFacetLocalNormals(): Vector3[];
  93223. /**
  93224. * Returns the facetLocalPositions array.
  93225. * The facet positions are expressed in the mesh local space
  93226. * @returns an array of Vector3
  93227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93228. */
  93229. getFacetLocalPositions(): Vector3[];
  93230. /**
  93231. * Returns the facetLocalPartioning array
  93232. * @returns an array of array of numbers
  93233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93234. */
  93235. getFacetLocalPartitioning(): number[][];
  93236. /**
  93237. * Returns the i-th facet position in the world system.
  93238. * This method allocates a new Vector3 per call
  93239. * @param i defines the facet index
  93240. * @returns a new Vector3
  93241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93242. */
  93243. getFacetPosition(i: number): Vector3;
  93244. /**
  93245. * Sets the reference Vector3 with the i-th facet position in the world system
  93246. * @param i defines the facet index
  93247. * @param ref defines the target vector
  93248. * @returns the current mesh
  93249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93250. */
  93251. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93252. /**
  93253. * Returns the i-th facet normal in the world system.
  93254. * This method allocates a new Vector3 per call
  93255. * @param i defines the facet index
  93256. * @returns a new Vector3
  93257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93258. */
  93259. getFacetNormal(i: number): Vector3;
  93260. /**
  93261. * Sets the reference Vector3 with the i-th facet normal in the world system
  93262. * @param i defines the facet index
  93263. * @param ref defines the target vector
  93264. * @returns the current mesh
  93265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93266. */
  93267. getFacetNormalToRef(i: number, ref: Vector3): this;
  93268. /**
  93269. * 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)
  93270. * @param x defines x coordinate
  93271. * @param y defines y coordinate
  93272. * @param z defines z coordinate
  93273. * @returns the array of facet indexes
  93274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93275. */
  93276. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93277. /**
  93278. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93279. * @param projected sets as the (x,y,z) world projection on the facet
  93280. * @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
  93281. * @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
  93282. * @param x defines x coordinate
  93283. * @param y defines y coordinate
  93284. * @param z defines z coordinate
  93285. * @returns the face index if found (or null instead)
  93286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93287. */
  93288. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93289. /**
  93290. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93291. * @param projected sets as the (x,y,z) local projection on the facet
  93292. * @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
  93293. * @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
  93294. * @param x defines x coordinate
  93295. * @param y defines y coordinate
  93296. * @param z defines z coordinate
  93297. * @returns the face index if found (or null instead)
  93298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93299. */
  93300. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93301. /**
  93302. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93303. * @returns the parameters
  93304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93305. */
  93306. getFacetDataParameters(): any;
  93307. /**
  93308. * Disables the feature FacetData and frees the related memory
  93309. * @returns the current mesh
  93310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93311. */
  93312. disableFacetData(): AbstractMesh;
  93313. /**
  93314. * Updates the AbstractMesh indices array
  93315. * @param indices defines the data source
  93316. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93317. * @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)
  93318. * @returns the current mesh
  93319. */
  93320. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93321. /**
  93322. * Creates new normals data for the mesh
  93323. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93324. * @returns the current mesh
  93325. */
  93326. createNormals(updatable: boolean): AbstractMesh;
  93327. /**
  93328. * Align the mesh with a normal
  93329. * @param normal defines the normal to use
  93330. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93331. * @returns the current mesh
  93332. */
  93333. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93334. /** @hidden */
  93335. _checkOcclusionQuery(): boolean;
  93336. /**
  93337. * Disables the mesh edge rendering mode
  93338. * @returns the currentAbstractMesh
  93339. */
  93340. disableEdgesRendering(): AbstractMesh;
  93341. /**
  93342. * Enables the edge rendering mode on the mesh.
  93343. * This mode makes the mesh edges visible
  93344. * @param epsilon defines the maximal distance between two angles to detect a face
  93345. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93346. * @returns the currentAbstractMesh
  93347. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93348. */
  93349. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93350. }
  93351. }
  93352. declare module BABYLON {
  93353. /**
  93354. * Interface used to define ActionEvent
  93355. */
  93356. export interface IActionEvent {
  93357. /** The mesh or sprite that triggered the action */
  93358. source: any;
  93359. /** The X mouse cursor position at the time of the event */
  93360. pointerX: number;
  93361. /** The Y mouse cursor position at the time of the event */
  93362. pointerY: number;
  93363. /** The mesh that is currently pointed at (can be null) */
  93364. meshUnderPointer: Nullable<AbstractMesh>;
  93365. /** the original (browser) event that triggered the ActionEvent */
  93366. sourceEvent?: any;
  93367. /** additional data for the event */
  93368. additionalData?: any;
  93369. }
  93370. /**
  93371. * ActionEvent is the event being sent when an action is triggered.
  93372. */
  93373. export class ActionEvent implements IActionEvent {
  93374. /** The mesh or sprite that triggered the action */
  93375. source: any;
  93376. /** The X mouse cursor position at the time of the event */
  93377. pointerX: number;
  93378. /** The Y mouse cursor position at the time of the event */
  93379. pointerY: number;
  93380. /** The mesh that is currently pointed at (can be null) */
  93381. meshUnderPointer: Nullable<AbstractMesh>;
  93382. /** the original (browser) event that triggered the ActionEvent */
  93383. sourceEvent?: any;
  93384. /** additional data for the event */
  93385. additionalData?: any;
  93386. /**
  93387. * Creates a new ActionEvent
  93388. * @param source The mesh or sprite that triggered the action
  93389. * @param pointerX The X mouse cursor position at the time of the event
  93390. * @param pointerY The Y mouse cursor position at the time of the event
  93391. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93392. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93393. * @param additionalData additional data for the event
  93394. */
  93395. constructor(
  93396. /** The mesh or sprite that triggered the action */
  93397. source: any,
  93398. /** The X mouse cursor position at the time of the event */
  93399. pointerX: number,
  93400. /** The Y mouse cursor position at the time of the event */
  93401. pointerY: number,
  93402. /** The mesh that is currently pointed at (can be null) */
  93403. meshUnderPointer: Nullable<AbstractMesh>,
  93404. /** the original (browser) event that triggered the ActionEvent */
  93405. sourceEvent?: any,
  93406. /** additional data for the event */
  93407. additionalData?: any);
  93408. /**
  93409. * Helper function to auto-create an ActionEvent from a source mesh.
  93410. * @param source The source mesh that triggered the event
  93411. * @param evt The original (browser) event
  93412. * @param additionalData additional data for the event
  93413. * @returns the new ActionEvent
  93414. */
  93415. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93416. /**
  93417. * Helper function to auto-create an ActionEvent from a source sprite
  93418. * @param source The source sprite that triggered the event
  93419. * @param scene Scene associated with the sprite
  93420. * @param evt The original (browser) event
  93421. * @param additionalData additional data for the event
  93422. * @returns the new ActionEvent
  93423. */
  93424. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93425. /**
  93426. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93427. * @param scene the scene where the event occurred
  93428. * @param evt The original (browser) event
  93429. * @returns the new ActionEvent
  93430. */
  93431. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93432. /**
  93433. * Helper function to auto-create an ActionEvent from a primitive
  93434. * @param prim defines the target primitive
  93435. * @param pointerPos defines the pointer position
  93436. * @param evt The original (browser) event
  93437. * @param additionalData additional data for the event
  93438. * @returns the new ActionEvent
  93439. */
  93440. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93441. }
  93442. }
  93443. declare module BABYLON {
  93444. /**
  93445. * Abstract class used to decouple action Manager from scene and meshes.
  93446. * Do not instantiate.
  93447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93448. */
  93449. export abstract class AbstractActionManager implements IDisposable {
  93450. /** Gets the list of active triggers */
  93451. static Triggers: {
  93452. [key: string]: number;
  93453. };
  93454. /** Gets the cursor to use when hovering items */
  93455. hoverCursor: string;
  93456. /** Gets the list of actions */
  93457. actions: IAction[];
  93458. /**
  93459. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93460. */
  93461. isRecursive: boolean;
  93462. /**
  93463. * Releases all associated resources
  93464. */
  93465. abstract dispose(): void;
  93466. /**
  93467. * Does this action manager has pointer triggers
  93468. */
  93469. abstract readonly hasPointerTriggers: boolean;
  93470. /**
  93471. * Does this action manager has pick triggers
  93472. */
  93473. abstract readonly hasPickTriggers: boolean;
  93474. /**
  93475. * Process a specific trigger
  93476. * @param trigger defines the trigger to process
  93477. * @param evt defines the event details to be processed
  93478. */
  93479. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93480. /**
  93481. * Does this action manager handles actions of any of the given triggers
  93482. * @param triggers defines the triggers to be tested
  93483. * @return a boolean indicating whether one (or more) of the triggers is handled
  93484. */
  93485. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93486. /**
  93487. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93488. * speed.
  93489. * @param triggerA defines the trigger to be tested
  93490. * @param triggerB defines the trigger to be tested
  93491. * @return a boolean indicating whether one (or more) of the triggers is handled
  93492. */
  93493. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93494. /**
  93495. * Does this action manager handles actions of a given trigger
  93496. * @param trigger defines the trigger to be tested
  93497. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93498. * @return whether the trigger is handled
  93499. */
  93500. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93501. /**
  93502. * Serialize this manager to a JSON object
  93503. * @param name defines the property name to store this manager
  93504. * @returns a JSON representation of this manager
  93505. */
  93506. abstract serialize(name: string): any;
  93507. /**
  93508. * Registers an action to this action manager
  93509. * @param action defines the action to be registered
  93510. * @return the action amended (prepared) after registration
  93511. */
  93512. abstract registerAction(action: IAction): Nullable<IAction>;
  93513. /**
  93514. * Unregisters an action to this action manager
  93515. * @param action defines the action to be unregistered
  93516. * @return a boolean indicating whether the action has been unregistered
  93517. */
  93518. abstract unregisterAction(action: IAction): Boolean;
  93519. /**
  93520. * Does exist one action manager with at least one trigger
  93521. **/
  93522. static readonly HasTriggers: boolean;
  93523. /**
  93524. * Does exist one action manager with at least one pick trigger
  93525. **/
  93526. static readonly HasPickTriggers: boolean;
  93527. /**
  93528. * Does exist one action manager that handles actions of a given trigger
  93529. * @param trigger defines the trigger to be tested
  93530. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93531. **/
  93532. static HasSpecificTrigger(trigger: number): boolean;
  93533. }
  93534. }
  93535. declare module BABYLON {
  93536. /**
  93537. * Defines how a node can be built from a string name.
  93538. */
  93539. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93540. /**
  93541. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93542. */
  93543. export class Node implements IBehaviorAware<Node> {
  93544. /** @hidden */
  93545. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93546. private static _NodeConstructors;
  93547. /**
  93548. * Add a new node constructor
  93549. * @param type defines the type name of the node to construct
  93550. * @param constructorFunc defines the constructor function
  93551. */
  93552. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93553. /**
  93554. * Returns a node constructor based on type name
  93555. * @param type defines the type name
  93556. * @param name defines the new node name
  93557. * @param scene defines the hosting scene
  93558. * @param options defines optional options to transmit to constructors
  93559. * @returns the new constructor or null
  93560. */
  93561. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93562. /**
  93563. * Gets or sets the name of the node
  93564. */
  93565. name: string;
  93566. /**
  93567. * Gets or sets the id of the node
  93568. */
  93569. id: string;
  93570. /**
  93571. * Gets or sets the unique id of the node
  93572. */
  93573. uniqueId: number;
  93574. /**
  93575. * Gets or sets a string used to store user defined state for the node
  93576. */
  93577. state: string;
  93578. /**
  93579. * Gets or sets an object used to store user defined information for the node
  93580. */
  93581. metadata: any;
  93582. /**
  93583. * For internal use only. Please do not use.
  93584. */
  93585. reservedDataStore: any;
  93586. /**
  93587. * List of inspectable custom properties (used by the Inspector)
  93588. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93589. */
  93590. inspectableCustomProperties: IInspectable[];
  93591. /**
  93592. * Gets or sets a boolean used to define if the node must be serialized
  93593. */
  93594. doNotSerialize: boolean;
  93595. /** @hidden */
  93596. _isDisposed: boolean;
  93597. /**
  93598. * Gets a list of Animations associated with the node
  93599. */
  93600. animations: Animation[];
  93601. protected _ranges: {
  93602. [name: string]: Nullable<AnimationRange>;
  93603. };
  93604. /**
  93605. * Callback raised when the node is ready to be used
  93606. */
  93607. onReady: Nullable<(node: Node) => void>;
  93608. private _isEnabled;
  93609. private _isParentEnabled;
  93610. private _isReady;
  93611. /** @hidden */
  93612. _currentRenderId: number;
  93613. private _parentUpdateId;
  93614. /** @hidden */
  93615. _childUpdateId: number;
  93616. /** @hidden */
  93617. _waitingParentId: Nullable<string>;
  93618. /** @hidden */
  93619. _scene: Scene;
  93620. /** @hidden */
  93621. _cache: any;
  93622. private _parentNode;
  93623. private _children;
  93624. /** @hidden */
  93625. _worldMatrix: Matrix;
  93626. /** @hidden */
  93627. _worldMatrixDeterminant: number;
  93628. /** @hidden */
  93629. _worldMatrixDeterminantIsDirty: boolean;
  93630. /** @hidden */
  93631. private _sceneRootNodesIndex;
  93632. /**
  93633. * Gets a boolean indicating if the node has been disposed
  93634. * @returns true if the node was disposed
  93635. */
  93636. isDisposed(): boolean;
  93637. /**
  93638. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93639. * @see https://doc.babylonjs.com/how_to/parenting
  93640. */
  93641. parent: Nullable<Node>;
  93642. private addToSceneRootNodes;
  93643. private removeFromSceneRootNodes;
  93644. private _animationPropertiesOverride;
  93645. /**
  93646. * Gets or sets the animation properties override
  93647. */
  93648. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93649. /**
  93650. * Gets a string idenfifying the name of the class
  93651. * @returns "Node" string
  93652. */
  93653. getClassName(): string;
  93654. /** @hidden */
  93655. readonly _isNode: boolean;
  93656. /**
  93657. * An event triggered when the mesh is disposed
  93658. */
  93659. onDisposeObservable: Observable<Node>;
  93660. private _onDisposeObserver;
  93661. /**
  93662. * Sets a callback that will be raised when the node will be disposed
  93663. */
  93664. onDispose: () => void;
  93665. /**
  93666. * Creates a new Node
  93667. * @param name the name and id to be given to this node
  93668. * @param scene the scene this node will be added to
  93669. * @param addToRootNodes the node will be added to scene.rootNodes
  93670. */
  93671. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93672. /**
  93673. * Gets the scene of the node
  93674. * @returns a scene
  93675. */
  93676. getScene(): Scene;
  93677. /**
  93678. * Gets the engine of the node
  93679. * @returns a Engine
  93680. */
  93681. getEngine(): Engine;
  93682. private _behaviors;
  93683. /**
  93684. * Attach a behavior to the node
  93685. * @see http://doc.babylonjs.com/features/behaviour
  93686. * @param behavior defines the behavior to attach
  93687. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93688. * @returns the current Node
  93689. */
  93690. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93691. /**
  93692. * Remove an attached behavior
  93693. * @see http://doc.babylonjs.com/features/behaviour
  93694. * @param behavior defines the behavior to attach
  93695. * @returns the current Node
  93696. */
  93697. removeBehavior(behavior: Behavior<Node>): Node;
  93698. /**
  93699. * Gets the list of attached behaviors
  93700. * @see http://doc.babylonjs.com/features/behaviour
  93701. */
  93702. readonly behaviors: Behavior<Node>[];
  93703. /**
  93704. * Gets an attached behavior by name
  93705. * @param name defines the name of the behavior to look for
  93706. * @see http://doc.babylonjs.com/features/behaviour
  93707. * @returns null if behavior was not found else the requested behavior
  93708. */
  93709. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93710. /**
  93711. * Returns the latest update of the World matrix
  93712. * @returns a Matrix
  93713. */
  93714. getWorldMatrix(): Matrix;
  93715. /** @hidden */
  93716. _getWorldMatrixDeterminant(): number;
  93717. /**
  93718. * Returns directly the latest state of the mesh World matrix.
  93719. * A Matrix is returned.
  93720. */
  93721. readonly worldMatrixFromCache: Matrix;
  93722. /** @hidden */
  93723. _initCache(): void;
  93724. /** @hidden */
  93725. updateCache(force?: boolean): void;
  93726. /** @hidden */
  93727. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93728. /** @hidden */
  93729. _updateCache(ignoreParentClass?: boolean): void;
  93730. /** @hidden */
  93731. _isSynchronized(): boolean;
  93732. /** @hidden */
  93733. _markSyncedWithParent(): void;
  93734. /** @hidden */
  93735. isSynchronizedWithParent(): boolean;
  93736. /** @hidden */
  93737. isSynchronized(): boolean;
  93738. /**
  93739. * Is this node ready to be used/rendered
  93740. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93741. * @return true if the node is ready
  93742. */
  93743. isReady(completeCheck?: boolean): boolean;
  93744. /**
  93745. * Is this node enabled?
  93746. * 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
  93747. * @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
  93748. * @return whether this node (and its parent) is enabled
  93749. */
  93750. isEnabled(checkAncestors?: boolean): boolean;
  93751. /** @hidden */
  93752. protected _syncParentEnabledState(): void;
  93753. /**
  93754. * Set the enabled state of this node
  93755. * @param value defines the new enabled state
  93756. */
  93757. setEnabled(value: boolean): void;
  93758. /**
  93759. * Is this node a descendant of the given node?
  93760. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93761. * @param ancestor defines the parent node to inspect
  93762. * @returns a boolean indicating if this node is a descendant of the given node
  93763. */
  93764. isDescendantOf(ancestor: Node): boolean;
  93765. /** @hidden */
  93766. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93767. /**
  93768. * Will return all nodes that have this node as ascendant
  93769. * @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
  93770. * @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
  93771. * @return all children nodes of all types
  93772. */
  93773. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93774. /**
  93775. * Get all child-meshes of this node
  93776. * @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)
  93777. * @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
  93778. * @returns an array of AbstractMesh
  93779. */
  93780. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93781. /**
  93782. * Get all direct children of this node
  93783. * @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
  93784. * @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)
  93785. * @returns an array of Node
  93786. */
  93787. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93788. /** @hidden */
  93789. _setReady(state: boolean): void;
  93790. /**
  93791. * Get an animation by name
  93792. * @param name defines the name of the animation to look for
  93793. * @returns null if not found else the requested animation
  93794. */
  93795. getAnimationByName(name: string): Nullable<Animation>;
  93796. /**
  93797. * Creates an animation range for this node
  93798. * @param name defines the name of the range
  93799. * @param from defines the starting key
  93800. * @param to defines the end key
  93801. */
  93802. createAnimationRange(name: string, from: number, to: number): void;
  93803. /**
  93804. * Delete a specific animation range
  93805. * @param name defines the name of the range to delete
  93806. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93807. */
  93808. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93809. /**
  93810. * Get an animation range by name
  93811. * @param name defines the name of the animation range to look for
  93812. * @returns null if not found else the requested animation range
  93813. */
  93814. getAnimationRange(name: string): Nullable<AnimationRange>;
  93815. /**
  93816. * Gets the list of all animation ranges defined on this node
  93817. * @returns an array
  93818. */
  93819. getAnimationRanges(): Nullable<AnimationRange>[];
  93820. /**
  93821. * Will start the animation sequence
  93822. * @param name defines the range frames for animation sequence
  93823. * @param loop defines if the animation should loop (false by default)
  93824. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93825. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93826. * @returns the object created for this animation. If range does not exist, it will return null
  93827. */
  93828. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93829. /**
  93830. * Serialize animation ranges into a JSON compatible object
  93831. * @returns serialization object
  93832. */
  93833. serializeAnimationRanges(): any;
  93834. /**
  93835. * Computes the world matrix of the node
  93836. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93837. * @returns the world matrix
  93838. */
  93839. computeWorldMatrix(force?: boolean): Matrix;
  93840. /**
  93841. * Releases resources associated with this node.
  93842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93844. */
  93845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93846. /**
  93847. * Parse animation range data from a serialization object and store them into a given node
  93848. * @param node defines where to store the animation ranges
  93849. * @param parsedNode defines the serialization object to read data from
  93850. * @param scene defines the hosting scene
  93851. */
  93852. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93853. /**
  93854. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93855. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93856. * @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
  93857. * @returns the new bounding vectors
  93858. */
  93859. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93860. min: Vector3;
  93861. max: Vector3;
  93862. };
  93863. }
  93864. }
  93865. declare module BABYLON {
  93866. /**
  93867. * @hidden
  93868. */
  93869. export class _IAnimationState {
  93870. key: number;
  93871. repeatCount: number;
  93872. workValue?: any;
  93873. loopMode?: number;
  93874. offsetValue?: any;
  93875. highLimitValue?: any;
  93876. }
  93877. /**
  93878. * Class used to store any kind of animation
  93879. */
  93880. export class Animation {
  93881. /**Name of the animation */
  93882. name: string;
  93883. /**Property to animate */
  93884. targetProperty: string;
  93885. /**The frames per second of the animation */
  93886. framePerSecond: number;
  93887. /**The data type of the animation */
  93888. dataType: number;
  93889. /**The loop mode of the animation */
  93890. loopMode?: number | undefined;
  93891. /**Specifies if blending should be enabled */
  93892. enableBlending?: boolean | undefined;
  93893. /**
  93894. * Use matrix interpolation instead of using direct key value when animating matrices
  93895. */
  93896. static AllowMatricesInterpolation: boolean;
  93897. /**
  93898. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93899. */
  93900. static AllowMatrixDecomposeForInterpolation: boolean;
  93901. /**
  93902. * Stores the key frames of the animation
  93903. */
  93904. private _keys;
  93905. /**
  93906. * Stores the easing function of the animation
  93907. */
  93908. private _easingFunction;
  93909. /**
  93910. * @hidden Internal use only
  93911. */
  93912. _runtimeAnimations: RuntimeAnimation[];
  93913. /**
  93914. * The set of event that will be linked to this animation
  93915. */
  93916. private _events;
  93917. /**
  93918. * Stores an array of target property paths
  93919. */
  93920. targetPropertyPath: string[];
  93921. /**
  93922. * Stores the blending speed of the animation
  93923. */
  93924. blendingSpeed: number;
  93925. /**
  93926. * Stores the animation ranges for the animation
  93927. */
  93928. private _ranges;
  93929. /**
  93930. * @hidden Internal use
  93931. */
  93932. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93933. /**
  93934. * Sets up an animation
  93935. * @param property The property to animate
  93936. * @param animationType The animation type to apply
  93937. * @param framePerSecond The frames per second of the animation
  93938. * @param easingFunction The easing function used in the animation
  93939. * @returns The created animation
  93940. */
  93941. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93942. /**
  93943. * Create and start an animation on a node
  93944. * @param name defines the name of the global animation that will be run on all nodes
  93945. * @param node defines the root node where the animation will take place
  93946. * @param targetProperty defines property to animate
  93947. * @param framePerSecond defines the number of frame per second yo use
  93948. * @param totalFrame defines the number of frames in total
  93949. * @param from defines the initial value
  93950. * @param to defines the final value
  93951. * @param loopMode defines which loop mode you want to use (off by default)
  93952. * @param easingFunction defines the easing function to use (linear by default)
  93953. * @param onAnimationEnd defines the callback to call when animation end
  93954. * @returns the animatable created for this animation
  93955. */
  93956. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93957. /**
  93958. * Create and start an animation on a node and its descendants
  93959. * @param name defines the name of the global animation that will be run on all nodes
  93960. * @param node defines the root node where the animation will take place
  93961. * @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
  93962. * @param targetProperty defines property to animate
  93963. * @param framePerSecond defines the number of frame per second to use
  93964. * @param totalFrame defines the number of frames in total
  93965. * @param from defines the initial value
  93966. * @param to defines the final value
  93967. * @param loopMode defines which loop mode you want to use (off by default)
  93968. * @param easingFunction defines the easing function to use (linear by default)
  93969. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93970. * @returns the list of animatables created for all nodes
  93971. * @example https://www.babylonjs-playground.com/#MH0VLI
  93972. */
  93973. 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[]>;
  93974. /**
  93975. * Creates a new animation, merges it with the existing animations and starts it
  93976. * @param name Name of the animation
  93977. * @param node Node which contains the scene that begins the animations
  93978. * @param targetProperty Specifies which property to animate
  93979. * @param framePerSecond The frames per second of the animation
  93980. * @param totalFrame The total number of frames
  93981. * @param from The frame at the beginning of the animation
  93982. * @param to The frame at the end of the animation
  93983. * @param loopMode Specifies the loop mode of the animation
  93984. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93985. * @param onAnimationEnd Callback to run once the animation is complete
  93986. * @returns Nullable animation
  93987. */
  93988. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93989. /**
  93990. * Transition property of an host to the target Value
  93991. * @param property The property to transition
  93992. * @param targetValue The target Value of the property
  93993. * @param host The object where the property to animate belongs
  93994. * @param scene Scene used to run the animation
  93995. * @param frameRate Framerate (in frame/s) to use
  93996. * @param transition The transition type we want to use
  93997. * @param duration The duration of the animation, in milliseconds
  93998. * @param onAnimationEnd Callback trigger at the end of the animation
  93999. * @returns Nullable animation
  94000. */
  94001. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94002. /**
  94003. * Return the array of runtime animations currently using this animation
  94004. */
  94005. readonly runtimeAnimations: RuntimeAnimation[];
  94006. /**
  94007. * Specifies if any of the runtime animations are currently running
  94008. */
  94009. readonly hasRunningRuntimeAnimations: boolean;
  94010. /**
  94011. * Initializes the animation
  94012. * @param name Name of the animation
  94013. * @param targetProperty Property to animate
  94014. * @param framePerSecond The frames per second of the animation
  94015. * @param dataType The data type of the animation
  94016. * @param loopMode The loop mode of the animation
  94017. * @param enableBlending Specifies if blending should be enabled
  94018. */
  94019. constructor(
  94020. /**Name of the animation */
  94021. name: string,
  94022. /**Property to animate */
  94023. targetProperty: string,
  94024. /**The frames per second of the animation */
  94025. framePerSecond: number,
  94026. /**The data type of the animation */
  94027. dataType: number,
  94028. /**The loop mode of the animation */
  94029. loopMode?: number | undefined,
  94030. /**Specifies if blending should be enabled */
  94031. enableBlending?: boolean | undefined);
  94032. /**
  94033. * Converts the animation to a string
  94034. * @param fullDetails support for multiple levels of logging within scene loading
  94035. * @returns String form of the animation
  94036. */
  94037. toString(fullDetails?: boolean): string;
  94038. /**
  94039. * Add an event to this animation
  94040. * @param event Event to add
  94041. */
  94042. addEvent(event: AnimationEvent): void;
  94043. /**
  94044. * Remove all events found at the given frame
  94045. * @param frame The frame to remove events from
  94046. */
  94047. removeEvents(frame: number): void;
  94048. /**
  94049. * Retrieves all the events from the animation
  94050. * @returns Events from the animation
  94051. */
  94052. getEvents(): AnimationEvent[];
  94053. /**
  94054. * Creates an animation range
  94055. * @param name Name of the animation range
  94056. * @param from Starting frame of the animation range
  94057. * @param to Ending frame of the animation
  94058. */
  94059. createRange(name: string, from: number, to: number): void;
  94060. /**
  94061. * Deletes an animation range by name
  94062. * @param name Name of the animation range to delete
  94063. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94064. */
  94065. deleteRange(name: string, deleteFrames?: boolean): void;
  94066. /**
  94067. * Gets the animation range by name, or null if not defined
  94068. * @param name Name of the animation range
  94069. * @returns Nullable animation range
  94070. */
  94071. getRange(name: string): Nullable<AnimationRange>;
  94072. /**
  94073. * Gets the key frames from the animation
  94074. * @returns The key frames of the animation
  94075. */
  94076. getKeys(): Array<IAnimationKey>;
  94077. /**
  94078. * Gets the highest frame rate of the animation
  94079. * @returns Highest frame rate of the animation
  94080. */
  94081. getHighestFrame(): number;
  94082. /**
  94083. * Gets the easing function of the animation
  94084. * @returns Easing function of the animation
  94085. */
  94086. getEasingFunction(): IEasingFunction;
  94087. /**
  94088. * Sets the easing function of the animation
  94089. * @param easingFunction A custom mathematical formula for animation
  94090. */
  94091. setEasingFunction(easingFunction: EasingFunction): void;
  94092. /**
  94093. * Interpolates a scalar linearly
  94094. * @param startValue Start value of the animation curve
  94095. * @param endValue End value of the animation curve
  94096. * @param gradient Scalar amount to interpolate
  94097. * @returns Interpolated scalar value
  94098. */
  94099. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94100. /**
  94101. * Interpolates a scalar cubically
  94102. * @param startValue Start value of the animation curve
  94103. * @param outTangent End tangent of the animation
  94104. * @param endValue End value of the animation curve
  94105. * @param inTangent Start tangent of the animation curve
  94106. * @param gradient Scalar amount to interpolate
  94107. * @returns Interpolated scalar value
  94108. */
  94109. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94110. /**
  94111. * Interpolates a quaternion using a spherical linear interpolation
  94112. * @param startValue Start value of the animation curve
  94113. * @param endValue End value of the animation curve
  94114. * @param gradient Scalar amount to interpolate
  94115. * @returns Interpolated quaternion value
  94116. */
  94117. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94118. /**
  94119. * Interpolates a quaternion cubically
  94120. * @param startValue Start value of the animation curve
  94121. * @param outTangent End tangent of the animation curve
  94122. * @param endValue End value of the animation curve
  94123. * @param inTangent Start tangent of the animation curve
  94124. * @param gradient Scalar amount to interpolate
  94125. * @returns Interpolated quaternion value
  94126. */
  94127. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94128. /**
  94129. * Interpolates a Vector3 linearl
  94130. * @param startValue Start value of the animation curve
  94131. * @param endValue End value of the animation curve
  94132. * @param gradient Scalar amount to interpolate
  94133. * @returns Interpolated scalar value
  94134. */
  94135. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94136. /**
  94137. * Interpolates a Vector3 cubically
  94138. * @param startValue Start value of the animation curve
  94139. * @param outTangent End tangent of the animation
  94140. * @param endValue End value of the animation curve
  94141. * @param inTangent Start tangent of the animation curve
  94142. * @param gradient Scalar amount to interpolate
  94143. * @returns InterpolatedVector3 value
  94144. */
  94145. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94146. /**
  94147. * Interpolates a Vector2 linearly
  94148. * @param startValue Start value of the animation curve
  94149. * @param endValue End value of the animation curve
  94150. * @param gradient Scalar amount to interpolate
  94151. * @returns Interpolated Vector2 value
  94152. */
  94153. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94154. /**
  94155. * Interpolates a Vector2 cubically
  94156. * @param startValue Start value of the animation curve
  94157. * @param outTangent End tangent of the animation
  94158. * @param endValue End value of the animation curve
  94159. * @param inTangent Start tangent of the animation curve
  94160. * @param gradient Scalar amount to interpolate
  94161. * @returns Interpolated Vector2 value
  94162. */
  94163. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94164. /**
  94165. * Interpolates a size linearly
  94166. * @param startValue Start value of the animation curve
  94167. * @param endValue End value of the animation curve
  94168. * @param gradient Scalar amount to interpolate
  94169. * @returns Interpolated Size value
  94170. */
  94171. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94172. /**
  94173. * Interpolates a Color3 linearly
  94174. * @param startValue Start value of the animation curve
  94175. * @param endValue End value of the animation curve
  94176. * @param gradient Scalar amount to interpolate
  94177. * @returns Interpolated Color3 value
  94178. */
  94179. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94180. /**
  94181. * @hidden Internal use only
  94182. */
  94183. _getKeyValue(value: any): any;
  94184. /**
  94185. * @hidden Internal use only
  94186. */
  94187. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94188. /**
  94189. * Defines the function to use to interpolate matrices
  94190. * @param startValue defines the start matrix
  94191. * @param endValue defines the end matrix
  94192. * @param gradient defines the gradient between both matrices
  94193. * @param result defines an optional target matrix where to store the interpolation
  94194. * @returns the interpolated matrix
  94195. */
  94196. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94197. /**
  94198. * Makes a copy of the animation
  94199. * @returns Cloned animation
  94200. */
  94201. clone(): Animation;
  94202. /**
  94203. * Sets the key frames of the animation
  94204. * @param values The animation key frames to set
  94205. */
  94206. setKeys(values: Array<IAnimationKey>): void;
  94207. /**
  94208. * Serializes the animation to an object
  94209. * @returns Serialized object
  94210. */
  94211. serialize(): any;
  94212. /**
  94213. * Float animation type
  94214. */
  94215. private static _ANIMATIONTYPE_FLOAT;
  94216. /**
  94217. * Vector3 animation type
  94218. */
  94219. private static _ANIMATIONTYPE_VECTOR3;
  94220. /**
  94221. * Quaternion animation type
  94222. */
  94223. private static _ANIMATIONTYPE_QUATERNION;
  94224. /**
  94225. * Matrix animation type
  94226. */
  94227. private static _ANIMATIONTYPE_MATRIX;
  94228. /**
  94229. * Color3 animation type
  94230. */
  94231. private static _ANIMATIONTYPE_COLOR3;
  94232. /**
  94233. * Vector2 animation type
  94234. */
  94235. private static _ANIMATIONTYPE_VECTOR2;
  94236. /**
  94237. * Size animation type
  94238. */
  94239. private static _ANIMATIONTYPE_SIZE;
  94240. /**
  94241. * Relative Loop Mode
  94242. */
  94243. private static _ANIMATIONLOOPMODE_RELATIVE;
  94244. /**
  94245. * Cycle Loop Mode
  94246. */
  94247. private static _ANIMATIONLOOPMODE_CYCLE;
  94248. /**
  94249. * Constant Loop Mode
  94250. */
  94251. private static _ANIMATIONLOOPMODE_CONSTANT;
  94252. /**
  94253. * Get the float animation type
  94254. */
  94255. static readonly ANIMATIONTYPE_FLOAT: number;
  94256. /**
  94257. * Get the Vector3 animation type
  94258. */
  94259. static readonly ANIMATIONTYPE_VECTOR3: number;
  94260. /**
  94261. * Get the Vector2 animation type
  94262. */
  94263. static readonly ANIMATIONTYPE_VECTOR2: number;
  94264. /**
  94265. * Get the Size animation type
  94266. */
  94267. static readonly ANIMATIONTYPE_SIZE: number;
  94268. /**
  94269. * Get the Quaternion animation type
  94270. */
  94271. static readonly ANIMATIONTYPE_QUATERNION: number;
  94272. /**
  94273. * Get the Matrix animation type
  94274. */
  94275. static readonly ANIMATIONTYPE_MATRIX: number;
  94276. /**
  94277. * Get the Color3 animation type
  94278. */
  94279. static readonly ANIMATIONTYPE_COLOR3: number;
  94280. /**
  94281. * Get the Relative Loop Mode
  94282. */
  94283. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94284. /**
  94285. * Get the Cycle Loop Mode
  94286. */
  94287. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94288. /**
  94289. * Get the Constant Loop Mode
  94290. */
  94291. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94292. /** @hidden */
  94293. static _UniversalLerp(left: any, right: any, amount: number): any;
  94294. /**
  94295. * Parses an animation object and creates an animation
  94296. * @param parsedAnimation Parsed animation object
  94297. * @returns Animation object
  94298. */
  94299. static Parse(parsedAnimation: any): Animation;
  94300. /**
  94301. * Appends the serialized animations from the source animations
  94302. * @param source Source containing the animations
  94303. * @param destination Target to store the animations
  94304. */
  94305. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94306. }
  94307. }
  94308. declare module BABYLON {
  94309. /**
  94310. * Interface containing an array of animations
  94311. */
  94312. export interface IAnimatable {
  94313. /**
  94314. * Array of animations
  94315. */
  94316. animations: Nullable<Array<Animation>>;
  94317. }
  94318. }
  94319. declare module BABYLON {
  94320. /**
  94321. * This represents all the required information to add a fresnel effect on a material:
  94322. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94323. */
  94324. export class FresnelParameters {
  94325. private _isEnabled;
  94326. /**
  94327. * Define if the fresnel effect is enable or not.
  94328. */
  94329. isEnabled: boolean;
  94330. /**
  94331. * Define the color used on edges (grazing angle)
  94332. */
  94333. leftColor: Color3;
  94334. /**
  94335. * Define the color used on center
  94336. */
  94337. rightColor: Color3;
  94338. /**
  94339. * Define bias applied to computed fresnel term
  94340. */
  94341. bias: number;
  94342. /**
  94343. * Defined the power exponent applied to fresnel term
  94344. */
  94345. power: number;
  94346. /**
  94347. * Clones the current fresnel and its valuues
  94348. * @returns a clone fresnel configuration
  94349. */
  94350. clone(): FresnelParameters;
  94351. /**
  94352. * Serializes the current fresnel parameters to a JSON representation.
  94353. * @return the JSON serialization
  94354. */
  94355. serialize(): any;
  94356. /**
  94357. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94358. * @param parsedFresnelParameters Define the JSON representation
  94359. * @returns the parsed parameters
  94360. */
  94361. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94362. }
  94363. }
  94364. declare module BABYLON {
  94365. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94366. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94367. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94368. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94369. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94370. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94371. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94372. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94373. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94374. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94375. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94376. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94377. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94378. /**
  94379. * Decorator used to define property that can be serialized as reference to a camera
  94380. * @param sourceName defines the name of the property to decorate
  94381. */
  94382. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94383. /**
  94384. * Class used to help serialization objects
  94385. */
  94386. export class SerializationHelper {
  94387. /** @hidden */
  94388. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94389. /** @hidden */
  94390. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94391. /** @hidden */
  94392. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94393. /** @hidden */
  94394. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94395. /**
  94396. * Appends the serialized animations from the source animations
  94397. * @param source Source containing the animations
  94398. * @param destination Target to store the animations
  94399. */
  94400. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94401. /**
  94402. * Static function used to serialized a specific entity
  94403. * @param entity defines the entity to serialize
  94404. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94405. * @returns a JSON compatible object representing the serialization of the entity
  94406. */
  94407. static Serialize<T>(entity: T, serializationObject?: any): any;
  94408. /**
  94409. * Creates a new entity from a serialization data object
  94410. * @param creationFunction defines a function used to instanciated the new entity
  94411. * @param source defines the source serialization data
  94412. * @param scene defines the hosting scene
  94413. * @param rootUrl defines the root url for resources
  94414. * @returns a new entity
  94415. */
  94416. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94417. /**
  94418. * Clones an object
  94419. * @param creationFunction defines the function used to instanciate the new object
  94420. * @param source defines the source object
  94421. * @returns the cloned object
  94422. */
  94423. static Clone<T>(creationFunction: () => T, source: T): T;
  94424. /**
  94425. * Instanciates a new object based on a source one (some data will be shared between both object)
  94426. * @param creationFunction defines the function used to instanciate the new object
  94427. * @param source defines the source object
  94428. * @returns the new object
  94429. */
  94430. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94431. }
  94432. }
  94433. declare module BABYLON {
  94434. /**
  94435. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94436. */
  94437. export interface CubeMapInfo {
  94438. /**
  94439. * The pixel array for the front face.
  94440. * This is stored in format, left to right, up to down format.
  94441. */
  94442. front: Nullable<ArrayBufferView>;
  94443. /**
  94444. * The pixel array for the back face.
  94445. * This is stored in format, left to right, up to down format.
  94446. */
  94447. back: Nullable<ArrayBufferView>;
  94448. /**
  94449. * The pixel array for the left face.
  94450. * This is stored in format, left to right, up to down format.
  94451. */
  94452. left: Nullable<ArrayBufferView>;
  94453. /**
  94454. * The pixel array for the right face.
  94455. * This is stored in format, left to right, up to down format.
  94456. */
  94457. right: Nullable<ArrayBufferView>;
  94458. /**
  94459. * The pixel array for the up face.
  94460. * This is stored in format, left to right, up to down format.
  94461. */
  94462. up: Nullable<ArrayBufferView>;
  94463. /**
  94464. * The pixel array for the down face.
  94465. * This is stored in format, left to right, up to down format.
  94466. */
  94467. down: Nullable<ArrayBufferView>;
  94468. /**
  94469. * The size of the cubemap stored.
  94470. *
  94471. * Each faces will be size * size pixels.
  94472. */
  94473. size: number;
  94474. /**
  94475. * The format of the texture.
  94476. *
  94477. * RGBA, RGB.
  94478. */
  94479. format: number;
  94480. /**
  94481. * The type of the texture data.
  94482. *
  94483. * UNSIGNED_INT, FLOAT.
  94484. */
  94485. type: number;
  94486. /**
  94487. * Specifies whether the texture is in gamma space.
  94488. */
  94489. gammaSpace: boolean;
  94490. }
  94491. /**
  94492. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94493. */
  94494. export class PanoramaToCubeMapTools {
  94495. private static FACE_FRONT;
  94496. private static FACE_BACK;
  94497. private static FACE_RIGHT;
  94498. private static FACE_LEFT;
  94499. private static FACE_DOWN;
  94500. private static FACE_UP;
  94501. /**
  94502. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94503. *
  94504. * @param float32Array The source data.
  94505. * @param inputWidth The width of the input panorama.
  94506. * @param inputHeight The height of the input panorama.
  94507. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94508. * @return The cubemap data
  94509. */
  94510. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94511. private static CreateCubemapTexture;
  94512. private static CalcProjectionSpherical;
  94513. }
  94514. }
  94515. declare module BABYLON {
  94516. /**
  94517. * Helper class dealing with the extraction of spherical polynomial dataArray
  94518. * from a cube map.
  94519. */
  94520. export class CubeMapToSphericalPolynomialTools {
  94521. private static FileFaces;
  94522. /**
  94523. * Converts a texture to the according Spherical Polynomial data.
  94524. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94525. *
  94526. * @param texture The texture to extract the information from.
  94527. * @return The Spherical Polynomial data.
  94528. */
  94529. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94530. /**
  94531. * Converts a cubemap to the according Spherical Polynomial data.
  94532. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94533. *
  94534. * @param cubeInfo The Cube map to extract the information from.
  94535. * @return The Spherical Polynomial data.
  94536. */
  94537. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94538. }
  94539. }
  94540. declare module BABYLON {
  94541. /**
  94542. * Class used to manipulate GUIDs
  94543. */
  94544. export class GUID {
  94545. /**
  94546. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94547. * Be aware Math.random() could cause collisions, but:
  94548. * "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"
  94549. * @returns a pseudo random id
  94550. */
  94551. static RandomId(): string;
  94552. }
  94553. }
  94554. declare module BABYLON {
  94555. /**
  94556. * Base class of all the textures in babylon.
  94557. * It groups all the common properties the materials, post process, lights... might need
  94558. * in order to make a correct use of the texture.
  94559. */
  94560. export class BaseTexture implements IAnimatable {
  94561. /**
  94562. * Default anisotropic filtering level for the application.
  94563. * It is set to 4 as a good tradeoff between perf and quality.
  94564. */
  94565. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94566. /**
  94567. * Gets or sets the unique id of the texture
  94568. */
  94569. uniqueId: number;
  94570. /**
  94571. * Define the name of the texture.
  94572. */
  94573. name: string;
  94574. /**
  94575. * Gets or sets an object used to store user defined information.
  94576. */
  94577. metadata: any;
  94578. /**
  94579. * For internal use only. Please do not use.
  94580. */
  94581. reservedDataStore: any;
  94582. private _hasAlpha;
  94583. /**
  94584. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94585. */
  94586. hasAlpha: boolean;
  94587. /**
  94588. * Defines if the alpha value should be determined via the rgb values.
  94589. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94590. */
  94591. getAlphaFromRGB: boolean;
  94592. /**
  94593. * Intensity or strength of the texture.
  94594. * It is commonly used by materials to fine tune the intensity of the texture
  94595. */
  94596. level: number;
  94597. /**
  94598. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94599. * This is part of the texture as textures usually maps to one uv set.
  94600. */
  94601. coordinatesIndex: number;
  94602. private _coordinatesMode;
  94603. /**
  94604. * How a texture is mapped.
  94605. *
  94606. * | Value | Type | Description |
  94607. * | ----- | ----------------------------------- | ----------- |
  94608. * | 0 | EXPLICIT_MODE | |
  94609. * | 1 | SPHERICAL_MODE | |
  94610. * | 2 | PLANAR_MODE | |
  94611. * | 3 | CUBIC_MODE | |
  94612. * | 4 | PROJECTION_MODE | |
  94613. * | 5 | SKYBOX_MODE | |
  94614. * | 6 | INVCUBIC_MODE | |
  94615. * | 7 | EQUIRECTANGULAR_MODE | |
  94616. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94617. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94618. */
  94619. coordinatesMode: number;
  94620. /**
  94621. * | Value | Type | Description |
  94622. * | ----- | ------------------ | ----------- |
  94623. * | 0 | CLAMP_ADDRESSMODE | |
  94624. * | 1 | WRAP_ADDRESSMODE | |
  94625. * | 2 | MIRROR_ADDRESSMODE | |
  94626. */
  94627. wrapU: number;
  94628. /**
  94629. * | Value | Type | Description |
  94630. * | ----- | ------------------ | ----------- |
  94631. * | 0 | CLAMP_ADDRESSMODE | |
  94632. * | 1 | WRAP_ADDRESSMODE | |
  94633. * | 2 | MIRROR_ADDRESSMODE | |
  94634. */
  94635. wrapV: number;
  94636. /**
  94637. * | Value | Type | Description |
  94638. * | ----- | ------------------ | ----------- |
  94639. * | 0 | CLAMP_ADDRESSMODE | |
  94640. * | 1 | WRAP_ADDRESSMODE | |
  94641. * | 2 | MIRROR_ADDRESSMODE | |
  94642. */
  94643. wrapR: number;
  94644. /**
  94645. * With compliant hardware and browser (supporting anisotropic filtering)
  94646. * this defines the level of anisotropic filtering in the texture.
  94647. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94648. */
  94649. anisotropicFilteringLevel: number;
  94650. /**
  94651. * Define if the texture is a cube texture or if false a 2d texture.
  94652. */
  94653. isCube: boolean;
  94654. /**
  94655. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94656. */
  94657. is3D: boolean;
  94658. /**
  94659. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94660. * HDR texture are usually stored in linear space.
  94661. * This only impacts the PBR and Background materials
  94662. */
  94663. gammaSpace: boolean;
  94664. /**
  94665. * Gets or sets whether or not the texture contains RGBD data.
  94666. */
  94667. isRGBD: boolean;
  94668. /**
  94669. * Is Z inverted in the texture (useful in a cube texture).
  94670. */
  94671. invertZ: boolean;
  94672. /**
  94673. * Are mip maps generated for this texture or not.
  94674. */
  94675. readonly noMipmap: boolean;
  94676. /**
  94677. * @hidden
  94678. */
  94679. lodLevelInAlpha: boolean;
  94680. /**
  94681. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94682. */
  94683. lodGenerationOffset: number;
  94684. /**
  94685. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94686. */
  94687. lodGenerationScale: number;
  94688. /**
  94689. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94690. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94691. * average roughness values.
  94692. */
  94693. linearSpecularLOD: boolean;
  94694. /**
  94695. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94696. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94697. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94698. */
  94699. irradianceTexture: Nullable<BaseTexture>;
  94700. /**
  94701. * Define if the texture is a render target.
  94702. */
  94703. isRenderTarget: boolean;
  94704. /**
  94705. * Define the unique id of the texture in the scene.
  94706. */
  94707. readonly uid: string;
  94708. /**
  94709. * Return a string representation of the texture.
  94710. * @returns the texture as a string
  94711. */
  94712. toString(): string;
  94713. /**
  94714. * Get the class name of the texture.
  94715. * @returns "BaseTexture"
  94716. */
  94717. getClassName(): string;
  94718. /**
  94719. * Define the list of animation attached to the texture.
  94720. */
  94721. animations: Animation[];
  94722. /**
  94723. * An event triggered when the texture is disposed.
  94724. */
  94725. onDisposeObservable: Observable<BaseTexture>;
  94726. private _onDisposeObserver;
  94727. /**
  94728. * Callback triggered when the texture has been disposed.
  94729. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94730. */
  94731. onDispose: () => void;
  94732. /**
  94733. * Define the current state of the loading sequence when in delayed load mode.
  94734. */
  94735. delayLoadState: number;
  94736. private _scene;
  94737. /** @hidden */
  94738. _texture: Nullable<InternalTexture>;
  94739. private _uid;
  94740. /**
  94741. * Define if the texture is preventinga material to render or not.
  94742. * If not and the texture is not ready, the engine will use a default black texture instead.
  94743. */
  94744. readonly isBlocking: boolean;
  94745. /**
  94746. * Instantiates a new BaseTexture.
  94747. * Base class of all the textures in babylon.
  94748. * It groups all the common properties the materials, post process, lights... might need
  94749. * in order to make a correct use of the texture.
  94750. * @param scene Define the scene the texture blongs to
  94751. */
  94752. constructor(scene: Nullable<Scene>);
  94753. /**
  94754. * Get the scene the texture belongs to.
  94755. * @returns the scene or null if undefined
  94756. */
  94757. getScene(): Nullable<Scene>;
  94758. /**
  94759. * Get the texture transform matrix used to offset tile the texture for istance.
  94760. * @returns the transformation matrix
  94761. */
  94762. getTextureMatrix(): Matrix;
  94763. /**
  94764. * Get the texture reflection matrix used to rotate/transform the reflection.
  94765. * @returns the reflection matrix
  94766. */
  94767. getReflectionTextureMatrix(): Matrix;
  94768. /**
  94769. * Get the underlying lower level texture from Babylon.
  94770. * @returns the insternal texture
  94771. */
  94772. getInternalTexture(): Nullable<InternalTexture>;
  94773. /**
  94774. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94775. * @returns true if ready or not blocking
  94776. */
  94777. isReadyOrNotBlocking(): boolean;
  94778. /**
  94779. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94780. * @returns true if fully ready
  94781. */
  94782. isReady(): boolean;
  94783. private _cachedSize;
  94784. /**
  94785. * Get the size of the texture.
  94786. * @returns the texture size.
  94787. */
  94788. getSize(): ISize;
  94789. /**
  94790. * Get the base size of the texture.
  94791. * It can be different from the size if the texture has been resized for POT for instance
  94792. * @returns the base size
  94793. */
  94794. getBaseSize(): ISize;
  94795. /**
  94796. * Update the sampling mode of the texture.
  94797. * Default is Trilinear mode.
  94798. *
  94799. * | Value | Type | Description |
  94800. * | ----- | ------------------ | ----------- |
  94801. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94802. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94803. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94804. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94805. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94806. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94807. * | 7 | NEAREST_LINEAR | |
  94808. * | 8 | NEAREST_NEAREST | |
  94809. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94810. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94811. * | 11 | LINEAR_LINEAR | |
  94812. * | 12 | LINEAR_NEAREST | |
  94813. *
  94814. * > _mag_: magnification filter (close to the viewer)
  94815. * > _min_: minification filter (far from the viewer)
  94816. * > _mip_: filter used between mip map levels
  94817. *@param samplingMode Define the new sampling mode of the texture
  94818. */
  94819. updateSamplingMode(samplingMode: number): void;
  94820. /**
  94821. * Scales the texture if is `canRescale()`
  94822. * @param ratio the resize factor we want to use to rescale
  94823. */
  94824. scale(ratio: number): void;
  94825. /**
  94826. * Get if the texture can rescale.
  94827. */
  94828. readonly canRescale: boolean;
  94829. /** @hidden */
  94830. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94831. /** @hidden */
  94832. _rebuild(): void;
  94833. /**
  94834. * Triggers the load sequence in delayed load mode.
  94835. */
  94836. delayLoad(): void;
  94837. /**
  94838. * Clones the texture.
  94839. * @returns the cloned texture
  94840. */
  94841. clone(): Nullable<BaseTexture>;
  94842. /**
  94843. * Get the texture underlying type (INT, FLOAT...)
  94844. */
  94845. readonly textureType: number;
  94846. /**
  94847. * Get the texture underlying format (RGB, RGBA...)
  94848. */
  94849. readonly textureFormat: number;
  94850. /**
  94851. * Indicates that textures need to be re-calculated for all materials
  94852. */
  94853. protected _markAllSubMeshesAsTexturesDirty(): void;
  94854. /**
  94855. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94856. * This will returns an RGBA array buffer containing either in values (0-255) or
  94857. * float values (0-1) depending of the underlying buffer type.
  94858. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94859. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94860. * @param buffer defines a user defined buffer to fill with data (can be null)
  94861. * @returns The Array buffer containing the pixels data.
  94862. */
  94863. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94864. /**
  94865. * Release and destroy the underlying lower level texture aka internalTexture.
  94866. */
  94867. releaseInternalTexture(): void;
  94868. /**
  94869. * Get the polynomial representation of the texture data.
  94870. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94871. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94872. */
  94873. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94874. /** @hidden */
  94875. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94876. /** @hidden */
  94877. readonly _lodTextureMid: Nullable<BaseTexture>;
  94878. /** @hidden */
  94879. readonly _lodTextureLow: Nullable<BaseTexture>;
  94880. /**
  94881. * Dispose the texture and release its associated resources.
  94882. */
  94883. dispose(): void;
  94884. /**
  94885. * Serialize the texture into a JSON representation that can be parsed later on.
  94886. * @returns the JSON representation of the texture
  94887. */
  94888. serialize(): any;
  94889. /**
  94890. * Helper function to be called back once a list of texture contains only ready textures.
  94891. * @param textures Define the list of textures to wait for
  94892. * @param callback Define the callback triggered once the entire list will be ready
  94893. */
  94894. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94895. }
  94896. }
  94897. declare module BABYLON {
  94898. /**
  94899. * Options to be used when creating an effect.
  94900. */
  94901. export class EffectCreationOptions {
  94902. /**
  94903. * Atrributes that will be used in the shader.
  94904. */
  94905. attributes: string[];
  94906. /**
  94907. * Uniform varible names that will be set in the shader.
  94908. */
  94909. uniformsNames: string[];
  94910. /**
  94911. * Uniform buffer varible names that will be set in the shader.
  94912. */
  94913. uniformBuffersNames: string[];
  94914. /**
  94915. * Sampler texture variable names that will be set in the shader.
  94916. */
  94917. samplers: string[];
  94918. /**
  94919. * Define statements that will be set in the shader.
  94920. */
  94921. defines: any;
  94922. /**
  94923. * Possible fallbacks for this effect to improve performance when needed.
  94924. */
  94925. fallbacks: Nullable<IEffectFallbacks>;
  94926. /**
  94927. * Callback that will be called when the shader is compiled.
  94928. */
  94929. onCompiled: Nullable<(effect: Effect) => void>;
  94930. /**
  94931. * Callback that will be called if an error occurs during shader compilation.
  94932. */
  94933. onError: Nullable<(effect: Effect, errors: string) => void>;
  94934. /**
  94935. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94936. */
  94937. indexParameters?: any;
  94938. /**
  94939. * Max number of lights that can be used in the shader.
  94940. */
  94941. maxSimultaneousLights?: number;
  94942. /**
  94943. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94944. */
  94945. transformFeedbackVaryings?: Nullable<string[]>;
  94946. }
  94947. /**
  94948. * Effect containing vertex and fragment shader that can be executed on an object.
  94949. */
  94950. export class Effect implements IDisposable {
  94951. /**
  94952. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94953. */
  94954. static ShadersRepository: string;
  94955. /**
  94956. * Name of the effect.
  94957. */
  94958. name: any;
  94959. /**
  94960. * String container all the define statements that should be set on the shader.
  94961. */
  94962. defines: string;
  94963. /**
  94964. * Callback that will be called when the shader is compiled.
  94965. */
  94966. onCompiled: Nullable<(effect: Effect) => void>;
  94967. /**
  94968. * Callback that will be called if an error occurs during shader compilation.
  94969. */
  94970. onError: Nullable<(effect: Effect, errors: string) => void>;
  94971. /**
  94972. * Callback that will be called when effect is bound.
  94973. */
  94974. onBind: Nullable<(effect: Effect) => void>;
  94975. /**
  94976. * Unique ID of the effect.
  94977. */
  94978. uniqueId: number;
  94979. /**
  94980. * Observable that will be called when the shader is compiled.
  94981. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94982. */
  94983. onCompileObservable: Observable<Effect>;
  94984. /**
  94985. * Observable that will be called if an error occurs during shader compilation.
  94986. */
  94987. onErrorObservable: Observable<Effect>;
  94988. /** @hidden */
  94989. _onBindObservable: Nullable<Observable<Effect>>;
  94990. /**
  94991. * Observable that will be called when effect is bound.
  94992. */
  94993. readonly onBindObservable: Observable<Effect>;
  94994. /** @hidden */
  94995. _bonesComputationForcedToCPU: boolean;
  94996. private static _uniqueIdSeed;
  94997. private _engine;
  94998. private _uniformBuffersNames;
  94999. private _uniformsNames;
  95000. private _samplerList;
  95001. private _samplers;
  95002. private _isReady;
  95003. private _compilationError;
  95004. private _attributesNames;
  95005. private _attributes;
  95006. private _uniforms;
  95007. /**
  95008. * Key for the effect.
  95009. * @hidden
  95010. */
  95011. _key: string;
  95012. private _indexParameters;
  95013. private _fallbacks;
  95014. private _vertexSourceCode;
  95015. private _fragmentSourceCode;
  95016. private _vertexSourceCodeOverride;
  95017. private _fragmentSourceCodeOverride;
  95018. private _transformFeedbackVaryings;
  95019. /**
  95020. * Compiled shader to webGL program.
  95021. * @hidden
  95022. */
  95023. _pipelineContext: Nullable<IPipelineContext>;
  95024. private _valueCache;
  95025. private static _baseCache;
  95026. /**
  95027. * Instantiates an effect.
  95028. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95029. * @param baseName Name of the effect.
  95030. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95031. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95032. * @param samplers List of sampler variables that will be passed to the shader.
  95033. * @param engine Engine to be used to render the effect
  95034. * @param defines Define statements to be added to the shader.
  95035. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95036. * @param onCompiled Callback that will be called when the shader is compiled.
  95037. * @param onError Callback that will be called if an error occurs during shader compilation.
  95038. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95039. */
  95040. 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);
  95041. private _useFinalCode;
  95042. /**
  95043. * Unique key for this effect
  95044. */
  95045. readonly key: string;
  95046. /**
  95047. * If the effect has been compiled and prepared.
  95048. * @returns if the effect is compiled and prepared.
  95049. */
  95050. isReady(): boolean;
  95051. private _isReadyInternal;
  95052. /**
  95053. * The engine the effect was initialized with.
  95054. * @returns the engine.
  95055. */
  95056. getEngine(): Engine;
  95057. /**
  95058. * The pipeline context for this effect
  95059. * @returns the associated pipeline context
  95060. */
  95061. getPipelineContext(): Nullable<IPipelineContext>;
  95062. /**
  95063. * The set of names of attribute variables for the shader.
  95064. * @returns An array of attribute names.
  95065. */
  95066. getAttributesNames(): string[];
  95067. /**
  95068. * Returns the attribute at the given index.
  95069. * @param index The index of the attribute.
  95070. * @returns The location of the attribute.
  95071. */
  95072. getAttributeLocation(index: number): number;
  95073. /**
  95074. * Returns the attribute based on the name of the variable.
  95075. * @param name of the attribute to look up.
  95076. * @returns the attribute location.
  95077. */
  95078. getAttributeLocationByName(name: string): number;
  95079. /**
  95080. * The number of attributes.
  95081. * @returns the numnber of attributes.
  95082. */
  95083. getAttributesCount(): number;
  95084. /**
  95085. * Gets the index of a uniform variable.
  95086. * @param uniformName of the uniform to look up.
  95087. * @returns the index.
  95088. */
  95089. getUniformIndex(uniformName: string): number;
  95090. /**
  95091. * Returns the attribute based on the name of the variable.
  95092. * @param uniformName of the uniform to look up.
  95093. * @returns the location of the uniform.
  95094. */
  95095. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95096. /**
  95097. * Returns an array of sampler variable names
  95098. * @returns The array of sampler variable neames.
  95099. */
  95100. getSamplers(): string[];
  95101. /**
  95102. * The error from the last compilation.
  95103. * @returns the error string.
  95104. */
  95105. getCompilationError(): string;
  95106. /**
  95107. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95108. * @param func The callback to be used.
  95109. */
  95110. executeWhenCompiled(func: (effect: Effect) => void): void;
  95111. private _checkIsReady;
  95112. /** @hidden */
  95113. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  95114. /** @hidden */
  95115. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  95116. /** @hidden */
  95117. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  95118. /**
  95119. * Recompiles the webGL program
  95120. * @param vertexSourceCode The source code for the vertex shader.
  95121. * @param fragmentSourceCode The source code for the fragment shader.
  95122. * @param onCompiled Callback called when completed.
  95123. * @param onError Callback called on error.
  95124. * @hidden
  95125. */
  95126. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95127. /**
  95128. * Prepares the effect
  95129. * @hidden
  95130. */
  95131. _prepareEffect(): void;
  95132. private _processCompilationErrors;
  95133. /**
  95134. * Checks if the effect is supported. (Must be called after compilation)
  95135. */
  95136. readonly isSupported: boolean;
  95137. /**
  95138. * Binds a texture to the engine to be used as output of the shader.
  95139. * @param channel Name of the output variable.
  95140. * @param texture Texture to bind.
  95141. * @hidden
  95142. */
  95143. _bindTexture(channel: string, texture: InternalTexture): void;
  95144. /**
  95145. * Sets a texture on the engine to be used in the shader.
  95146. * @param channel Name of the sampler variable.
  95147. * @param texture Texture to set.
  95148. */
  95149. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95150. /**
  95151. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95152. * @param channel Name of the sampler variable.
  95153. * @param texture Texture to set.
  95154. */
  95155. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95156. /**
  95157. * Sets an array of textures on the engine to be used in the shader.
  95158. * @param channel Name of the variable.
  95159. * @param textures Textures to set.
  95160. */
  95161. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95162. /**
  95163. * 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)
  95164. * @param channel Name of the sampler variable.
  95165. * @param postProcess Post process to get the input texture from.
  95166. */
  95167. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95168. /**
  95169. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95170. * 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)
  95171. * @param channel Name of the sampler variable.
  95172. * @param postProcess Post process to get the output texture from.
  95173. */
  95174. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95175. /** @hidden */
  95176. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95177. /** @hidden */
  95178. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95179. /** @hidden */
  95180. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95181. /** @hidden */
  95182. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95183. /**
  95184. * Binds a buffer to a uniform.
  95185. * @param buffer Buffer to bind.
  95186. * @param name Name of the uniform variable to bind to.
  95187. */
  95188. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95189. /**
  95190. * Binds block to a uniform.
  95191. * @param blockName Name of the block to bind.
  95192. * @param index Index to bind.
  95193. */
  95194. bindUniformBlock(blockName: string, index: number): void;
  95195. /**
  95196. * Sets an interger value on a uniform variable.
  95197. * @param uniformName Name of the variable.
  95198. * @param value Value to be set.
  95199. * @returns this effect.
  95200. */
  95201. setInt(uniformName: string, value: number): Effect;
  95202. /**
  95203. * Sets an int array on a uniform variable.
  95204. * @param uniformName Name of the variable.
  95205. * @param array array to be set.
  95206. * @returns this effect.
  95207. */
  95208. setIntArray(uniformName: string, array: Int32Array): Effect;
  95209. /**
  95210. * 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)
  95211. * @param uniformName Name of the variable.
  95212. * @param array array to be set.
  95213. * @returns this effect.
  95214. */
  95215. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95216. /**
  95217. * 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)
  95218. * @param uniformName Name of the variable.
  95219. * @param array array to be set.
  95220. * @returns this effect.
  95221. */
  95222. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95223. /**
  95224. * 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)
  95225. * @param uniformName Name of the variable.
  95226. * @param array array to be set.
  95227. * @returns this effect.
  95228. */
  95229. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95230. /**
  95231. * Sets an float array on a uniform variable.
  95232. * @param uniformName Name of the variable.
  95233. * @param array array to be set.
  95234. * @returns this effect.
  95235. */
  95236. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95237. /**
  95238. * 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)
  95239. * @param uniformName Name of the variable.
  95240. * @param array array to be set.
  95241. * @returns this effect.
  95242. */
  95243. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95244. /**
  95245. * 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)
  95246. * @param uniformName Name of the variable.
  95247. * @param array array to be set.
  95248. * @returns this effect.
  95249. */
  95250. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95251. /**
  95252. * 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)
  95253. * @param uniformName Name of the variable.
  95254. * @param array array to be set.
  95255. * @returns this effect.
  95256. */
  95257. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95258. /**
  95259. * Sets an array on a uniform variable.
  95260. * @param uniformName Name of the variable.
  95261. * @param array array to be set.
  95262. * @returns this effect.
  95263. */
  95264. setArray(uniformName: string, array: number[]): Effect;
  95265. /**
  95266. * 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)
  95267. * @param uniformName Name of the variable.
  95268. * @param array array to be set.
  95269. * @returns this effect.
  95270. */
  95271. setArray2(uniformName: string, array: number[]): Effect;
  95272. /**
  95273. * 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)
  95274. * @param uniformName Name of the variable.
  95275. * @param array array to be set.
  95276. * @returns this effect.
  95277. */
  95278. setArray3(uniformName: string, array: number[]): Effect;
  95279. /**
  95280. * 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)
  95281. * @param uniformName Name of the variable.
  95282. * @param array array to be set.
  95283. * @returns this effect.
  95284. */
  95285. setArray4(uniformName: string, array: number[]): Effect;
  95286. /**
  95287. * Sets matrices on a uniform variable.
  95288. * @param uniformName Name of the variable.
  95289. * @param matrices matrices to be set.
  95290. * @returns this effect.
  95291. */
  95292. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95293. /**
  95294. * Sets matrix on a uniform variable.
  95295. * @param uniformName Name of the variable.
  95296. * @param matrix matrix to be set.
  95297. * @returns this effect.
  95298. */
  95299. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95300. /**
  95301. * 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)
  95302. * @param uniformName Name of the variable.
  95303. * @param matrix matrix to be set.
  95304. * @returns this effect.
  95305. */
  95306. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95307. /**
  95308. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95309. * @param uniformName Name of the variable.
  95310. * @param matrix matrix to be set.
  95311. * @returns this effect.
  95312. */
  95313. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95314. /**
  95315. * Sets a float on a uniform variable.
  95316. * @param uniformName Name of the variable.
  95317. * @param value value to be set.
  95318. * @returns this effect.
  95319. */
  95320. setFloat(uniformName: string, value: number): Effect;
  95321. /**
  95322. * Sets a boolean on a uniform variable.
  95323. * @param uniformName Name of the variable.
  95324. * @param bool value to be set.
  95325. * @returns this effect.
  95326. */
  95327. setBool(uniformName: string, bool: boolean): Effect;
  95328. /**
  95329. * Sets a Vector2 on a uniform variable.
  95330. * @param uniformName Name of the variable.
  95331. * @param vector2 vector2 to be set.
  95332. * @returns this effect.
  95333. */
  95334. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95335. /**
  95336. * Sets a float2 on a uniform variable.
  95337. * @param uniformName Name of the variable.
  95338. * @param x First float in float2.
  95339. * @param y Second float in float2.
  95340. * @returns this effect.
  95341. */
  95342. setFloat2(uniformName: string, x: number, y: number): Effect;
  95343. /**
  95344. * Sets a Vector3 on a uniform variable.
  95345. * @param uniformName Name of the variable.
  95346. * @param vector3 Value to be set.
  95347. * @returns this effect.
  95348. */
  95349. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95350. /**
  95351. * Sets a float3 on a uniform variable.
  95352. * @param uniformName Name of the variable.
  95353. * @param x First float in float3.
  95354. * @param y Second float in float3.
  95355. * @param z Third float in float3.
  95356. * @returns this effect.
  95357. */
  95358. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95359. /**
  95360. * Sets a Vector4 on a uniform variable.
  95361. * @param uniformName Name of the variable.
  95362. * @param vector4 Value to be set.
  95363. * @returns this effect.
  95364. */
  95365. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95366. /**
  95367. * Sets a float4 on a uniform variable.
  95368. * @param uniformName Name of the variable.
  95369. * @param x First float in float4.
  95370. * @param y Second float in float4.
  95371. * @param z Third float in float4.
  95372. * @param w Fourth float in float4.
  95373. * @returns this effect.
  95374. */
  95375. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95376. /**
  95377. * Sets a Color3 on a uniform variable.
  95378. * @param uniformName Name of the variable.
  95379. * @param color3 Value to be set.
  95380. * @returns this effect.
  95381. */
  95382. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95383. /**
  95384. * Sets a Color4 on a uniform variable.
  95385. * @param uniformName Name of the variable.
  95386. * @param color3 Value to be set.
  95387. * @param alpha Alpha value to be set.
  95388. * @returns this effect.
  95389. */
  95390. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95391. /**
  95392. * Sets a Color4 on a uniform variable
  95393. * @param uniformName defines the name of the variable
  95394. * @param color4 defines the value to be set
  95395. * @returns this effect.
  95396. */
  95397. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95398. /** Release all associated resources */
  95399. dispose(): void;
  95400. /**
  95401. * This function will add a new shader to the shader store
  95402. * @param name the name of the shader
  95403. * @param pixelShader optional pixel shader content
  95404. * @param vertexShader optional vertex shader content
  95405. */
  95406. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95407. /**
  95408. * Store of each shader (The can be looked up using effect.key)
  95409. */
  95410. static ShadersStore: {
  95411. [key: string]: string;
  95412. };
  95413. /**
  95414. * Store of each included file for a shader (The can be looked up using effect.key)
  95415. */
  95416. static IncludesShadersStore: {
  95417. [key: string]: string;
  95418. };
  95419. /**
  95420. * Resets the cache of effects.
  95421. */
  95422. static ResetCache(): void;
  95423. }
  95424. }
  95425. declare module BABYLON {
  95426. /**
  95427. * Class used to describe the capabilities of the engine relatively to the current browser
  95428. */
  95429. export class EngineCapabilities {
  95430. /** Maximum textures units per fragment shader */
  95431. maxTexturesImageUnits: number;
  95432. /** Maximum texture units per vertex shader */
  95433. maxVertexTextureImageUnits: number;
  95434. /** Maximum textures units in the entire pipeline */
  95435. maxCombinedTexturesImageUnits: number;
  95436. /** Maximum texture size */
  95437. maxTextureSize: number;
  95438. /** Maximum cube texture size */
  95439. maxCubemapTextureSize: number;
  95440. /** Maximum render texture size */
  95441. maxRenderTextureSize: number;
  95442. /** Maximum number of vertex attributes */
  95443. maxVertexAttribs: number;
  95444. /** Maximum number of varyings */
  95445. maxVaryingVectors: number;
  95446. /** Maximum number of uniforms per vertex shader */
  95447. maxVertexUniformVectors: number;
  95448. /** Maximum number of uniforms per fragment shader */
  95449. maxFragmentUniformVectors: number;
  95450. /** Defines if standard derivates (dx/dy) are supported */
  95451. standardDerivatives: boolean;
  95452. /** Defines if s3tc texture compression is supported */
  95453. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95454. /** Defines if pvrtc texture compression is supported */
  95455. pvrtc: any;
  95456. /** Defines if etc1 texture compression is supported */
  95457. etc1: any;
  95458. /** Defines if etc2 texture compression is supported */
  95459. etc2: any;
  95460. /** Defines if astc texture compression is supported */
  95461. astc: any;
  95462. /** Defines if float textures are supported */
  95463. textureFloat: boolean;
  95464. /** Defines if vertex array objects are supported */
  95465. vertexArrayObject: boolean;
  95466. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95467. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95468. /** Gets the maximum level of anisotropy supported */
  95469. maxAnisotropy: number;
  95470. /** Defines if instancing is supported */
  95471. instancedArrays: boolean;
  95472. /** Defines if 32 bits indices are supported */
  95473. uintIndices: boolean;
  95474. /** Defines if high precision shaders are supported */
  95475. highPrecisionShaderSupported: boolean;
  95476. /** Defines if depth reading in the fragment shader is supported */
  95477. fragmentDepthSupported: boolean;
  95478. /** Defines if float texture linear filtering is supported*/
  95479. textureFloatLinearFiltering: boolean;
  95480. /** Defines if rendering to float textures is supported */
  95481. textureFloatRender: boolean;
  95482. /** Defines if half float textures are supported*/
  95483. textureHalfFloat: boolean;
  95484. /** Defines if half float texture linear filtering is supported*/
  95485. textureHalfFloatLinearFiltering: boolean;
  95486. /** Defines if rendering to half float textures is supported */
  95487. textureHalfFloatRender: boolean;
  95488. /** Defines if textureLOD shader command is supported */
  95489. textureLOD: boolean;
  95490. /** Defines if draw buffers extension is supported */
  95491. drawBuffersExtension: boolean;
  95492. /** Defines if depth textures are supported */
  95493. depthTextureExtension: boolean;
  95494. /** Defines if float color buffer are supported */
  95495. colorBufferFloat: boolean;
  95496. /** Gets disjoint timer query extension (null if not supported) */
  95497. timerQuery: EXT_disjoint_timer_query;
  95498. /** Defines if timestamp can be used with timer query */
  95499. canUseTimestampForTimerQuery: boolean;
  95500. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95501. multiview: any;
  95502. /** Function used to let the system compiles shaders in background */
  95503. parallelShaderCompile: {
  95504. COMPLETION_STATUS_KHR: number;
  95505. };
  95506. /** Max number of texture samples for MSAA */
  95507. maxMSAASamples: number;
  95508. /** Defines if the blend min max extension is supported */
  95509. blendMinMax: boolean;
  95510. }
  95511. }
  95512. declare module BABYLON {
  95513. /**
  95514. * This class is used to track a performance counter which is number based.
  95515. * The user has access to many properties which give statistics of different nature.
  95516. *
  95517. * The implementer can track two kinds of Performance Counter: time and count.
  95518. * 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.
  95519. * 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.
  95520. */
  95521. export class PerfCounter {
  95522. /**
  95523. * Gets or sets a global boolean to turn on and off all the counters
  95524. */
  95525. static Enabled: boolean;
  95526. /**
  95527. * Returns the smallest value ever
  95528. */
  95529. readonly min: number;
  95530. /**
  95531. * Returns the biggest value ever
  95532. */
  95533. readonly max: number;
  95534. /**
  95535. * Returns the average value since the performance counter is running
  95536. */
  95537. readonly average: number;
  95538. /**
  95539. * Returns the average value of the last second the counter was monitored
  95540. */
  95541. readonly lastSecAverage: number;
  95542. /**
  95543. * Returns the current value
  95544. */
  95545. readonly current: number;
  95546. /**
  95547. * Gets the accumulated total
  95548. */
  95549. readonly total: number;
  95550. /**
  95551. * Gets the total value count
  95552. */
  95553. readonly count: number;
  95554. /**
  95555. * Creates a new counter
  95556. */
  95557. constructor();
  95558. /**
  95559. * Call this method to start monitoring a new frame.
  95560. * 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.
  95561. */
  95562. fetchNewFrame(): void;
  95563. /**
  95564. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95565. * @param newCount the count value to add to the monitored count
  95566. * @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.
  95567. */
  95568. addCount(newCount: number, fetchResult: boolean): void;
  95569. /**
  95570. * Start monitoring this performance counter
  95571. */
  95572. beginMonitoring(): void;
  95573. /**
  95574. * Compute the time lapsed since the previous beginMonitoring() call.
  95575. * @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
  95576. */
  95577. endMonitoring(newFrame?: boolean): void;
  95578. private _fetchResult;
  95579. private _startMonitoringTime;
  95580. private _min;
  95581. private _max;
  95582. private _average;
  95583. private _current;
  95584. private _totalValueCount;
  95585. private _totalAccumulated;
  95586. private _lastSecAverage;
  95587. private _lastSecAccumulated;
  95588. private _lastSecTime;
  95589. private _lastSecValueCount;
  95590. }
  95591. }
  95592. declare module BABYLON {
  95593. /**
  95594. * @hidden
  95595. **/
  95596. export class DepthCullingState {
  95597. private _isDepthTestDirty;
  95598. private _isDepthMaskDirty;
  95599. private _isDepthFuncDirty;
  95600. private _isCullFaceDirty;
  95601. private _isCullDirty;
  95602. private _isZOffsetDirty;
  95603. private _isFrontFaceDirty;
  95604. private _depthTest;
  95605. private _depthMask;
  95606. private _depthFunc;
  95607. private _cull;
  95608. private _cullFace;
  95609. private _zOffset;
  95610. private _frontFace;
  95611. /**
  95612. * Initializes the state.
  95613. */
  95614. constructor();
  95615. readonly isDirty: boolean;
  95616. zOffset: number;
  95617. cullFace: Nullable<number>;
  95618. cull: Nullable<boolean>;
  95619. depthFunc: Nullable<number>;
  95620. depthMask: boolean;
  95621. depthTest: boolean;
  95622. frontFace: Nullable<number>;
  95623. reset(): void;
  95624. apply(gl: WebGLRenderingContext): void;
  95625. }
  95626. }
  95627. declare module BABYLON {
  95628. /**
  95629. * @hidden
  95630. **/
  95631. export class StencilState {
  95632. /** 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 */
  95633. static readonly ALWAYS: number;
  95634. /** Passed to stencilOperation to specify that stencil value must be kept */
  95635. static readonly KEEP: number;
  95636. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95637. static readonly REPLACE: number;
  95638. private _isStencilTestDirty;
  95639. private _isStencilMaskDirty;
  95640. private _isStencilFuncDirty;
  95641. private _isStencilOpDirty;
  95642. private _stencilTest;
  95643. private _stencilMask;
  95644. private _stencilFunc;
  95645. private _stencilFuncRef;
  95646. private _stencilFuncMask;
  95647. private _stencilOpStencilFail;
  95648. private _stencilOpDepthFail;
  95649. private _stencilOpStencilDepthPass;
  95650. readonly isDirty: boolean;
  95651. stencilFunc: number;
  95652. stencilFuncRef: number;
  95653. stencilFuncMask: number;
  95654. stencilOpStencilFail: number;
  95655. stencilOpDepthFail: number;
  95656. stencilOpStencilDepthPass: number;
  95657. stencilMask: number;
  95658. stencilTest: boolean;
  95659. constructor();
  95660. reset(): void;
  95661. apply(gl: WebGLRenderingContext): void;
  95662. }
  95663. }
  95664. declare module BABYLON {
  95665. /**
  95666. * @hidden
  95667. **/
  95668. export class AlphaState {
  95669. private _isAlphaBlendDirty;
  95670. private _isBlendFunctionParametersDirty;
  95671. private _isBlendEquationParametersDirty;
  95672. private _isBlendConstantsDirty;
  95673. private _alphaBlend;
  95674. private _blendFunctionParameters;
  95675. private _blendEquationParameters;
  95676. private _blendConstants;
  95677. /**
  95678. * Initializes the state.
  95679. */
  95680. constructor();
  95681. readonly isDirty: boolean;
  95682. alphaBlend: boolean;
  95683. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95684. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95685. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95686. reset(): void;
  95687. apply(gl: WebGLRenderingContext): void;
  95688. }
  95689. }
  95690. declare module BABYLON {
  95691. /** @hidden */
  95692. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95693. attributeProcessor(attribute: string): string;
  95694. varyingProcessor(varying: string, isFragment: boolean): string;
  95695. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95696. }
  95697. }
  95698. declare module BABYLON {
  95699. /**
  95700. * Interface for attribute information associated with buffer instanciation
  95701. */
  95702. export class InstancingAttributeInfo {
  95703. /**
  95704. * Index/offset of the attribute in the vertex shader
  95705. */
  95706. index: number;
  95707. /**
  95708. * size of the attribute, 1, 2, 3 or 4
  95709. */
  95710. attributeSize: number;
  95711. /**
  95712. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95713. * default is FLOAT
  95714. */
  95715. attribyteType: number;
  95716. /**
  95717. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95718. */
  95719. normalized: boolean;
  95720. /**
  95721. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95722. */
  95723. offset: number;
  95724. /**
  95725. * Name of the GLSL attribute, for debugging purpose only
  95726. */
  95727. attributeName: string;
  95728. }
  95729. }
  95730. declare module BABYLON {
  95731. interface ThinEngine {
  95732. /**
  95733. * Update a video texture
  95734. * @param texture defines the texture to update
  95735. * @param video defines the video element to use
  95736. * @param invertY defines if data must be stored with Y axis inverted
  95737. */
  95738. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95739. }
  95740. }
  95741. declare module BABYLON {
  95742. /**
  95743. * Settings for finer control over video usage
  95744. */
  95745. export interface VideoTextureSettings {
  95746. /**
  95747. * Applies `autoplay` to video, if specified
  95748. */
  95749. autoPlay?: boolean;
  95750. /**
  95751. * Applies `loop` to video, if specified
  95752. */
  95753. loop?: boolean;
  95754. /**
  95755. * Automatically updates internal texture from video at every frame in the render loop
  95756. */
  95757. autoUpdateTexture: boolean;
  95758. /**
  95759. * Image src displayed during the video loading or until the user interacts with the video.
  95760. */
  95761. poster?: string;
  95762. }
  95763. /**
  95764. * If you want to display a video in your scene, this is the special texture for that.
  95765. * This special texture works similar to other textures, with the exception of a few parameters.
  95766. * @see https://doc.babylonjs.com/how_to/video_texture
  95767. */
  95768. export class VideoTexture extends Texture {
  95769. /**
  95770. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95771. */
  95772. readonly autoUpdateTexture: boolean;
  95773. /**
  95774. * The video instance used by the texture internally
  95775. */
  95776. readonly video: HTMLVideoElement;
  95777. private _onUserActionRequestedObservable;
  95778. /**
  95779. * Event triggerd when a dom action is required by the user to play the video.
  95780. * This happens due to recent changes in browser policies preventing video to auto start.
  95781. */
  95782. readonly onUserActionRequestedObservable: Observable<Texture>;
  95783. private _generateMipMaps;
  95784. private _engine;
  95785. private _stillImageCaptured;
  95786. private _displayingPosterTexture;
  95787. private _settings;
  95788. private _createInternalTextureOnEvent;
  95789. private _frameId;
  95790. /**
  95791. * Creates a video texture.
  95792. * If you want to display a video in your scene, this is the special texture for that.
  95793. * This special texture works similar to other textures, with the exception of a few parameters.
  95794. * @see https://doc.babylonjs.com/how_to/video_texture
  95795. * @param name optional name, will detect from video source, if not defined
  95796. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95797. * @param scene is obviously the current scene.
  95798. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95799. * @param invertY is false by default but can be used to invert video on Y axis
  95800. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95801. * @param settings allows finer control over video usage
  95802. */
  95803. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95804. private _getName;
  95805. private _getVideo;
  95806. private _createInternalTexture;
  95807. private reset;
  95808. /**
  95809. * @hidden Internal method to initiate `update`.
  95810. */
  95811. _rebuild(): void;
  95812. /**
  95813. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95814. */
  95815. update(): void;
  95816. /**
  95817. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95818. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95819. */
  95820. updateTexture(isVisible: boolean): void;
  95821. protected _updateInternalTexture: () => void;
  95822. /**
  95823. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95824. * @param url New url.
  95825. */
  95826. updateURL(url: string): void;
  95827. /**
  95828. * Dispose the texture and release its associated resources.
  95829. */
  95830. dispose(): void;
  95831. /**
  95832. * Creates a video texture straight from a stream.
  95833. * @param scene Define the scene the texture should be created in
  95834. * @param stream Define the stream the texture should be created from
  95835. * @returns The created video texture as a promise
  95836. */
  95837. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95838. /**
  95839. * Creates a video texture straight from your WebCam video feed.
  95840. * @param scene Define the scene the texture should be created in
  95841. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95842. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95843. * @returns The created video texture as a promise
  95844. */
  95845. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95846. minWidth: number;
  95847. maxWidth: number;
  95848. minHeight: number;
  95849. maxHeight: number;
  95850. deviceId: string;
  95851. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95852. /**
  95853. * Creates a video texture straight from your WebCam video feed.
  95854. * @param scene Define the scene the texture should be created in
  95855. * @param onReady Define a callback to triggered once the texture will be ready
  95856. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95857. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95858. */
  95859. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95860. minWidth: number;
  95861. maxWidth: number;
  95862. minHeight: number;
  95863. maxHeight: number;
  95864. deviceId: string;
  95865. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95866. }
  95867. }
  95868. declare module BABYLON {
  95869. /**
  95870. * Defines the interface used by objects working like Scene
  95871. * @hidden
  95872. */
  95873. interface ISceneLike {
  95874. _addPendingData(data: any): void;
  95875. _removePendingData(data: any): void;
  95876. offlineProvider: IOfflineProvider;
  95877. }
  95878. /** Interface defining initialization parameters for Engine class */
  95879. export interface EngineOptions extends WebGLContextAttributes {
  95880. /**
  95881. * Defines if the engine should no exceed a specified device ratio
  95882. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95883. */
  95884. limitDeviceRatio?: number;
  95885. /**
  95886. * Defines if webvr should be enabled automatically
  95887. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95888. */
  95889. autoEnableWebVR?: boolean;
  95890. /**
  95891. * Defines if webgl2 should be turned off even if supported
  95892. * @see http://doc.babylonjs.com/features/webgl2
  95893. */
  95894. disableWebGL2Support?: boolean;
  95895. /**
  95896. * Defines if webaudio should be initialized as well
  95897. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95898. */
  95899. audioEngine?: boolean;
  95900. /**
  95901. * Defines if animations should run using a deterministic lock step
  95902. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95903. */
  95904. deterministicLockstep?: boolean;
  95905. /** Defines the maximum steps to use with deterministic lock step mode */
  95906. lockstepMaxSteps?: number;
  95907. /**
  95908. * Defines that engine should ignore context lost events
  95909. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95910. */
  95911. doNotHandleContextLost?: boolean;
  95912. /**
  95913. * Defines that engine should ignore modifying touch action attribute and style
  95914. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95915. */
  95916. doNotHandleTouchAction?: boolean;
  95917. /**
  95918. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95919. */
  95920. useHighPrecisionFloats?: boolean;
  95921. }
  95922. /**
  95923. * The base engine class (root of all engines)
  95924. */
  95925. export class ThinEngine {
  95926. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95927. static ExceptionList: ({
  95928. key: string;
  95929. capture: string;
  95930. captureConstraint: number;
  95931. targets: string[];
  95932. } | {
  95933. key: string;
  95934. capture: null;
  95935. captureConstraint: null;
  95936. targets: string[];
  95937. })[];
  95938. /** @hidden */
  95939. static _TextureLoaders: IInternalTextureLoader[];
  95940. /**
  95941. * Returns the current npm package of the sdk
  95942. */
  95943. static readonly NpmPackage: string;
  95944. /**
  95945. * Returns the current version of the framework
  95946. */
  95947. static readonly Version: string;
  95948. /**
  95949. * Returns a string describing the current engine
  95950. */
  95951. readonly description: string;
  95952. /**
  95953. * Gets or sets the epsilon value used by collision engine
  95954. */
  95955. static CollisionsEpsilon: number;
  95956. /**
  95957. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95958. */
  95959. static ShadersRepository: string;
  95960. /** @hidden */
  95961. _shaderProcessor: IShaderProcessor;
  95962. /**
  95963. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95964. */
  95965. forcePOTTextures: boolean;
  95966. /**
  95967. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95968. */
  95969. isFullscreen: boolean;
  95970. /**
  95971. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95972. */
  95973. cullBackFaces: boolean;
  95974. /**
  95975. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95976. */
  95977. renderEvenInBackground: boolean;
  95978. /**
  95979. * Gets or sets a boolean indicating that cache can be kept between frames
  95980. */
  95981. preventCacheWipeBetweenFrames: boolean;
  95982. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95983. validateShaderPrograms: boolean;
  95984. /**
  95985. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95986. */
  95987. disableUniformBuffers: boolean;
  95988. /** @hidden */
  95989. _uniformBuffers: UniformBuffer[];
  95990. /**
  95991. * Gets a boolean indicating that the engine supports uniform buffers
  95992. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95993. */
  95994. readonly supportsUniformBuffers: boolean;
  95995. /** @hidden */
  95996. _gl: WebGLRenderingContext;
  95997. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95998. protected _windowIsBackground: boolean;
  95999. protected _webGLVersion: number;
  96000. protected _highPrecisionShadersAllowed: boolean;
  96001. /** @hidden */
  96002. readonly _shouldUseHighPrecisionShader: boolean;
  96003. /**
  96004. * Gets a boolean indicating that only power of 2 textures are supported
  96005. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96006. */
  96007. readonly needPOTTextures: boolean;
  96008. /** @hidden */
  96009. _badOS: boolean;
  96010. /** @hidden */
  96011. _badDesktopOS: boolean;
  96012. private _hardwareScalingLevel;
  96013. /** @hidden */
  96014. _caps: EngineCapabilities;
  96015. private _isStencilEnable;
  96016. protected _colorWrite: boolean;
  96017. /** @hidden */
  96018. _drawCalls: PerfCounter;
  96019. private _glVersion;
  96020. private _glRenderer;
  96021. private _glVendor;
  96022. /** @hidden */
  96023. _videoTextureSupported: boolean;
  96024. protected _renderingQueueLaunched: boolean;
  96025. protected _activeRenderLoops: (() => void)[];
  96026. /**
  96027. * Observable signaled when a context lost event is raised
  96028. */
  96029. onContextLostObservable: Observable<ThinEngine>;
  96030. /**
  96031. * Observable signaled when a context restored event is raised
  96032. */
  96033. onContextRestoredObservable: Observable<ThinEngine>;
  96034. private _onContextLost;
  96035. private _onContextRestored;
  96036. protected _contextWasLost: boolean;
  96037. /** @hidden */
  96038. _doNotHandleContextLost: boolean;
  96039. /**
  96040. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96041. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96042. */
  96043. doNotHandleContextLost: boolean;
  96044. /**
  96045. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96046. */
  96047. disableVertexArrayObjects: boolean;
  96048. /** @hidden */
  96049. protected _depthCullingState: DepthCullingState;
  96050. /** @hidden */
  96051. protected _stencilState: StencilState;
  96052. /** @hidden */
  96053. protected _alphaState: AlphaState;
  96054. /** @hidden */
  96055. _internalTexturesCache: InternalTexture[];
  96056. /** @hidden */
  96057. protected _activeChannel: number;
  96058. private _currentTextureChannel;
  96059. /** @hidden */
  96060. protected _boundTexturesCache: {
  96061. [key: string]: Nullable<InternalTexture>;
  96062. };
  96063. /** @hidden */
  96064. protected _currentEffect: Nullable<Effect>;
  96065. /** @hidden */
  96066. protected _currentProgram: Nullable<WebGLProgram>;
  96067. private _compiledEffects;
  96068. private _vertexAttribArraysEnabled;
  96069. /** @hidden */
  96070. protected _cachedViewport: Nullable<IViewportLike>;
  96071. private _cachedVertexArrayObject;
  96072. /** @hidden */
  96073. protected _cachedVertexBuffers: any;
  96074. /** @hidden */
  96075. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96076. /** @hidden */
  96077. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96078. /** @hidden */
  96079. _currentRenderTarget: Nullable<InternalTexture>;
  96080. private _uintIndicesCurrentlySet;
  96081. private _currentBoundBuffer;
  96082. /** @hidden */
  96083. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96084. private _currentBufferPointers;
  96085. private _currentInstanceLocations;
  96086. private _currentInstanceBuffers;
  96087. private _textureUnits;
  96088. /** @hidden */
  96089. _workingCanvas: Nullable<HTMLCanvasElement>;
  96090. /** @hidden */
  96091. _workingContext: Nullable<CanvasRenderingContext2D>;
  96092. /** @hidden */
  96093. _bindedRenderFunction: any;
  96094. private _vaoRecordInProgress;
  96095. private _mustWipeVertexAttributes;
  96096. private _emptyTexture;
  96097. private _emptyCubeTexture;
  96098. private _emptyTexture3D;
  96099. /** @hidden */
  96100. _frameHandler: number;
  96101. private _nextFreeTextureSlots;
  96102. private _maxSimultaneousTextures;
  96103. private _activeRequests;
  96104. protected _texturesSupported: string[];
  96105. /** @hidden */
  96106. _textureFormatInUse: Nullable<string>;
  96107. protected readonly _supportsHardwareTextureRescaling: boolean;
  96108. /**
  96109. * Gets the list of texture formats supported
  96110. */
  96111. readonly texturesSupported: Array<string>;
  96112. /**
  96113. * Gets the list of texture formats in use
  96114. */
  96115. readonly textureFormatInUse: Nullable<string>;
  96116. /**
  96117. * Gets the current viewport
  96118. */
  96119. readonly currentViewport: Nullable<IViewportLike>;
  96120. /**
  96121. * Gets the default empty texture
  96122. */
  96123. readonly emptyTexture: InternalTexture;
  96124. /**
  96125. * Gets the default empty 3D texture
  96126. */
  96127. readonly emptyTexture3D: InternalTexture;
  96128. /**
  96129. * Gets the default empty cube texture
  96130. */
  96131. readonly emptyCubeTexture: InternalTexture;
  96132. /**
  96133. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96134. */
  96135. readonly premultipliedAlpha: boolean;
  96136. /**
  96137. * Creates a new engine
  96138. * @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
  96139. * @param antialias defines enable antialiasing (default: false)
  96140. * @param options defines further options to be sent to the getContext() function
  96141. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96142. */
  96143. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96144. private _rebuildInternalTextures;
  96145. private _rebuildEffects;
  96146. /**
  96147. * Gets a boolean indicating if all created effects are ready
  96148. * @returns true if all effects are ready
  96149. */
  96150. areAllEffectsReady(): boolean;
  96151. protected _rebuildBuffers(): void;
  96152. private _initGLContext;
  96153. /**
  96154. * Gets version of the current webGL context
  96155. */
  96156. readonly webGLVersion: number;
  96157. /**
  96158. * Gets a string idenfifying the name of the class
  96159. * @returns "Engine" string
  96160. */
  96161. getClassName(): string;
  96162. /**
  96163. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96164. */
  96165. readonly isStencilEnable: boolean;
  96166. /** @hidden */
  96167. _prepareWorkingCanvas(): void;
  96168. /**
  96169. * Reset the texture cache to empty state
  96170. */
  96171. resetTextureCache(): void;
  96172. /**
  96173. * Gets an object containing information about the current webGL context
  96174. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96175. */
  96176. getGlInfo(): {
  96177. vendor: string;
  96178. renderer: string;
  96179. version: string;
  96180. };
  96181. /**
  96182. * Defines the hardware scaling level.
  96183. * By default the hardware scaling level is computed from the window device ratio.
  96184. * 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.
  96185. * @param level defines the level to use
  96186. */
  96187. setHardwareScalingLevel(level: number): void;
  96188. /**
  96189. * Gets the current hardware scaling level.
  96190. * By default the hardware scaling level is computed from the window device ratio.
  96191. * 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.
  96192. * @returns a number indicating the current hardware scaling level
  96193. */
  96194. getHardwareScalingLevel(): number;
  96195. /**
  96196. * Gets the list of loaded textures
  96197. * @returns an array containing all loaded textures
  96198. */
  96199. getLoadedTexturesCache(): InternalTexture[];
  96200. /**
  96201. * Gets the object containing all engine capabilities
  96202. * @returns the EngineCapabilities object
  96203. */
  96204. getCaps(): EngineCapabilities;
  96205. /**
  96206. * stop executing a render loop function and remove it from the execution array
  96207. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96208. */
  96209. stopRenderLoop(renderFunction?: () => void): void;
  96210. /** @hidden */
  96211. _renderLoop(): void;
  96212. /**
  96213. * Gets the HTML canvas attached with the current webGL context
  96214. * @returns a HTML canvas
  96215. */
  96216. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96217. /**
  96218. * Gets host window
  96219. * @returns the host window object
  96220. */
  96221. getHostWindow(): Window;
  96222. /**
  96223. * Gets the current render width
  96224. * @param useScreen defines if screen size must be used (or the current render target if any)
  96225. * @returns a number defining the current render width
  96226. */
  96227. getRenderWidth(useScreen?: boolean): number;
  96228. /**
  96229. * Gets the current render height
  96230. * @param useScreen defines if screen size must be used (or the current render target if any)
  96231. * @returns a number defining the current render height
  96232. */
  96233. getRenderHeight(useScreen?: boolean): number;
  96234. /**
  96235. * Can be used to override the current requestAnimationFrame requester.
  96236. * @hidden
  96237. */
  96238. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96239. /**
  96240. * Register and execute a render loop. The engine can have more than one render function
  96241. * @param renderFunction defines the function to continuously execute
  96242. */
  96243. runRenderLoop(renderFunction: () => void): void;
  96244. /**
  96245. * Clear the current render buffer or the current render target (if any is set up)
  96246. * @param color defines the color to use
  96247. * @param backBuffer defines if the back buffer must be cleared
  96248. * @param depth defines if the depth buffer must be cleared
  96249. * @param stencil defines if the stencil buffer must be cleared
  96250. */
  96251. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96252. private _viewportCached;
  96253. /** @hidden */
  96254. _viewport(x: number, y: number, width: number, height: number): void;
  96255. /**
  96256. * Set the WebGL's viewport
  96257. * @param viewport defines the viewport element to be used
  96258. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96259. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96260. */
  96261. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96262. /**
  96263. * Begin a new frame
  96264. */
  96265. beginFrame(): void;
  96266. /**
  96267. * Enf the current frame
  96268. */
  96269. endFrame(): void;
  96270. /**
  96271. * Resize the view according to the canvas' size
  96272. */
  96273. resize(): void;
  96274. /**
  96275. * Force a specific size of the canvas
  96276. * @param width defines the new canvas' width
  96277. * @param height defines the new canvas' height
  96278. */
  96279. setSize(width: number, height: number): void;
  96280. /**
  96281. * Binds the frame buffer to the specified texture.
  96282. * @param texture The texture to render to or null for the default canvas
  96283. * @param faceIndex The face of the texture to render to in case of cube texture
  96284. * @param requiredWidth The width of the target to render to
  96285. * @param requiredHeight The height of the target to render to
  96286. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96287. * @param depthStencilTexture The depth stencil texture to use to render
  96288. * @param lodLevel defines le lod level to bind to the frame buffer
  96289. */
  96290. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96291. /** @hidden */
  96292. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96293. /**
  96294. * Unbind the current render target texture from the webGL context
  96295. * @param texture defines the render target texture to unbind
  96296. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96297. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96298. */
  96299. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96300. /**
  96301. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96302. */
  96303. flushFramebuffer(): void;
  96304. /**
  96305. * Unbind the current render target and bind the default framebuffer
  96306. */
  96307. restoreDefaultFramebuffer(): void;
  96308. private _resetVertexBufferBinding;
  96309. /**
  96310. * Creates a vertex buffer
  96311. * @param data the data for the vertex buffer
  96312. * @returns the new WebGL static buffer
  96313. */
  96314. createVertexBuffer(data: DataArray): DataBuffer;
  96315. private _createVertexBuffer;
  96316. /**
  96317. * Creates a dynamic vertex buffer
  96318. * @param data the data for the dynamic vertex buffer
  96319. * @returns the new WebGL dynamic buffer
  96320. */
  96321. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96322. /**
  96323. * Update a dynamic index buffer
  96324. * @param indexBuffer defines the target index buffer
  96325. * @param indices defines the data to update
  96326. * @param offset defines the offset in the target index buffer where update should start
  96327. */
  96328. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96329. /**
  96330. * Updates a dynamic vertex buffer.
  96331. * @param vertexBuffer the vertex buffer to update
  96332. * @param data the data used to update the vertex buffer
  96333. * @param byteOffset the byte offset of the data
  96334. * @param byteLength the byte length of the data
  96335. */
  96336. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96337. private _resetIndexBufferBinding;
  96338. /**
  96339. * Creates a new index buffer
  96340. * @param indices defines the content of the index buffer
  96341. * @param updatable defines if the index buffer must be updatable
  96342. * @returns a new webGL buffer
  96343. */
  96344. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96345. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96346. /**
  96347. * Bind a webGL buffer to the webGL context
  96348. * @param buffer defines the buffer to bind
  96349. */
  96350. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96351. private bindIndexBuffer;
  96352. private bindBuffer;
  96353. /**
  96354. * update the bound buffer with the given data
  96355. * @param data defines the data to update
  96356. */
  96357. updateArrayBuffer(data: Float32Array): void;
  96358. private _vertexAttribPointer;
  96359. private _bindIndexBufferWithCache;
  96360. private _bindVertexBuffersAttributes;
  96361. /**
  96362. * Records a vertex array object
  96363. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96364. * @param vertexBuffers defines the list of vertex buffers to store
  96365. * @param indexBuffer defines the index buffer to store
  96366. * @param effect defines the effect to store
  96367. * @returns the new vertex array object
  96368. */
  96369. recordVertexArrayObject(vertexBuffers: {
  96370. [key: string]: VertexBuffer;
  96371. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96372. /**
  96373. * Bind a specific vertex array object
  96374. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96375. * @param vertexArrayObject defines the vertex array object to bind
  96376. * @param indexBuffer defines the index buffer to bind
  96377. */
  96378. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96379. /**
  96380. * Bind webGl buffers directly to the webGL context
  96381. * @param vertexBuffer defines the vertex buffer to bind
  96382. * @param indexBuffer defines the index buffer to bind
  96383. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96384. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96385. * @param effect defines the effect associated with the vertex buffer
  96386. */
  96387. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96388. private _unbindVertexArrayObject;
  96389. /**
  96390. * Bind a list of vertex buffers to the webGL context
  96391. * @param vertexBuffers defines the list of vertex buffers to bind
  96392. * @param indexBuffer defines the index buffer to bind
  96393. * @param effect defines the effect associated with the vertex buffers
  96394. */
  96395. bindBuffers(vertexBuffers: {
  96396. [key: string]: Nullable<VertexBuffer>;
  96397. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96398. /**
  96399. * Unbind all instance attributes
  96400. */
  96401. unbindInstanceAttributes(): void;
  96402. /**
  96403. * Release and free the memory of a vertex array object
  96404. * @param vao defines the vertex array object to delete
  96405. */
  96406. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96407. /** @hidden */
  96408. _releaseBuffer(buffer: DataBuffer): boolean;
  96409. protected _deleteBuffer(buffer: DataBuffer): void;
  96410. /**
  96411. * Creates a webGL buffer to use with instanciation
  96412. * @param capacity defines the size of the buffer
  96413. * @returns the webGL buffer
  96414. */
  96415. createInstancesBuffer(capacity: number): DataBuffer;
  96416. /**
  96417. * Delete a webGL buffer used with instanciation
  96418. * @param buffer defines the webGL buffer to delete
  96419. */
  96420. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96421. /**
  96422. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96423. * @param instancesBuffer defines the webGL buffer to update and bind
  96424. * @param data defines the data to store in the buffer
  96425. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96426. */
  96427. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96428. /**
  96429. * Apply all cached states (depth, culling, stencil and alpha)
  96430. */
  96431. applyStates(): void;
  96432. /**
  96433. * Send a draw order
  96434. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96435. * @param indexStart defines the starting index
  96436. * @param indexCount defines the number of index to draw
  96437. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96438. */
  96439. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96440. /**
  96441. * Draw a list of points
  96442. * @param verticesStart defines the index of first vertex to draw
  96443. * @param verticesCount defines the count of vertices to draw
  96444. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96445. */
  96446. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96447. /**
  96448. * Draw a list of unindexed primitives
  96449. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96450. * @param verticesStart defines the index of first vertex to draw
  96451. * @param verticesCount defines the count of vertices to draw
  96452. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96453. */
  96454. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96455. /**
  96456. * Draw a list of indexed primitives
  96457. * @param fillMode defines the primitive to use
  96458. * @param indexStart defines the starting index
  96459. * @param indexCount defines the number of index to draw
  96460. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96461. */
  96462. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96463. /**
  96464. * Draw a list of unindexed primitives
  96465. * @param fillMode defines the primitive to use
  96466. * @param verticesStart defines the index of first vertex to draw
  96467. * @param verticesCount defines the count of vertices to draw
  96468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96469. */
  96470. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96471. private _drawMode;
  96472. /** @hidden */
  96473. _releaseEffect(effect: Effect): void;
  96474. /** @hidden */
  96475. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96476. /**
  96477. * Create a new effect (used to store vertex/fragment shaders)
  96478. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96479. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96480. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96481. * @param samplers defines an array of string used to represent textures
  96482. * @param defines defines the string containing the defines to use to compile the shaders
  96483. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96484. * @param onCompiled defines a function to call when the effect creation is successful
  96485. * @param onError defines a function to call when the effect creation has failed
  96486. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96487. * @returns the new Effect
  96488. */
  96489. 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;
  96490. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96491. private _compileShader;
  96492. private _compileRawShader;
  96493. /**
  96494. * Directly creates a webGL program
  96495. * @param pipelineContext defines the pipeline context to attach to
  96496. * @param vertexCode defines the vertex shader code to use
  96497. * @param fragmentCode defines the fragment shader code to use
  96498. * @param context defines the webGL context to use (if not set, the current one will be used)
  96499. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96500. * @returns the new webGL program
  96501. */
  96502. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96503. /**
  96504. * Creates a webGL program
  96505. * @param pipelineContext defines the pipeline context to attach to
  96506. * @param vertexCode defines the vertex shader code to use
  96507. * @param fragmentCode defines the fragment shader code to use
  96508. * @param defines defines the string containing the defines to use to compile the shaders
  96509. * @param context defines the webGL context to use (if not set, the current one will be used)
  96510. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96511. * @returns the new webGL program
  96512. */
  96513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96514. /**
  96515. * Creates a new pipeline context
  96516. * @returns the new pipeline
  96517. */
  96518. createPipelineContext(): IPipelineContext;
  96519. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96520. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96521. /** @hidden */
  96522. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96523. /** @hidden */
  96524. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96525. /** @hidden */
  96526. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96527. /**
  96528. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96529. * @param pipelineContext defines the pipeline context to use
  96530. * @param uniformsNames defines the list of uniform names
  96531. * @returns an array of webGL uniform locations
  96532. */
  96533. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96534. /**
  96535. * Gets the lsit of active attributes for a given webGL program
  96536. * @param pipelineContext defines the pipeline context to use
  96537. * @param attributesNames defines the list of attribute names to get
  96538. * @returns an array of indices indicating the offset of each attribute
  96539. */
  96540. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96541. /**
  96542. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96543. * @param effect defines the effect to activate
  96544. */
  96545. enableEffect(effect: Nullable<Effect>): void;
  96546. /**
  96547. * Set the value of an uniform to an array of int32
  96548. * @param uniform defines the webGL uniform location where to store the value
  96549. * @param array defines the array of int32 to store
  96550. */
  96551. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96552. /**
  96553. * Set the value of an uniform to an array of int32 (stored as vec2)
  96554. * @param uniform defines the webGL uniform location where to store the value
  96555. * @param array defines the array of int32 to store
  96556. */
  96557. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96558. /**
  96559. * Set the value of an uniform to an array of int32 (stored as vec3)
  96560. * @param uniform defines the webGL uniform location where to store the value
  96561. * @param array defines the array of int32 to store
  96562. */
  96563. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96564. /**
  96565. * Set the value of an uniform to an array of int32 (stored as vec4)
  96566. * @param uniform defines the webGL uniform location where to store the value
  96567. * @param array defines the array of int32 to store
  96568. */
  96569. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96570. /**
  96571. * Set the value of an uniform to an array of float32
  96572. * @param uniform defines the webGL uniform location where to store the value
  96573. * @param array defines the array of float32 to store
  96574. */
  96575. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96576. /**
  96577. * Set the value of an uniform to an array of float32 (stored as vec2)
  96578. * @param uniform defines the webGL uniform location where to store the value
  96579. * @param array defines the array of float32 to store
  96580. */
  96581. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96582. /**
  96583. * Set the value of an uniform to an array of float32 (stored as vec3)
  96584. * @param uniform defines the webGL uniform location where to store the value
  96585. * @param array defines the array of float32 to store
  96586. */
  96587. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96588. /**
  96589. * Set the value of an uniform to an array of float32 (stored as vec4)
  96590. * @param uniform defines the webGL uniform location where to store the value
  96591. * @param array defines the array of float32 to store
  96592. */
  96593. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96594. /**
  96595. * Set the value of an uniform to an array of number
  96596. * @param uniform defines the webGL uniform location where to store the value
  96597. * @param array defines the array of number to store
  96598. */
  96599. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96600. /**
  96601. * Set the value of an uniform to an array of number (stored as vec2)
  96602. * @param uniform defines the webGL uniform location where to store the value
  96603. * @param array defines the array of number to store
  96604. */
  96605. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96606. /**
  96607. * Set the value of an uniform to an array of number (stored as vec3)
  96608. * @param uniform defines the webGL uniform location where to store the value
  96609. * @param array defines the array of number to store
  96610. */
  96611. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96612. /**
  96613. * Set the value of an uniform to an array of number (stored as vec4)
  96614. * @param uniform defines the webGL uniform location where to store the value
  96615. * @param array defines the array of number to store
  96616. */
  96617. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96618. /**
  96619. * Set the value of an uniform to an array of float32 (stored as matrices)
  96620. * @param uniform defines the webGL uniform location where to store the value
  96621. * @param matrices defines the array of float32 to store
  96622. */
  96623. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96624. /**
  96625. * Set the value of an uniform to a matrix (3x3)
  96626. * @param uniform defines the webGL uniform location where to store the value
  96627. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96628. */
  96629. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96630. /**
  96631. * Set the value of an uniform to a matrix (2x2)
  96632. * @param uniform defines the webGL uniform location where to store the value
  96633. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96634. */
  96635. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96636. /**
  96637. * Set the value of an uniform to a number (int)
  96638. * @param uniform defines the webGL uniform location where to store the value
  96639. * @param value defines the int number to store
  96640. */
  96641. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96642. /**
  96643. * Set the value of an uniform to a number (float)
  96644. * @param uniform defines the webGL uniform location where to store the value
  96645. * @param value defines the float number to store
  96646. */
  96647. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96648. /**
  96649. * Set the value of an uniform to a vec2
  96650. * @param uniform defines the webGL uniform location where to store the value
  96651. * @param x defines the 1st component of the value
  96652. * @param y defines the 2nd component of the value
  96653. */
  96654. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96655. /**
  96656. * Set the value of an uniform to a vec3
  96657. * @param uniform defines the webGL uniform location where to store the value
  96658. * @param x defines the 1st component of the value
  96659. * @param y defines the 2nd component of the value
  96660. * @param z defines the 3rd component of the value
  96661. */
  96662. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96663. /**
  96664. * Set the value of an uniform to a boolean
  96665. * @param uniform defines the webGL uniform location where to store the value
  96666. * @param bool defines the boolean to store
  96667. */
  96668. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96669. /**
  96670. * Set the value of an uniform to a vec4
  96671. * @param uniform defines the webGL uniform location where to store the value
  96672. * @param x defines the 1st component of the value
  96673. * @param y defines the 2nd component of the value
  96674. * @param z defines the 3rd component of the value
  96675. * @param w defines the 4th component of the value
  96676. */
  96677. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96678. /**
  96679. * Sets a Color4 on a uniform variable
  96680. * @param uniform defines the uniform location
  96681. * @param color4 defines the value to be set
  96682. */
  96683. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96684. /**
  96685. * Gets the depth culling state manager
  96686. */
  96687. readonly depthCullingState: DepthCullingState;
  96688. /**
  96689. * Gets the alpha state manager
  96690. */
  96691. readonly alphaState: AlphaState;
  96692. /**
  96693. * Gets the stencil state manager
  96694. */
  96695. readonly stencilState: StencilState;
  96696. /**
  96697. * Clears the list of texture accessible through engine.
  96698. * This can help preventing texture load conflict due to name collision.
  96699. */
  96700. clearInternalTexturesCache(): void;
  96701. /**
  96702. * Force the entire cache to be cleared
  96703. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96704. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96705. */
  96706. wipeCaches(bruteForce?: boolean): void;
  96707. /** @hidden */
  96708. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96709. min: number;
  96710. mag: number;
  96711. };
  96712. /** @hidden */
  96713. _createTexture(): WebGLTexture;
  96714. /**
  96715. * Usually called from Texture.ts.
  96716. * Passed information to create a WebGLTexture
  96717. * @param urlArg defines a value which contains one of the following:
  96718. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96719. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96720. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96721. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96722. * @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)
  96723. * @param scene needed for loading to the correct scene
  96724. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96725. * @param onLoad optional callback to be called upon successful completion
  96726. * @param onError optional callback to be called upon failure
  96727. * @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
  96728. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96729. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96730. * @param forcedExtension defines the extension to use to pick the right loader
  96731. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96732. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96733. */
  96734. 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;
  96735. /**
  96736. * @hidden
  96737. */
  96738. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96739. /**
  96740. * Creates a raw texture
  96741. * @param data defines the data to store in the texture
  96742. * @param width defines the width of the texture
  96743. * @param height defines the height of the texture
  96744. * @param format defines the format of the data
  96745. * @param generateMipMaps defines if the engine should generate the mip levels
  96746. * @param invertY defines if data must be stored with Y axis inverted
  96747. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96748. * @param compression defines the compression used (null by default)
  96749. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96750. * @returns the raw texture inside an InternalTexture
  96751. */
  96752. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96753. /**
  96754. * Creates a new raw cube texture
  96755. * @param data defines the array of data to use to create each face
  96756. * @param size defines the size of the textures
  96757. * @param format defines the format of the data
  96758. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96759. * @param generateMipMaps defines if the engine should generate the mip levels
  96760. * @param invertY defines if data must be stored with Y axis inverted
  96761. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96762. * @param compression defines the compression used (null by default)
  96763. * @returns the cube texture as an InternalTexture
  96764. */
  96765. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96766. /**
  96767. * Creates a new raw 3D texture
  96768. * @param data defines the data used to create the texture
  96769. * @param width defines the width of the texture
  96770. * @param height defines the height of the texture
  96771. * @param depth defines the depth of the texture
  96772. * @param format defines the format of the texture
  96773. * @param generateMipMaps defines if the engine must generate mip levels
  96774. * @param invertY defines if data must be stored with Y axis inverted
  96775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96776. * @param compression defines the compressed used (can be null)
  96777. * @param textureType defines the compressed used (can be null)
  96778. * @returns a new raw 3D texture (stored in an InternalTexture)
  96779. */
  96780. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96781. private _unpackFlipYCached;
  96782. /**
  96783. * In case you are sharing the context with other applications, it might
  96784. * be interested to not cache the unpack flip y state to ensure a consistent
  96785. * value would be set.
  96786. */
  96787. enableUnpackFlipYCached: boolean;
  96788. /** @hidden */
  96789. _unpackFlipY(value: boolean): void;
  96790. /** @hidden */
  96791. _getUnpackAlignement(): number;
  96792. /**
  96793. * Update the sampling mode of a given texture
  96794. * @param samplingMode defines the required sampling mode
  96795. * @param texture defines the texture to update
  96796. */
  96797. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96798. /**
  96799. * Updates a depth texture Comparison Mode and Function.
  96800. * If the comparison Function is equal to 0, the mode will be set to none.
  96801. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96802. * @param texture The texture to set the comparison function for
  96803. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96804. */
  96805. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96806. /** @hidden */
  96807. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96808. width: number;
  96809. height: number;
  96810. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96811. /**
  96812. * Creates a depth stencil texture.
  96813. * This is only available in WebGL 2 or with the depth texture extension available.
  96814. * @param size The size of face edge in the texture.
  96815. * @param options The options defining the texture.
  96816. * @returns The texture
  96817. */
  96818. createDepthStencilTexture(size: number | {
  96819. width: number;
  96820. height: number;
  96821. }, options: DepthTextureCreationOptions): InternalTexture;
  96822. /**
  96823. * Creates a depth stencil texture.
  96824. * This is only available in WebGL 2 or with the depth texture extension available.
  96825. * @param size The size of face edge in the texture.
  96826. * @param options The options defining the texture.
  96827. * @returns The texture
  96828. */
  96829. private _createDepthStencilTexture;
  96830. /**
  96831. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96832. * @param renderTarget The render target to set the frame buffer for
  96833. */
  96834. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96835. /** @hidden */
  96836. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96837. /** @hidden */
  96838. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96839. /** @hidden */
  96840. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96841. /** @hidden */
  96842. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96843. /** @hidden */
  96844. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96845. /**
  96846. * @hidden
  96847. */
  96848. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96849. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96850. private _prepareWebGLTexture;
  96851. /** @hidden */
  96852. _releaseFramebufferObjects(texture: InternalTexture): void;
  96853. /** @hidden */
  96854. _releaseTexture(texture: InternalTexture): void;
  96855. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96856. protected _setProgram(program: WebGLProgram): void;
  96857. protected _boundUniforms: {
  96858. [key: number]: WebGLUniformLocation;
  96859. };
  96860. /**
  96861. * Binds an effect to the webGL context
  96862. * @param effect defines the effect to bind
  96863. */
  96864. bindSamplers(effect: Effect): void;
  96865. private _activateCurrentTexture;
  96866. /** @hidden */
  96867. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96868. /** @hidden */
  96869. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96870. /**
  96871. * Unbind all textures from the webGL context
  96872. */
  96873. unbindAllTextures(): void;
  96874. /**
  96875. * Sets a texture to the according uniform.
  96876. * @param channel The texture channel
  96877. * @param uniform The uniform to set
  96878. * @param texture The texture to apply
  96879. */
  96880. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96881. private _bindSamplerUniformToChannel;
  96882. private _getTextureWrapMode;
  96883. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96884. /**
  96885. * Sets an array of texture to the webGL context
  96886. * @param channel defines the channel where the texture array must be set
  96887. * @param uniform defines the associated uniform location
  96888. * @param textures defines the array of textures to bind
  96889. */
  96890. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96891. /** @hidden */
  96892. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96893. private _setTextureParameterFloat;
  96894. private _setTextureParameterInteger;
  96895. /**
  96896. * Unbind all vertex attributes from the webGL context
  96897. */
  96898. unbindAllAttributes(): void;
  96899. /**
  96900. * 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
  96901. */
  96902. releaseEffects(): void;
  96903. /**
  96904. * Dispose and release all associated resources
  96905. */
  96906. dispose(): void;
  96907. /**
  96908. * Attach a new callback raised when context lost event is fired
  96909. * @param callback defines the callback to call
  96910. */
  96911. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96912. /**
  96913. * Attach a new callback raised when context restored event is fired
  96914. * @param callback defines the callback to call
  96915. */
  96916. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96917. /**
  96918. * Get the current error code of the webGL context
  96919. * @returns the error code
  96920. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96921. */
  96922. getError(): number;
  96923. private _canRenderToFloatFramebuffer;
  96924. private _canRenderToHalfFloatFramebuffer;
  96925. private _canRenderToFramebuffer;
  96926. /** @hidden */
  96927. _getWebGLTextureType(type: number): number;
  96928. /** @hidden */
  96929. _getInternalFormat(format: number): number;
  96930. /** @hidden */
  96931. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96932. /** @hidden */
  96933. _getRGBAMultiSampleBufferFormat(type: number): number;
  96934. /** @hidden */
  96935. _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;
  96936. /**
  96937. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96938. * @returns true if the engine can be created
  96939. * @ignorenaming
  96940. */
  96941. static isSupported(): boolean;
  96942. /**
  96943. * Find the next highest power of two.
  96944. * @param x Number to start search from.
  96945. * @return Next highest power of two.
  96946. */
  96947. static CeilingPOT(x: number): number;
  96948. /**
  96949. * Find the next lowest power of two.
  96950. * @param x Number to start search from.
  96951. * @return Next lowest power of two.
  96952. */
  96953. static FloorPOT(x: number): number;
  96954. /**
  96955. * Find the nearest power of two.
  96956. * @param x Number to start search from.
  96957. * @return Next nearest power of two.
  96958. */
  96959. static NearestPOT(x: number): number;
  96960. /**
  96961. * Get the closest exponent of two
  96962. * @param value defines the value to approximate
  96963. * @param max defines the maximum value to return
  96964. * @param mode defines how to define the closest value
  96965. * @returns closest exponent of two of the given value
  96966. */
  96967. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96968. /**
  96969. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96970. * @param func - the function to be called
  96971. * @param requester - the object that will request the next frame. Falls back to window.
  96972. * @returns frame number
  96973. */
  96974. static QueueNewFrame(func: () => void, requester?: any): number;
  96975. }
  96976. }
  96977. declare module BABYLON {
  96978. /**
  96979. * Class used to store data associated with WebGL texture data for the engine
  96980. * This class should not be used directly
  96981. */
  96982. export class InternalTexture {
  96983. /** @hidden */
  96984. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96985. /**
  96986. * The source of the texture data is unknown
  96987. */
  96988. static DATASOURCE_UNKNOWN: number;
  96989. /**
  96990. * Texture data comes from an URL
  96991. */
  96992. static DATASOURCE_URL: number;
  96993. /**
  96994. * Texture data is only used for temporary storage
  96995. */
  96996. static DATASOURCE_TEMP: number;
  96997. /**
  96998. * Texture data comes from raw data (ArrayBuffer)
  96999. */
  97000. static DATASOURCE_RAW: number;
  97001. /**
  97002. * Texture content is dynamic (video or dynamic texture)
  97003. */
  97004. static DATASOURCE_DYNAMIC: number;
  97005. /**
  97006. * Texture content is generated by rendering to it
  97007. */
  97008. static DATASOURCE_RENDERTARGET: number;
  97009. /**
  97010. * Texture content is part of a multi render target process
  97011. */
  97012. static DATASOURCE_MULTIRENDERTARGET: number;
  97013. /**
  97014. * Texture data comes from a cube data file
  97015. */
  97016. static DATASOURCE_CUBE: number;
  97017. /**
  97018. * Texture data comes from a raw cube data
  97019. */
  97020. static DATASOURCE_CUBERAW: number;
  97021. /**
  97022. * Texture data come from a prefiltered cube data file
  97023. */
  97024. static DATASOURCE_CUBEPREFILTERED: number;
  97025. /**
  97026. * Texture content is raw 3D data
  97027. */
  97028. static DATASOURCE_RAW3D: number;
  97029. /**
  97030. * Texture content is a depth texture
  97031. */
  97032. static DATASOURCE_DEPTHTEXTURE: number;
  97033. /**
  97034. * Texture data comes from a raw cube data encoded with RGBD
  97035. */
  97036. static DATASOURCE_CUBERAW_RGBD: number;
  97037. /**
  97038. * Defines if the texture is ready
  97039. */
  97040. isReady: boolean;
  97041. /**
  97042. * Defines if the texture is a cube texture
  97043. */
  97044. isCube: boolean;
  97045. /**
  97046. * Defines if the texture contains 3D data
  97047. */
  97048. is3D: boolean;
  97049. /**
  97050. * Defines if the texture contains multiview data
  97051. */
  97052. isMultiview: boolean;
  97053. /**
  97054. * Gets the URL used to load this texture
  97055. */
  97056. url: string;
  97057. /**
  97058. * Gets the sampling mode of the texture
  97059. */
  97060. samplingMode: number;
  97061. /**
  97062. * Gets a boolean indicating if the texture needs mipmaps generation
  97063. */
  97064. generateMipMaps: boolean;
  97065. /**
  97066. * Gets the number of samples used by the texture (WebGL2+ only)
  97067. */
  97068. samples: number;
  97069. /**
  97070. * Gets the type of the texture (int, float...)
  97071. */
  97072. type: number;
  97073. /**
  97074. * Gets the format of the texture (RGB, RGBA...)
  97075. */
  97076. format: number;
  97077. /**
  97078. * Observable called when the texture is loaded
  97079. */
  97080. onLoadedObservable: Observable<InternalTexture>;
  97081. /**
  97082. * Gets the width of the texture
  97083. */
  97084. width: number;
  97085. /**
  97086. * Gets the height of the texture
  97087. */
  97088. height: number;
  97089. /**
  97090. * Gets the depth of the texture
  97091. */
  97092. depth: number;
  97093. /**
  97094. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97095. */
  97096. baseWidth: number;
  97097. /**
  97098. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97099. */
  97100. baseHeight: number;
  97101. /**
  97102. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97103. */
  97104. baseDepth: number;
  97105. /**
  97106. * Gets a boolean indicating if the texture is inverted on Y axis
  97107. */
  97108. invertY: boolean;
  97109. /** @hidden */
  97110. _invertVScale: boolean;
  97111. /** @hidden */
  97112. _associatedChannel: number;
  97113. /** @hidden */
  97114. _dataSource: number;
  97115. /** @hidden */
  97116. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97117. /** @hidden */
  97118. _bufferView: Nullable<ArrayBufferView>;
  97119. /** @hidden */
  97120. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97121. /** @hidden */
  97122. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97123. /** @hidden */
  97124. _size: number;
  97125. /** @hidden */
  97126. _extension: string;
  97127. /** @hidden */
  97128. _files: Nullable<string[]>;
  97129. /** @hidden */
  97130. _workingCanvas: Nullable<HTMLCanvasElement>;
  97131. /** @hidden */
  97132. _workingContext: Nullable<CanvasRenderingContext2D>;
  97133. /** @hidden */
  97134. _framebuffer: Nullable<WebGLFramebuffer>;
  97135. /** @hidden */
  97136. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97137. /** @hidden */
  97138. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97139. /** @hidden */
  97140. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97141. /** @hidden */
  97142. _attachments: Nullable<number[]>;
  97143. /** @hidden */
  97144. _cachedCoordinatesMode: Nullable<number>;
  97145. /** @hidden */
  97146. _cachedWrapU: Nullable<number>;
  97147. /** @hidden */
  97148. _cachedWrapV: Nullable<number>;
  97149. /** @hidden */
  97150. _cachedWrapR: Nullable<number>;
  97151. /** @hidden */
  97152. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97153. /** @hidden */
  97154. _isDisabled: boolean;
  97155. /** @hidden */
  97156. _compression: Nullable<string>;
  97157. /** @hidden */
  97158. _generateStencilBuffer: boolean;
  97159. /** @hidden */
  97160. _generateDepthBuffer: boolean;
  97161. /** @hidden */
  97162. _comparisonFunction: number;
  97163. /** @hidden */
  97164. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97165. /** @hidden */
  97166. _lodGenerationScale: number;
  97167. /** @hidden */
  97168. _lodGenerationOffset: number;
  97169. /** @hidden */
  97170. _colorTextureArray: Nullable<WebGLTexture>;
  97171. /** @hidden */
  97172. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97173. /** @hidden */
  97174. _lodTextureHigh: Nullable<BaseTexture>;
  97175. /** @hidden */
  97176. _lodTextureMid: Nullable<BaseTexture>;
  97177. /** @hidden */
  97178. _lodTextureLow: Nullable<BaseTexture>;
  97179. /** @hidden */
  97180. _isRGBD: boolean;
  97181. /** @hidden */
  97182. _linearSpecularLOD: boolean;
  97183. /** @hidden */
  97184. _irradianceTexture: Nullable<BaseTexture>;
  97185. /** @hidden */
  97186. _webGLTexture: Nullable<WebGLTexture>;
  97187. /** @hidden */
  97188. _references: number;
  97189. private _engine;
  97190. /**
  97191. * Gets the Engine the texture belongs to.
  97192. * @returns The babylon engine
  97193. */
  97194. getEngine(): ThinEngine;
  97195. /**
  97196. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  97197. */
  97198. readonly dataSource: number;
  97199. /**
  97200. * Creates a new InternalTexture
  97201. * @param engine defines the engine to use
  97202. * @param dataSource defines the type of data that will be used
  97203. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97204. */
  97205. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  97206. /**
  97207. * Increments the number of references (ie. the number of Texture that point to it)
  97208. */
  97209. incrementReferences(): void;
  97210. /**
  97211. * Change the size of the texture (not the size of the content)
  97212. * @param width defines the new width
  97213. * @param height defines the new height
  97214. * @param depth defines the new depth (1 by default)
  97215. */
  97216. updateSize(width: int, height: int, depth?: int): void;
  97217. /** @hidden */
  97218. _rebuild(): void;
  97219. /** @hidden */
  97220. _swapAndDie(target: InternalTexture): void;
  97221. /**
  97222. * Dispose the current allocated resources
  97223. */
  97224. dispose(): void;
  97225. }
  97226. }
  97227. declare module BABYLON {
  97228. /**
  97229. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97231. */
  97232. export class Analyser {
  97233. /**
  97234. * Gets or sets the smoothing
  97235. * @ignorenaming
  97236. */
  97237. SMOOTHING: number;
  97238. /**
  97239. * Gets or sets the FFT table size
  97240. * @ignorenaming
  97241. */
  97242. FFT_SIZE: number;
  97243. /**
  97244. * Gets or sets the bar graph amplitude
  97245. * @ignorenaming
  97246. */
  97247. BARGRAPHAMPLITUDE: number;
  97248. /**
  97249. * Gets or sets the position of the debug canvas
  97250. * @ignorenaming
  97251. */
  97252. DEBUGCANVASPOS: {
  97253. x: number;
  97254. y: number;
  97255. };
  97256. /**
  97257. * Gets or sets the debug canvas size
  97258. * @ignorenaming
  97259. */
  97260. DEBUGCANVASSIZE: {
  97261. width: number;
  97262. height: number;
  97263. };
  97264. private _byteFreqs;
  97265. private _byteTime;
  97266. private _floatFreqs;
  97267. private _webAudioAnalyser;
  97268. private _debugCanvas;
  97269. private _debugCanvasContext;
  97270. private _scene;
  97271. private _registerFunc;
  97272. private _audioEngine;
  97273. /**
  97274. * Creates a new analyser
  97275. * @param scene defines hosting scene
  97276. */
  97277. constructor(scene: Scene);
  97278. /**
  97279. * Get the number of data values you will have to play with for the visualization
  97280. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97281. * @returns a number
  97282. */
  97283. getFrequencyBinCount(): number;
  97284. /**
  97285. * Gets the current frequency data as a byte array
  97286. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97287. * @returns a Uint8Array
  97288. */
  97289. getByteFrequencyData(): Uint8Array;
  97290. /**
  97291. * Gets the current waveform as a byte array
  97292. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97293. * @returns a Uint8Array
  97294. */
  97295. getByteTimeDomainData(): Uint8Array;
  97296. /**
  97297. * Gets the current frequency data as a float array
  97298. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97299. * @returns a Float32Array
  97300. */
  97301. getFloatFrequencyData(): Float32Array;
  97302. /**
  97303. * Renders the debug canvas
  97304. */
  97305. drawDebugCanvas(): void;
  97306. /**
  97307. * Stops rendering the debug canvas and removes it
  97308. */
  97309. stopDebugCanvas(): void;
  97310. /**
  97311. * Connects two audio nodes
  97312. * @param inputAudioNode defines first node to connect
  97313. * @param outputAudioNode defines second node to connect
  97314. */
  97315. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97316. /**
  97317. * Releases all associated resources
  97318. */
  97319. dispose(): void;
  97320. }
  97321. }
  97322. declare module BABYLON {
  97323. /**
  97324. * This represents an audio engine and it is responsible
  97325. * to play, synchronize and analyse sounds throughout the application.
  97326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97327. */
  97328. export interface IAudioEngine extends IDisposable {
  97329. /**
  97330. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97331. */
  97332. readonly canUseWebAudio: boolean;
  97333. /**
  97334. * Gets the current AudioContext if available.
  97335. */
  97336. readonly audioContext: Nullable<AudioContext>;
  97337. /**
  97338. * The master gain node defines the global audio volume of your audio engine.
  97339. */
  97340. readonly masterGain: GainNode;
  97341. /**
  97342. * Gets whether or not mp3 are supported by your browser.
  97343. */
  97344. readonly isMP3supported: boolean;
  97345. /**
  97346. * Gets whether or not ogg are supported by your browser.
  97347. */
  97348. readonly isOGGsupported: boolean;
  97349. /**
  97350. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97351. * @ignoreNaming
  97352. */
  97353. WarnedWebAudioUnsupported: boolean;
  97354. /**
  97355. * Defines if the audio engine relies on a custom unlocked button.
  97356. * In this case, the embedded button will not be displayed.
  97357. */
  97358. useCustomUnlockedButton: boolean;
  97359. /**
  97360. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97361. */
  97362. readonly unlocked: boolean;
  97363. /**
  97364. * Event raised when audio has been unlocked on the browser.
  97365. */
  97366. onAudioUnlockedObservable: Observable<AudioEngine>;
  97367. /**
  97368. * Event raised when audio has been locked on the browser.
  97369. */
  97370. onAudioLockedObservable: Observable<AudioEngine>;
  97371. /**
  97372. * Flags the audio engine in Locked state.
  97373. * This happens due to new browser policies preventing audio to autoplay.
  97374. */
  97375. lock(): void;
  97376. /**
  97377. * Unlocks the audio engine once a user action has been done on the dom.
  97378. * This is helpful to resume play once browser policies have been satisfied.
  97379. */
  97380. unlock(): void;
  97381. }
  97382. /**
  97383. * This represents the default audio engine used in babylon.
  97384. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97386. */
  97387. export class AudioEngine implements IAudioEngine {
  97388. private _audioContext;
  97389. private _audioContextInitialized;
  97390. private _muteButton;
  97391. private _hostElement;
  97392. /**
  97393. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97394. */
  97395. canUseWebAudio: boolean;
  97396. /**
  97397. * The master gain node defines the global audio volume of your audio engine.
  97398. */
  97399. masterGain: GainNode;
  97400. /**
  97401. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97402. * @ignoreNaming
  97403. */
  97404. WarnedWebAudioUnsupported: boolean;
  97405. /**
  97406. * Gets whether or not mp3 are supported by your browser.
  97407. */
  97408. isMP3supported: boolean;
  97409. /**
  97410. * Gets whether or not ogg are supported by your browser.
  97411. */
  97412. isOGGsupported: boolean;
  97413. /**
  97414. * Gets whether audio has been unlocked on the device.
  97415. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97416. * a user interaction has happened.
  97417. */
  97418. unlocked: boolean;
  97419. /**
  97420. * Defines if the audio engine relies on a custom unlocked button.
  97421. * In this case, the embedded button will not be displayed.
  97422. */
  97423. useCustomUnlockedButton: boolean;
  97424. /**
  97425. * Event raised when audio has been unlocked on the browser.
  97426. */
  97427. onAudioUnlockedObservable: Observable<AudioEngine>;
  97428. /**
  97429. * Event raised when audio has been locked on the browser.
  97430. */
  97431. onAudioLockedObservable: Observable<AudioEngine>;
  97432. /**
  97433. * Gets the current AudioContext if available.
  97434. */
  97435. readonly audioContext: Nullable<AudioContext>;
  97436. private _connectedAnalyser;
  97437. /**
  97438. * Instantiates a new audio engine.
  97439. *
  97440. * There should be only one per page as some browsers restrict the number
  97441. * of audio contexts you can create.
  97442. * @param hostElement defines the host element where to display the mute icon if necessary
  97443. */
  97444. constructor(hostElement?: Nullable<HTMLElement>);
  97445. /**
  97446. * Flags the audio engine in Locked state.
  97447. * This happens due to new browser policies preventing audio to autoplay.
  97448. */
  97449. lock(): void;
  97450. /**
  97451. * Unlocks the audio engine once a user action has been done on the dom.
  97452. * This is helpful to resume play once browser policies have been satisfied.
  97453. */
  97454. unlock(): void;
  97455. private _resumeAudioContext;
  97456. private _initializeAudioContext;
  97457. private _tryToRun;
  97458. private _triggerRunningState;
  97459. private _triggerSuspendedState;
  97460. private _displayMuteButton;
  97461. private _moveButtonToTopLeft;
  97462. private _onResize;
  97463. private _hideMuteButton;
  97464. /**
  97465. * Destroy and release the resources associated with the audio ccontext.
  97466. */
  97467. dispose(): void;
  97468. /**
  97469. * Gets the global volume sets on the master gain.
  97470. * @returns the global volume if set or -1 otherwise
  97471. */
  97472. getGlobalVolume(): number;
  97473. /**
  97474. * Sets the global volume of your experience (sets on the master gain).
  97475. * @param newVolume Defines the new global volume of the application
  97476. */
  97477. setGlobalVolume(newVolume: number): void;
  97478. /**
  97479. * Connect the audio engine to an audio analyser allowing some amazing
  97480. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97482. * @param analyser The analyser to connect to the engine
  97483. */
  97484. connectToAnalyser(analyser: Analyser): void;
  97485. }
  97486. }
  97487. declare module BABYLON {
  97488. /**
  97489. * Interface used to present a loading screen while loading a scene
  97490. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97491. */
  97492. export interface ILoadingScreen {
  97493. /**
  97494. * Function called to display the loading screen
  97495. */
  97496. displayLoadingUI: () => void;
  97497. /**
  97498. * Function called to hide the loading screen
  97499. */
  97500. hideLoadingUI: () => void;
  97501. /**
  97502. * Gets or sets the color to use for the background
  97503. */
  97504. loadingUIBackgroundColor: string;
  97505. /**
  97506. * Gets or sets the text to display while loading
  97507. */
  97508. loadingUIText: string;
  97509. }
  97510. /**
  97511. * Class used for the default loading screen
  97512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97513. */
  97514. export class DefaultLoadingScreen implements ILoadingScreen {
  97515. private _renderingCanvas;
  97516. private _loadingText;
  97517. private _loadingDivBackgroundColor;
  97518. private _loadingDiv;
  97519. private _loadingTextDiv;
  97520. /** Gets or sets the logo url to use for the default loading screen */
  97521. static DefaultLogoUrl: string;
  97522. /** Gets or sets the spinner url to use for the default loading screen */
  97523. static DefaultSpinnerUrl: string;
  97524. /**
  97525. * Creates a new default loading screen
  97526. * @param _renderingCanvas defines the canvas used to render the scene
  97527. * @param _loadingText defines the default text to display
  97528. * @param _loadingDivBackgroundColor defines the default background color
  97529. */
  97530. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97531. /**
  97532. * Function called to display the loading screen
  97533. */
  97534. displayLoadingUI(): void;
  97535. /**
  97536. * Function called to hide the loading screen
  97537. */
  97538. hideLoadingUI(): void;
  97539. /**
  97540. * Gets or sets the text to display while loading
  97541. */
  97542. loadingUIText: string;
  97543. /**
  97544. * Gets or sets the color to use for the background
  97545. */
  97546. loadingUIBackgroundColor: string;
  97547. private _resizeLoadingUI;
  97548. }
  97549. }
  97550. declare module BABYLON {
  97551. /**
  97552. * Interface for any object that can request an animation frame
  97553. */
  97554. export interface ICustomAnimationFrameRequester {
  97555. /**
  97556. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97557. */
  97558. renderFunction?: Function;
  97559. /**
  97560. * Called to request the next frame to render to
  97561. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97562. */
  97563. requestAnimationFrame: Function;
  97564. /**
  97565. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97566. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97567. */
  97568. requestID?: number;
  97569. }
  97570. }
  97571. declare module BABYLON {
  97572. /**
  97573. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97574. */
  97575. export class PerformanceMonitor {
  97576. private _enabled;
  97577. private _rollingFrameTime;
  97578. private _lastFrameTimeMs;
  97579. /**
  97580. * constructor
  97581. * @param frameSampleSize The number of samples required to saturate the sliding window
  97582. */
  97583. constructor(frameSampleSize?: number);
  97584. /**
  97585. * Samples current frame
  97586. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97587. */
  97588. sampleFrame(timeMs?: number): void;
  97589. /**
  97590. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97591. */
  97592. readonly averageFrameTime: number;
  97593. /**
  97594. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97595. */
  97596. readonly averageFrameTimeVariance: number;
  97597. /**
  97598. * Returns the frame time of the most recent frame
  97599. */
  97600. readonly instantaneousFrameTime: number;
  97601. /**
  97602. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97603. */
  97604. readonly averageFPS: number;
  97605. /**
  97606. * Returns the average framerate in frames per second using the most recent frame time
  97607. */
  97608. readonly instantaneousFPS: number;
  97609. /**
  97610. * Returns true if enough samples have been taken to completely fill the sliding window
  97611. */
  97612. readonly isSaturated: boolean;
  97613. /**
  97614. * Enables contributions to the sliding window sample set
  97615. */
  97616. enable(): void;
  97617. /**
  97618. * Disables contributions to the sliding window sample set
  97619. * Samples will not be interpolated over the disabled period
  97620. */
  97621. disable(): void;
  97622. /**
  97623. * Returns true if sampling is enabled
  97624. */
  97625. readonly isEnabled: boolean;
  97626. /**
  97627. * Resets performance monitor
  97628. */
  97629. reset(): void;
  97630. }
  97631. /**
  97632. * RollingAverage
  97633. *
  97634. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97635. */
  97636. export class RollingAverage {
  97637. /**
  97638. * Current average
  97639. */
  97640. average: number;
  97641. /**
  97642. * Current variance
  97643. */
  97644. variance: number;
  97645. protected _samples: Array<number>;
  97646. protected _sampleCount: number;
  97647. protected _pos: number;
  97648. protected _m2: number;
  97649. /**
  97650. * constructor
  97651. * @param length The number of samples required to saturate the sliding window
  97652. */
  97653. constructor(length: number);
  97654. /**
  97655. * Adds a sample to the sample set
  97656. * @param v The sample value
  97657. */
  97658. add(v: number): void;
  97659. /**
  97660. * Returns previously added values or null if outside of history or outside the sliding window domain
  97661. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97662. * @return Value previously recorded with add() or null if outside of range
  97663. */
  97664. history(i: number): number;
  97665. /**
  97666. * Returns true if enough samples have been taken to completely fill the sliding window
  97667. * @return true if sample-set saturated
  97668. */
  97669. isSaturated(): boolean;
  97670. /**
  97671. * Resets the rolling average (equivalent to 0 samples taken so far)
  97672. */
  97673. reset(): void;
  97674. /**
  97675. * Wraps a value around the sample range boundaries
  97676. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97677. * @return Wrapped position in sample range
  97678. */
  97679. protected _wrapPosition(i: number): number;
  97680. }
  97681. }
  97682. declare module BABYLON {
  97683. /**
  97684. * Defines the interface used by display changed events
  97685. */
  97686. export interface IDisplayChangedEventArgs {
  97687. /** Gets the vrDisplay object (if any) */
  97688. vrDisplay: Nullable<any>;
  97689. /** Gets a boolean indicating if webVR is supported */
  97690. vrSupported: boolean;
  97691. }
  97692. /**
  97693. * Defines the interface used by objects containing a viewport (like a camera)
  97694. */
  97695. interface IViewportOwnerLike {
  97696. /**
  97697. * Gets or sets the viewport
  97698. */
  97699. viewport: IViewportLike;
  97700. }
  97701. /**
  97702. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97703. */
  97704. export class Engine extends ThinEngine {
  97705. /** Defines that alpha blending is disabled */
  97706. static readonly ALPHA_DISABLE: number;
  97707. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97708. static readonly ALPHA_ADD: number;
  97709. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97710. static readonly ALPHA_COMBINE: number;
  97711. /** Defines that alpha blending to DEST - SRC * DEST */
  97712. static readonly ALPHA_SUBTRACT: number;
  97713. /** Defines that alpha blending to SRC * DEST */
  97714. static readonly ALPHA_MULTIPLY: number;
  97715. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97716. static readonly ALPHA_MAXIMIZED: number;
  97717. /** Defines that alpha blending to SRC + DEST */
  97718. static readonly ALPHA_ONEONE: number;
  97719. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97720. static readonly ALPHA_PREMULTIPLIED: number;
  97721. /**
  97722. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97723. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97724. */
  97725. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97726. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97727. static readonly ALPHA_INTERPOLATE: number;
  97728. /**
  97729. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97730. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97731. */
  97732. static readonly ALPHA_SCREENMODE: number;
  97733. /** Defines that the ressource is not delayed*/
  97734. static readonly DELAYLOADSTATE_NONE: number;
  97735. /** Defines that the ressource was successfully delay loaded */
  97736. static readonly DELAYLOADSTATE_LOADED: number;
  97737. /** Defines that the ressource is currently delay loading */
  97738. static readonly DELAYLOADSTATE_LOADING: number;
  97739. /** Defines that the ressource is delayed and has not started loading */
  97740. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97741. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97742. static readonly NEVER: number;
  97743. /** 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 */
  97744. static readonly ALWAYS: number;
  97745. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97746. static readonly LESS: number;
  97747. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97748. static readonly EQUAL: number;
  97749. /** 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 */
  97750. static readonly LEQUAL: number;
  97751. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97752. static readonly GREATER: number;
  97753. /** 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 */
  97754. static readonly GEQUAL: number;
  97755. /** 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 */
  97756. static readonly NOTEQUAL: number;
  97757. /** Passed to stencilOperation to specify that stencil value must be kept */
  97758. static readonly KEEP: number;
  97759. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97760. static readonly REPLACE: number;
  97761. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97762. static readonly INCR: number;
  97763. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97764. static readonly DECR: number;
  97765. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97766. static readonly INVERT: number;
  97767. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97768. static readonly INCR_WRAP: number;
  97769. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97770. static readonly DECR_WRAP: number;
  97771. /** Texture is not repeating outside of 0..1 UVs */
  97772. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97773. /** Texture is repeating outside of 0..1 UVs */
  97774. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97775. /** Texture is repeating and mirrored */
  97776. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97777. /** ALPHA */
  97778. static readonly TEXTUREFORMAT_ALPHA: number;
  97779. /** LUMINANCE */
  97780. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97781. /** LUMINANCE_ALPHA */
  97782. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97783. /** RGB */
  97784. static readonly TEXTUREFORMAT_RGB: number;
  97785. /** RGBA */
  97786. static readonly TEXTUREFORMAT_RGBA: number;
  97787. /** RED */
  97788. static readonly TEXTUREFORMAT_RED: number;
  97789. /** RED (2nd reference) */
  97790. static readonly TEXTUREFORMAT_R: number;
  97791. /** RG */
  97792. static readonly TEXTUREFORMAT_RG: number;
  97793. /** RED_INTEGER */
  97794. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97795. /** RED_INTEGER (2nd reference) */
  97796. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97797. /** RG_INTEGER */
  97798. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97799. /** RGB_INTEGER */
  97800. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97801. /** RGBA_INTEGER */
  97802. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97803. /** UNSIGNED_BYTE */
  97804. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97805. /** UNSIGNED_BYTE (2nd reference) */
  97806. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97807. /** FLOAT */
  97808. static readonly TEXTURETYPE_FLOAT: number;
  97809. /** HALF_FLOAT */
  97810. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97811. /** BYTE */
  97812. static readonly TEXTURETYPE_BYTE: number;
  97813. /** SHORT */
  97814. static readonly TEXTURETYPE_SHORT: number;
  97815. /** UNSIGNED_SHORT */
  97816. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97817. /** INT */
  97818. static readonly TEXTURETYPE_INT: number;
  97819. /** UNSIGNED_INT */
  97820. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97821. /** UNSIGNED_SHORT_4_4_4_4 */
  97822. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97823. /** UNSIGNED_SHORT_5_5_5_1 */
  97824. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97825. /** UNSIGNED_SHORT_5_6_5 */
  97826. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97827. /** UNSIGNED_INT_2_10_10_10_REV */
  97828. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97829. /** UNSIGNED_INT_24_8 */
  97830. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97831. /** UNSIGNED_INT_10F_11F_11F_REV */
  97832. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97833. /** UNSIGNED_INT_5_9_9_9_REV */
  97834. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97835. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97836. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97837. /** nearest is mag = nearest and min = nearest and mip = linear */
  97838. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97839. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97840. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97841. /** Trilinear is mag = linear and min = linear and mip = linear */
  97842. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97843. /** nearest is mag = nearest and min = nearest and mip = linear */
  97844. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97845. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97846. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97847. /** Trilinear is mag = linear and min = linear and mip = linear */
  97848. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97849. /** mag = nearest and min = nearest and mip = nearest */
  97850. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97851. /** mag = nearest and min = linear and mip = nearest */
  97852. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97853. /** mag = nearest and min = linear and mip = linear */
  97854. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97855. /** mag = nearest and min = linear and mip = none */
  97856. static readonly TEXTURE_NEAREST_LINEAR: number;
  97857. /** mag = nearest and min = nearest and mip = none */
  97858. static readonly TEXTURE_NEAREST_NEAREST: number;
  97859. /** mag = linear and min = nearest and mip = nearest */
  97860. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97861. /** mag = linear and min = nearest and mip = linear */
  97862. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97863. /** mag = linear and min = linear and mip = none */
  97864. static readonly TEXTURE_LINEAR_LINEAR: number;
  97865. /** mag = linear and min = nearest and mip = none */
  97866. static readonly TEXTURE_LINEAR_NEAREST: number;
  97867. /** Explicit coordinates mode */
  97868. static readonly TEXTURE_EXPLICIT_MODE: number;
  97869. /** Spherical coordinates mode */
  97870. static readonly TEXTURE_SPHERICAL_MODE: number;
  97871. /** Planar coordinates mode */
  97872. static readonly TEXTURE_PLANAR_MODE: number;
  97873. /** Cubic coordinates mode */
  97874. static readonly TEXTURE_CUBIC_MODE: number;
  97875. /** Projection coordinates mode */
  97876. static readonly TEXTURE_PROJECTION_MODE: number;
  97877. /** Skybox coordinates mode */
  97878. static readonly TEXTURE_SKYBOX_MODE: number;
  97879. /** Inverse Cubic coordinates mode */
  97880. static readonly TEXTURE_INVCUBIC_MODE: number;
  97881. /** Equirectangular coordinates mode */
  97882. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97883. /** Equirectangular Fixed coordinates mode */
  97884. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97885. /** Equirectangular Fixed Mirrored coordinates mode */
  97886. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97887. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97888. static readonly SCALEMODE_FLOOR: number;
  97889. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97890. static readonly SCALEMODE_NEAREST: number;
  97891. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97892. static readonly SCALEMODE_CEILING: number;
  97893. /**
  97894. * Returns the current npm package of the sdk
  97895. */
  97896. static readonly NpmPackage: string;
  97897. /**
  97898. * Returns the current version of the framework
  97899. */
  97900. static readonly Version: string;
  97901. /** Gets the list of created engines */
  97902. static readonly Instances: Engine[];
  97903. /**
  97904. * Gets the latest created engine
  97905. */
  97906. static readonly LastCreatedEngine: Nullable<Engine>;
  97907. /**
  97908. * Gets the latest created scene
  97909. */
  97910. static readonly LastCreatedScene: Nullable<Scene>;
  97911. /**
  97912. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97913. * @param flag defines which part of the materials must be marked as dirty
  97914. * @param predicate defines a predicate used to filter which materials should be affected
  97915. */
  97916. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97917. /**
  97918. * Method called to create the default loading screen.
  97919. * This can be overriden in your own app.
  97920. * @param canvas The rendering canvas element
  97921. * @returns The loading screen
  97922. */
  97923. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97924. /**
  97925. * Method called to create the default rescale post process on each engine.
  97926. */
  97927. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97928. /**
  97929. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97930. **/
  97931. enableOfflineSupport: boolean;
  97932. /**
  97933. * 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)
  97934. **/
  97935. disableManifestCheck: boolean;
  97936. /**
  97937. * Gets the list of created scenes
  97938. */
  97939. scenes: Scene[];
  97940. /**
  97941. * Event raised when a new scene is created
  97942. */
  97943. onNewSceneAddedObservable: Observable<Scene>;
  97944. /**
  97945. * Gets the list of created postprocesses
  97946. */
  97947. postProcesses: PostProcess[];
  97948. /**
  97949. * Gets a boolean indicating if the pointer is currently locked
  97950. */
  97951. isPointerLock: boolean;
  97952. /**
  97953. * Observable event triggered each time the rendering canvas is resized
  97954. */
  97955. onResizeObservable: Observable<Engine>;
  97956. /**
  97957. * Observable event triggered each time the canvas loses focus
  97958. */
  97959. onCanvasBlurObservable: Observable<Engine>;
  97960. /**
  97961. * Observable event triggered each time the canvas gains focus
  97962. */
  97963. onCanvasFocusObservable: Observable<Engine>;
  97964. /**
  97965. * Observable event triggered each time the canvas receives pointerout event
  97966. */
  97967. onCanvasPointerOutObservable: Observable<PointerEvent>;
  97968. /**
  97969. * Observable event triggered before each texture is initialized
  97970. */
  97971. onBeforeTextureInitObservable: Observable<Texture>;
  97972. /**
  97973. * Observable raised when the engine begins a new frame
  97974. */
  97975. onBeginFrameObservable: Observable<Engine>;
  97976. /**
  97977. * If set, will be used to request the next animation frame for the render loop
  97978. */
  97979. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  97980. /**
  97981. * Observable raised when the engine ends the current frame
  97982. */
  97983. onEndFrameObservable: Observable<Engine>;
  97984. /**
  97985. * Observable raised when the engine is about to compile a shader
  97986. */
  97987. onBeforeShaderCompilationObservable: Observable<Engine>;
  97988. /**
  97989. * Observable raised when the engine has jsut compiled a shader
  97990. */
  97991. onAfterShaderCompilationObservable: Observable<Engine>;
  97992. /**
  97993. * Gets the audio engine
  97994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97995. * @ignorenaming
  97996. */
  97997. static audioEngine: IAudioEngine;
  97998. /**
  97999. * Default AudioEngine factory responsible of creating the Audio Engine.
  98000. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98001. */
  98002. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98003. /**
  98004. * Default offline support factory responsible of creating a tool used to store data locally.
  98005. * By default, this will create a Database object if the workload has been embedded.
  98006. */
  98007. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98008. private _loadingScreen;
  98009. private _pointerLockRequested;
  98010. private _dummyFramebuffer;
  98011. private _rescalePostProcess;
  98012. /** @hidden */
  98013. protected _alphaMode: number;
  98014. /** @hidden */
  98015. protected _alphaEquation: number;
  98016. private _deterministicLockstep;
  98017. private _lockstepMaxSteps;
  98018. protected readonly _supportsHardwareTextureRescaling: boolean;
  98019. private _fps;
  98020. private _deltaTime;
  98021. /**
  98022. * Turn this value on if you want to pause FPS computation when in background
  98023. */
  98024. disablePerformanceMonitorInBackground: boolean;
  98025. private _performanceMonitor;
  98026. /**
  98027. * Gets the performance monitor attached to this engine
  98028. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98029. */
  98030. readonly performanceMonitor: PerformanceMonitor;
  98031. private _onFocus;
  98032. private _onBlur;
  98033. private _onCanvasPointerOut;
  98034. private _onCanvasBlur;
  98035. private _onCanvasFocus;
  98036. private _onFullscreenChange;
  98037. private _onPointerLockChange;
  98038. /**
  98039. * Creates a new engine
  98040. * @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
  98041. * @param antialias defines enable antialiasing (default: false)
  98042. * @param options defines further options to be sent to the getContext() function
  98043. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98044. */
  98045. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98046. /**
  98047. * Gets current aspect ratio
  98048. * @param viewportOwner defines the camera to use to get the aspect ratio
  98049. * @param useScreen defines if screen size must be used (or the current render target if any)
  98050. * @returns a number defining the aspect ratio
  98051. */
  98052. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98053. /**
  98054. * Gets current screen aspect ratio
  98055. * @returns a number defining the aspect ratio
  98056. */
  98057. getScreenAspectRatio(): number;
  98058. /**
  98059. * Gets host document
  98060. * @returns the host document object
  98061. */
  98062. getHostDocument(): Document;
  98063. /**
  98064. * Gets the client rect of the HTML canvas attached with the current webGL context
  98065. * @returns a client rectanglee
  98066. */
  98067. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98068. /**
  98069. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98070. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98071. * @returns true if engine is in deterministic lock step mode
  98072. */
  98073. isDeterministicLockStep(): boolean;
  98074. /**
  98075. * Gets the max steps when engine is running in deterministic lock step
  98076. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98077. * @returns the max steps
  98078. */
  98079. getLockstepMaxSteps(): number;
  98080. /**
  98081. * Force the mipmap generation for the given render target texture
  98082. * @param texture defines the render target texture to use
  98083. */
  98084. generateMipMapsForCubemap(texture: InternalTexture): void;
  98085. /** States */
  98086. /**
  98087. * Set various states to the webGL context
  98088. * @param culling defines backface culling state
  98089. * @param zOffset defines the value to apply to zOffset (0 by default)
  98090. * @param force defines if states must be applied even if cache is up to date
  98091. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98092. */
  98093. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98094. /**
  98095. * Set the z offset to apply to current rendering
  98096. * @param value defines the offset to apply
  98097. */
  98098. setZOffset(value: number): void;
  98099. /**
  98100. * Gets the current value of the zOffset
  98101. * @returns the current zOffset state
  98102. */
  98103. getZOffset(): number;
  98104. /**
  98105. * Enable or disable depth buffering
  98106. * @param enable defines the state to set
  98107. */
  98108. setDepthBuffer(enable: boolean): void;
  98109. /**
  98110. * Gets a boolean indicating if depth writing is enabled
  98111. * @returns the current depth writing state
  98112. */
  98113. getDepthWrite(): boolean;
  98114. /**
  98115. * Enable or disable depth writing
  98116. * @param enable defines the state to set
  98117. */
  98118. setDepthWrite(enable: boolean): void;
  98119. /**
  98120. * Enable or disable color writing
  98121. * @param enable defines the state to set
  98122. */
  98123. setColorWrite(enable: boolean): void;
  98124. /**
  98125. * Gets a boolean indicating if color writing is enabled
  98126. * @returns the current color writing state
  98127. */
  98128. getColorWrite(): boolean;
  98129. /**
  98130. * Sets alpha constants used by some alpha blending modes
  98131. * @param r defines the red component
  98132. * @param g defines the green component
  98133. * @param b defines the blue component
  98134. * @param a defines the alpha component
  98135. */
  98136. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98137. /**
  98138. * Sets the current alpha mode
  98139. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98140. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98141. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98142. */
  98143. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98144. /**
  98145. * Gets the current alpha mode
  98146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98147. * @returns the current alpha mode
  98148. */
  98149. getAlphaMode(): number;
  98150. /**
  98151. * Sets the current alpha equation
  98152. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98153. */
  98154. setAlphaEquation(equation: number): void;
  98155. /**
  98156. * Gets the current alpha equation.
  98157. * @returns the current alpha equation
  98158. */
  98159. getAlphaEquation(): number;
  98160. /**
  98161. * Gets a boolean indicating if stencil buffer is enabled
  98162. * @returns the current stencil buffer state
  98163. */
  98164. getStencilBuffer(): boolean;
  98165. /**
  98166. * Enable or disable the stencil buffer
  98167. * @param enable defines if the stencil buffer must be enabled or disabled
  98168. */
  98169. setStencilBuffer(enable: boolean): void;
  98170. /**
  98171. * Gets the current stencil mask
  98172. * @returns a number defining the new stencil mask to use
  98173. */
  98174. getStencilMask(): number;
  98175. /**
  98176. * Sets the current stencil mask
  98177. * @param mask defines the new stencil mask to use
  98178. */
  98179. setStencilMask(mask: number): void;
  98180. /**
  98181. * Gets the current stencil function
  98182. * @returns a number defining the stencil function to use
  98183. */
  98184. getStencilFunction(): number;
  98185. /**
  98186. * Gets the current stencil reference value
  98187. * @returns a number defining the stencil reference value to use
  98188. */
  98189. getStencilFunctionReference(): number;
  98190. /**
  98191. * Gets the current stencil mask
  98192. * @returns a number defining the stencil mask to use
  98193. */
  98194. getStencilFunctionMask(): number;
  98195. /**
  98196. * Sets the current stencil function
  98197. * @param stencilFunc defines the new stencil function to use
  98198. */
  98199. setStencilFunction(stencilFunc: number): void;
  98200. /**
  98201. * Sets the current stencil reference
  98202. * @param reference defines the new stencil reference to use
  98203. */
  98204. setStencilFunctionReference(reference: number): void;
  98205. /**
  98206. * Sets the current stencil mask
  98207. * @param mask defines the new stencil mask to use
  98208. */
  98209. setStencilFunctionMask(mask: number): void;
  98210. /**
  98211. * Gets the current stencil operation when stencil fails
  98212. * @returns a number defining stencil operation to use when stencil fails
  98213. */
  98214. getStencilOperationFail(): number;
  98215. /**
  98216. * Gets the current stencil operation when depth fails
  98217. * @returns a number defining stencil operation to use when depth fails
  98218. */
  98219. getStencilOperationDepthFail(): number;
  98220. /**
  98221. * Gets the current stencil operation when stencil passes
  98222. * @returns a number defining stencil operation to use when stencil passes
  98223. */
  98224. getStencilOperationPass(): number;
  98225. /**
  98226. * Sets the stencil operation to use when stencil fails
  98227. * @param operation defines the stencil operation to use when stencil fails
  98228. */
  98229. setStencilOperationFail(operation: number): void;
  98230. /**
  98231. * Sets the stencil operation to use when depth fails
  98232. * @param operation defines the stencil operation to use when depth fails
  98233. */
  98234. setStencilOperationDepthFail(operation: number): void;
  98235. /**
  98236. * Sets the stencil operation to use when stencil passes
  98237. * @param operation defines the stencil operation to use when stencil passes
  98238. */
  98239. setStencilOperationPass(operation: number): void;
  98240. /**
  98241. * Sets a boolean indicating if the dithering state is enabled or disabled
  98242. * @param value defines the dithering state
  98243. */
  98244. setDitheringState(value: boolean): void;
  98245. /**
  98246. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98247. * @param value defines the rasterizer state
  98248. */
  98249. setRasterizerState(value: boolean): void;
  98250. /**
  98251. * Gets the current depth function
  98252. * @returns a number defining the depth function
  98253. */
  98254. getDepthFunction(): Nullable<number>;
  98255. /**
  98256. * Sets the current depth function
  98257. * @param depthFunc defines the function to use
  98258. */
  98259. setDepthFunction(depthFunc: number): void;
  98260. /**
  98261. * Sets the current depth function to GREATER
  98262. */
  98263. setDepthFunctionToGreater(): void;
  98264. /**
  98265. * Sets the current depth function to GEQUAL
  98266. */
  98267. setDepthFunctionToGreaterOrEqual(): void;
  98268. /**
  98269. * Sets the current depth function to LESS
  98270. */
  98271. setDepthFunctionToLess(): void;
  98272. /**
  98273. * Sets the current depth function to LEQUAL
  98274. */
  98275. setDepthFunctionToLessOrEqual(): void;
  98276. private _cachedStencilBuffer;
  98277. private _cachedStencilFunction;
  98278. private _cachedStencilMask;
  98279. private _cachedStencilOperationPass;
  98280. private _cachedStencilOperationFail;
  98281. private _cachedStencilOperationDepthFail;
  98282. private _cachedStencilReference;
  98283. /**
  98284. * Caches the the state of the stencil buffer
  98285. */
  98286. cacheStencilState(): void;
  98287. /**
  98288. * Restores the state of the stencil buffer
  98289. */
  98290. restoreStencilState(): void;
  98291. /**
  98292. * Directly set the WebGL Viewport
  98293. * @param x defines the x coordinate of the viewport (in screen space)
  98294. * @param y defines the y coordinate of the viewport (in screen space)
  98295. * @param width defines the width of the viewport (in screen space)
  98296. * @param height defines the height of the viewport (in screen space)
  98297. * @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
  98298. */
  98299. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98300. /**
  98301. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98302. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98303. * @param y defines the y-coordinate of the corner of the clear rectangle
  98304. * @param width defines the width of the clear rectangle
  98305. * @param height defines the height of the clear rectangle
  98306. * @param clearColor defines the clear color
  98307. */
  98308. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98309. /**
  98310. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98311. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98312. * @param y defines the y-coordinate of the corner of the clear rectangle
  98313. * @param width defines the width of the clear rectangle
  98314. * @param height defines the height of the clear rectangle
  98315. */
  98316. enableScissor(x: number, y: number, width: number, height: number): void;
  98317. /**
  98318. * Disable previously set scissor test rectangle
  98319. */
  98320. disableScissor(): void;
  98321. /**
  98322. * Initializes a webVR display and starts listening to display change events
  98323. * The onVRDisplayChangedObservable will be notified upon these changes
  98324. * @returns The onVRDisplayChangedObservable
  98325. */
  98326. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98327. /** @hidden */
  98328. _prepareVRComponent(): void;
  98329. /** @hidden */
  98330. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98331. /** @hidden */
  98332. _submitVRFrame(): void;
  98333. /**
  98334. * Call this function to leave webVR mode
  98335. * Will do nothing if webVR is not supported or if there is no webVR device
  98336. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98337. */
  98338. disableVR(): void;
  98339. /**
  98340. * Gets a boolean indicating that the system is in VR mode and is presenting
  98341. * @returns true if VR mode is engaged
  98342. */
  98343. isVRPresenting(): boolean;
  98344. /** @hidden */
  98345. _requestVRFrame(): void;
  98346. /** @hidden */
  98347. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98348. /**
  98349. * Gets the source code of the vertex shader associated with a specific webGL program
  98350. * @param program defines the program to use
  98351. * @returns a string containing the source code of the vertex shader associated with the program
  98352. */
  98353. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98354. /**
  98355. * Gets the source code of the fragment shader associated with a specific webGL program
  98356. * @param program defines the program to use
  98357. * @returns a string containing the source code of the fragment shader associated with the program
  98358. */
  98359. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98360. /**
  98361. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98362. * @param x defines the x coordinate of the rectangle where pixels must be read
  98363. * @param y defines the y coordinate of the rectangle where pixels must be read
  98364. * @param width defines the width of the rectangle where pixels must be read
  98365. * @param height defines the height of the rectangle where pixels must be read
  98366. * @returns a Uint8Array containing RGBA colors
  98367. */
  98368. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98369. /**
  98370. * Sets a depth stencil texture from a render target to the according uniform.
  98371. * @param channel The texture channel
  98372. * @param uniform The uniform to set
  98373. * @param texture The render target texture containing the depth stencil texture to apply
  98374. */
  98375. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98376. /**
  98377. * Sets a texture to the webGL context from a postprocess
  98378. * @param channel defines the channel to use
  98379. * @param postProcess defines the source postprocess
  98380. */
  98381. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98382. /**
  98383. * Binds the output of the passed in post process to the texture channel specified
  98384. * @param channel The channel the texture should be bound to
  98385. * @param postProcess The post process which's output should be bound
  98386. */
  98387. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98388. /** @hidden */
  98389. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98390. protected _rebuildBuffers(): void;
  98391. _renderLoop(): void;
  98392. /**
  98393. * Toggle full screen mode
  98394. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98395. */
  98396. switchFullscreen(requestPointerLock: boolean): void;
  98397. /**
  98398. * Enters full screen mode
  98399. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98400. */
  98401. enterFullscreen(requestPointerLock: boolean): void;
  98402. /**
  98403. * Exits full screen mode
  98404. */
  98405. exitFullscreen(): void;
  98406. /**
  98407. * Enters Pointerlock mode
  98408. */
  98409. enterPointerlock(): void;
  98410. /**
  98411. * Exits Pointerlock mode
  98412. */
  98413. exitPointerlock(): void;
  98414. /**
  98415. * Begin a new frame
  98416. */
  98417. beginFrame(): void;
  98418. /**
  98419. * Enf the current frame
  98420. */
  98421. endFrame(): void;
  98422. resize(): void;
  98423. /**
  98424. * Set the compressed texture format to use, based on the formats you have, and the formats
  98425. * supported by the hardware / browser.
  98426. *
  98427. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98428. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98429. * to API arguments needed to compressed textures. This puts the burden on the container
  98430. * generator to house the arcane code for determining these for current & future formats.
  98431. *
  98432. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98433. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98434. *
  98435. * Note: The result of this call is not taken into account when a texture is base64.
  98436. *
  98437. * @param formatsAvailable defines the list of those format families you have created
  98438. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98439. *
  98440. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98441. * @returns The extension selected.
  98442. */
  98443. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98444. /**
  98445. * Force a specific size of the canvas
  98446. * @param width defines the new canvas' width
  98447. * @param height defines the new canvas' height
  98448. */
  98449. setSize(width: number, height: number): void;
  98450. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98451. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98452. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98453. _releaseTexture(texture: InternalTexture): void;
  98454. /**
  98455. * @hidden
  98456. * Rescales a texture
  98457. * @param source input texutre
  98458. * @param destination destination texture
  98459. * @param scene scene to use to render the resize
  98460. * @param internalFormat format to use when resizing
  98461. * @param onComplete callback to be called when resize has completed
  98462. */
  98463. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98464. /**
  98465. * Gets the current framerate
  98466. * @returns a number representing the framerate
  98467. */
  98468. getFps(): number;
  98469. /**
  98470. * Gets the time spent between current and previous frame
  98471. * @returns a number representing the delta time in ms
  98472. */
  98473. getDeltaTime(): number;
  98474. private _measureFps;
  98475. /**
  98476. * Creates a new render target texture
  98477. * @param size defines the size of the texture
  98478. * @param options defines the options used to create the texture
  98479. * @returns a new render target texture stored in an InternalTexture
  98480. */
  98481. createRenderTargetTexture(size: number | {
  98482. width: number;
  98483. height: number;
  98484. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98485. /**
  98486. * Updates the sample count of a render target texture
  98487. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98488. * @param texture defines the texture to update
  98489. * @param samples defines the sample count to set
  98490. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98491. */
  98492. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98493. /** @hidden */
  98494. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98495. dispose(): void;
  98496. private _disableTouchAction;
  98497. /**
  98498. * Display the loading screen
  98499. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98500. */
  98501. displayLoadingUI(): void;
  98502. /**
  98503. * Hide the loading screen
  98504. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98505. */
  98506. hideLoadingUI(): void;
  98507. /**
  98508. * Gets the current loading screen object
  98509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98510. */
  98511. /**
  98512. * Sets the current loading screen object
  98513. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98514. */
  98515. loadingScreen: ILoadingScreen;
  98516. /**
  98517. * Sets the current loading screen text
  98518. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98519. */
  98520. loadingUIText: string;
  98521. /**
  98522. * Sets the current loading screen background color
  98523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98524. */
  98525. loadingUIBackgroundColor: string;
  98526. /** Pointerlock and fullscreen */
  98527. /**
  98528. * Ask the browser to promote the current element to pointerlock mode
  98529. * @param element defines the DOM element to promote
  98530. */
  98531. static _RequestPointerlock(element: HTMLElement): void;
  98532. /**
  98533. * Asks the browser to exit pointerlock mode
  98534. */
  98535. static _ExitPointerlock(): void;
  98536. /**
  98537. * Ask the browser to promote the current element to fullscreen rendering mode
  98538. * @param element defines the DOM element to promote
  98539. */
  98540. static _RequestFullscreen(element: HTMLElement): void;
  98541. /**
  98542. * Asks the browser to exit fullscreen mode
  98543. */
  98544. static _ExitFullscreen(): void;
  98545. }
  98546. }
  98547. declare module BABYLON {
  98548. /**
  98549. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98550. * during the life time of the application.
  98551. */
  98552. export class EngineStore {
  98553. /** Gets the list of created engines */
  98554. static Instances: Engine[];
  98555. /** @hidden */
  98556. static _LastCreatedScene: Nullable<Scene>;
  98557. /**
  98558. * Gets the latest created engine
  98559. */
  98560. static readonly LastCreatedEngine: Nullable<Engine>;
  98561. /**
  98562. * Gets the latest created scene
  98563. */
  98564. static readonly LastCreatedScene: Nullable<Scene>;
  98565. /**
  98566. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98567. * @ignorenaming
  98568. */
  98569. static UseFallbackTexture: boolean;
  98570. /**
  98571. * Texture content used if a texture cannot loaded
  98572. * @ignorenaming
  98573. */
  98574. static FallbackTexture: string;
  98575. }
  98576. }
  98577. declare module BABYLON {
  98578. /**
  98579. * Helper class that provides a small promise polyfill
  98580. */
  98581. export class PromisePolyfill {
  98582. /**
  98583. * Static function used to check if the polyfill is required
  98584. * If this is the case then the function will inject the polyfill to window.Promise
  98585. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98586. */
  98587. static Apply(force?: boolean): void;
  98588. }
  98589. }
  98590. declare module BABYLON {
  98591. /**
  98592. * Interface for screenshot methods with describe argument called `size` as object with options
  98593. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98594. */
  98595. export interface IScreenshotSize {
  98596. /**
  98597. * number in pixels for canvas height
  98598. */
  98599. height?: number;
  98600. /**
  98601. * multiplier allowing render at a higher or lower resolution
  98602. * If value is defined then height and width will be ignored and taken from camera
  98603. */
  98604. precision?: number;
  98605. /**
  98606. * number in pixels for canvas width
  98607. */
  98608. width?: number;
  98609. }
  98610. }
  98611. declare module BABYLON {
  98612. interface IColor4Like {
  98613. r: float;
  98614. g: float;
  98615. b: float;
  98616. a: float;
  98617. }
  98618. /**
  98619. * Class containing a set of static utilities functions
  98620. */
  98621. export class Tools {
  98622. /**
  98623. * Gets or sets the base URL to use to load assets
  98624. */
  98625. static BaseUrl: string;
  98626. /**
  98627. * Enable/Disable Custom HTTP Request Headers globally.
  98628. * default = false
  98629. * @see CustomRequestHeaders
  98630. */
  98631. static UseCustomRequestHeaders: boolean;
  98632. /**
  98633. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98634. * i.e. when loading files, where the server/service expects an Authorization header
  98635. */
  98636. static CustomRequestHeaders: {
  98637. [key: string]: string;
  98638. };
  98639. /**
  98640. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98641. */
  98642. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98643. /**
  98644. * Default behaviour for cors in the application.
  98645. * It can be a string if the expected behavior is identical in the entire app.
  98646. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98647. */
  98648. static CorsBehavior: string | ((url: string | string[]) => string);
  98649. /**
  98650. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98651. * @ignorenaming
  98652. */
  98653. static UseFallbackTexture: boolean;
  98654. /**
  98655. * Use this object to register external classes like custom textures or material
  98656. * to allow the laoders to instantiate them
  98657. */
  98658. static RegisteredExternalClasses: {
  98659. [key: string]: Object;
  98660. };
  98661. /**
  98662. * Texture content used if a texture cannot loaded
  98663. * @ignorenaming
  98664. */
  98665. static fallbackTexture: string;
  98666. /**
  98667. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98668. * @param u defines the coordinate on X axis
  98669. * @param v defines the coordinate on Y axis
  98670. * @param width defines the width of the source data
  98671. * @param height defines the height of the source data
  98672. * @param pixels defines the source byte array
  98673. * @param color defines the output color
  98674. */
  98675. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98676. /**
  98677. * Interpolates between a and b via alpha
  98678. * @param a The lower value (returned when alpha = 0)
  98679. * @param b The upper value (returned when alpha = 1)
  98680. * @param alpha The interpolation-factor
  98681. * @return The mixed value
  98682. */
  98683. static Mix(a: number, b: number, alpha: number): number;
  98684. /**
  98685. * Tries to instantiate a new object from a given class name
  98686. * @param className defines the class name to instantiate
  98687. * @returns the new object or null if the system was not able to do the instantiation
  98688. */
  98689. static Instantiate(className: string): any;
  98690. /**
  98691. * Provides a slice function that will work even on IE
  98692. * @param data defines the array to slice
  98693. * @param start defines the start of the data (optional)
  98694. * @param end defines the end of the data (optional)
  98695. * @returns the new sliced array
  98696. */
  98697. static Slice<T>(data: T, start?: number, end?: number): T;
  98698. /**
  98699. * Polyfill for setImmediate
  98700. * @param action defines the action to execute after the current execution block
  98701. */
  98702. static SetImmediate(action: () => void): void;
  98703. /**
  98704. * Function indicating if a number is an exponent of 2
  98705. * @param value defines the value to test
  98706. * @returns true if the value is an exponent of 2
  98707. */
  98708. static IsExponentOfTwo(value: number): boolean;
  98709. private static _tmpFloatArray;
  98710. /**
  98711. * Returns the nearest 32-bit single precision float representation of a Number
  98712. * @param value A Number. If the parameter is of a different type, it will get converted
  98713. * to a number or to NaN if it cannot be converted
  98714. * @returns number
  98715. */
  98716. static FloatRound(value: number): number;
  98717. /**
  98718. * Extracts the filename from a path
  98719. * @param path defines the path to use
  98720. * @returns the filename
  98721. */
  98722. static GetFilename(path: string): string;
  98723. /**
  98724. * Extracts the "folder" part of a path (everything before the filename).
  98725. * @param uri The URI to extract the info from
  98726. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98727. * @returns The "folder" part of the path
  98728. */
  98729. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98730. /**
  98731. * Extracts text content from a DOM element hierarchy
  98732. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98733. */
  98734. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98735. /**
  98736. * Convert an angle in radians to degrees
  98737. * @param angle defines the angle to convert
  98738. * @returns the angle in degrees
  98739. */
  98740. static ToDegrees(angle: number): number;
  98741. /**
  98742. * Convert an angle in degrees to radians
  98743. * @param angle defines the angle to convert
  98744. * @returns the angle in radians
  98745. */
  98746. static ToRadians(angle: number): number;
  98747. /**
  98748. * Encode a buffer to a base64 string
  98749. * @param buffer defines the buffer to encode
  98750. * @returns the encoded string
  98751. */
  98752. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98753. /**
  98754. * Returns an array if obj is not an array
  98755. * @param obj defines the object to evaluate as an array
  98756. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98757. * @returns either obj directly if obj is an array or a new array containing obj
  98758. */
  98759. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98760. /**
  98761. * Gets the pointer prefix to use
  98762. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98763. */
  98764. static GetPointerPrefix(): string;
  98765. /**
  98766. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98767. * @param url define the url we are trying
  98768. * @param element define the dom element where to configure the cors policy
  98769. */
  98770. static SetCorsBehavior(url: string | string[], element: {
  98771. crossOrigin: string | null;
  98772. }): void;
  98773. /**
  98774. * Removes unwanted characters from an url
  98775. * @param url defines the url to clean
  98776. * @returns the cleaned url
  98777. */
  98778. static CleanUrl(url: string): string;
  98779. /**
  98780. * Gets or sets a function used to pre-process url before using them to load assets
  98781. */
  98782. static PreprocessUrl: (url: string) => string;
  98783. /**
  98784. * Loads an image as an HTMLImageElement.
  98785. * @param input url string, ArrayBuffer, or Blob to load
  98786. * @param onLoad callback called when the image successfully loads
  98787. * @param onError callback called when the image fails to load
  98788. * @param offlineProvider offline provider for caching
  98789. * @returns the HTMLImageElement of the loaded image
  98790. */
  98791. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98792. /**
  98793. * Loads a file
  98794. * @param url url string, ArrayBuffer, or Blob to load
  98795. * @param onSuccess callback called when the file successfully loads
  98796. * @param onProgress callback called while file is loading (if the server supports this mode)
  98797. * @param offlineProvider defines the offline provider for caching
  98798. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98799. * @param onError callback called when the file fails to load
  98800. * @returns a file request object
  98801. */
  98802. 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;
  98803. /**
  98804. * Loads a file from a url
  98805. * @param url the file url to load
  98806. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98807. */
  98808. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98809. /**
  98810. * Load a script (identified by an url). When the url returns, the
  98811. * content of this file is added into a new script element, attached to the DOM (body element)
  98812. * @param scriptUrl defines the url of the script to laod
  98813. * @param onSuccess defines the callback called when the script is loaded
  98814. * @param onError defines the callback to call if an error occurs
  98815. * @param scriptId defines the id of the script element
  98816. */
  98817. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98818. /**
  98819. * Load an asynchronous script (identified by an url). When the url returns, the
  98820. * content of this file is added into a new script element, attached to the DOM (body element)
  98821. * @param scriptUrl defines the url of the script to laod
  98822. * @param scriptId defines the id of the script element
  98823. * @returns a promise request object
  98824. */
  98825. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98826. /**
  98827. * Loads a file from a blob
  98828. * @param fileToLoad defines the blob to use
  98829. * @param callback defines the callback to call when data is loaded
  98830. * @param progressCallback defines the callback to call during loading process
  98831. * @returns a file request object
  98832. */
  98833. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98834. /**
  98835. * Loads a file
  98836. * @param fileToLoad defines the file to load
  98837. * @param callback defines the callback to call when data is loaded
  98838. * @param progressCallBack defines the callback to call during loading process
  98839. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98840. * @returns a file request object
  98841. */
  98842. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98843. /**
  98844. * Creates a data url from a given string content
  98845. * @param content defines the content to convert
  98846. * @returns the new data url link
  98847. */
  98848. static FileAsURL(content: string): string;
  98849. /**
  98850. * Format the given number to a specific decimal format
  98851. * @param value defines the number to format
  98852. * @param decimals defines the number of decimals to use
  98853. * @returns the formatted string
  98854. */
  98855. static Format(value: number, decimals?: number): string;
  98856. /**
  98857. * Tries to copy an object by duplicating every property
  98858. * @param source defines the source object
  98859. * @param destination defines the target object
  98860. * @param doNotCopyList defines a list of properties to avoid
  98861. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98862. */
  98863. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98864. /**
  98865. * Gets a boolean indicating if the given object has no own property
  98866. * @param obj defines the object to test
  98867. * @returns true if object has no own property
  98868. */
  98869. static IsEmpty(obj: any): boolean;
  98870. /**
  98871. * Function used to register events at window level
  98872. * @param windowElement defines the Window object to use
  98873. * @param events defines the events to register
  98874. */
  98875. static RegisterTopRootEvents(windowElement: Window, events: {
  98876. name: string;
  98877. handler: Nullable<(e: FocusEvent) => any>;
  98878. }[]): void;
  98879. /**
  98880. * Function used to unregister events from window level
  98881. * @param windowElement defines the Window object to use
  98882. * @param events defines the events to unregister
  98883. */
  98884. static UnregisterTopRootEvents(windowElement: Window, events: {
  98885. name: string;
  98886. handler: Nullable<(e: FocusEvent) => any>;
  98887. }[]): void;
  98888. /**
  98889. * @ignore
  98890. */
  98891. static _ScreenshotCanvas: HTMLCanvasElement;
  98892. /**
  98893. * Dumps the current bound framebuffer
  98894. * @param width defines the rendering width
  98895. * @param height defines the rendering height
  98896. * @param engine defines the hosting engine
  98897. * @param successCallback defines the callback triggered once the data are available
  98898. * @param mimeType defines the mime type of the result
  98899. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98900. */
  98901. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98902. /**
  98903. * Converts the canvas data to blob.
  98904. * This acts as a polyfill for browsers not supporting the to blob function.
  98905. * @param canvas Defines the canvas to extract the data from
  98906. * @param successCallback Defines the callback triggered once the data are available
  98907. * @param mimeType Defines the mime type of the result
  98908. */
  98909. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98910. /**
  98911. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98912. * @param successCallback defines the callback triggered once the data are available
  98913. * @param mimeType defines the mime type of the result
  98914. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98915. */
  98916. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98917. /**
  98918. * Downloads a blob in the browser
  98919. * @param blob defines the blob to download
  98920. * @param fileName defines the name of the downloaded file
  98921. */
  98922. static Download(blob: Blob, fileName: string): void;
  98923. /**
  98924. * Captures a screenshot of the current rendering
  98925. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98926. * @param engine defines the rendering engine
  98927. * @param camera defines the source camera
  98928. * @param size This parameter can be set to a single number or to an object with the
  98929. * following (optional) properties: precision, width, height. If a single number is passed,
  98930. * it will be used for both width and height. If an object is passed, the screenshot size
  98931. * will be derived from the parameters. The precision property is a multiplier allowing
  98932. * rendering at a higher or lower resolution
  98933. * @param successCallback defines the callback receives a single parameter which contains the
  98934. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98935. * src parameter of an <img> to display it
  98936. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98937. * Check your browser for supported MIME types
  98938. */
  98939. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98940. /**
  98941. * Captures a screenshot of the current rendering
  98942. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98943. * @param engine defines the rendering engine
  98944. * @param camera defines the source camera
  98945. * @param size This parameter can be set to a single number or to an object with the
  98946. * following (optional) properties: precision, width, height. If a single number is passed,
  98947. * it will be used for both width and height. If an object is passed, the screenshot size
  98948. * will be derived from the parameters. The precision property is a multiplier allowing
  98949. * rendering at a higher or lower resolution
  98950. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98951. * Check your browser for supported MIME types
  98952. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98953. * to the src parameter of an <img> to display it
  98954. */
  98955. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98956. /**
  98957. * Generates an image screenshot from the specified camera.
  98958. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98959. * @param engine The engine to use for rendering
  98960. * @param camera The camera to use for rendering
  98961. * @param size This parameter can be set to a single number or to an object with the
  98962. * following (optional) properties: precision, width, height. If a single number is passed,
  98963. * it will be used for both width and height. If an object is passed, the screenshot size
  98964. * will be derived from the parameters. The precision property is a multiplier allowing
  98965. * rendering at a higher or lower resolution
  98966. * @param successCallback The callback receives a single parameter which contains the
  98967. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98968. * src parameter of an <img> to display it
  98969. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98970. * Check your browser for supported MIME types
  98971. * @param samples Texture samples (default: 1)
  98972. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98973. * @param fileName A name for for the downloaded file.
  98974. */
  98975. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98976. /**
  98977. * Generates an image screenshot from the specified camera.
  98978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98979. * @param engine The engine to use for rendering
  98980. * @param camera The camera to use for rendering
  98981. * @param size This parameter can be set to a single number or to an object with the
  98982. * following (optional) properties: precision, width, height. If a single number is passed,
  98983. * it will be used for both width and height. If an object is passed, the screenshot size
  98984. * will be derived from the parameters. The precision property is a multiplier allowing
  98985. * rendering at a higher or lower resolution
  98986. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98987. * Check your browser for supported MIME types
  98988. * @param samples Texture samples (default: 1)
  98989. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98990. * @param fileName A name for for the downloaded file.
  98991. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98992. * to the src parameter of an <img> to display it
  98993. */
  98994. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98995. /**
  98996. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98997. * Be aware Math.random() could cause collisions, but:
  98998. * "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"
  98999. * @returns a pseudo random id
  99000. */
  99001. static RandomId(): string;
  99002. /**
  99003. * Test if the given uri is a base64 string
  99004. * @param uri The uri to test
  99005. * @return True if the uri is a base64 string or false otherwise
  99006. */
  99007. static IsBase64(uri: string): boolean;
  99008. /**
  99009. * Decode the given base64 uri.
  99010. * @param uri The uri to decode
  99011. * @return The decoded base64 data.
  99012. */
  99013. static DecodeBase64(uri: string): ArrayBuffer;
  99014. /**
  99015. * Gets the absolute url.
  99016. * @param url the input url
  99017. * @return the absolute url
  99018. */
  99019. static GetAbsoluteUrl(url: string): string;
  99020. /**
  99021. * No log
  99022. */
  99023. static readonly NoneLogLevel: number;
  99024. /**
  99025. * Only message logs
  99026. */
  99027. static readonly MessageLogLevel: number;
  99028. /**
  99029. * Only warning logs
  99030. */
  99031. static readonly WarningLogLevel: number;
  99032. /**
  99033. * Only error logs
  99034. */
  99035. static readonly ErrorLogLevel: number;
  99036. /**
  99037. * All logs
  99038. */
  99039. static readonly AllLogLevel: number;
  99040. /**
  99041. * Gets a value indicating the number of loading errors
  99042. * @ignorenaming
  99043. */
  99044. static readonly errorsCount: number;
  99045. /**
  99046. * Callback called when a new log is added
  99047. */
  99048. static OnNewCacheEntry: (entry: string) => void;
  99049. /**
  99050. * Log a message to the console
  99051. * @param message defines the message to log
  99052. */
  99053. static Log(message: string): void;
  99054. /**
  99055. * Write a warning message to the console
  99056. * @param message defines the message to log
  99057. */
  99058. static Warn(message: string): void;
  99059. /**
  99060. * Write an error message to the console
  99061. * @param message defines the message to log
  99062. */
  99063. static Error(message: string): void;
  99064. /**
  99065. * Gets current log cache (list of logs)
  99066. */
  99067. static readonly LogCache: string;
  99068. /**
  99069. * Clears the log cache
  99070. */
  99071. static ClearLogCache(): void;
  99072. /**
  99073. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99074. */
  99075. static LogLevels: number;
  99076. /**
  99077. * Checks if the window object exists
  99078. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99079. */
  99080. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99081. /**
  99082. * No performance log
  99083. */
  99084. static readonly PerformanceNoneLogLevel: number;
  99085. /**
  99086. * Use user marks to log performance
  99087. */
  99088. static readonly PerformanceUserMarkLogLevel: number;
  99089. /**
  99090. * Log performance to the console
  99091. */
  99092. static readonly PerformanceConsoleLogLevel: number;
  99093. private static _performance;
  99094. /**
  99095. * Sets the current performance log level
  99096. */
  99097. static PerformanceLogLevel: number;
  99098. private static _StartPerformanceCounterDisabled;
  99099. private static _EndPerformanceCounterDisabled;
  99100. private static _StartUserMark;
  99101. private static _EndUserMark;
  99102. private static _StartPerformanceConsole;
  99103. private static _EndPerformanceConsole;
  99104. /**
  99105. * Starts a performance counter
  99106. */
  99107. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99108. /**
  99109. * Ends a specific performance coutner
  99110. */
  99111. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99112. /**
  99113. * Gets either window.performance.now() if supported or Date.now() else
  99114. */
  99115. static readonly Now: number;
  99116. /**
  99117. * This method will return the name of the class used to create the instance of the given object.
  99118. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99119. * @param object the object to get the class name from
  99120. * @param isType defines if the object is actually a type
  99121. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99122. */
  99123. static GetClassName(object: any, isType?: boolean): string;
  99124. /**
  99125. * Gets the first element of an array satisfying a given predicate
  99126. * @param array defines the array to browse
  99127. * @param predicate defines the predicate to use
  99128. * @returns null if not found or the element
  99129. */
  99130. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99131. /**
  99132. * This method will return the name of the full name of the class, including its owning module (if any).
  99133. * 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).
  99134. * @param object the object to get the class name from
  99135. * @param isType defines if the object is actually a type
  99136. * @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.
  99137. * @ignorenaming
  99138. */
  99139. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99140. /**
  99141. * Returns a promise that resolves after the given amount of time.
  99142. * @param delay Number of milliseconds to delay
  99143. * @returns Promise that resolves after the given amount of time
  99144. */
  99145. static DelayAsync(delay: number): Promise<void>;
  99146. }
  99147. /**
  99148. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99149. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99150. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99151. * @param name The name of the class, case should be preserved
  99152. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99153. */
  99154. export function className(name: string, module?: string): (target: Object) => void;
  99155. /**
  99156. * An implementation of a loop for asynchronous functions.
  99157. */
  99158. export class AsyncLoop {
  99159. /**
  99160. * Defines the number of iterations for the loop
  99161. */
  99162. iterations: number;
  99163. /**
  99164. * Defines the current index of the loop.
  99165. */
  99166. index: number;
  99167. private _done;
  99168. private _fn;
  99169. private _successCallback;
  99170. /**
  99171. * Constructor.
  99172. * @param iterations the number of iterations.
  99173. * @param func the function to run each iteration
  99174. * @param successCallback the callback that will be called upon succesful execution
  99175. * @param offset starting offset.
  99176. */
  99177. constructor(
  99178. /**
  99179. * Defines the number of iterations for the loop
  99180. */
  99181. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99182. /**
  99183. * Execute the next iteration. Must be called after the last iteration was finished.
  99184. */
  99185. executeNext(): void;
  99186. /**
  99187. * Break the loop and run the success callback.
  99188. */
  99189. breakLoop(): void;
  99190. /**
  99191. * Create and run an async loop.
  99192. * @param iterations the number of iterations.
  99193. * @param fn the function to run each iteration
  99194. * @param successCallback the callback that will be called upon succesful execution
  99195. * @param offset starting offset.
  99196. * @returns the created async loop object
  99197. */
  99198. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99199. /**
  99200. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99201. * @param iterations total number of iterations
  99202. * @param syncedIterations number of synchronous iterations in each async iteration.
  99203. * @param fn the function to call each iteration.
  99204. * @param callback a success call back that will be called when iterating stops.
  99205. * @param breakFunction a break condition (optional)
  99206. * @param timeout timeout settings for the setTimeout function. default - 0.
  99207. * @returns the created async loop object
  99208. */
  99209. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99210. }
  99211. }
  99212. declare module BABYLON {
  99213. /**
  99214. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99215. * The underlying implementation relies on an associative array to ensure the best performances.
  99216. * The value can be anything including 'null' but except 'undefined'
  99217. */
  99218. export class StringDictionary<T> {
  99219. /**
  99220. * This will clear this dictionary and copy the content from the 'source' one.
  99221. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99222. * @param source the dictionary to take the content from and copy to this dictionary
  99223. */
  99224. copyFrom(source: StringDictionary<T>): void;
  99225. /**
  99226. * Get a value based from its key
  99227. * @param key the given key to get the matching value from
  99228. * @return the value if found, otherwise undefined is returned
  99229. */
  99230. get(key: string): T | undefined;
  99231. /**
  99232. * Get a value from its key or add it if it doesn't exist.
  99233. * This method will ensure you that a given key/data will be present in the dictionary.
  99234. * @param key the given key to get the matching value from
  99235. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99236. * The factory will only be invoked if there's no data for the given key.
  99237. * @return the value corresponding to the key.
  99238. */
  99239. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99240. /**
  99241. * Get a value from its key if present in the dictionary otherwise add it
  99242. * @param key the key to get the value from
  99243. * @param val if there's no such key/value pair in the dictionary add it with this value
  99244. * @return the value corresponding to the key
  99245. */
  99246. getOrAdd(key: string, val: T): T;
  99247. /**
  99248. * Check if there's a given key in the dictionary
  99249. * @param key the key to check for
  99250. * @return true if the key is present, false otherwise
  99251. */
  99252. contains(key: string): boolean;
  99253. /**
  99254. * Add a new key and its corresponding value
  99255. * @param key the key to add
  99256. * @param value the value corresponding to the key
  99257. * @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
  99258. */
  99259. add(key: string, value: T): boolean;
  99260. /**
  99261. * Update a specific value associated to a key
  99262. * @param key defines the key to use
  99263. * @param value defines the value to store
  99264. * @returns true if the value was updated (or false if the key was not found)
  99265. */
  99266. set(key: string, value: T): boolean;
  99267. /**
  99268. * Get the element of the given key and remove it from the dictionary
  99269. * @param key defines the key to search
  99270. * @returns the value associated with the key or null if not found
  99271. */
  99272. getAndRemove(key: string): Nullable<T>;
  99273. /**
  99274. * Remove a key/value from the dictionary.
  99275. * @param key the key to remove
  99276. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99277. */
  99278. remove(key: string): boolean;
  99279. /**
  99280. * Clear the whole content of the dictionary
  99281. */
  99282. clear(): void;
  99283. /**
  99284. * Gets the current count
  99285. */
  99286. readonly count: number;
  99287. /**
  99288. * Execute a callback on each key/val of the dictionary.
  99289. * Note that you can remove any element in this dictionary in the callback implementation
  99290. * @param callback the callback to execute on a given key/value pair
  99291. */
  99292. forEach(callback: (key: string, val: T) => void): void;
  99293. /**
  99294. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99295. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99296. * Note that you can remove any element in this dictionary in the callback implementation
  99297. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99298. * @returns the first item
  99299. */
  99300. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99301. private _count;
  99302. private _data;
  99303. }
  99304. }
  99305. declare module BABYLON {
  99306. /** @hidden */
  99307. export interface ICollisionCoordinator {
  99308. createCollider(): Collider;
  99309. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99310. init(scene: Scene): void;
  99311. }
  99312. /** @hidden */
  99313. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99314. private _scene;
  99315. private _scaledPosition;
  99316. private _scaledVelocity;
  99317. private _finalPosition;
  99318. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99319. createCollider(): Collider;
  99320. init(scene: Scene): void;
  99321. private _collideWithWorld;
  99322. }
  99323. }
  99324. declare module BABYLON {
  99325. /**
  99326. * Class used to manage all inputs for the scene.
  99327. */
  99328. export class InputManager {
  99329. /** The distance in pixel that you have to move to prevent some events */
  99330. static DragMovementThreshold: number;
  99331. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99332. static LongPressDelay: number;
  99333. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99334. static DoubleClickDelay: number;
  99335. /** If you need to check double click without raising a single click at first click, enable this flag */
  99336. static ExclusiveDoubleClickMode: boolean;
  99337. private _wheelEventName;
  99338. private _onPointerMove;
  99339. private _onPointerDown;
  99340. private _onPointerUp;
  99341. private _initClickEvent;
  99342. private _initActionManager;
  99343. private _delayedSimpleClick;
  99344. private _delayedSimpleClickTimeout;
  99345. private _previousDelayedSimpleClickTimeout;
  99346. private _meshPickProceed;
  99347. private _previousButtonPressed;
  99348. private _currentPickResult;
  99349. private _previousPickResult;
  99350. private _totalPointersPressed;
  99351. private _doubleClickOccured;
  99352. private _pointerOverMesh;
  99353. private _pickedDownMesh;
  99354. private _pickedUpMesh;
  99355. private _pointerX;
  99356. private _pointerY;
  99357. private _unTranslatedPointerX;
  99358. private _unTranslatedPointerY;
  99359. private _startingPointerPosition;
  99360. private _previousStartingPointerPosition;
  99361. private _startingPointerTime;
  99362. private _previousStartingPointerTime;
  99363. private _pointerCaptures;
  99364. private _onKeyDown;
  99365. private _onKeyUp;
  99366. private _onCanvasFocusObserver;
  99367. private _onCanvasBlurObserver;
  99368. private _scene;
  99369. /**
  99370. * Creates a new InputManager
  99371. * @param scene defines the hosting scene
  99372. */
  99373. constructor(scene: Scene);
  99374. /**
  99375. * Gets the mesh that is currently under the pointer
  99376. */
  99377. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99378. /**
  99379. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99380. */
  99381. readonly unTranslatedPointer: Vector2;
  99382. /**
  99383. * Gets or sets the current on-screen X position of the pointer
  99384. */
  99385. pointerX: number;
  99386. /**
  99387. * Gets or sets the current on-screen Y position of the pointer
  99388. */
  99389. pointerY: number;
  99390. private _updatePointerPosition;
  99391. private _processPointerMove;
  99392. private _setRayOnPointerInfo;
  99393. private _checkPrePointerObservable;
  99394. /**
  99395. * Use this method to simulate a pointer move on a mesh
  99396. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99397. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99398. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99399. */
  99400. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99401. /**
  99402. * Use this method to simulate a pointer down on a mesh
  99403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99406. */
  99407. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99408. private _processPointerDown;
  99409. /** @hidden */
  99410. _isPointerSwiping(): boolean;
  99411. /**
  99412. * Use this method to simulate a pointer up on a mesh
  99413. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99414. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99415. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99416. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99417. */
  99418. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99419. private _processPointerUp;
  99420. /**
  99421. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99422. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99423. * @returns true if the pointer was captured
  99424. */
  99425. isPointerCaptured(pointerId?: number): boolean;
  99426. /**
  99427. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99428. * @param attachUp defines if you want to attach events to pointerup
  99429. * @param attachDown defines if you want to attach events to pointerdown
  99430. * @param attachMove defines if you want to attach events to pointermove
  99431. */
  99432. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99433. /**
  99434. * Detaches all event handlers
  99435. */
  99436. detachControl(): void;
  99437. /**
  99438. * Force the value of meshUnderPointer
  99439. * @param mesh defines the mesh to use
  99440. */
  99441. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99442. /**
  99443. * Gets the mesh under the pointer
  99444. * @returns a Mesh or null if no mesh is under the pointer
  99445. */
  99446. getPointerOverMesh(): Nullable<AbstractMesh>;
  99447. }
  99448. }
  99449. declare module BABYLON {
  99450. /**
  99451. * Helper class used to generate session unique ID
  99452. */
  99453. export class UniqueIdGenerator {
  99454. private static _UniqueIdCounter;
  99455. /**
  99456. * Gets an unique (relatively to the current scene) Id
  99457. */
  99458. static readonly UniqueId: number;
  99459. }
  99460. }
  99461. declare module BABYLON {
  99462. /**
  99463. * This class defines the direct association between an animation and a target
  99464. */
  99465. export class TargetedAnimation {
  99466. /**
  99467. * Animation to perform
  99468. */
  99469. animation: Animation;
  99470. /**
  99471. * Target to animate
  99472. */
  99473. target: any;
  99474. /**
  99475. * Serialize the object
  99476. * @returns the JSON object representing the current entity
  99477. */
  99478. serialize(): any;
  99479. }
  99480. /**
  99481. * Use this class to create coordinated animations on multiple targets
  99482. */
  99483. export class AnimationGroup implements IDisposable {
  99484. /** The name of the animation group */
  99485. name: string;
  99486. private _scene;
  99487. private _targetedAnimations;
  99488. private _animatables;
  99489. private _from;
  99490. private _to;
  99491. private _isStarted;
  99492. private _isPaused;
  99493. private _speedRatio;
  99494. private _loopAnimation;
  99495. /**
  99496. * Gets or sets the unique id of the node
  99497. */
  99498. uniqueId: number;
  99499. /**
  99500. * This observable will notify when one animation have ended
  99501. */
  99502. onAnimationEndObservable: Observable<TargetedAnimation>;
  99503. /**
  99504. * Observer raised when one animation loops
  99505. */
  99506. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99507. /**
  99508. * This observable will notify when all animations have ended.
  99509. */
  99510. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99511. /**
  99512. * This observable will notify when all animations have paused.
  99513. */
  99514. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99515. /**
  99516. * This observable will notify when all animations are playing.
  99517. */
  99518. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99519. /**
  99520. * Gets the first frame
  99521. */
  99522. readonly from: number;
  99523. /**
  99524. * Gets the last frame
  99525. */
  99526. readonly to: number;
  99527. /**
  99528. * Define if the animations are started
  99529. */
  99530. readonly isStarted: boolean;
  99531. /**
  99532. * Gets a value indicating that the current group is playing
  99533. */
  99534. readonly isPlaying: boolean;
  99535. /**
  99536. * Gets or sets the speed ratio to use for all animations
  99537. */
  99538. /**
  99539. * Gets or sets the speed ratio to use for all animations
  99540. */
  99541. speedRatio: number;
  99542. /**
  99543. * Gets or sets if all animations should loop or not
  99544. */
  99545. loopAnimation: boolean;
  99546. /**
  99547. * Gets the targeted animations for this animation group
  99548. */
  99549. readonly targetedAnimations: Array<TargetedAnimation>;
  99550. /**
  99551. * returning the list of animatables controlled by this animation group.
  99552. */
  99553. readonly animatables: Array<Animatable>;
  99554. /**
  99555. * Instantiates a new Animation Group.
  99556. * This helps managing several animations at once.
  99557. * @see http://doc.babylonjs.com/how_to/group
  99558. * @param name Defines the name of the group
  99559. * @param scene Defines the scene the group belongs to
  99560. */
  99561. constructor(
  99562. /** The name of the animation group */
  99563. name: string, scene?: Nullable<Scene>);
  99564. /**
  99565. * Add an animation (with its target) in the group
  99566. * @param animation defines the animation we want to add
  99567. * @param target defines the target of the animation
  99568. * @returns the TargetedAnimation object
  99569. */
  99570. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99571. /**
  99572. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99573. * It can add constant keys at begin or end
  99574. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99575. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99576. * @returns the animation group
  99577. */
  99578. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99579. /**
  99580. * Start all animations on given targets
  99581. * @param loop defines if animations must loop
  99582. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99583. * @param from defines the from key (optional)
  99584. * @param to defines the to key (optional)
  99585. * @returns the current animation group
  99586. */
  99587. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99588. /**
  99589. * Pause all animations
  99590. * @returns the animation group
  99591. */
  99592. pause(): AnimationGroup;
  99593. /**
  99594. * Play all animations to initial state
  99595. * This function will start() the animations if they were not started or will restart() them if they were paused
  99596. * @param loop defines if animations must loop
  99597. * @returns the animation group
  99598. */
  99599. play(loop?: boolean): AnimationGroup;
  99600. /**
  99601. * Reset all animations to initial state
  99602. * @returns the animation group
  99603. */
  99604. reset(): AnimationGroup;
  99605. /**
  99606. * Restart animations from key 0
  99607. * @returns the animation group
  99608. */
  99609. restart(): AnimationGroup;
  99610. /**
  99611. * Stop all animations
  99612. * @returns the animation group
  99613. */
  99614. stop(): AnimationGroup;
  99615. /**
  99616. * Set animation weight for all animatables
  99617. * @param weight defines the weight to use
  99618. * @return the animationGroup
  99619. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99620. */
  99621. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99622. /**
  99623. * Synchronize and normalize all animatables with a source animatable
  99624. * @param root defines the root animatable to synchronize with
  99625. * @return the animationGroup
  99626. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99627. */
  99628. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99629. /**
  99630. * Goes to a specific frame in this animation group
  99631. * @param frame the frame number to go to
  99632. * @return the animationGroup
  99633. */
  99634. goToFrame(frame: number): AnimationGroup;
  99635. /**
  99636. * Dispose all associated resources
  99637. */
  99638. dispose(): void;
  99639. private _checkAnimationGroupEnded;
  99640. /**
  99641. * Clone the current animation group and returns a copy
  99642. * @param newName defines the name of the new group
  99643. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99644. * @returns the new aniamtion group
  99645. */
  99646. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99647. /**
  99648. * Serializes the animationGroup to an object
  99649. * @returns Serialized object
  99650. */
  99651. serialize(): any;
  99652. /**
  99653. * Returns a new AnimationGroup object parsed from the source provided.
  99654. * @param parsedAnimationGroup defines the source
  99655. * @param scene defines the scene that will receive the animationGroup
  99656. * @returns a new AnimationGroup
  99657. */
  99658. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99659. /**
  99660. * Returns the string "AnimationGroup"
  99661. * @returns "AnimationGroup"
  99662. */
  99663. getClassName(): string;
  99664. /**
  99665. * Creates a detailled string about the object
  99666. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99667. * @returns a string representing the object
  99668. */
  99669. toString(fullDetails?: boolean): string;
  99670. }
  99671. }
  99672. declare module BABYLON {
  99673. /**
  99674. * Define an interface for all classes that will hold resources
  99675. */
  99676. export interface IDisposable {
  99677. /**
  99678. * Releases all held resources
  99679. */
  99680. dispose(): void;
  99681. }
  99682. /** Interface defining initialization parameters for Scene class */
  99683. export interface SceneOptions {
  99684. /**
  99685. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99686. * It will improve performance when the number of geometries becomes important.
  99687. */
  99688. useGeometryUniqueIdsMap?: boolean;
  99689. /**
  99690. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99691. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99692. */
  99693. useMaterialMeshMap?: boolean;
  99694. /**
  99695. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned 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. useClonedMeshhMap?: boolean;
  99699. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99700. virtual?: boolean;
  99701. }
  99702. /**
  99703. * Represents a scene to be rendered by the engine.
  99704. * @see http://doc.babylonjs.com/features/scene
  99705. */
  99706. export class Scene extends AbstractScene implements IAnimatable {
  99707. /** The fog is deactivated */
  99708. static readonly FOGMODE_NONE: number;
  99709. /** The fog density is following an exponential function */
  99710. static readonly FOGMODE_EXP: number;
  99711. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99712. static readonly FOGMODE_EXP2: number;
  99713. /** The fog density is following a linear function. */
  99714. static readonly FOGMODE_LINEAR: number;
  99715. /**
  99716. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99718. */
  99719. static MinDeltaTime: number;
  99720. /**
  99721. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99722. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99723. */
  99724. static MaxDeltaTime: number;
  99725. /**
  99726. * Factory used to create the default material.
  99727. * @param name The name of the material to create
  99728. * @param scene The scene to create the material for
  99729. * @returns The default material
  99730. */
  99731. static DefaultMaterialFactory(scene: Scene): Material;
  99732. /**
  99733. * Factory used to create the a collision coordinator.
  99734. * @returns The collision coordinator
  99735. */
  99736. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99737. /** @hidden */
  99738. _inputManager: InputManager;
  99739. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99740. cameraToUseForPointers: Nullable<Camera>;
  99741. /** @hidden */
  99742. readonly _isScene: boolean;
  99743. /**
  99744. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99745. */
  99746. autoClear: boolean;
  99747. /**
  99748. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99749. */
  99750. autoClearDepthAndStencil: boolean;
  99751. /**
  99752. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99753. */
  99754. clearColor: Color4;
  99755. /**
  99756. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99757. */
  99758. ambientColor: Color3;
  99759. /**
  99760. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99761. * It should only be one of the following (if not the default embedded one):
  99762. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99763. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99764. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99765. * The material properties need to be setup according to the type of texture in use.
  99766. */
  99767. environmentBRDFTexture: BaseTexture;
  99768. /** @hidden */
  99769. protected _environmentTexture: Nullable<BaseTexture>;
  99770. /**
  99771. * Texture used in all pbr material as the reflection texture.
  99772. * As in the majority of the scene they are the same (exception for multi room and so on),
  99773. * this is easier to reference from here than from all the materials.
  99774. */
  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 set here than in all the materials.
  99779. */
  99780. environmentTexture: Nullable<BaseTexture>;
  99781. /** @hidden */
  99782. protected _environmentIntensity: number;
  99783. /**
  99784. * Intensity of the environment in all pbr material.
  99785. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99786. * As in the majority of the scene they are the same (exception for multi room and so on),
  99787. * this is easier to reference from here than from all the materials.
  99788. */
  99789. /**
  99790. * Intensity of the environment in all pbr material.
  99791. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99792. * As in the majority of the scene they are the same (exception for multi room and so on),
  99793. * this is easier to set here than in all the materials.
  99794. */
  99795. environmentIntensity: number;
  99796. /** @hidden */
  99797. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99798. /**
  99799. * Default image processing configuration used either in the rendering
  99800. * Forward main pass or through the imageProcessingPostProcess if present.
  99801. * As in the majority of the scene they are the same (exception for multi camera),
  99802. * this is easier to reference from here than from all the materials and post process.
  99803. *
  99804. * No setter as we it is a shared configuration, you can set the values instead.
  99805. */
  99806. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99807. private _forceWireframe;
  99808. /**
  99809. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99810. */
  99811. forceWireframe: boolean;
  99812. private _forcePointsCloud;
  99813. /**
  99814. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99815. */
  99816. forcePointsCloud: boolean;
  99817. /**
  99818. * Gets or sets the active clipplane 1
  99819. */
  99820. clipPlane: Nullable<Plane>;
  99821. /**
  99822. * Gets or sets the active clipplane 2
  99823. */
  99824. clipPlane2: Nullable<Plane>;
  99825. /**
  99826. * Gets or sets the active clipplane 3
  99827. */
  99828. clipPlane3: Nullable<Plane>;
  99829. /**
  99830. * Gets or sets the active clipplane 4
  99831. */
  99832. clipPlane4: Nullable<Plane>;
  99833. /**
  99834. * Gets or sets a boolean indicating if animations are enabled
  99835. */
  99836. animationsEnabled: boolean;
  99837. private _animationPropertiesOverride;
  99838. /**
  99839. * Gets or sets the animation properties override
  99840. */
  99841. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99842. /**
  99843. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99844. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99845. */
  99846. useConstantAnimationDeltaTime: boolean;
  99847. /**
  99848. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99849. * Please note that it requires to run a ray cast through the scene on every frame
  99850. */
  99851. constantlyUpdateMeshUnderPointer: boolean;
  99852. /**
  99853. * Defines the HTML cursor to use when hovering over interactive elements
  99854. */
  99855. hoverCursor: string;
  99856. /**
  99857. * Defines the HTML default cursor to use (empty by default)
  99858. */
  99859. defaultCursor: string;
  99860. /**
  99861. * This is used to call preventDefault() on pointer down
  99862. * in order to block unwanted artifacts like system double clicks
  99863. */
  99864. preventDefaultOnPointerDown: boolean;
  99865. /**
  99866. * This is used to call preventDefault() on pointer up
  99867. * in order to block unwanted artifacts like system double clicks
  99868. */
  99869. preventDefaultOnPointerUp: boolean;
  99870. /**
  99871. * Gets or sets user defined metadata
  99872. */
  99873. metadata: any;
  99874. /**
  99875. * For internal use only. Please do not use.
  99876. */
  99877. reservedDataStore: any;
  99878. /**
  99879. * Gets the name of the plugin used to load this scene (null by default)
  99880. */
  99881. loadingPluginName: string;
  99882. /**
  99883. * Use this array to add regular expressions used to disable offline support for specific urls
  99884. */
  99885. disableOfflineSupportExceptionRules: RegExp[];
  99886. /**
  99887. * An event triggered when the scene is disposed.
  99888. */
  99889. onDisposeObservable: Observable<Scene>;
  99890. private _onDisposeObserver;
  99891. /** Sets a function to be executed when this scene is disposed. */
  99892. onDispose: () => void;
  99893. /**
  99894. * An event triggered before rendering the scene (right after animations and physics)
  99895. */
  99896. onBeforeRenderObservable: Observable<Scene>;
  99897. private _onBeforeRenderObserver;
  99898. /** Sets a function to be executed before rendering this scene */
  99899. beforeRender: Nullable<() => void>;
  99900. /**
  99901. * An event triggered after rendering the scene
  99902. */
  99903. onAfterRenderObservable: Observable<Scene>;
  99904. /**
  99905. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99906. */
  99907. onAfterRenderCameraObservable: Observable<Camera>;
  99908. private _onAfterRenderObserver;
  99909. /** Sets a function to be executed after rendering this scene */
  99910. afterRender: Nullable<() => void>;
  99911. /**
  99912. * An event triggered before animating the scene
  99913. */
  99914. onBeforeAnimationsObservable: Observable<Scene>;
  99915. /**
  99916. * An event triggered after animations processing
  99917. */
  99918. onAfterAnimationsObservable: Observable<Scene>;
  99919. /**
  99920. * An event triggered before draw calls are ready to be sent
  99921. */
  99922. onBeforeDrawPhaseObservable: Observable<Scene>;
  99923. /**
  99924. * An event triggered after draw calls have been sent
  99925. */
  99926. onAfterDrawPhaseObservable: Observable<Scene>;
  99927. /**
  99928. * An event triggered when the scene is ready
  99929. */
  99930. onReadyObservable: Observable<Scene>;
  99931. /**
  99932. * An event triggered before rendering a camera
  99933. */
  99934. onBeforeCameraRenderObservable: Observable<Camera>;
  99935. private _onBeforeCameraRenderObserver;
  99936. /** Sets a function to be executed before rendering a camera*/
  99937. beforeCameraRender: () => void;
  99938. /**
  99939. * An event triggered after rendering a camera
  99940. */
  99941. onAfterCameraRenderObservable: Observable<Camera>;
  99942. private _onAfterCameraRenderObserver;
  99943. /** Sets a function to be executed after rendering a camera*/
  99944. afterCameraRender: () => void;
  99945. /**
  99946. * An event triggered when active meshes evaluation is about to start
  99947. */
  99948. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99949. /**
  99950. * An event triggered when active meshes evaluation is done
  99951. */
  99952. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99953. /**
  99954. * An event triggered when particles rendering is about to start
  99955. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99956. */
  99957. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99958. /**
  99959. * An event triggered when particles rendering is done
  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. onAfterParticlesRenderingObservable: Observable<Scene>;
  99963. /**
  99964. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99965. */
  99966. onDataLoadedObservable: Observable<Scene>;
  99967. /**
  99968. * An event triggered when a camera is created
  99969. */
  99970. onNewCameraAddedObservable: Observable<Camera>;
  99971. /**
  99972. * An event triggered when a camera is removed
  99973. */
  99974. onCameraRemovedObservable: Observable<Camera>;
  99975. /**
  99976. * An event triggered when a light is created
  99977. */
  99978. onNewLightAddedObservable: Observable<Light>;
  99979. /**
  99980. * An event triggered when a light is removed
  99981. */
  99982. onLightRemovedObservable: Observable<Light>;
  99983. /**
  99984. * An event triggered when a geometry is created
  99985. */
  99986. onNewGeometryAddedObservable: Observable<Geometry>;
  99987. /**
  99988. * An event triggered when a geometry is removed
  99989. */
  99990. onGeometryRemovedObservable: Observable<Geometry>;
  99991. /**
  99992. * An event triggered when a transform node is created
  99993. */
  99994. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99995. /**
  99996. * An event triggered when a transform node is removed
  99997. */
  99998. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99999. /**
  100000. * An event triggered when a mesh is created
  100001. */
  100002. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100003. /**
  100004. * An event triggered when a mesh is removed
  100005. */
  100006. onMeshRemovedObservable: Observable<AbstractMesh>;
  100007. /**
  100008. * An event triggered when a skeleton is created
  100009. */
  100010. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100011. /**
  100012. * An event triggered when a skeleton is removed
  100013. */
  100014. onSkeletonRemovedObservable: Observable<Skeleton>;
  100015. /**
  100016. * An event triggered when a material is created
  100017. */
  100018. onNewMaterialAddedObservable: Observable<Material>;
  100019. /**
  100020. * An event triggered when a material is removed
  100021. */
  100022. onMaterialRemovedObservable: Observable<Material>;
  100023. /**
  100024. * An event triggered when a texture is created
  100025. */
  100026. onNewTextureAddedObservable: Observable<BaseTexture>;
  100027. /**
  100028. * An event triggered when a texture is removed
  100029. */
  100030. onTextureRemovedObservable: Observable<BaseTexture>;
  100031. /**
  100032. * An event triggered when render targets are about to be rendered
  100033. * Can happen multiple times per frame.
  100034. */
  100035. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100036. /**
  100037. * An event triggered when render targets were rendered.
  100038. * Can happen multiple times per frame.
  100039. */
  100040. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100041. /**
  100042. * An event triggered before calculating deterministic simulation step
  100043. */
  100044. onBeforeStepObservable: Observable<Scene>;
  100045. /**
  100046. * An event triggered after calculating deterministic simulation step
  100047. */
  100048. onAfterStepObservable: Observable<Scene>;
  100049. /**
  100050. * An event triggered when the activeCamera property is updated
  100051. */
  100052. onActiveCameraChanged: Observable<Scene>;
  100053. /**
  100054. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100055. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100056. * 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)
  100057. */
  100058. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100059. /**
  100060. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100061. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100062. * 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)
  100063. */
  100064. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100065. /**
  100066. * This Observable will when a mesh has been imported into the scene.
  100067. */
  100068. onMeshImportedObservable: Observable<AbstractMesh>;
  100069. /**
  100070. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100071. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100072. */
  100073. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100074. /** @hidden */
  100075. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100076. /**
  100077. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100078. */
  100079. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100080. /**
  100081. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100082. */
  100083. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100084. /**
  100085. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100086. */
  100087. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100088. /** Callback called when a pointer move is detected */
  100089. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100090. /** Callback called when a pointer down is detected */
  100091. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100092. /** Callback called when a pointer up is detected */
  100093. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100094. /** Callback called when a pointer pick is detected */
  100095. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100096. /**
  100097. * 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).
  100098. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100099. */
  100100. onPrePointerObservable: Observable<PointerInfoPre>;
  100101. /**
  100102. * Observable event triggered each time an input event is received from the rendering canvas
  100103. */
  100104. onPointerObservable: Observable<PointerInfo>;
  100105. /**
  100106. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100107. */
  100108. readonly unTranslatedPointer: Vector2;
  100109. /**
  100110. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100111. */
  100112. static DragMovementThreshold: number;
  100113. /**
  100114. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100115. */
  100116. static LongPressDelay: number;
  100117. /**
  100118. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100119. */
  100120. static DoubleClickDelay: number;
  100121. /** If you need to check double click without raising a single click at first click, enable this flag */
  100122. static ExclusiveDoubleClickMode: boolean;
  100123. /** @hidden */
  100124. _mirroredCameraPosition: Nullable<Vector3>;
  100125. /**
  100126. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100127. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100128. */
  100129. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100130. /**
  100131. * Observable event triggered each time an keyboard event is received from the hosting window
  100132. */
  100133. onKeyboardObservable: Observable<KeyboardInfo>;
  100134. private _useRightHandedSystem;
  100135. /**
  100136. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100137. */
  100138. useRightHandedSystem: boolean;
  100139. private _timeAccumulator;
  100140. private _currentStepId;
  100141. private _currentInternalStep;
  100142. /**
  100143. * Sets the step Id used by deterministic lock step
  100144. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100145. * @param newStepId defines the step Id
  100146. */
  100147. setStepId(newStepId: number): void;
  100148. /**
  100149. * Gets the step Id used by deterministic lock step
  100150. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100151. * @returns the step Id
  100152. */
  100153. getStepId(): number;
  100154. /**
  100155. * Gets the internal step used by deterministic lock step
  100156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100157. * @returns the internal step
  100158. */
  100159. getInternalStep(): number;
  100160. private _fogEnabled;
  100161. /**
  100162. * Gets or sets a boolean indicating if fog is enabled on this scene
  100163. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100164. * (Default is true)
  100165. */
  100166. fogEnabled: boolean;
  100167. private _fogMode;
  100168. /**
  100169. * Gets or sets the fog mode to use
  100170. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100171. * | mode | value |
  100172. * | --- | --- |
  100173. * | FOGMODE_NONE | 0 |
  100174. * | FOGMODE_EXP | 1 |
  100175. * | FOGMODE_EXP2 | 2 |
  100176. * | FOGMODE_LINEAR | 3 |
  100177. */
  100178. fogMode: number;
  100179. /**
  100180. * Gets or sets the fog color to use
  100181. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100182. * (Default is Color3(0.2, 0.2, 0.3))
  100183. */
  100184. fogColor: Color3;
  100185. /**
  100186. * Gets or sets the fog density to use
  100187. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100188. * (Default is 0.1)
  100189. */
  100190. fogDensity: number;
  100191. /**
  100192. * Gets or sets the fog start distance to use
  100193. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100194. * (Default is 0)
  100195. */
  100196. fogStart: number;
  100197. /**
  100198. * Gets or sets the fog end distance to use
  100199. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100200. * (Default is 1000)
  100201. */
  100202. fogEnd: number;
  100203. private _shadowsEnabled;
  100204. /**
  100205. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100206. */
  100207. shadowsEnabled: boolean;
  100208. private _lightsEnabled;
  100209. /**
  100210. * Gets or sets a boolean indicating if lights are enabled on this scene
  100211. */
  100212. lightsEnabled: boolean;
  100213. /** All of the active cameras added to this scene. */
  100214. activeCameras: Camera[];
  100215. /** @hidden */
  100216. _activeCamera: Nullable<Camera>;
  100217. /** Gets or sets the current active camera */
  100218. activeCamera: Nullable<Camera>;
  100219. private _defaultMaterial;
  100220. /** The default material used on meshes when no material is affected */
  100221. /** The default material used on meshes when no material is affected */
  100222. defaultMaterial: Material;
  100223. private _texturesEnabled;
  100224. /**
  100225. * Gets or sets a boolean indicating if textures are enabled on this scene
  100226. */
  100227. texturesEnabled: boolean;
  100228. /**
  100229. * Gets or sets a boolean indicating if particles are enabled on this scene
  100230. */
  100231. particlesEnabled: boolean;
  100232. /**
  100233. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100234. */
  100235. spritesEnabled: boolean;
  100236. private _skeletonsEnabled;
  100237. /**
  100238. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100239. */
  100240. skeletonsEnabled: boolean;
  100241. /**
  100242. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100243. */
  100244. lensFlaresEnabled: boolean;
  100245. /**
  100246. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100247. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100248. */
  100249. collisionsEnabled: boolean;
  100250. private _collisionCoordinator;
  100251. /** @hidden */
  100252. readonly collisionCoordinator: ICollisionCoordinator;
  100253. /**
  100254. * Defines the gravity applied to this scene (used only for collisions)
  100255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100256. */
  100257. gravity: Vector3;
  100258. /**
  100259. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100260. */
  100261. postProcessesEnabled: boolean;
  100262. /**
  100263. * The list of postprocesses added to the scene
  100264. */
  100265. postProcesses: PostProcess[];
  100266. /**
  100267. * Gets the current postprocess manager
  100268. */
  100269. postProcessManager: PostProcessManager;
  100270. /**
  100271. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100272. */
  100273. renderTargetsEnabled: boolean;
  100274. /**
  100275. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100276. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100277. */
  100278. dumpNextRenderTargets: boolean;
  100279. /**
  100280. * The list of user defined render targets added to the scene
  100281. */
  100282. customRenderTargets: RenderTargetTexture[];
  100283. /**
  100284. * Defines if texture loading must be delayed
  100285. * If true, textures will only be loaded when they need to be rendered
  100286. */
  100287. useDelayedTextureLoading: boolean;
  100288. /**
  100289. * Gets the list of meshes imported to the scene through SceneLoader
  100290. */
  100291. importedMeshesFiles: String[];
  100292. /**
  100293. * Gets or sets a boolean indicating if probes are enabled on this scene
  100294. */
  100295. probesEnabled: boolean;
  100296. /**
  100297. * Gets or sets the current offline provider to use to store scene data
  100298. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100299. */
  100300. offlineProvider: IOfflineProvider;
  100301. /**
  100302. * Gets or sets the action manager associated with the scene
  100303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100304. */
  100305. actionManager: AbstractActionManager;
  100306. private _meshesForIntersections;
  100307. /**
  100308. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100309. */
  100310. proceduralTexturesEnabled: boolean;
  100311. private _engine;
  100312. private _totalVertices;
  100313. /** @hidden */
  100314. _activeIndices: PerfCounter;
  100315. /** @hidden */
  100316. _activeParticles: PerfCounter;
  100317. /** @hidden */
  100318. _activeBones: PerfCounter;
  100319. private _animationRatio;
  100320. /** @hidden */
  100321. _animationTimeLast: number;
  100322. /** @hidden */
  100323. _animationTime: number;
  100324. /**
  100325. * Gets or sets a general scale for animation speed
  100326. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100327. */
  100328. animationTimeScale: number;
  100329. /** @hidden */
  100330. _cachedMaterial: Nullable<Material>;
  100331. /** @hidden */
  100332. _cachedEffect: Nullable<Effect>;
  100333. /** @hidden */
  100334. _cachedVisibility: Nullable<number>;
  100335. private _renderId;
  100336. private _frameId;
  100337. private _executeWhenReadyTimeoutId;
  100338. private _intermediateRendering;
  100339. private _viewUpdateFlag;
  100340. private _projectionUpdateFlag;
  100341. /** @hidden */
  100342. _toBeDisposed: Nullable<IDisposable>[];
  100343. private _activeRequests;
  100344. /** @hidden */
  100345. _pendingData: any[];
  100346. private _isDisposed;
  100347. /**
  100348. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100349. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100350. */
  100351. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100352. private _activeMeshes;
  100353. private _processedMaterials;
  100354. private _renderTargets;
  100355. /** @hidden */
  100356. _activeParticleSystems: SmartArray<IParticleSystem>;
  100357. private _activeSkeletons;
  100358. private _softwareSkinnedMeshes;
  100359. private _renderingManager;
  100360. /** @hidden */
  100361. _activeAnimatables: Animatable[];
  100362. private _transformMatrix;
  100363. private _sceneUbo;
  100364. /** @hidden */
  100365. _viewMatrix: Matrix;
  100366. private _projectionMatrix;
  100367. /** @hidden */
  100368. _forcedViewPosition: Nullable<Vector3>;
  100369. /** @hidden */
  100370. _frustumPlanes: Plane[];
  100371. /**
  100372. * Gets the list of frustum planes (built from the active camera)
  100373. */
  100374. readonly frustumPlanes: Plane[];
  100375. /**
  100376. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100377. * This is useful if there are more lights that the maximum simulteanous authorized
  100378. */
  100379. requireLightSorting: boolean;
  100380. /** @hidden */
  100381. readonly useMaterialMeshMap: boolean;
  100382. /** @hidden */
  100383. readonly useClonedMeshhMap: boolean;
  100384. private _externalData;
  100385. private _uid;
  100386. /**
  100387. * @hidden
  100388. * Backing store of defined scene components.
  100389. */
  100390. _components: ISceneComponent[];
  100391. /**
  100392. * @hidden
  100393. * Backing store of defined scene components.
  100394. */
  100395. _serializableComponents: ISceneSerializableComponent[];
  100396. /**
  100397. * List of components to register on the next registration step.
  100398. */
  100399. private _transientComponents;
  100400. /**
  100401. * Registers the transient components if needed.
  100402. */
  100403. private _registerTransientComponents;
  100404. /**
  100405. * @hidden
  100406. * Add a component to the scene.
  100407. * Note that the ccomponent could be registered on th next frame if this is called after
  100408. * the register component stage.
  100409. * @param component Defines the component to add to the scene
  100410. */
  100411. _addComponent(component: ISceneComponent): void;
  100412. /**
  100413. * @hidden
  100414. * Gets a component from the scene.
  100415. * @param name defines the name of the component to retrieve
  100416. * @returns the component or null if not present
  100417. */
  100418. _getComponent(name: string): Nullable<ISceneComponent>;
  100419. /**
  100420. * @hidden
  100421. * Defines the actions happening before camera updates.
  100422. */
  100423. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100424. /**
  100425. * @hidden
  100426. * Defines the actions happening before clear the canvas.
  100427. */
  100428. _beforeClearStage: Stage<SimpleStageAction>;
  100429. /**
  100430. * @hidden
  100431. * Defines the actions when collecting render targets for the frame.
  100432. */
  100433. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100434. /**
  100435. * @hidden
  100436. * Defines the actions happening for one camera in the frame.
  100437. */
  100438. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100439. /**
  100440. * @hidden
  100441. * Defines the actions happening during the per mesh ready checks.
  100442. */
  100443. _isReadyForMeshStage: Stage<MeshStageAction>;
  100444. /**
  100445. * @hidden
  100446. * Defines the actions happening before evaluate active mesh checks.
  100447. */
  100448. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100449. /**
  100450. * @hidden
  100451. * Defines the actions happening during the evaluate sub mesh checks.
  100452. */
  100453. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100454. /**
  100455. * @hidden
  100456. * Defines the actions happening during the active mesh stage.
  100457. */
  100458. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100459. /**
  100460. * @hidden
  100461. * Defines the actions happening during the per camera render target step.
  100462. */
  100463. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100464. /**
  100465. * @hidden
  100466. * Defines the actions happening just before the active camera is drawing.
  100467. */
  100468. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100469. /**
  100470. * @hidden
  100471. * Defines the actions happening just before a render target is drawing.
  100472. */
  100473. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100474. /**
  100475. * @hidden
  100476. * Defines the actions happening just before a rendering group is drawing.
  100477. */
  100478. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100479. /**
  100480. * @hidden
  100481. * Defines the actions happening just before a mesh is drawing.
  100482. */
  100483. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100484. /**
  100485. * @hidden
  100486. * Defines the actions happening just after a mesh has been drawn.
  100487. */
  100488. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100489. /**
  100490. * @hidden
  100491. * Defines the actions happening just after a rendering group has been drawn.
  100492. */
  100493. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100494. /**
  100495. * @hidden
  100496. * Defines the actions happening just after the active camera has been drawn.
  100497. */
  100498. _afterCameraDrawStage: Stage<CameraStageAction>;
  100499. /**
  100500. * @hidden
  100501. * Defines the actions happening just after a render target has been drawn.
  100502. */
  100503. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100504. /**
  100505. * @hidden
  100506. * Defines the actions happening just after rendering all cameras and computing intersections.
  100507. */
  100508. _afterRenderStage: Stage<SimpleStageAction>;
  100509. /**
  100510. * @hidden
  100511. * Defines the actions happening when a pointer move event happens.
  100512. */
  100513. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100514. /**
  100515. * @hidden
  100516. * Defines the actions happening when a pointer down event happens.
  100517. */
  100518. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100519. /**
  100520. * @hidden
  100521. * Defines the actions happening when a pointer up event happens.
  100522. */
  100523. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100524. /**
  100525. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100526. */
  100527. private geometriesByUniqueId;
  100528. /**
  100529. * Creates a new Scene
  100530. * @param engine defines the engine to use to render this scene
  100531. * @param options defines the scene options
  100532. */
  100533. constructor(engine: Engine, options?: SceneOptions);
  100534. /**
  100535. * Gets a string idenfifying the name of the class
  100536. * @returns "Scene" string
  100537. */
  100538. getClassName(): string;
  100539. private _defaultMeshCandidates;
  100540. /**
  100541. * @hidden
  100542. */
  100543. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100544. private _defaultSubMeshCandidates;
  100545. /**
  100546. * @hidden
  100547. */
  100548. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100549. /**
  100550. * Sets the default candidate providers for the scene.
  100551. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100552. * and getCollidingSubMeshCandidates to their default function
  100553. */
  100554. setDefaultCandidateProviders(): void;
  100555. /**
  100556. * Gets the mesh that is currently under the pointer
  100557. */
  100558. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100559. /**
  100560. * Gets or sets the current on-screen X position of the pointer
  100561. */
  100562. pointerX: number;
  100563. /**
  100564. * Gets or sets the current on-screen Y position of the pointer
  100565. */
  100566. pointerY: number;
  100567. /**
  100568. * Gets the cached material (ie. the latest rendered one)
  100569. * @returns the cached material
  100570. */
  100571. getCachedMaterial(): Nullable<Material>;
  100572. /**
  100573. * Gets the cached effect (ie. the latest rendered one)
  100574. * @returns the cached effect
  100575. */
  100576. getCachedEffect(): Nullable<Effect>;
  100577. /**
  100578. * Gets the cached visibility state (ie. the latest rendered one)
  100579. * @returns the cached visibility state
  100580. */
  100581. getCachedVisibility(): Nullable<number>;
  100582. /**
  100583. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100584. * @param material defines the current material
  100585. * @param effect defines the current effect
  100586. * @param visibility defines the current visibility state
  100587. * @returns true if one parameter is not cached
  100588. */
  100589. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100590. /**
  100591. * Gets the engine associated with the scene
  100592. * @returns an Engine
  100593. */
  100594. getEngine(): Engine;
  100595. /**
  100596. * Gets the total number of vertices rendered per frame
  100597. * @returns the total number of vertices rendered per frame
  100598. */
  100599. getTotalVertices(): number;
  100600. /**
  100601. * Gets the performance counter for total vertices
  100602. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100603. */
  100604. readonly totalVerticesPerfCounter: PerfCounter;
  100605. /**
  100606. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100607. * @returns the total number of active indices rendered per frame
  100608. */
  100609. getActiveIndices(): number;
  100610. /**
  100611. * Gets the performance counter for active indices
  100612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100613. */
  100614. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100615. /**
  100616. * Gets the total number of active particles rendered per frame
  100617. * @returns the total number of active particles rendered per frame
  100618. */
  100619. getActiveParticles(): number;
  100620. /**
  100621. * Gets the performance counter for active particles
  100622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100623. */
  100624. readonly activeParticlesPerfCounter: PerfCounter;
  100625. /**
  100626. * Gets the total number of active bones rendered per frame
  100627. * @returns the total number of active bones rendered per frame
  100628. */
  100629. getActiveBones(): number;
  100630. /**
  100631. * Gets the performance counter for active bones
  100632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100633. */
  100634. readonly activeBonesPerfCounter: PerfCounter;
  100635. /**
  100636. * Gets the array of active meshes
  100637. * @returns an array of AbstractMesh
  100638. */
  100639. getActiveMeshes(): SmartArray<AbstractMesh>;
  100640. /**
  100641. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100642. * @returns a number
  100643. */
  100644. getAnimationRatio(): number;
  100645. /**
  100646. * Gets an unique Id for the current render phase
  100647. * @returns a number
  100648. */
  100649. getRenderId(): number;
  100650. /**
  100651. * Gets an unique Id for the current frame
  100652. * @returns a number
  100653. */
  100654. getFrameId(): number;
  100655. /** Call this function if you want to manually increment the render Id*/
  100656. incrementRenderId(): void;
  100657. private _createUbo;
  100658. /**
  100659. * Use this method to simulate a pointer move on a mesh
  100660. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100661. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100662. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100663. * @returns the current scene
  100664. */
  100665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100666. /**
  100667. * Use this method to simulate a pointer down on a mesh
  100668. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100669. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100670. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100671. * @returns the current scene
  100672. */
  100673. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100674. /**
  100675. * Use this method to simulate a pointer up on a mesh
  100676. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100677. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100678. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100679. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100680. * @returns the current scene
  100681. */
  100682. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100683. /**
  100684. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100685. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100686. * @returns true if the pointer was captured
  100687. */
  100688. isPointerCaptured(pointerId?: number): boolean;
  100689. /**
  100690. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100691. * @param attachUp defines if you want to attach events to pointerup
  100692. * @param attachDown defines if you want to attach events to pointerdown
  100693. * @param attachMove defines if you want to attach events to pointermove
  100694. */
  100695. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100696. /** Detaches all event handlers*/
  100697. detachControl(): void;
  100698. /**
  100699. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100700. * Delay loaded resources are not taking in account
  100701. * @return true if all required resources are ready
  100702. */
  100703. isReady(): boolean;
  100704. /** Resets all cached information relative to material (including effect and visibility) */
  100705. resetCachedMaterial(): void;
  100706. /**
  100707. * Registers a function to be called before every frame render
  100708. * @param func defines the function to register
  100709. */
  100710. registerBeforeRender(func: () => void): void;
  100711. /**
  100712. * Unregisters a function called before every frame render
  100713. * @param func defines the function to unregister
  100714. */
  100715. unregisterBeforeRender(func: () => void): void;
  100716. /**
  100717. * Registers a function to be called after every frame render
  100718. * @param func defines the function to register
  100719. */
  100720. registerAfterRender(func: () => void): void;
  100721. /**
  100722. * Unregisters a function called after every frame render
  100723. * @param func defines the function to unregister
  100724. */
  100725. unregisterAfterRender(func: () => void): void;
  100726. private _executeOnceBeforeRender;
  100727. /**
  100728. * The provided function will run before render once and will be disposed afterwards.
  100729. * A timeout delay can be provided so that the function will be executed in N ms.
  100730. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100731. * @param func The function to be executed.
  100732. * @param timeout optional delay in ms
  100733. */
  100734. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100735. /** @hidden */
  100736. _addPendingData(data: any): void;
  100737. /** @hidden */
  100738. _removePendingData(data: any): void;
  100739. /**
  100740. * Returns the number of items waiting to be loaded
  100741. * @returns the number of items waiting to be loaded
  100742. */
  100743. getWaitingItemsCount(): number;
  100744. /**
  100745. * Returns a boolean indicating if the scene is still loading data
  100746. */
  100747. readonly isLoading: boolean;
  100748. /**
  100749. * Registers a function to be executed when the scene is ready
  100750. * @param {Function} func - the function to be executed
  100751. */
  100752. executeWhenReady(func: () => void): void;
  100753. /**
  100754. * Returns a promise that resolves when the scene is ready
  100755. * @returns A promise that resolves when the scene is ready
  100756. */
  100757. whenReadyAsync(): Promise<void>;
  100758. /** @hidden */
  100759. _checkIsReady(): void;
  100760. /**
  100761. * Gets all animatable attached to the scene
  100762. */
  100763. readonly animatables: Animatable[];
  100764. /**
  100765. * Resets the last animation time frame.
  100766. * Useful to override when animations start running when loading a scene for the first time.
  100767. */
  100768. resetLastAnimationTimeFrame(): void;
  100769. /**
  100770. * Gets the current view matrix
  100771. * @returns a Matrix
  100772. */
  100773. getViewMatrix(): Matrix;
  100774. /**
  100775. * Gets the current projection matrix
  100776. * @returns a Matrix
  100777. */
  100778. getProjectionMatrix(): Matrix;
  100779. /**
  100780. * Gets the current transform matrix
  100781. * @returns a Matrix made of View * Projection
  100782. */
  100783. getTransformMatrix(): Matrix;
  100784. /**
  100785. * Sets the current transform matrix
  100786. * @param viewL defines the View matrix to use
  100787. * @param projectionL defines the Projection matrix to use
  100788. * @param viewR defines the right View matrix to use (if provided)
  100789. * @param projectionR defines the right Projection matrix to use (if provided)
  100790. */
  100791. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100792. /**
  100793. * Gets the uniform buffer used to store scene data
  100794. * @returns a UniformBuffer
  100795. */
  100796. getSceneUniformBuffer(): UniformBuffer;
  100797. /**
  100798. * Gets an unique (relatively to the current scene) Id
  100799. * @returns an unique number for the scene
  100800. */
  100801. getUniqueId(): number;
  100802. /**
  100803. * Add a mesh to the list of scene's meshes
  100804. * @param newMesh defines the mesh to add
  100805. * @param recursive if all child meshes should also be added to the scene
  100806. */
  100807. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100808. /**
  100809. * Remove a mesh for the list of scene's meshes
  100810. * @param toRemove defines the mesh to remove
  100811. * @param recursive if all child meshes should also be removed from the scene
  100812. * @returns the index where the mesh was in the mesh list
  100813. */
  100814. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100815. /**
  100816. * Add a transform node to the list of scene's transform nodes
  100817. * @param newTransformNode defines the transform node to add
  100818. */
  100819. addTransformNode(newTransformNode: TransformNode): void;
  100820. /**
  100821. * Remove a transform node for the list of scene's transform nodes
  100822. * @param toRemove defines the transform node to remove
  100823. * @returns the index where the transform node was in the transform node list
  100824. */
  100825. removeTransformNode(toRemove: TransformNode): number;
  100826. /**
  100827. * Remove a skeleton for the list of scene's skeletons
  100828. * @param toRemove defines the skeleton to remove
  100829. * @returns the index where the skeleton was in the skeleton list
  100830. */
  100831. removeSkeleton(toRemove: Skeleton): number;
  100832. /**
  100833. * Remove a morph target for the list of scene's morph targets
  100834. * @param toRemove defines the morph target to remove
  100835. * @returns the index where the morph target was in the morph target list
  100836. */
  100837. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100838. /**
  100839. * Remove a light for the list of scene's lights
  100840. * @param toRemove defines the light to remove
  100841. * @returns the index where the light was in the light list
  100842. */
  100843. removeLight(toRemove: Light): number;
  100844. /**
  100845. * Remove a camera for the list of scene's cameras
  100846. * @param toRemove defines the camera to remove
  100847. * @returns the index where the camera was in the camera list
  100848. */
  100849. removeCamera(toRemove: Camera): number;
  100850. /**
  100851. * Remove a particle system for the list of scene's particle systems
  100852. * @param toRemove defines the particle system to remove
  100853. * @returns the index where the particle system was in the particle system list
  100854. */
  100855. removeParticleSystem(toRemove: IParticleSystem): number;
  100856. /**
  100857. * Remove a animation for the list of scene's animations
  100858. * @param toRemove defines the animation to remove
  100859. * @returns the index where the animation was in the animation list
  100860. */
  100861. removeAnimation(toRemove: Animation): number;
  100862. /**
  100863. * Will stop the animation of the given target
  100864. * @param target - the target
  100865. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100866. * @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)
  100867. */
  100868. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100869. /**
  100870. * Removes the given animation group from this scene.
  100871. * @param toRemove The animation group to remove
  100872. * @returns The index of the removed animation group
  100873. */
  100874. removeAnimationGroup(toRemove: AnimationGroup): number;
  100875. /**
  100876. * Removes the given multi-material from this scene.
  100877. * @param toRemove The multi-material to remove
  100878. * @returns The index of the removed multi-material
  100879. */
  100880. removeMultiMaterial(toRemove: MultiMaterial): number;
  100881. /**
  100882. * Removes the given material from this scene.
  100883. * @param toRemove The material to remove
  100884. * @returns The index of the removed material
  100885. */
  100886. removeMaterial(toRemove: Material): number;
  100887. /**
  100888. * Removes the given action manager from this scene.
  100889. * @param toRemove The action manager to remove
  100890. * @returns The index of the removed action manager
  100891. */
  100892. removeActionManager(toRemove: AbstractActionManager): number;
  100893. /**
  100894. * Removes the given texture from this scene.
  100895. * @param toRemove The texture to remove
  100896. * @returns The index of the removed texture
  100897. */
  100898. removeTexture(toRemove: BaseTexture): number;
  100899. /**
  100900. * Adds the given light to this scene
  100901. * @param newLight The light to add
  100902. */
  100903. addLight(newLight: Light): void;
  100904. /**
  100905. * Sorts the list list based on light priorities
  100906. */
  100907. sortLightsByPriority(): void;
  100908. /**
  100909. * Adds the given camera to this scene
  100910. * @param newCamera The camera to add
  100911. */
  100912. addCamera(newCamera: Camera): void;
  100913. /**
  100914. * Adds the given skeleton to this scene
  100915. * @param newSkeleton The skeleton to add
  100916. */
  100917. addSkeleton(newSkeleton: Skeleton): void;
  100918. /**
  100919. * Adds the given particle system to this scene
  100920. * @param newParticleSystem The particle system to add
  100921. */
  100922. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100923. /**
  100924. * Adds the given animation to this scene
  100925. * @param newAnimation The animation to add
  100926. */
  100927. addAnimation(newAnimation: Animation): void;
  100928. /**
  100929. * Adds the given animation group to this scene.
  100930. * @param newAnimationGroup The animation group to add
  100931. */
  100932. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100933. /**
  100934. * Adds the given multi-material to this scene
  100935. * @param newMultiMaterial The multi-material to add
  100936. */
  100937. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100938. /**
  100939. * Adds the given material to this scene
  100940. * @param newMaterial The material to add
  100941. */
  100942. addMaterial(newMaterial: Material): void;
  100943. /**
  100944. * Adds the given morph target to this scene
  100945. * @param newMorphTargetManager The morph target to add
  100946. */
  100947. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100948. /**
  100949. * Adds the given geometry to this scene
  100950. * @param newGeometry The geometry to add
  100951. */
  100952. addGeometry(newGeometry: Geometry): void;
  100953. /**
  100954. * Adds the given action manager to this scene
  100955. * @param newActionManager The action manager to add
  100956. */
  100957. addActionManager(newActionManager: AbstractActionManager): void;
  100958. /**
  100959. * Adds the given texture to this scene.
  100960. * @param newTexture The texture to add
  100961. */
  100962. addTexture(newTexture: BaseTexture): void;
  100963. /**
  100964. * Switch active camera
  100965. * @param newCamera defines the new active camera
  100966. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100967. */
  100968. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100969. /**
  100970. * sets the active camera of the scene using its ID
  100971. * @param id defines the camera's ID
  100972. * @return the new active camera or null if none found.
  100973. */
  100974. setActiveCameraByID(id: string): Nullable<Camera>;
  100975. /**
  100976. * sets the active camera of the scene using its name
  100977. * @param name defines the camera's name
  100978. * @returns the new active camera or null if none found.
  100979. */
  100980. setActiveCameraByName(name: string): Nullable<Camera>;
  100981. /**
  100982. * get an animation group using its name
  100983. * @param name defines the material's name
  100984. * @return the animation group or null if none found.
  100985. */
  100986. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100987. /**
  100988. * Get a material using its unique id
  100989. * @param uniqueId defines the material's unique id
  100990. * @return the material or null if none found.
  100991. */
  100992. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100993. /**
  100994. * get a material using its id
  100995. * @param id defines the material's ID
  100996. * @return the material or null if none found.
  100997. */
  100998. getMaterialByID(id: string): Nullable<Material>;
  100999. /**
  101000. * Gets a the last added material using a given id
  101001. * @param id defines the material's ID
  101002. * @return the last material with the given id or null if none found.
  101003. */
  101004. getLastMaterialByID(id: string): Nullable<Material>;
  101005. /**
  101006. * Gets a material using its name
  101007. * @param name defines the material's name
  101008. * @return the material or null if none found.
  101009. */
  101010. getMaterialByName(name: string): Nullable<Material>;
  101011. /**
  101012. * Get a texture using its unique id
  101013. * @param uniqueId defines the texture's unique id
  101014. * @return the texture or null if none found.
  101015. */
  101016. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101017. /**
  101018. * Gets a camera using its id
  101019. * @param id defines the id to look for
  101020. * @returns the camera or null if not found
  101021. */
  101022. getCameraByID(id: string): Nullable<Camera>;
  101023. /**
  101024. * Gets a camera using its unique id
  101025. * @param uniqueId defines the unique id to look for
  101026. * @returns the camera or null if not found
  101027. */
  101028. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101029. /**
  101030. * Gets a camera using its name
  101031. * @param name defines the camera's name
  101032. * @return the camera or null if none found.
  101033. */
  101034. getCameraByName(name: string): Nullable<Camera>;
  101035. /**
  101036. * Gets a bone using its id
  101037. * @param id defines the bone's id
  101038. * @return the bone or null if not found
  101039. */
  101040. getBoneByID(id: string): Nullable<Bone>;
  101041. /**
  101042. * Gets a bone using its id
  101043. * @param name defines the bone's name
  101044. * @return the bone or null if not found
  101045. */
  101046. getBoneByName(name: string): Nullable<Bone>;
  101047. /**
  101048. * Gets a light node using its name
  101049. * @param name defines the the light's name
  101050. * @return the light or null if none found.
  101051. */
  101052. getLightByName(name: string): Nullable<Light>;
  101053. /**
  101054. * Gets a light node using its id
  101055. * @param id defines the light's id
  101056. * @return the light or null if none found.
  101057. */
  101058. getLightByID(id: string): Nullable<Light>;
  101059. /**
  101060. * Gets a light node using its scene-generated unique ID
  101061. * @param uniqueId defines the light's unique id
  101062. * @return the light or null if none found.
  101063. */
  101064. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101065. /**
  101066. * Gets a particle system by id
  101067. * @param id defines the particle system id
  101068. * @return the corresponding system or null if none found
  101069. */
  101070. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101071. /**
  101072. * Gets a geometry using its ID
  101073. * @param id defines the geometry's id
  101074. * @return the geometry or null if none found.
  101075. */
  101076. getGeometryByID(id: string): Nullable<Geometry>;
  101077. private _getGeometryByUniqueID;
  101078. /**
  101079. * Add a new geometry to this scene
  101080. * @param geometry defines the geometry to be added to the scene.
  101081. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101082. * @return a boolean defining if the geometry was added or not
  101083. */
  101084. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101085. /**
  101086. * Removes an existing geometry
  101087. * @param geometry defines the geometry to be removed from the scene
  101088. * @return a boolean defining if the geometry was removed or not
  101089. */
  101090. removeGeometry(geometry: Geometry): boolean;
  101091. /**
  101092. * Gets the list of geometries attached to the scene
  101093. * @returns an array of Geometry
  101094. */
  101095. getGeometries(): Geometry[];
  101096. /**
  101097. * Gets the first added mesh found of a given ID
  101098. * @param id defines the id to search for
  101099. * @return the mesh found or null if not found at all
  101100. */
  101101. getMeshByID(id: string): Nullable<AbstractMesh>;
  101102. /**
  101103. * Gets a list of meshes using their id
  101104. * @param id defines the id to search for
  101105. * @returns a list of meshes
  101106. */
  101107. getMeshesByID(id: string): Array<AbstractMesh>;
  101108. /**
  101109. * Gets the first added transform node found of a given ID
  101110. * @param id defines the id to search for
  101111. * @return the found transform node or null if not found at all.
  101112. */
  101113. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101114. /**
  101115. * Gets a transform node with its auto-generated unique id
  101116. * @param uniqueId efines the unique id to search for
  101117. * @return the found transform node or null if not found at all.
  101118. */
  101119. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101120. /**
  101121. * Gets a list of transform nodes using their id
  101122. * @param id defines the id to search for
  101123. * @returns a list of transform nodes
  101124. */
  101125. getTransformNodesByID(id: string): Array<TransformNode>;
  101126. /**
  101127. * Gets a mesh with its auto-generated unique id
  101128. * @param uniqueId defines the unique id to search for
  101129. * @return the found mesh or null if not found at all.
  101130. */
  101131. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101132. /**
  101133. * Gets a the last added mesh using a given id
  101134. * @param id defines the id to search for
  101135. * @return the found mesh or null if not found at all.
  101136. */
  101137. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101138. /**
  101139. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101140. * @param id defines the id to search for
  101141. * @return the found node or null if not found at all
  101142. */
  101143. getLastEntryByID(id: string): Nullable<Node>;
  101144. /**
  101145. * Gets a node (Mesh, Camera, Light) using a given id
  101146. * @param id defines the id to search for
  101147. * @return the found node or null if not found at all
  101148. */
  101149. getNodeByID(id: string): Nullable<Node>;
  101150. /**
  101151. * Gets a node (Mesh, Camera, Light) using a given name
  101152. * @param name defines the name to search for
  101153. * @return the found node or null if not found at all.
  101154. */
  101155. getNodeByName(name: string): Nullable<Node>;
  101156. /**
  101157. * Gets a mesh using a given name
  101158. * @param name defines the name to search for
  101159. * @return the found mesh or null if not found at all.
  101160. */
  101161. getMeshByName(name: string): Nullable<AbstractMesh>;
  101162. /**
  101163. * Gets a transform node using a given name
  101164. * @param name defines the name to search for
  101165. * @return the found transform node or null if not found at all.
  101166. */
  101167. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101168. /**
  101169. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101170. * @param id defines the id to search for
  101171. * @return the found skeleton or null if not found at all.
  101172. */
  101173. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101174. /**
  101175. * Gets a skeleton using a given auto generated unique id
  101176. * @param uniqueId defines the unique id to search for
  101177. * @return the found skeleton or null if not found at all.
  101178. */
  101179. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101180. /**
  101181. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101182. * @param id defines the id to search for
  101183. * @return the found skeleton or null if not found at all.
  101184. */
  101185. getSkeletonById(id: string): Nullable<Skeleton>;
  101186. /**
  101187. * Gets a skeleton using a given name
  101188. * @param name defines the name to search for
  101189. * @return the found skeleton or null if not found at all.
  101190. */
  101191. getSkeletonByName(name: string): Nullable<Skeleton>;
  101192. /**
  101193. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101194. * @param id defines the id to search for
  101195. * @return the found morph target manager or null if not found at all.
  101196. */
  101197. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101198. /**
  101199. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101200. * @param id defines the id to search for
  101201. * @return the found morph target or null if not found at all.
  101202. */
  101203. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101204. /**
  101205. * Gets a boolean indicating if the given mesh is active
  101206. * @param mesh defines the mesh to look for
  101207. * @returns true if the mesh is in the active list
  101208. */
  101209. isActiveMesh(mesh: AbstractMesh): boolean;
  101210. /**
  101211. * Return a unique id as a string which can serve as an identifier for the scene
  101212. */
  101213. readonly uid: string;
  101214. /**
  101215. * Add an externaly attached data from its key.
  101216. * This method call will fail and return false, if such key already exists.
  101217. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101218. * @param key the unique key that identifies the data
  101219. * @param data the data object to associate to the key for this Engine instance
  101220. * @return true if no such key were already present and the data was added successfully, false otherwise
  101221. */
  101222. addExternalData<T>(key: string, data: T): boolean;
  101223. /**
  101224. * Get an externaly attached data from its key
  101225. * @param key the unique key that identifies the data
  101226. * @return the associated data, if present (can be null), or undefined if not present
  101227. */
  101228. getExternalData<T>(key: string): Nullable<T>;
  101229. /**
  101230. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101231. * @param key the unique key that identifies the data
  101232. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101233. * @return the associated data, can be null if the factory returned null.
  101234. */
  101235. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101236. /**
  101237. * Remove an externaly attached data from the Engine instance
  101238. * @param key the unique key that identifies the data
  101239. * @return true if the data was successfully removed, false if it doesn't exist
  101240. */
  101241. removeExternalData(key: string): boolean;
  101242. private _evaluateSubMesh;
  101243. /**
  101244. * Clear the processed materials smart array preventing retention point in material dispose.
  101245. */
  101246. freeProcessedMaterials(): void;
  101247. private _preventFreeActiveMeshesAndRenderingGroups;
  101248. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101249. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101250. * when disposing several meshes in a row or a hierarchy of meshes.
  101251. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101252. */
  101253. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101254. /**
  101255. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101256. */
  101257. freeActiveMeshes(): void;
  101258. /**
  101259. * Clear the info related to rendering groups preventing retention points during dispose.
  101260. */
  101261. freeRenderingGroups(): void;
  101262. /** @hidden */
  101263. _isInIntermediateRendering(): boolean;
  101264. /**
  101265. * Lambda returning the list of potentially active meshes.
  101266. */
  101267. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101268. /**
  101269. * Lambda returning the list of potentially active sub meshes.
  101270. */
  101271. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101272. /**
  101273. * Lambda returning the list of potentially intersecting sub meshes.
  101274. */
  101275. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101276. /**
  101277. * Lambda returning the list of potentially colliding sub meshes.
  101278. */
  101279. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101280. private _activeMeshesFrozen;
  101281. /**
  101282. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101283. * @returns the current scene
  101284. */
  101285. freezeActiveMeshes(): Scene;
  101286. /**
  101287. * Use this function to restart evaluating active meshes on every frame
  101288. * @returns the current scene
  101289. */
  101290. unfreezeActiveMeshes(): Scene;
  101291. private _evaluateActiveMeshes;
  101292. private _activeMesh;
  101293. /**
  101294. * Update the transform matrix to update from the current active camera
  101295. * @param force defines a boolean used to force the update even if cache is up to date
  101296. */
  101297. updateTransformMatrix(force?: boolean): void;
  101298. private _bindFrameBuffer;
  101299. /** @hidden */
  101300. _allowPostProcessClearColor: boolean;
  101301. /** @hidden */
  101302. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101303. private _processSubCameras;
  101304. private _checkIntersections;
  101305. /** @hidden */
  101306. _advancePhysicsEngineStep(step: number): void;
  101307. /**
  101308. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101309. */
  101310. getDeterministicFrameTime: () => number;
  101311. /** @hidden */
  101312. _animate(): void;
  101313. /** Execute all animations (for a frame) */
  101314. animate(): void;
  101315. /**
  101316. * Render the scene
  101317. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101318. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101319. */
  101320. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101321. /**
  101322. * Freeze all materials
  101323. * A frozen material will not be updatable but should be faster to render
  101324. */
  101325. freezeMaterials(): void;
  101326. /**
  101327. * Unfreeze all materials
  101328. * A frozen material will not be updatable but should be faster to render
  101329. */
  101330. unfreezeMaterials(): void;
  101331. /**
  101332. * Releases all held ressources
  101333. */
  101334. dispose(): void;
  101335. /**
  101336. * Gets if the scene is already disposed
  101337. */
  101338. readonly isDisposed: boolean;
  101339. /**
  101340. * Call this function to reduce memory footprint of the scene.
  101341. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101342. */
  101343. clearCachedVertexData(): void;
  101344. /**
  101345. * This function will remove the local cached buffer data from texture.
  101346. * It will save memory but will prevent the texture from being rebuilt
  101347. */
  101348. cleanCachedTextureBuffer(): void;
  101349. /**
  101350. * Get the world extend vectors with an optional filter
  101351. *
  101352. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101353. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101354. */
  101355. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101356. min: Vector3;
  101357. max: Vector3;
  101358. };
  101359. /**
  101360. * Creates a ray that can be used to pick in the scene
  101361. * @param x defines the x coordinate of the origin (on-screen)
  101362. * @param y defines the y coordinate of the origin (on-screen)
  101363. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101364. * @param camera defines the camera to use for the picking
  101365. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101366. * @returns a Ray
  101367. */
  101368. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101369. /**
  101370. * Creates a ray that can be used to pick in the scene
  101371. * @param x defines the x coordinate of the origin (on-screen)
  101372. * @param y defines the y coordinate of the origin (on-screen)
  101373. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101374. * @param result defines the ray where to store the picking ray
  101375. * @param camera defines the camera to use for the picking
  101376. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101377. * @returns the current scene
  101378. */
  101379. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101380. /**
  101381. * Creates a ray that can be used to pick in the scene
  101382. * @param x defines the x coordinate of the origin (on-screen)
  101383. * @param y defines the y coordinate of the origin (on-screen)
  101384. * @param camera defines the camera to use for the picking
  101385. * @returns a Ray
  101386. */
  101387. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101388. /**
  101389. * Creates a ray that can be used to pick in the scene
  101390. * @param x defines the x coordinate of the origin (on-screen)
  101391. * @param y defines the y coordinate of the origin (on-screen)
  101392. * @param result defines the ray where to store the picking ray
  101393. * @param camera defines the camera to use for the picking
  101394. * @returns the current scene
  101395. */
  101396. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101397. /** Launch a ray to try to pick a mesh in the scene
  101398. * @param x position on screen
  101399. * @param y position on screen
  101400. * @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
  101401. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101402. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101404. * @returns a PickingInfo
  101405. */
  101406. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101407. /** Use the given ray to pick a mesh in the scene
  101408. * @param ray The ray to use to pick meshes
  101409. * @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
  101410. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101412. * @returns a PickingInfo
  101413. */
  101414. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101415. /**
  101416. * Launch a ray to try to pick a mesh in the scene
  101417. * @param x X position on screen
  101418. * @param y Y position on screen
  101419. * @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
  101420. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101421. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101422. * @returns an array of PickingInfo
  101423. */
  101424. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101425. /**
  101426. * Launch a ray to try to pick a mesh in the scene
  101427. * @param ray Ray to use
  101428. * @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
  101429. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101430. * @returns an array of PickingInfo
  101431. */
  101432. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101433. /**
  101434. * Force the value of meshUnderPointer
  101435. * @param mesh defines the mesh to use
  101436. */
  101437. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101438. /**
  101439. * Gets the mesh under the pointer
  101440. * @returns a Mesh or null if no mesh is under the pointer
  101441. */
  101442. getPointerOverMesh(): Nullable<AbstractMesh>;
  101443. /** @hidden */
  101444. _rebuildGeometries(): void;
  101445. /** @hidden */
  101446. _rebuildTextures(): void;
  101447. private _getByTags;
  101448. /**
  101449. * Get a list of meshes by tags
  101450. * @param tagsQuery defines the tags query to use
  101451. * @param forEach defines a predicate used to filter results
  101452. * @returns an array of Mesh
  101453. */
  101454. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101455. /**
  101456. * Get a list of cameras by tags
  101457. * @param tagsQuery defines the tags query to use
  101458. * @param forEach defines a predicate used to filter results
  101459. * @returns an array of Camera
  101460. */
  101461. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101462. /**
  101463. * Get a list of lights by tags
  101464. * @param tagsQuery defines the tags query to use
  101465. * @param forEach defines a predicate used to filter results
  101466. * @returns an array of Light
  101467. */
  101468. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101469. /**
  101470. * Get a list of materials by tags
  101471. * @param tagsQuery defines the tags query to use
  101472. * @param forEach defines a predicate used to filter results
  101473. * @returns an array of Material
  101474. */
  101475. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101476. /**
  101477. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101478. * This allowed control for front to back rendering or reversly depending of the special needs.
  101479. *
  101480. * @param renderingGroupId The rendering group id corresponding to its index
  101481. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101482. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101483. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101484. */
  101485. 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;
  101486. /**
  101487. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101488. *
  101489. * @param renderingGroupId The rendering group id corresponding to its index
  101490. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101491. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101492. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101493. */
  101494. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101495. /**
  101496. * Gets the current auto clear configuration for one rendering group of the rendering
  101497. * manager.
  101498. * @param index the rendering group index to get the information for
  101499. * @returns The auto clear setup for the requested rendering group
  101500. */
  101501. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101502. private _blockMaterialDirtyMechanism;
  101503. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101504. blockMaterialDirtyMechanism: boolean;
  101505. /**
  101506. * Will flag all materials as dirty to trigger new shader compilation
  101507. * @param flag defines the flag used to specify which material part must be marked as dirty
  101508. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101509. */
  101510. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101511. /** @hidden */
  101512. _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;
  101513. /** @hidden */
  101514. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101515. }
  101516. }
  101517. declare module BABYLON {
  101518. /**
  101519. * Set of assets to keep when moving a scene into an asset container.
  101520. */
  101521. export class KeepAssets extends AbstractScene {
  101522. }
  101523. /**
  101524. * Container with a set of assets that can be added or removed from a scene.
  101525. */
  101526. export class AssetContainer extends AbstractScene {
  101527. /**
  101528. * The scene the AssetContainer belongs to.
  101529. */
  101530. scene: Scene;
  101531. /**
  101532. * Instantiates an AssetContainer.
  101533. * @param scene The scene the AssetContainer belongs to.
  101534. */
  101535. constructor(scene: Scene);
  101536. /**
  101537. * Adds all the assets from the container to the scene.
  101538. */
  101539. addAllToScene(): void;
  101540. /**
  101541. * Removes all the assets in the container from the scene
  101542. */
  101543. removeAllFromScene(): void;
  101544. /**
  101545. * Disposes all the assets in the container
  101546. */
  101547. dispose(): void;
  101548. private _moveAssets;
  101549. /**
  101550. * Removes all the assets contained in the scene and adds them to the container.
  101551. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101552. */
  101553. moveAllFromScene(keepAssets?: KeepAssets): void;
  101554. /**
  101555. * 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.
  101556. * @returns the root mesh
  101557. */
  101558. createRootMesh(): Mesh;
  101559. }
  101560. }
  101561. declare module BABYLON {
  101562. /**
  101563. * Defines how the parser contract is defined.
  101564. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101565. */
  101566. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101567. /**
  101568. * Defines how the individual parser contract is defined.
  101569. * These parser can parse an individual asset
  101570. */
  101571. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101572. /**
  101573. * Base class of the scene acting as a container for the different elements composing a scene.
  101574. * This class is dynamically extended by the different components of the scene increasing
  101575. * flexibility and reducing coupling
  101576. */
  101577. export abstract class AbstractScene {
  101578. /**
  101579. * Stores the list of available parsers in the application.
  101580. */
  101581. private static _BabylonFileParsers;
  101582. /**
  101583. * Stores the list of available individual parsers in the application.
  101584. */
  101585. private static _IndividualBabylonFileParsers;
  101586. /**
  101587. * Adds a parser in the list of available ones
  101588. * @param name Defines the name of the parser
  101589. * @param parser Defines the parser to add
  101590. */
  101591. static AddParser(name: string, parser: BabylonFileParser): void;
  101592. /**
  101593. * Gets a general parser from the list of avaialble ones
  101594. * @param name Defines the name of the parser
  101595. * @returns the requested parser or null
  101596. */
  101597. static GetParser(name: string): Nullable<BabylonFileParser>;
  101598. /**
  101599. * Adds n individual parser in the list of available ones
  101600. * @param name Defines the name of the parser
  101601. * @param parser Defines the parser to add
  101602. */
  101603. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101604. /**
  101605. * Gets an individual parser from the list of avaialble ones
  101606. * @param name Defines the name of the parser
  101607. * @returns the requested parser or null
  101608. */
  101609. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101610. /**
  101611. * Parser json data and populate both a scene and its associated container object
  101612. * @param jsonData Defines the data to parse
  101613. * @param scene Defines the scene to parse the data for
  101614. * @param container Defines the container attached to the parsing sequence
  101615. * @param rootUrl Defines the root url of the data
  101616. */
  101617. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101618. /**
  101619. * Gets the list of root nodes (ie. nodes with no parent)
  101620. */
  101621. rootNodes: Node[];
  101622. /** All of the cameras added to this scene
  101623. * @see http://doc.babylonjs.com/babylon101/cameras
  101624. */
  101625. cameras: Camera[];
  101626. /**
  101627. * All of the lights added to this scene
  101628. * @see http://doc.babylonjs.com/babylon101/lights
  101629. */
  101630. lights: Light[];
  101631. /**
  101632. * All of the (abstract) meshes added to this scene
  101633. */
  101634. meshes: AbstractMesh[];
  101635. /**
  101636. * The list of skeletons added to the scene
  101637. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101638. */
  101639. skeletons: Skeleton[];
  101640. /**
  101641. * All of the particle systems added to this scene
  101642. * @see http://doc.babylonjs.com/babylon101/particles
  101643. */
  101644. particleSystems: IParticleSystem[];
  101645. /**
  101646. * Gets a list of Animations associated with the scene
  101647. */
  101648. animations: Animation[];
  101649. /**
  101650. * All of the animation groups added to this scene
  101651. * @see http://doc.babylonjs.com/how_to/group
  101652. */
  101653. animationGroups: AnimationGroup[];
  101654. /**
  101655. * All of the multi-materials added to this scene
  101656. * @see http://doc.babylonjs.com/how_to/multi_materials
  101657. */
  101658. multiMaterials: MultiMaterial[];
  101659. /**
  101660. * All of the materials added to this scene
  101661. * In the context of a Scene, it is not supposed to be modified manually.
  101662. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101663. * Note also that the order of the Material wihin the array is not significant and might change.
  101664. * @see http://doc.babylonjs.com/babylon101/materials
  101665. */
  101666. materials: Material[];
  101667. /**
  101668. * The list of morph target managers added to the scene
  101669. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101670. */
  101671. morphTargetManagers: MorphTargetManager[];
  101672. /**
  101673. * The list of geometries used in the scene.
  101674. */
  101675. geometries: Geometry[];
  101676. /**
  101677. * All of the tranform nodes added to this scene
  101678. * In the context of a Scene, it is not supposed to be modified manually.
  101679. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101680. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101681. * @see http://doc.babylonjs.com/how_to/transformnode
  101682. */
  101683. transformNodes: TransformNode[];
  101684. /**
  101685. * ActionManagers available on the scene.
  101686. */
  101687. actionManagers: AbstractActionManager[];
  101688. /**
  101689. * Textures to keep.
  101690. */
  101691. textures: BaseTexture[];
  101692. /**
  101693. * Environment texture for the scene
  101694. */
  101695. environmentTexture: Nullable<BaseTexture>;
  101696. }
  101697. }
  101698. declare module BABYLON {
  101699. /**
  101700. * Interface used to define options for Sound class
  101701. */
  101702. export interface ISoundOptions {
  101703. /**
  101704. * Does the sound autoplay once loaded.
  101705. */
  101706. autoplay?: boolean;
  101707. /**
  101708. * Does the sound loop after it finishes playing once.
  101709. */
  101710. loop?: boolean;
  101711. /**
  101712. * Sound's volume
  101713. */
  101714. volume?: number;
  101715. /**
  101716. * Is it a spatial sound?
  101717. */
  101718. spatialSound?: boolean;
  101719. /**
  101720. * Maximum distance to hear that sound
  101721. */
  101722. maxDistance?: number;
  101723. /**
  101724. * Uses user defined attenuation function
  101725. */
  101726. useCustomAttenuation?: boolean;
  101727. /**
  101728. * Define the roll off factor of spatial sounds.
  101729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101730. */
  101731. rolloffFactor?: number;
  101732. /**
  101733. * Define the reference distance the sound should be heard perfectly.
  101734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101735. */
  101736. refDistance?: number;
  101737. /**
  101738. * Define the distance attenuation model the sound will follow.
  101739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101740. */
  101741. distanceModel?: string;
  101742. /**
  101743. * Defines the playback speed (1 by default)
  101744. */
  101745. playbackRate?: number;
  101746. /**
  101747. * Defines if the sound is from a streaming source
  101748. */
  101749. streaming?: boolean;
  101750. /**
  101751. * Defines an optional length (in seconds) inside the sound file
  101752. */
  101753. length?: number;
  101754. /**
  101755. * Defines an optional offset (in seconds) inside the sound file
  101756. */
  101757. offset?: number;
  101758. /**
  101759. * If true, URLs will not be required to state the audio file codec to use.
  101760. */
  101761. skipCodecCheck?: boolean;
  101762. }
  101763. /**
  101764. * Defines a sound that can be played in the application.
  101765. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101767. */
  101768. export class Sound {
  101769. /**
  101770. * The name of the sound in the scene.
  101771. */
  101772. name: string;
  101773. /**
  101774. * Does the sound autoplay once loaded.
  101775. */
  101776. autoplay: boolean;
  101777. /**
  101778. * Does the sound loop after it finishes playing once.
  101779. */
  101780. loop: boolean;
  101781. /**
  101782. * Does the sound use a custom attenuation curve to simulate the falloff
  101783. * happening when the source gets further away from the camera.
  101784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101785. */
  101786. useCustomAttenuation: boolean;
  101787. /**
  101788. * The sound track id this sound belongs to.
  101789. */
  101790. soundTrackId: number;
  101791. /**
  101792. * Is this sound currently played.
  101793. */
  101794. isPlaying: boolean;
  101795. /**
  101796. * Is this sound currently paused.
  101797. */
  101798. isPaused: boolean;
  101799. /**
  101800. * Does this sound enables spatial sound.
  101801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101802. */
  101803. spatialSound: boolean;
  101804. /**
  101805. * Define the reference distance the sound should be heard perfectly.
  101806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101807. */
  101808. refDistance: number;
  101809. /**
  101810. * Define the roll off factor of spatial sounds.
  101811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101812. */
  101813. rolloffFactor: number;
  101814. /**
  101815. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101817. */
  101818. maxDistance: number;
  101819. /**
  101820. * Define the distance attenuation model the sound will follow.
  101821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101822. */
  101823. distanceModel: string;
  101824. /**
  101825. * @hidden
  101826. * Back Compat
  101827. **/
  101828. onended: () => any;
  101829. /**
  101830. * Observable event when the current playing sound finishes.
  101831. */
  101832. onEndedObservable: Observable<Sound>;
  101833. private _panningModel;
  101834. private _playbackRate;
  101835. private _streaming;
  101836. private _startTime;
  101837. private _startOffset;
  101838. private _position;
  101839. /** @hidden */
  101840. _positionInEmitterSpace: boolean;
  101841. private _localDirection;
  101842. private _volume;
  101843. private _isReadyToPlay;
  101844. private _isDirectional;
  101845. private _readyToPlayCallback;
  101846. private _audioBuffer;
  101847. private _soundSource;
  101848. private _streamingSource;
  101849. private _soundPanner;
  101850. private _soundGain;
  101851. private _inputAudioNode;
  101852. private _outputAudioNode;
  101853. private _coneInnerAngle;
  101854. private _coneOuterAngle;
  101855. private _coneOuterGain;
  101856. private _scene;
  101857. private _connectedTransformNode;
  101858. private _customAttenuationFunction;
  101859. private _registerFunc;
  101860. private _isOutputConnected;
  101861. private _htmlAudioElement;
  101862. private _urlType;
  101863. private _length?;
  101864. private _offset?;
  101865. /** @hidden */
  101866. static _SceneComponentInitialization: (scene: Scene) => void;
  101867. /**
  101868. * Create a sound and attach it to a scene
  101869. * @param name Name of your sound
  101870. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101871. * @param scene defines the scene the sound belongs to
  101872. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101873. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101874. */
  101875. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101876. /**
  101877. * Release the sound and its associated resources
  101878. */
  101879. dispose(): void;
  101880. /**
  101881. * Gets if the sounds is ready to be played or not.
  101882. * @returns true if ready, otherwise false
  101883. */
  101884. isReady(): boolean;
  101885. private _soundLoaded;
  101886. /**
  101887. * Sets the data of the sound from an audiobuffer
  101888. * @param audioBuffer The audioBuffer containing the data
  101889. */
  101890. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101891. /**
  101892. * Updates the current sounds options such as maxdistance, loop...
  101893. * @param options A JSON object containing values named as the object properties
  101894. */
  101895. updateOptions(options: ISoundOptions): void;
  101896. private _createSpatialParameters;
  101897. private _updateSpatialParameters;
  101898. /**
  101899. * Switch the panning model to HRTF:
  101900. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101902. */
  101903. switchPanningModelToHRTF(): void;
  101904. /**
  101905. * Switch the panning model to Equal Power:
  101906. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101908. */
  101909. switchPanningModelToEqualPower(): void;
  101910. private _switchPanningModel;
  101911. /**
  101912. * Connect this sound to a sound track audio node like gain...
  101913. * @param soundTrackAudioNode the sound track audio node to connect to
  101914. */
  101915. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101916. /**
  101917. * Transform this sound into a directional source
  101918. * @param coneInnerAngle Size of the inner cone in degree
  101919. * @param coneOuterAngle Size of the outer cone in degree
  101920. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101921. */
  101922. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101923. /**
  101924. * Gets or sets the inner angle for the directional cone.
  101925. */
  101926. /**
  101927. * Gets or sets the inner angle for the directional cone.
  101928. */
  101929. directionalConeInnerAngle: number;
  101930. /**
  101931. * Gets or sets the outer angle for the directional cone.
  101932. */
  101933. /**
  101934. * Gets or sets the outer angle for the directional cone.
  101935. */
  101936. directionalConeOuterAngle: number;
  101937. /**
  101938. * Sets the position of the emitter if spatial sound is enabled
  101939. * @param newPosition Defines the new posisiton
  101940. */
  101941. setPosition(newPosition: Vector3): void;
  101942. /**
  101943. * Sets the local direction of the emitter if spatial sound is enabled
  101944. * @param newLocalDirection Defines the new local direction
  101945. */
  101946. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101947. private _updateDirection;
  101948. /** @hidden */
  101949. updateDistanceFromListener(): void;
  101950. /**
  101951. * Sets a new custom attenuation function for the sound.
  101952. * @param callback Defines the function used for the attenuation
  101953. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101954. */
  101955. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101956. /**
  101957. * Play the sound
  101958. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101959. * @param offset (optional) Start the sound at a specific time in seconds
  101960. * @param length (optional) Sound duration (in seconds)
  101961. */
  101962. play(time?: number, offset?: number, length?: number): void;
  101963. private _onended;
  101964. /**
  101965. * Stop the sound
  101966. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101967. */
  101968. stop(time?: number): void;
  101969. /**
  101970. * Put the sound in pause
  101971. */
  101972. pause(): void;
  101973. /**
  101974. * Sets a dedicated volume for this sounds
  101975. * @param newVolume Define the new volume of the sound
  101976. * @param time Define time for gradual change to new volume
  101977. */
  101978. setVolume(newVolume: number, time?: number): void;
  101979. /**
  101980. * Set the sound play back rate
  101981. * @param newPlaybackRate Define the playback rate the sound should be played at
  101982. */
  101983. setPlaybackRate(newPlaybackRate: number): void;
  101984. /**
  101985. * Gets the volume of the sound.
  101986. * @returns the volume of the sound
  101987. */
  101988. getVolume(): number;
  101989. /**
  101990. * Attach the sound to a dedicated mesh
  101991. * @param transformNode The transform node to connect the sound with
  101992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101993. */
  101994. attachToMesh(transformNode: TransformNode): void;
  101995. /**
  101996. * Detach the sound from the previously attached mesh
  101997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101998. */
  101999. detachFromMesh(): void;
  102000. private _onRegisterAfterWorldMatrixUpdate;
  102001. /**
  102002. * Clone the current sound in the scene.
  102003. * @returns the new sound clone
  102004. */
  102005. clone(): Nullable<Sound>;
  102006. /**
  102007. * Gets the current underlying audio buffer containing the data
  102008. * @returns the audio buffer
  102009. */
  102010. getAudioBuffer(): Nullable<AudioBuffer>;
  102011. /**
  102012. * Serializes the Sound in a JSON representation
  102013. * @returns the JSON representation of the sound
  102014. */
  102015. serialize(): any;
  102016. /**
  102017. * Parse a JSON representation of a sound to innstantiate in a given scene
  102018. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102019. * @param scene Define the scene the new parsed sound should be created in
  102020. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102021. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102022. * @returns the newly parsed sound
  102023. */
  102024. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102025. }
  102026. }
  102027. declare module BABYLON {
  102028. /**
  102029. * This defines an action helpful to play a defined sound on a triggered action.
  102030. */
  102031. export class PlaySoundAction extends Action {
  102032. private _sound;
  102033. /**
  102034. * Instantiate the action
  102035. * @param triggerOptions defines the trigger options
  102036. * @param sound defines the sound to play
  102037. * @param condition defines the trigger related conditions
  102038. */
  102039. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102040. /** @hidden */
  102041. _prepare(): void;
  102042. /**
  102043. * Execute the action and play the sound.
  102044. */
  102045. execute(): void;
  102046. /**
  102047. * Serializes the actions and its related information.
  102048. * @param parent defines the object to serialize in
  102049. * @returns the serialized object
  102050. */
  102051. serialize(parent: any): any;
  102052. }
  102053. /**
  102054. * This defines an action helpful to stop a defined sound on a triggered action.
  102055. */
  102056. export class StopSoundAction extends Action {
  102057. private _sound;
  102058. /**
  102059. * Instantiate the action
  102060. * @param triggerOptions defines the trigger options
  102061. * @param sound defines the sound to stop
  102062. * @param condition defines the trigger related conditions
  102063. */
  102064. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102065. /** @hidden */
  102066. _prepare(): void;
  102067. /**
  102068. * Execute the action and stop the sound.
  102069. */
  102070. execute(): void;
  102071. /**
  102072. * Serializes the actions and its related information.
  102073. * @param parent defines the object to serialize in
  102074. * @returns the serialized object
  102075. */
  102076. serialize(parent: any): any;
  102077. }
  102078. }
  102079. declare module BABYLON {
  102080. /**
  102081. * This defines an action responsible to change the value of a property
  102082. * by interpolating between its current value and the newly set one once triggered.
  102083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102084. */
  102085. export class InterpolateValueAction extends Action {
  102086. /**
  102087. * Defines the path of the property where the value should be interpolated
  102088. */
  102089. propertyPath: string;
  102090. /**
  102091. * Defines the target value at the end of the interpolation.
  102092. */
  102093. value: any;
  102094. /**
  102095. * Defines the time it will take for the property to interpolate to the value.
  102096. */
  102097. duration: number;
  102098. /**
  102099. * Defines if the other scene animations should be stopped when the action has been triggered
  102100. */
  102101. stopOtherAnimations?: boolean;
  102102. /**
  102103. * Defines a callback raised once the interpolation animation has been done.
  102104. */
  102105. onInterpolationDone?: () => void;
  102106. /**
  102107. * Observable triggered once the interpolation animation has been done.
  102108. */
  102109. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102110. private _target;
  102111. private _effectiveTarget;
  102112. private _property;
  102113. /**
  102114. * Instantiate the action
  102115. * @param triggerOptions defines the trigger options
  102116. * @param target defines the object containing the value to interpolate
  102117. * @param propertyPath defines the path to the property in the target object
  102118. * @param value defines the target value at the end of the interpolation
  102119. * @param duration deines the time it will take for the property to interpolate to the value.
  102120. * @param condition defines the trigger related conditions
  102121. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102122. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102123. */
  102124. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102125. /** @hidden */
  102126. _prepare(): void;
  102127. /**
  102128. * Execute the action starts the value interpolation.
  102129. */
  102130. execute(): void;
  102131. /**
  102132. * Serializes the actions and its related information.
  102133. * @param parent defines the object to serialize in
  102134. * @returns the serialized object
  102135. */
  102136. serialize(parent: any): any;
  102137. }
  102138. }
  102139. declare module BABYLON {
  102140. /**
  102141. * Options allowed during the creation of a sound track.
  102142. */
  102143. export interface ISoundTrackOptions {
  102144. /**
  102145. * The volume the sound track should take during creation
  102146. */
  102147. volume?: number;
  102148. /**
  102149. * Define if the sound track is the main sound track of the scene
  102150. */
  102151. mainTrack?: boolean;
  102152. }
  102153. /**
  102154. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102155. * It will be also used in a future release to apply effects on a specific track.
  102156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102157. */
  102158. export class SoundTrack {
  102159. /**
  102160. * The unique identifier of the sound track in the scene.
  102161. */
  102162. id: number;
  102163. /**
  102164. * The list of sounds included in the sound track.
  102165. */
  102166. soundCollection: Array<Sound>;
  102167. private _outputAudioNode;
  102168. private _scene;
  102169. private _isMainTrack;
  102170. private _connectedAnalyser;
  102171. private _options;
  102172. private _isInitialized;
  102173. /**
  102174. * Creates a new sound track.
  102175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102176. * @param scene Define the scene the sound track belongs to
  102177. * @param options
  102178. */
  102179. constructor(scene: Scene, options?: ISoundTrackOptions);
  102180. private _initializeSoundTrackAudioGraph;
  102181. /**
  102182. * Release the sound track and its associated resources
  102183. */
  102184. dispose(): void;
  102185. /**
  102186. * Adds a sound to this sound track
  102187. * @param sound define the cound to add
  102188. * @ignoreNaming
  102189. */
  102190. AddSound(sound: Sound): void;
  102191. /**
  102192. * Removes a sound to this sound track
  102193. * @param sound define the cound to remove
  102194. * @ignoreNaming
  102195. */
  102196. RemoveSound(sound: Sound): void;
  102197. /**
  102198. * Set a global volume for the full sound track.
  102199. * @param newVolume Define the new volume of the sound track
  102200. */
  102201. setVolume(newVolume: number): void;
  102202. /**
  102203. * Switch the panning model to HRTF:
  102204. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102206. */
  102207. switchPanningModelToHRTF(): void;
  102208. /**
  102209. * Switch the panning model to Equal Power:
  102210. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102212. */
  102213. switchPanningModelToEqualPower(): void;
  102214. /**
  102215. * Connect the sound track to an audio analyser allowing some amazing
  102216. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102218. * @param analyser The analyser to connect to the engine
  102219. */
  102220. connectToAnalyser(analyser: Analyser): void;
  102221. }
  102222. }
  102223. declare module BABYLON {
  102224. interface AbstractScene {
  102225. /**
  102226. * The list of sounds used in the scene.
  102227. */
  102228. sounds: Nullable<Array<Sound>>;
  102229. }
  102230. interface Scene {
  102231. /**
  102232. * @hidden
  102233. * Backing field
  102234. */
  102235. _mainSoundTrack: SoundTrack;
  102236. /**
  102237. * The main sound track played by the scene.
  102238. * It cotains your primary collection of sounds.
  102239. */
  102240. mainSoundTrack: SoundTrack;
  102241. /**
  102242. * The list of sound tracks added to the scene
  102243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102244. */
  102245. soundTracks: Nullable<Array<SoundTrack>>;
  102246. /**
  102247. * Gets a sound using a given name
  102248. * @param name defines the name to search for
  102249. * @return the found sound or null if not found at all.
  102250. */
  102251. getSoundByName(name: string): Nullable<Sound>;
  102252. /**
  102253. * Gets or sets if audio support is enabled
  102254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102255. */
  102256. audioEnabled: boolean;
  102257. /**
  102258. * Gets or sets if audio will be output to headphones
  102259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102260. */
  102261. headphone: boolean;
  102262. /**
  102263. * Gets or sets custom audio listener position provider
  102264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102265. */
  102266. audioListenerPositionProvider: Nullable<() => Vector3>;
  102267. }
  102268. /**
  102269. * Defines the sound scene component responsible to manage any sounds
  102270. * in a given scene.
  102271. */
  102272. export class AudioSceneComponent implements ISceneSerializableComponent {
  102273. /**
  102274. * The component name helpfull to identify the component in the list of scene components.
  102275. */
  102276. readonly name: string;
  102277. /**
  102278. * The scene the component belongs to.
  102279. */
  102280. scene: Scene;
  102281. private _audioEnabled;
  102282. /**
  102283. * Gets whether audio is enabled or not.
  102284. * Please use related enable/disable method to switch state.
  102285. */
  102286. readonly audioEnabled: boolean;
  102287. private _headphone;
  102288. /**
  102289. * Gets whether audio is outputing to headphone or not.
  102290. * Please use the according Switch methods to change output.
  102291. */
  102292. readonly headphone: boolean;
  102293. private _audioListenerPositionProvider;
  102294. /**
  102295. * Gets the current audio listener position provider
  102296. */
  102297. /**
  102298. * Sets a custom listener position for all sounds in the scene
  102299. * By default, this is the position of the first active camera
  102300. */
  102301. audioListenerPositionProvider: Nullable<() => Vector3>;
  102302. /**
  102303. * Creates a new instance of the component for the given scene
  102304. * @param scene Defines the scene to register the component in
  102305. */
  102306. constructor(scene: Scene);
  102307. /**
  102308. * Registers the component in a given scene
  102309. */
  102310. register(): void;
  102311. /**
  102312. * Rebuilds the elements related to this component in case of
  102313. * context lost for instance.
  102314. */
  102315. rebuild(): void;
  102316. /**
  102317. * Serializes the component data to the specified json object
  102318. * @param serializationObject The object to serialize to
  102319. */
  102320. serialize(serializationObject: any): void;
  102321. /**
  102322. * Adds all the elements from the container to the scene
  102323. * @param container the container holding the elements
  102324. */
  102325. addFromContainer(container: AbstractScene): void;
  102326. /**
  102327. * Removes all the elements in the container from the scene
  102328. * @param container contains the elements to remove
  102329. * @param dispose if the removed element should be disposed (default: false)
  102330. */
  102331. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102332. /**
  102333. * Disposes the component and the associated ressources.
  102334. */
  102335. dispose(): void;
  102336. /**
  102337. * Disables audio in the associated scene.
  102338. */
  102339. disableAudio(): void;
  102340. /**
  102341. * Enables audio in the associated scene.
  102342. */
  102343. enableAudio(): void;
  102344. /**
  102345. * Switch audio to headphone output.
  102346. */
  102347. switchAudioModeForHeadphones(): void;
  102348. /**
  102349. * Switch audio to normal speakers.
  102350. */
  102351. switchAudioModeForNormalSpeakers(): void;
  102352. private _afterRender;
  102353. }
  102354. }
  102355. declare module BABYLON {
  102356. /**
  102357. * Wraps one or more Sound objects and selects one with random weight for playback.
  102358. */
  102359. export class WeightedSound {
  102360. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102361. loop: boolean;
  102362. private _coneInnerAngle;
  102363. private _coneOuterAngle;
  102364. private _volume;
  102365. /** A Sound is currently playing. */
  102366. isPlaying: boolean;
  102367. /** A Sound is currently paused. */
  102368. isPaused: boolean;
  102369. private _sounds;
  102370. private _weights;
  102371. private _currentIndex?;
  102372. /**
  102373. * Creates a new WeightedSound from the list of sounds given.
  102374. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102375. * @param sounds Array of Sounds that will be selected from.
  102376. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102377. */
  102378. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102379. /**
  102380. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102381. */
  102382. /**
  102383. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102384. */
  102385. directionalConeInnerAngle: number;
  102386. /**
  102387. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102388. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102389. */
  102390. /**
  102391. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102392. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102393. */
  102394. directionalConeOuterAngle: number;
  102395. /**
  102396. * Playback volume.
  102397. */
  102398. /**
  102399. * Playback volume.
  102400. */
  102401. volume: number;
  102402. private _onended;
  102403. /**
  102404. * Suspend playback
  102405. */
  102406. pause(): void;
  102407. /**
  102408. * Stop playback
  102409. */
  102410. stop(): void;
  102411. /**
  102412. * Start playback.
  102413. * @param startOffset Position the clip head at a specific time in seconds.
  102414. */
  102415. play(startOffset?: number): void;
  102416. }
  102417. }
  102418. declare module BABYLON {
  102419. /**
  102420. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102421. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102422. */
  102423. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102424. /**
  102425. * Gets the name of the behavior.
  102426. */
  102427. readonly name: string;
  102428. /**
  102429. * The easing function used by animations
  102430. */
  102431. static EasingFunction: BackEase;
  102432. /**
  102433. * The easing mode used by animations
  102434. */
  102435. static EasingMode: number;
  102436. /**
  102437. * The duration of the animation, in milliseconds
  102438. */
  102439. transitionDuration: number;
  102440. /**
  102441. * Length of the distance animated by the transition when lower radius is reached
  102442. */
  102443. lowerRadiusTransitionRange: number;
  102444. /**
  102445. * Length of the distance animated by the transition when upper radius is reached
  102446. */
  102447. upperRadiusTransitionRange: number;
  102448. private _autoTransitionRange;
  102449. /**
  102450. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102451. */
  102452. /**
  102453. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102454. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102455. */
  102456. autoTransitionRange: boolean;
  102457. private _attachedCamera;
  102458. private _onAfterCheckInputsObserver;
  102459. private _onMeshTargetChangedObserver;
  102460. /**
  102461. * Initializes the behavior.
  102462. */
  102463. init(): void;
  102464. /**
  102465. * Attaches the behavior to its arc rotate camera.
  102466. * @param camera Defines the camera to attach the behavior to
  102467. */
  102468. attach(camera: ArcRotateCamera): void;
  102469. /**
  102470. * Detaches the behavior from its current arc rotate camera.
  102471. */
  102472. detach(): void;
  102473. private _radiusIsAnimating;
  102474. private _radiusBounceTransition;
  102475. private _animatables;
  102476. private _cachedWheelPrecision;
  102477. /**
  102478. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102479. * @param radiusLimit The limit to check against.
  102480. * @return Bool to indicate if at limit.
  102481. */
  102482. private _isRadiusAtLimit;
  102483. /**
  102484. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102485. * @param radiusDelta The delta by which to animate to. Can be negative.
  102486. */
  102487. private _applyBoundRadiusAnimation;
  102488. /**
  102489. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102490. */
  102491. protected _clearAnimationLocks(): void;
  102492. /**
  102493. * Stops and removes all animations that have been applied to the camera
  102494. */
  102495. stopAllAnimations(): void;
  102496. }
  102497. }
  102498. declare module BABYLON {
  102499. /**
  102500. * 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.
  102501. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102502. */
  102503. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102504. /**
  102505. * Gets the name of the behavior.
  102506. */
  102507. readonly name: string;
  102508. private _mode;
  102509. private _radiusScale;
  102510. private _positionScale;
  102511. private _defaultElevation;
  102512. private _elevationReturnTime;
  102513. private _elevationReturnWaitTime;
  102514. private _zoomStopsAnimation;
  102515. private _framingTime;
  102516. /**
  102517. * The easing function used by animations
  102518. */
  102519. static EasingFunction: ExponentialEase;
  102520. /**
  102521. * The easing mode used by animations
  102522. */
  102523. static EasingMode: number;
  102524. /**
  102525. * Sets the current mode used by the behavior
  102526. */
  102527. /**
  102528. * Gets current mode used by the behavior.
  102529. */
  102530. mode: number;
  102531. /**
  102532. * Sets the scale applied to the radius (1 by default)
  102533. */
  102534. /**
  102535. * Gets the scale applied to the radius
  102536. */
  102537. radiusScale: number;
  102538. /**
  102539. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102540. */
  102541. /**
  102542. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102543. */
  102544. positionScale: number;
  102545. /**
  102546. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102547. * behaviour is triggered, in radians.
  102548. */
  102549. /**
  102550. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102551. * behaviour is triggered, in radians.
  102552. */
  102553. defaultElevation: number;
  102554. /**
  102555. * Sets the time (in milliseconds) taken to return to the default beta position.
  102556. * Negative value indicates camera should not return to default.
  102557. */
  102558. /**
  102559. * Gets the time (in milliseconds) taken to return to the default beta position.
  102560. * Negative value indicates camera should not return to default.
  102561. */
  102562. elevationReturnTime: number;
  102563. /**
  102564. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102565. */
  102566. /**
  102567. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102568. */
  102569. elevationReturnWaitTime: number;
  102570. /**
  102571. * Sets the flag that indicates if user zooming should stop animation.
  102572. */
  102573. /**
  102574. * Gets the flag that indicates if user zooming should stop animation.
  102575. */
  102576. zoomStopsAnimation: boolean;
  102577. /**
  102578. * Sets the transition time when framing the mesh, in milliseconds
  102579. */
  102580. /**
  102581. * Gets the transition time when framing the mesh, in milliseconds
  102582. */
  102583. framingTime: number;
  102584. /**
  102585. * Define if the behavior should automatically change the configured
  102586. * camera limits and sensibilities.
  102587. */
  102588. autoCorrectCameraLimitsAndSensibility: boolean;
  102589. private _onPrePointerObservableObserver;
  102590. private _onAfterCheckInputsObserver;
  102591. private _onMeshTargetChangedObserver;
  102592. private _attachedCamera;
  102593. private _isPointerDown;
  102594. private _lastInteractionTime;
  102595. /**
  102596. * Initializes the behavior.
  102597. */
  102598. init(): void;
  102599. /**
  102600. * Attaches the behavior to its arc rotate camera.
  102601. * @param camera Defines the camera to attach the behavior to
  102602. */
  102603. attach(camera: ArcRotateCamera): void;
  102604. /**
  102605. * Detaches the behavior from its current arc rotate camera.
  102606. */
  102607. detach(): void;
  102608. private _animatables;
  102609. private _betaIsAnimating;
  102610. private _betaTransition;
  102611. private _radiusTransition;
  102612. private _vectorTransition;
  102613. /**
  102614. * Targets the given mesh and updates zoom level accordingly.
  102615. * @param mesh The mesh to target.
  102616. * @param radius Optional. If a cached radius position already exists, overrides default.
  102617. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102618. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102619. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102620. */
  102621. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102622. /**
  102623. * Targets the given mesh with its children and updates zoom level accordingly.
  102624. * @param mesh The mesh to target.
  102625. * @param radius Optional. If a cached radius position already exists, overrides default.
  102626. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102627. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102628. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102629. */
  102630. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102631. /**
  102632. * Targets the given meshes with their children and updates zoom level accordingly.
  102633. * @param meshes The mesh to target.
  102634. * @param radius Optional. If a cached radius position already exists, overrides default.
  102635. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102636. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102637. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102638. */
  102639. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102640. /**
  102641. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102642. * @param minimumWorld Determines the smaller position of the bounding box extend
  102643. * @param maximumWorld Determines the bigger position of the bounding box extend
  102644. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102645. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102646. */
  102647. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102648. /**
  102649. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102650. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102651. * frustum width.
  102652. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102653. * to fully enclose the mesh in the viewing frustum.
  102654. */
  102655. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102656. /**
  102657. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102658. * is automatically returned to its default position (expected to be above ground plane).
  102659. */
  102660. private _maintainCameraAboveGround;
  102661. /**
  102662. * Returns the frustum slope based on the canvas ratio and camera FOV
  102663. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102664. */
  102665. private _getFrustumSlope;
  102666. /**
  102667. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102668. */
  102669. private _clearAnimationLocks;
  102670. /**
  102671. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102672. */
  102673. private _applyUserInteraction;
  102674. /**
  102675. * Stops and removes all animations that have been applied to the camera
  102676. */
  102677. stopAllAnimations(): void;
  102678. /**
  102679. * Gets a value indicating if the user is moving the camera
  102680. */
  102681. readonly isUserIsMoving: boolean;
  102682. /**
  102683. * The camera can move all the way towards the mesh.
  102684. */
  102685. static IgnoreBoundsSizeMode: number;
  102686. /**
  102687. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102688. */
  102689. static FitFrustumSidesMode: number;
  102690. }
  102691. }
  102692. declare module BABYLON {
  102693. /**
  102694. * Base class for Camera Pointer Inputs.
  102695. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102696. * for example usage.
  102697. */
  102698. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102699. /**
  102700. * Defines the camera the input is attached to.
  102701. */
  102702. abstract camera: Camera;
  102703. /**
  102704. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102705. */
  102706. protected _altKey: boolean;
  102707. protected _ctrlKey: boolean;
  102708. protected _metaKey: boolean;
  102709. protected _shiftKey: boolean;
  102710. /**
  102711. * Which mouse buttons were pressed at time of last mouse event.
  102712. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102713. */
  102714. protected _buttonsPressed: number;
  102715. /**
  102716. * Defines the buttons associated with the input to handle camera move.
  102717. */
  102718. buttons: number[];
  102719. /**
  102720. * Attach the input controls to a specific dom element to get the input from.
  102721. * @param element Defines the element the controls should be listened from
  102722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102723. */
  102724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102725. /**
  102726. * Detach the current controls from the specified dom element.
  102727. * @param element Defines the element to stop listening the inputs from
  102728. */
  102729. detachControl(element: Nullable<HTMLElement>): void;
  102730. /**
  102731. * Gets the class name of the current input.
  102732. * @returns the class name
  102733. */
  102734. getClassName(): string;
  102735. /**
  102736. * Get the friendly name associated with the input class.
  102737. * @returns the input friendly name
  102738. */
  102739. getSimpleName(): string;
  102740. /**
  102741. * Called on pointer POINTERDOUBLETAP event.
  102742. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102743. */
  102744. protected onDoubleTap(type: string): void;
  102745. /**
  102746. * Called on pointer POINTERMOVE event if only a single touch is active.
  102747. * Override this method to provide functionality.
  102748. */
  102749. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102750. /**
  102751. * Called on pointer POINTERMOVE event if multiple touches are active.
  102752. * Override this method to provide functionality.
  102753. */
  102754. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102755. /**
  102756. * Called on JS contextmenu event.
  102757. * Override this method to provide functionality.
  102758. */
  102759. protected onContextMenu(evt: PointerEvent): void;
  102760. /**
  102761. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102762. * press.
  102763. * Override this method to provide functionality.
  102764. */
  102765. protected onButtonDown(evt: PointerEvent): void;
  102766. /**
  102767. * Called each time a new POINTERUP event occurs. Ie, for each button
  102768. * release.
  102769. * Override this method to provide functionality.
  102770. */
  102771. protected onButtonUp(evt: PointerEvent): void;
  102772. /**
  102773. * Called when window becomes inactive.
  102774. * Override this method to provide functionality.
  102775. */
  102776. protected onLostFocus(): void;
  102777. private _pointerInput;
  102778. private _observer;
  102779. private _onLostFocus;
  102780. private pointA;
  102781. private pointB;
  102782. }
  102783. }
  102784. declare module BABYLON {
  102785. /**
  102786. * Manage the pointers inputs to control an arc rotate camera.
  102787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102788. */
  102789. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102790. /**
  102791. * Defines the camera the input is attached to.
  102792. */
  102793. camera: ArcRotateCamera;
  102794. /**
  102795. * Gets the class name of the current input.
  102796. * @returns the class name
  102797. */
  102798. getClassName(): string;
  102799. /**
  102800. * Defines the buttons associated with the input to handle camera move.
  102801. */
  102802. buttons: number[];
  102803. /**
  102804. * Defines the pointer angular sensibility along the X axis or how fast is
  102805. * the camera rotating.
  102806. */
  102807. angularSensibilityX: number;
  102808. /**
  102809. * Defines the pointer angular sensibility along the Y axis or how fast is
  102810. * the camera rotating.
  102811. */
  102812. angularSensibilityY: number;
  102813. /**
  102814. * Defines the pointer pinch precision or how fast is the camera zooming.
  102815. */
  102816. pinchPrecision: number;
  102817. /**
  102818. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102819. * from 0.
  102820. * It defines the percentage of current camera.radius to use as delta when
  102821. * pinch zoom is used.
  102822. */
  102823. pinchDeltaPercentage: number;
  102824. /**
  102825. * Defines the pointer panning sensibility or how fast is the camera moving.
  102826. */
  102827. panningSensibility: number;
  102828. /**
  102829. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102830. */
  102831. multiTouchPanning: boolean;
  102832. /**
  102833. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102834. * zoom (pinch) through multitouch.
  102835. */
  102836. multiTouchPanAndZoom: boolean;
  102837. /**
  102838. * Revers pinch action direction.
  102839. */
  102840. pinchInwards: boolean;
  102841. private _isPanClick;
  102842. private _twoFingerActivityCount;
  102843. private _isPinching;
  102844. /**
  102845. * Called on pointer POINTERMOVE event if only a single touch is active.
  102846. */
  102847. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102848. /**
  102849. * Called on pointer POINTERDOUBLETAP event.
  102850. */
  102851. protected onDoubleTap(type: string): void;
  102852. /**
  102853. * Called on pointer POINTERMOVE event if multiple touches are active.
  102854. */
  102855. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102856. /**
  102857. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102858. * press.
  102859. */
  102860. protected onButtonDown(evt: PointerEvent): void;
  102861. /**
  102862. * Called each time a new POINTERUP event occurs. Ie, for each button
  102863. * release.
  102864. */
  102865. protected onButtonUp(evt: PointerEvent): void;
  102866. /**
  102867. * Called when window becomes inactive.
  102868. */
  102869. protected onLostFocus(): void;
  102870. }
  102871. }
  102872. declare module BABYLON {
  102873. /**
  102874. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102876. */
  102877. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102878. /**
  102879. * Defines the camera the input is attached to.
  102880. */
  102881. camera: ArcRotateCamera;
  102882. /**
  102883. * Defines the list of key codes associated with the up action (increase alpha)
  102884. */
  102885. keysUp: number[];
  102886. /**
  102887. * Defines the list of key codes associated with the down action (decrease alpha)
  102888. */
  102889. keysDown: number[];
  102890. /**
  102891. * Defines the list of key codes associated with the left action (increase beta)
  102892. */
  102893. keysLeft: number[];
  102894. /**
  102895. * Defines the list of key codes associated with the right action (decrease beta)
  102896. */
  102897. keysRight: number[];
  102898. /**
  102899. * Defines the list of key codes associated with the reset action.
  102900. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102901. */
  102902. keysReset: number[];
  102903. /**
  102904. * Defines the panning sensibility of the inputs.
  102905. * (How fast is the camera paning)
  102906. */
  102907. panningSensibility: number;
  102908. /**
  102909. * Defines the zooming sensibility of the inputs.
  102910. * (How fast is the camera zooming)
  102911. */
  102912. zoomingSensibility: number;
  102913. /**
  102914. * Defines wether maintaining the alt key down switch the movement mode from
  102915. * orientation to zoom.
  102916. */
  102917. useAltToZoom: boolean;
  102918. /**
  102919. * Rotation speed of the camera
  102920. */
  102921. angularSpeed: number;
  102922. private _keys;
  102923. private _ctrlPressed;
  102924. private _altPressed;
  102925. private _onCanvasBlurObserver;
  102926. private _onKeyboardObserver;
  102927. private _engine;
  102928. private _scene;
  102929. /**
  102930. * Attach the input controls to a specific dom element to get the input from.
  102931. * @param element Defines the element the controls should be listened from
  102932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102933. */
  102934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102935. /**
  102936. * Detach the current controls from the specified dom element.
  102937. * @param element Defines the element to stop listening the inputs from
  102938. */
  102939. detachControl(element: Nullable<HTMLElement>): void;
  102940. /**
  102941. * Update the current camera state depending on the inputs that have been used this frame.
  102942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102943. */
  102944. checkInputs(): void;
  102945. /**
  102946. * Gets the class name of the current intput.
  102947. * @returns the class name
  102948. */
  102949. getClassName(): string;
  102950. /**
  102951. * Get the friendly name associated with the input class.
  102952. * @returns the input friendly name
  102953. */
  102954. getSimpleName(): string;
  102955. }
  102956. }
  102957. declare module BABYLON {
  102958. /**
  102959. * Manage the mouse wheel inputs to control an arc rotate camera.
  102960. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102961. */
  102962. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102963. /**
  102964. * Defines the camera the input is attached to.
  102965. */
  102966. camera: ArcRotateCamera;
  102967. /**
  102968. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102969. */
  102970. wheelPrecision: number;
  102971. /**
  102972. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102973. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102974. */
  102975. wheelDeltaPercentage: number;
  102976. private _wheel;
  102977. private _observer;
  102978. private computeDeltaFromMouseWheelLegacyEvent;
  102979. /**
  102980. * Attach the input controls to a specific dom element to get the input from.
  102981. * @param element Defines the element the controls should be listened from
  102982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102983. */
  102984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102985. /**
  102986. * Detach the current controls from the specified dom element.
  102987. * @param element Defines the element to stop listening the inputs from
  102988. */
  102989. detachControl(element: Nullable<HTMLElement>): void;
  102990. /**
  102991. * Gets the class name of the current intput.
  102992. * @returns the class name
  102993. */
  102994. getClassName(): string;
  102995. /**
  102996. * Get the friendly name associated with the input class.
  102997. * @returns the input friendly name
  102998. */
  102999. getSimpleName(): string;
  103000. }
  103001. }
  103002. declare module BABYLON {
  103003. /**
  103004. * Default Inputs manager for the ArcRotateCamera.
  103005. * It groups all the default supported inputs for ease of use.
  103006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103007. */
  103008. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103009. /**
  103010. * Instantiates a new ArcRotateCameraInputsManager.
  103011. * @param camera Defines the camera the inputs belong to
  103012. */
  103013. constructor(camera: ArcRotateCamera);
  103014. /**
  103015. * Add mouse wheel input support to the input manager.
  103016. * @returns the current input manager
  103017. */
  103018. addMouseWheel(): ArcRotateCameraInputsManager;
  103019. /**
  103020. * Add pointers input support to the input manager.
  103021. * @returns the current input manager
  103022. */
  103023. addPointers(): ArcRotateCameraInputsManager;
  103024. /**
  103025. * Add keyboard input support to the input manager.
  103026. * @returns the current input manager
  103027. */
  103028. addKeyboard(): ArcRotateCameraInputsManager;
  103029. }
  103030. }
  103031. declare module BABYLON {
  103032. /**
  103033. * This represents an orbital type of camera.
  103034. *
  103035. * 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.
  103036. * 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.
  103037. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103038. */
  103039. export class ArcRotateCamera extends TargetCamera {
  103040. /**
  103041. * Defines the rotation angle of the camera along the longitudinal axis.
  103042. */
  103043. alpha: number;
  103044. /**
  103045. * Defines the rotation angle of the camera along the latitudinal axis.
  103046. */
  103047. beta: number;
  103048. /**
  103049. * Defines the radius of the camera from it s target point.
  103050. */
  103051. radius: number;
  103052. protected _target: Vector3;
  103053. protected _targetHost: Nullable<AbstractMesh>;
  103054. /**
  103055. * Defines the target point of the camera.
  103056. * The camera looks towards it form the radius distance.
  103057. */
  103058. target: Vector3;
  103059. /**
  103060. * Define the current local position of the camera in the scene
  103061. */
  103062. position: Vector3;
  103063. protected _upVector: Vector3;
  103064. protected _upToYMatrix: Matrix;
  103065. protected _YToUpMatrix: Matrix;
  103066. /**
  103067. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103068. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103069. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103070. */
  103071. upVector: Vector3;
  103072. /**
  103073. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103074. */
  103075. setMatUp(): void;
  103076. /**
  103077. * Current inertia value on the longitudinal axis.
  103078. * The bigger this number the longer it will take for the camera to stop.
  103079. */
  103080. inertialAlphaOffset: number;
  103081. /**
  103082. * Current inertia value on the latitudinal axis.
  103083. * The bigger this number the longer it will take for the camera to stop.
  103084. */
  103085. inertialBetaOffset: number;
  103086. /**
  103087. * Current inertia value on the radius axis.
  103088. * The bigger this number the longer it will take for the camera to stop.
  103089. */
  103090. inertialRadiusOffset: number;
  103091. /**
  103092. * Minimum allowed angle on the longitudinal axis.
  103093. * This can help limiting how the Camera is able to move in the scene.
  103094. */
  103095. lowerAlphaLimit: Nullable<number>;
  103096. /**
  103097. * Maximum allowed angle on the longitudinal axis.
  103098. * This can help limiting how the Camera is able to move in the scene.
  103099. */
  103100. upperAlphaLimit: Nullable<number>;
  103101. /**
  103102. * Minimum allowed angle on the latitudinal axis.
  103103. * This can help limiting how the Camera is able to move in the scene.
  103104. */
  103105. lowerBetaLimit: number;
  103106. /**
  103107. * Maximum allowed angle on the latitudinal axis.
  103108. * This can help limiting how the Camera is able to move in the scene.
  103109. */
  103110. upperBetaLimit: number;
  103111. /**
  103112. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103113. * This can help limiting how the Camera is able to move in the scene.
  103114. */
  103115. lowerRadiusLimit: Nullable<number>;
  103116. /**
  103117. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103118. * This can help limiting how the Camera is able to move in the scene.
  103119. */
  103120. upperRadiusLimit: Nullable<number>;
  103121. /**
  103122. * Defines the current inertia value used during panning of the camera along the X axis.
  103123. */
  103124. inertialPanningX: number;
  103125. /**
  103126. * Defines the current inertia value used during panning of the camera along the Y axis.
  103127. */
  103128. inertialPanningY: number;
  103129. /**
  103130. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103131. * Basically if your fingers moves away from more than this distance you will be considered
  103132. * in pinch mode.
  103133. */
  103134. pinchToPanMaxDistance: number;
  103135. /**
  103136. * Defines the maximum distance the camera can pan.
  103137. * This could help keeping the cammera always in your scene.
  103138. */
  103139. panningDistanceLimit: Nullable<number>;
  103140. /**
  103141. * Defines the target of the camera before paning.
  103142. */
  103143. panningOriginTarget: Vector3;
  103144. /**
  103145. * Defines the value of the inertia used during panning.
  103146. * 0 would mean stop inertia and one would mean no decelleration at all.
  103147. */
  103148. panningInertia: number;
  103149. /**
  103150. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103151. */
  103152. angularSensibilityX: number;
  103153. /**
  103154. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103155. */
  103156. angularSensibilityY: number;
  103157. /**
  103158. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103159. */
  103160. pinchPrecision: number;
  103161. /**
  103162. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103163. * It will be used instead of pinchDeltaPrecision if different from 0.
  103164. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103165. */
  103166. pinchDeltaPercentage: number;
  103167. /**
  103168. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103169. */
  103170. panningSensibility: number;
  103171. /**
  103172. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103173. */
  103174. keysUp: number[];
  103175. /**
  103176. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103177. */
  103178. keysDown: number[];
  103179. /**
  103180. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103181. */
  103182. keysLeft: number[];
  103183. /**
  103184. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103185. */
  103186. keysRight: number[];
  103187. /**
  103188. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103189. */
  103190. wheelPrecision: number;
  103191. /**
  103192. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103193. * It will be used instead of pinchDeltaPrecision if different from 0.
  103194. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103195. */
  103196. wheelDeltaPercentage: number;
  103197. /**
  103198. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103199. */
  103200. zoomOnFactor: number;
  103201. /**
  103202. * Defines a screen offset for the camera position.
  103203. */
  103204. targetScreenOffset: Vector2;
  103205. /**
  103206. * Allows the camera to be completely reversed.
  103207. * If false the camera can not arrive upside down.
  103208. */
  103209. allowUpsideDown: boolean;
  103210. /**
  103211. * Define if double tap/click is used to restore the previously saved state of the camera.
  103212. */
  103213. useInputToRestoreState: boolean;
  103214. /** @hidden */
  103215. _viewMatrix: Matrix;
  103216. /** @hidden */
  103217. _useCtrlForPanning: boolean;
  103218. /** @hidden */
  103219. _panningMouseButton: number;
  103220. /**
  103221. * Defines the input associated to the camera.
  103222. */
  103223. inputs: ArcRotateCameraInputsManager;
  103224. /** @hidden */
  103225. _reset: () => void;
  103226. /**
  103227. * Defines the allowed panning axis.
  103228. */
  103229. panningAxis: Vector3;
  103230. protected _localDirection: Vector3;
  103231. protected _transformedDirection: Vector3;
  103232. private _bouncingBehavior;
  103233. /**
  103234. * Gets the bouncing behavior of the camera if it has been enabled.
  103235. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103236. */
  103237. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103238. /**
  103239. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103241. */
  103242. useBouncingBehavior: boolean;
  103243. private _framingBehavior;
  103244. /**
  103245. * Gets the framing behavior of the camera if it has been enabled.
  103246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103247. */
  103248. readonly framingBehavior: Nullable<FramingBehavior>;
  103249. /**
  103250. * Defines if the framing behavior of the camera is enabled on the camera.
  103251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103252. */
  103253. useFramingBehavior: boolean;
  103254. private _autoRotationBehavior;
  103255. /**
  103256. * Gets the auto rotation behavior of the camera if it has been enabled.
  103257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103258. */
  103259. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103260. /**
  103261. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103263. */
  103264. useAutoRotationBehavior: boolean;
  103265. /**
  103266. * Observable triggered when the mesh target has been changed on the camera.
  103267. */
  103268. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103269. /**
  103270. * Event raised when the camera is colliding with a mesh.
  103271. */
  103272. onCollide: (collidedMesh: AbstractMesh) => void;
  103273. /**
  103274. * Defines whether the camera should check collision with the objects oh the scene.
  103275. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103276. */
  103277. checkCollisions: boolean;
  103278. /**
  103279. * Defines the collision radius of the camera.
  103280. * This simulates a sphere around the camera.
  103281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103282. */
  103283. collisionRadius: Vector3;
  103284. protected _collider: Collider;
  103285. protected _previousPosition: Vector3;
  103286. protected _collisionVelocity: Vector3;
  103287. protected _newPosition: Vector3;
  103288. protected _previousAlpha: number;
  103289. protected _previousBeta: number;
  103290. protected _previousRadius: number;
  103291. protected _collisionTriggered: boolean;
  103292. protected _targetBoundingCenter: Nullable<Vector3>;
  103293. private _computationVector;
  103294. /**
  103295. * Instantiates a new ArcRotateCamera in a given scene
  103296. * @param name Defines the name of the camera
  103297. * @param alpha Defines the camera rotation along the logitudinal axis
  103298. * @param beta Defines the camera rotation along the latitudinal axis
  103299. * @param radius Defines the camera distance from its target
  103300. * @param target Defines the camera target
  103301. * @param scene Defines the scene the camera belongs to
  103302. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103303. */
  103304. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103305. /** @hidden */
  103306. _initCache(): void;
  103307. /** @hidden */
  103308. _updateCache(ignoreParentClass?: boolean): void;
  103309. protected _getTargetPosition(): Vector3;
  103310. private _storedAlpha;
  103311. private _storedBeta;
  103312. private _storedRadius;
  103313. private _storedTarget;
  103314. private _storedTargetScreenOffset;
  103315. /**
  103316. * Stores the current state of the camera (alpha, beta, radius and target)
  103317. * @returns the camera itself
  103318. */
  103319. storeState(): Camera;
  103320. /**
  103321. * @hidden
  103322. * Restored camera state. You must call storeState() first
  103323. */
  103324. _restoreStateValues(): boolean;
  103325. /** @hidden */
  103326. _isSynchronizedViewMatrix(): boolean;
  103327. /**
  103328. * Attached controls to the current camera.
  103329. * @param element Defines the element the controls should be listened from
  103330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103331. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103332. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103333. */
  103334. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103335. /**
  103336. * Detach the current controls from the camera.
  103337. * The camera will stop reacting to inputs.
  103338. * @param element Defines the element to stop listening the inputs from
  103339. */
  103340. detachControl(element: HTMLElement): void;
  103341. /** @hidden */
  103342. _checkInputs(): void;
  103343. protected _checkLimits(): void;
  103344. /**
  103345. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103346. */
  103347. rebuildAnglesAndRadius(): void;
  103348. /**
  103349. * Use a position to define the current camera related information like aplha, beta and radius
  103350. * @param position Defines the position to set the camera at
  103351. */
  103352. setPosition(position: Vector3): void;
  103353. /**
  103354. * Defines the target the camera should look at.
  103355. * This will automatically adapt alpha beta and radius to fit within the new target.
  103356. * @param target Defines the new target as a Vector or a mesh
  103357. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103358. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103359. */
  103360. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103361. /** @hidden */
  103362. _getViewMatrix(): Matrix;
  103363. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103364. /**
  103365. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103366. * @param meshes Defines the mesh to zoom on
  103367. * @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)
  103368. */
  103369. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103370. /**
  103371. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103372. * The target will be changed but the radius
  103373. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103374. * @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)
  103375. */
  103376. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103377. min: Vector3;
  103378. max: Vector3;
  103379. distance: number;
  103380. }, doNotUpdateMaxZ?: boolean): void;
  103381. /**
  103382. * @override
  103383. * Override Camera.createRigCamera
  103384. */
  103385. createRigCamera(name: string, cameraIndex: number): Camera;
  103386. /**
  103387. * @hidden
  103388. * @override
  103389. * Override Camera._updateRigCameras
  103390. */
  103391. _updateRigCameras(): void;
  103392. /**
  103393. * Destroy the camera and release the current resources hold by it.
  103394. */
  103395. dispose(): void;
  103396. /**
  103397. * Gets the current object class name.
  103398. * @return the class name
  103399. */
  103400. getClassName(): string;
  103401. }
  103402. }
  103403. declare module BABYLON {
  103404. /**
  103405. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103406. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103407. */
  103408. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103409. /**
  103410. * Gets the name of the behavior.
  103411. */
  103412. readonly name: string;
  103413. private _zoomStopsAnimation;
  103414. private _idleRotationSpeed;
  103415. private _idleRotationWaitTime;
  103416. private _idleRotationSpinupTime;
  103417. /**
  103418. * Sets the flag that indicates if user zooming should stop animation.
  103419. */
  103420. /**
  103421. * Gets the flag that indicates if user zooming should stop animation.
  103422. */
  103423. zoomStopsAnimation: boolean;
  103424. /**
  103425. * Sets the default speed at which the camera rotates around the model.
  103426. */
  103427. /**
  103428. * Gets the default speed at which the camera rotates around the model.
  103429. */
  103430. idleRotationSpeed: number;
  103431. /**
  103432. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103433. */
  103434. /**
  103435. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103436. */
  103437. idleRotationWaitTime: number;
  103438. /**
  103439. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103440. */
  103441. /**
  103442. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103443. */
  103444. idleRotationSpinupTime: number;
  103445. /**
  103446. * Gets a value indicating if the camera is currently rotating because of this behavior
  103447. */
  103448. readonly rotationInProgress: boolean;
  103449. private _onPrePointerObservableObserver;
  103450. private _onAfterCheckInputsObserver;
  103451. private _attachedCamera;
  103452. private _isPointerDown;
  103453. private _lastFrameTime;
  103454. private _lastInteractionTime;
  103455. private _cameraRotationSpeed;
  103456. /**
  103457. * Initializes the behavior.
  103458. */
  103459. init(): void;
  103460. /**
  103461. * Attaches the behavior to its arc rotate camera.
  103462. * @param camera Defines the camera to attach the behavior to
  103463. */
  103464. attach(camera: ArcRotateCamera): void;
  103465. /**
  103466. * Detaches the behavior from its current arc rotate camera.
  103467. */
  103468. detach(): void;
  103469. /**
  103470. * Returns true if user is scrolling.
  103471. * @return true if user is scrolling.
  103472. */
  103473. private _userIsZooming;
  103474. private _lastFrameRadius;
  103475. private _shouldAnimationStopForInteraction;
  103476. /**
  103477. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103478. */
  103479. private _applyUserInteraction;
  103480. private _userIsMoving;
  103481. }
  103482. }
  103483. declare module BABYLON {
  103484. /**
  103485. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103486. */
  103487. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103488. private ui;
  103489. /**
  103490. * The name of the behavior
  103491. */
  103492. name: string;
  103493. /**
  103494. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103495. */
  103496. distanceAwayFromFace: number;
  103497. /**
  103498. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103499. */
  103500. distanceAwayFromBottomOfFace: number;
  103501. private _faceVectors;
  103502. private _target;
  103503. private _scene;
  103504. private _onRenderObserver;
  103505. private _tmpMatrix;
  103506. private _tmpVector;
  103507. /**
  103508. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103509. * @param ui The transform node that should be attched to the mesh
  103510. */
  103511. constructor(ui: TransformNode);
  103512. /**
  103513. * Initializes the behavior
  103514. */
  103515. init(): void;
  103516. private _closestFace;
  103517. private _zeroVector;
  103518. private _lookAtTmpMatrix;
  103519. private _lookAtToRef;
  103520. /**
  103521. * Attaches the AttachToBoxBehavior to the passed in mesh
  103522. * @param target The mesh that the specified node will be attached to
  103523. */
  103524. attach(target: Mesh): void;
  103525. /**
  103526. * Detaches the behavior from the mesh
  103527. */
  103528. detach(): void;
  103529. }
  103530. }
  103531. declare module BABYLON {
  103532. /**
  103533. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103534. */
  103535. export class FadeInOutBehavior implements Behavior<Mesh> {
  103536. /**
  103537. * Time in milliseconds to delay before fading in (Default: 0)
  103538. */
  103539. delay: number;
  103540. /**
  103541. * Time in milliseconds for the mesh to fade in (Default: 300)
  103542. */
  103543. fadeInTime: number;
  103544. private _millisecondsPerFrame;
  103545. private _hovered;
  103546. private _hoverValue;
  103547. private _ownerNode;
  103548. /**
  103549. * Instatiates the FadeInOutBehavior
  103550. */
  103551. constructor();
  103552. /**
  103553. * The name of the behavior
  103554. */
  103555. readonly name: string;
  103556. /**
  103557. * Initializes the behavior
  103558. */
  103559. init(): void;
  103560. /**
  103561. * Attaches the fade behavior on the passed in mesh
  103562. * @param ownerNode The mesh that will be faded in/out once attached
  103563. */
  103564. attach(ownerNode: Mesh): void;
  103565. /**
  103566. * Detaches the behavior from the mesh
  103567. */
  103568. detach(): void;
  103569. /**
  103570. * Triggers the mesh to begin fading in or out
  103571. * @param value if the object should fade in or out (true to fade in)
  103572. */
  103573. fadeIn(value: boolean): void;
  103574. private _update;
  103575. private _setAllVisibility;
  103576. }
  103577. }
  103578. declare module BABYLON {
  103579. /**
  103580. * Class containing a set of static utilities functions for managing Pivots
  103581. * @hidden
  103582. */
  103583. export class PivotTools {
  103584. private static _PivotCached;
  103585. private static _OldPivotPoint;
  103586. private static _PivotTranslation;
  103587. private static _PivotTmpVector;
  103588. /** @hidden */
  103589. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103590. /** @hidden */
  103591. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103592. }
  103593. }
  103594. declare module BABYLON {
  103595. /**
  103596. * Class containing static functions to help procedurally build meshes
  103597. */
  103598. export class PlaneBuilder {
  103599. /**
  103600. * Creates a plane mesh
  103601. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103602. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103603. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103607. * @param name defines the name of the mesh
  103608. * @param options defines the options used to create the mesh
  103609. * @param scene defines the hosting scene
  103610. * @returns the plane mesh
  103611. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103612. */
  103613. static CreatePlane(name: string, options: {
  103614. size?: number;
  103615. width?: number;
  103616. height?: number;
  103617. sideOrientation?: number;
  103618. frontUVs?: Vector4;
  103619. backUVs?: Vector4;
  103620. updatable?: boolean;
  103621. sourcePlane?: Plane;
  103622. }, scene?: Nullable<Scene>): Mesh;
  103623. }
  103624. }
  103625. declare module BABYLON {
  103626. /**
  103627. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103628. */
  103629. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103630. private static _AnyMouseID;
  103631. /**
  103632. * Abstract mesh the behavior is set on
  103633. */
  103634. attachedNode: AbstractMesh;
  103635. private _dragPlane;
  103636. private _scene;
  103637. private _pointerObserver;
  103638. private _beforeRenderObserver;
  103639. private static _planeScene;
  103640. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103641. /**
  103642. * 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)
  103643. */
  103644. maxDragAngle: number;
  103645. /**
  103646. * @hidden
  103647. */
  103648. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103649. /**
  103650. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103651. */
  103652. currentDraggingPointerID: number;
  103653. /**
  103654. * The last position where the pointer hit the drag plane in world space
  103655. */
  103656. lastDragPosition: Vector3;
  103657. /**
  103658. * If the behavior is currently in a dragging state
  103659. */
  103660. dragging: boolean;
  103661. /**
  103662. * 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)
  103663. */
  103664. dragDeltaRatio: number;
  103665. /**
  103666. * If the drag plane orientation should be updated during the dragging (Default: true)
  103667. */
  103668. updateDragPlane: boolean;
  103669. private _debugMode;
  103670. private _moving;
  103671. /**
  103672. * Fires each time the attached mesh is dragged with the pointer
  103673. * * delta between last drag position and current drag position in world space
  103674. * * dragDistance along the drag axis
  103675. * * dragPlaneNormal normal of the current drag plane used during the drag
  103676. * * dragPlanePoint in world space where the drag intersects the drag plane
  103677. */
  103678. onDragObservable: Observable<{
  103679. delta: Vector3;
  103680. dragPlanePoint: Vector3;
  103681. dragPlaneNormal: Vector3;
  103682. dragDistance: number;
  103683. pointerId: number;
  103684. }>;
  103685. /**
  103686. * Fires each time a drag begins (eg. mouse down on mesh)
  103687. */
  103688. onDragStartObservable: Observable<{
  103689. dragPlanePoint: Vector3;
  103690. pointerId: number;
  103691. }>;
  103692. /**
  103693. * Fires each time a drag ends (eg. mouse release after drag)
  103694. */
  103695. onDragEndObservable: Observable<{
  103696. dragPlanePoint: Vector3;
  103697. pointerId: number;
  103698. }>;
  103699. /**
  103700. * If the attached mesh should be moved when dragged
  103701. */
  103702. moveAttached: boolean;
  103703. /**
  103704. * If the drag behavior will react to drag events (Default: true)
  103705. */
  103706. enabled: boolean;
  103707. /**
  103708. * If pointer events should start and release the drag (Default: true)
  103709. */
  103710. startAndReleaseDragOnPointerEvents: boolean;
  103711. /**
  103712. * If camera controls should be detached during the drag
  103713. */
  103714. detachCameraControls: boolean;
  103715. /**
  103716. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103717. */
  103718. useObjectOrienationForDragging: boolean;
  103719. private _options;
  103720. /**
  103721. * Creates a pointer drag behavior that can be attached to a mesh
  103722. * @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)
  103723. */
  103724. constructor(options?: {
  103725. dragAxis?: Vector3;
  103726. dragPlaneNormal?: Vector3;
  103727. });
  103728. /**
  103729. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103730. */
  103731. validateDrag: (targetPosition: Vector3) => boolean;
  103732. /**
  103733. * The name of the behavior
  103734. */
  103735. readonly name: string;
  103736. /**
  103737. * Initializes the behavior
  103738. */
  103739. init(): void;
  103740. private _tmpVector;
  103741. private _alternatePickedPoint;
  103742. private _worldDragAxis;
  103743. private _targetPosition;
  103744. private _attachedElement;
  103745. /**
  103746. * Attaches the drag behavior the passed in mesh
  103747. * @param ownerNode The mesh that will be dragged around once attached
  103748. * @param predicate Predicate to use for pick filtering
  103749. */
  103750. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103751. /**
  103752. * Force relase the drag action by code.
  103753. */
  103754. releaseDrag(): void;
  103755. private _startDragRay;
  103756. private _lastPointerRay;
  103757. /**
  103758. * Simulates the start of a pointer drag event on the behavior
  103759. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103760. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103761. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103762. */
  103763. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103764. private _startDrag;
  103765. private _dragDelta;
  103766. private _moveDrag;
  103767. private _pickWithRayOnDragPlane;
  103768. private _pointA;
  103769. private _pointB;
  103770. private _pointC;
  103771. private _lineA;
  103772. private _lineB;
  103773. private _localAxis;
  103774. private _lookAt;
  103775. private _updateDragPlanePosition;
  103776. /**
  103777. * Detaches the behavior from the mesh
  103778. */
  103779. detach(): void;
  103780. }
  103781. }
  103782. declare module BABYLON {
  103783. /**
  103784. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103785. */
  103786. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103787. private _dragBehaviorA;
  103788. private _dragBehaviorB;
  103789. private _startDistance;
  103790. private _initialScale;
  103791. private _targetScale;
  103792. private _ownerNode;
  103793. private _sceneRenderObserver;
  103794. /**
  103795. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103796. */
  103797. constructor();
  103798. /**
  103799. * The name of the behavior
  103800. */
  103801. readonly name: string;
  103802. /**
  103803. * Initializes the behavior
  103804. */
  103805. init(): void;
  103806. private _getCurrentDistance;
  103807. /**
  103808. * Attaches the scale behavior the passed in mesh
  103809. * @param ownerNode The mesh that will be scaled around once attached
  103810. */
  103811. attach(ownerNode: Mesh): void;
  103812. /**
  103813. * Detaches the behavior from the mesh
  103814. */
  103815. detach(): void;
  103816. }
  103817. }
  103818. declare module BABYLON {
  103819. /**
  103820. * 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
  103821. */
  103822. export class SixDofDragBehavior implements Behavior<Mesh> {
  103823. private static _virtualScene;
  103824. private _ownerNode;
  103825. private _sceneRenderObserver;
  103826. private _scene;
  103827. private _targetPosition;
  103828. private _virtualOriginMesh;
  103829. private _virtualDragMesh;
  103830. private _pointerObserver;
  103831. private _moving;
  103832. private _startingOrientation;
  103833. /**
  103834. * 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)
  103835. */
  103836. private zDragFactor;
  103837. /**
  103838. * If the object should rotate to face the drag origin
  103839. */
  103840. rotateDraggedObject: boolean;
  103841. /**
  103842. * If the behavior is currently in a dragging state
  103843. */
  103844. dragging: boolean;
  103845. /**
  103846. * 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)
  103847. */
  103848. dragDeltaRatio: number;
  103849. /**
  103850. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103851. */
  103852. currentDraggingPointerID: number;
  103853. /**
  103854. * If camera controls should be detached during the drag
  103855. */
  103856. detachCameraControls: boolean;
  103857. /**
  103858. * Fires each time a drag starts
  103859. */
  103860. onDragStartObservable: Observable<{}>;
  103861. /**
  103862. * Fires each time a drag ends (eg. mouse release after drag)
  103863. */
  103864. onDragEndObservable: Observable<{}>;
  103865. /**
  103866. * 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
  103867. */
  103868. constructor();
  103869. /**
  103870. * The name of the behavior
  103871. */
  103872. readonly name: string;
  103873. /**
  103874. * Initializes the behavior
  103875. */
  103876. init(): void;
  103877. /**
  103878. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103879. */
  103880. private readonly _pointerCamera;
  103881. /**
  103882. * Attaches the scale behavior the passed in mesh
  103883. * @param ownerNode The mesh that will be scaled around once attached
  103884. */
  103885. attach(ownerNode: Mesh): void;
  103886. /**
  103887. * Detaches the behavior from the mesh
  103888. */
  103889. detach(): void;
  103890. }
  103891. }
  103892. declare module BABYLON {
  103893. /**
  103894. * Class used to apply inverse kinematics to bones
  103895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103896. */
  103897. export class BoneIKController {
  103898. private static _tmpVecs;
  103899. private static _tmpQuat;
  103900. private static _tmpMats;
  103901. /**
  103902. * Gets or sets the target mesh
  103903. */
  103904. targetMesh: AbstractMesh;
  103905. /** Gets or sets the mesh used as pole */
  103906. poleTargetMesh: AbstractMesh;
  103907. /**
  103908. * Gets or sets the bone used as pole
  103909. */
  103910. poleTargetBone: Nullable<Bone>;
  103911. /**
  103912. * Gets or sets the target position
  103913. */
  103914. targetPosition: Vector3;
  103915. /**
  103916. * Gets or sets the pole target position
  103917. */
  103918. poleTargetPosition: Vector3;
  103919. /**
  103920. * Gets or sets the pole target local offset
  103921. */
  103922. poleTargetLocalOffset: Vector3;
  103923. /**
  103924. * Gets or sets the pole angle
  103925. */
  103926. poleAngle: number;
  103927. /**
  103928. * Gets or sets the mesh associated with the controller
  103929. */
  103930. mesh: AbstractMesh;
  103931. /**
  103932. * 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)
  103933. */
  103934. slerpAmount: number;
  103935. private _bone1Quat;
  103936. private _bone1Mat;
  103937. private _bone2Ang;
  103938. private _bone1;
  103939. private _bone2;
  103940. private _bone1Length;
  103941. private _bone2Length;
  103942. private _maxAngle;
  103943. private _maxReach;
  103944. private _rightHandedSystem;
  103945. private _bendAxis;
  103946. private _slerping;
  103947. private _adjustRoll;
  103948. /**
  103949. * Gets or sets maximum allowed angle
  103950. */
  103951. maxAngle: number;
  103952. /**
  103953. * Creates a new BoneIKController
  103954. * @param mesh defines the mesh to control
  103955. * @param bone defines the bone to control
  103956. * @param options defines options to set up the controller
  103957. */
  103958. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103959. targetMesh?: AbstractMesh;
  103960. poleTargetMesh?: AbstractMesh;
  103961. poleTargetBone?: Bone;
  103962. poleTargetLocalOffset?: Vector3;
  103963. poleAngle?: number;
  103964. bendAxis?: Vector3;
  103965. maxAngle?: number;
  103966. slerpAmount?: number;
  103967. });
  103968. private _setMaxAngle;
  103969. /**
  103970. * Force the controller to update the bones
  103971. */
  103972. update(): void;
  103973. }
  103974. }
  103975. declare module BABYLON {
  103976. /**
  103977. * Class used to make a bone look toward a point in space
  103978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103979. */
  103980. export class BoneLookController {
  103981. private static _tmpVecs;
  103982. private static _tmpQuat;
  103983. private static _tmpMats;
  103984. /**
  103985. * The target Vector3 that the bone will look at
  103986. */
  103987. target: Vector3;
  103988. /**
  103989. * The mesh that the bone is attached to
  103990. */
  103991. mesh: AbstractMesh;
  103992. /**
  103993. * The bone that will be looking to the target
  103994. */
  103995. bone: Bone;
  103996. /**
  103997. * The up axis of the coordinate system that is used when the bone is rotated
  103998. */
  103999. upAxis: Vector3;
  104000. /**
  104001. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104002. */
  104003. upAxisSpace: Space;
  104004. /**
  104005. * Used to make an adjustment to the yaw of the bone
  104006. */
  104007. adjustYaw: number;
  104008. /**
  104009. * Used to make an adjustment to the pitch of the bone
  104010. */
  104011. adjustPitch: number;
  104012. /**
  104013. * Used to make an adjustment to the roll of the bone
  104014. */
  104015. adjustRoll: number;
  104016. /**
  104017. * 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)
  104018. */
  104019. slerpAmount: number;
  104020. private _minYaw;
  104021. private _maxYaw;
  104022. private _minPitch;
  104023. private _maxPitch;
  104024. private _minYawSin;
  104025. private _minYawCos;
  104026. private _maxYawSin;
  104027. private _maxYawCos;
  104028. private _midYawConstraint;
  104029. private _minPitchTan;
  104030. private _maxPitchTan;
  104031. private _boneQuat;
  104032. private _slerping;
  104033. private _transformYawPitch;
  104034. private _transformYawPitchInv;
  104035. private _firstFrameSkipped;
  104036. private _yawRange;
  104037. private _fowardAxis;
  104038. /**
  104039. * Gets or sets the minimum yaw angle that the bone can look to
  104040. */
  104041. minYaw: number;
  104042. /**
  104043. * Gets or sets the maximum yaw angle that the bone can look to
  104044. */
  104045. maxYaw: number;
  104046. /**
  104047. * Gets or sets the minimum pitch angle that the bone can look to
  104048. */
  104049. minPitch: number;
  104050. /**
  104051. * Gets or sets the maximum pitch angle that the bone can look to
  104052. */
  104053. maxPitch: number;
  104054. /**
  104055. * Create a BoneLookController
  104056. * @param mesh the mesh that the bone belongs to
  104057. * @param bone the bone that will be looking to the target
  104058. * @param target the target Vector3 to look at
  104059. * @param options optional settings:
  104060. * * maxYaw: the maximum angle the bone will yaw to
  104061. * * minYaw: the minimum angle the bone will yaw to
  104062. * * maxPitch: the maximum angle the bone will pitch to
  104063. * * minPitch: the minimum angle the bone will yaw to
  104064. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104065. * * upAxis: the up axis of the coordinate system
  104066. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104067. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104068. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104069. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104070. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104071. * * adjustRoll: used to make an adjustment to the roll of the bone
  104072. **/
  104073. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104074. maxYaw?: number;
  104075. minYaw?: number;
  104076. maxPitch?: number;
  104077. minPitch?: number;
  104078. slerpAmount?: number;
  104079. upAxis?: Vector3;
  104080. upAxisSpace?: Space;
  104081. yawAxis?: Vector3;
  104082. pitchAxis?: Vector3;
  104083. adjustYaw?: number;
  104084. adjustPitch?: number;
  104085. adjustRoll?: number;
  104086. });
  104087. /**
  104088. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104089. */
  104090. update(): void;
  104091. private _getAngleDiff;
  104092. private _getAngleBetween;
  104093. private _isAngleBetween;
  104094. }
  104095. }
  104096. declare module BABYLON {
  104097. /**
  104098. * Manage the gamepad inputs to control an arc rotate camera.
  104099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104100. */
  104101. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104102. /**
  104103. * Defines the camera the input is attached to.
  104104. */
  104105. camera: ArcRotateCamera;
  104106. /**
  104107. * Defines the gamepad the input is gathering event from.
  104108. */
  104109. gamepad: Nullable<Gamepad>;
  104110. /**
  104111. * Defines the gamepad rotation sensiblity.
  104112. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104113. */
  104114. gamepadRotationSensibility: number;
  104115. /**
  104116. * Defines the gamepad move sensiblity.
  104117. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104118. */
  104119. gamepadMoveSensibility: number;
  104120. private _onGamepadConnectedObserver;
  104121. private _onGamepadDisconnectedObserver;
  104122. /**
  104123. * Attach the input controls to a specific dom element to get the input from.
  104124. * @param element Defines the element the controls should be listened from
  104125. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104126. */
  104127. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104128. /**
  104129. * Detach the current controls from the specified dom element.
  104130. * @param element Defines the element to stop listening the inputs from
  104131. */
  104132. detachControl(element: Nullable<HTMLElement>): void;
  104133. /**
  104134. * Update the current camera state depending on the inputs that have been used this frame.
  104135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104136. */
  104137. checkInputs(): void;
  104138. /**
  104139. * Gets the class name of the current intput.
  104140. * @returns the class name
  104141. */
  104142. getClassName(): string;
  104143. /**
  104144. * Get the friendly name associated with the input class.
  104145. * @returns the input friendly name
  104146. */
  104147. getSimpleName(): string;
  104148. }
  104149. }
  104150. declare module BABYLON {
  104151. interface ArcRotateCameraInputsManager {
  104152. /**
  104153. * Add orientation input support to the input manager.
  104154. * @returns the current input manager
  104155. */
  104156. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104157. }
  104158. /**
  104159. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104161. */
  104162. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104163. /**
  104164. * Defines the camera the input is attached to.
  104165. */
  104166. camera: ArcRotateCamera;
  104167. /**
  104168. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104169. */
  104170. alphaCorrection: number;
  104171. /**
  104172. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104173. */
  104174. gammaCorrection: number;
  104175. private _alpha;
  104176. private _gamma;
  104177. private _dirty;
  104178. private _deviceOrientationHandler;
  104179. /**
  104180. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104181. */
  104182. constructor();
  104183. /**
  104184. * Attach the input controls to a specific dom element to get the input from.
  104185. * @param element Defines the element the controls should be listened from
  104186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104187. */
  104188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104189. /** @hidden */
  104190. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104191. /**
  104192. * Update the current camera state depending on the inputs that have been used this frame.
  104193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104194. */
  104195. checkInputs(): void;
  104196. /**
  104197. * Detach the current controls from the specified dom element.
  104198. * @param element Defines the element to stop listening the inputs from
  104199. */
  104200. detachControl(element: Nullable<HTMLElement>): void;
  104201. /**
  104202. * Gets the class name of the current intput.
  104203. * @returns the class name
  104204. */
  104205. getClassName(): string;
  104206. /**
  104207. * Get the friendly name associated with the input class.
  104208. * @returns the input friendly name
  104209. */
  104210. getSimpleName(): string;
  104211. }
  104212. }
  104213. declare module BABYLON {
  104214. /**
  104215. * Listen to mouse events to control the camera.
  104216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104217. */
  104218. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104219. /**
  104220. * Defines the camera the input is attached to.
  104221. */
  104222. camera: FlyCamera;
  104223. /**
  104224. * Defines if touch is enabled. (Default is true.)
  104225. */
  104226. touchEnabled: boolean;
  104227. /**
  104228. * Defines the buttons associated with the input to handle camera rotation.
  104229. */
  104230. buttons: number[];
  104231. /**
  104232. * Assign buttons for Yaw control.
  104233. */
  104234. buttonsYaw: number[];
  104235. /**
  104236. * Assign buttons for Pitch control.
  104237. */
  104238. buttonsPitch: number[];
  104239. /**
  104240. * Assign buttons for Roll control.
  104241. */
  104242. buttonsRoll: number[];
  104243. /**
  104244. * Detect if any button is being pressed while mouse is moved.
  104245. * -1 = Mouse locked.
  104246. * 0 = Left button.
  104247. * 1 = Middle Button.
  104248. * 2 = Right Button.
  104249. */
  104250. activeButton: number;
  104251. /**
  104252. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104253. * Higher values reduce its sensitivity.
  104254. */
  104255. angularSensibility: number;
  104256. private _mousemoveCallback;
  104257. private _observer;
  104258. private _rollObserver;
  104259. private previousPosition;
  104260. private noPreventDefault;
  104261. private element;
  104262. /**
  104263. * Listen to mouse events to control the camera.
  104264. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104266. */
  104267. constructor(touchEnabled?: boolean);
  104268. /**
  104269. * Attach the mouse control to the HTML DOM element.
  104270. * @param element Defines the element that listens to the input events.
  104271. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104272. */
  104273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104274. /**
  104275. * Detach the current controls from the specified dom element.
  104276. * @param element Defines the element to stop listening the inputs from
  104277. */
  104278. detachControl(element: Nullable<HTMLElement>): void;
  104279. /**
  104280. * Gets the class name of the current input.
  104281. * @returns the class name.
  104282. */
  104283. getClassName(): string;
  104284. /**
  104285. * Get the friendly name associated with the input class.
  104286. * @returns the input's friendly name.
  104287. */
  104288. getSimpleName(): string;
  104289. private _pointerInput;
  104290. private _onMouseMove;
  104291. /**
  104292. * Rotate camera by mouse offset.
  104293. */
  104294. private rotateCamera;
  104295. }
  104296. }
  104297. declare module BABYLON {
  104298. /**
  104299. * Default Inputs manager for the FlyCamera.
  104300. * It groups all the default supported inputs for ease of use.
  104301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104302. */
  104303. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104304. /**
  104305. * Instantiates a new FlyCameraInputsManager.
  104306. * @param camera Defines the camera the inputs belong to.
  104307. */
  104308. constructor(camera: FlyCamera);
  104309. /**
  104310. * Add keyboard input support to the input manager.
  104311. * @returns the new FlyCameraKeyboardMoveInput().
  104312. */
  104313. addKeyboard(): FlyCameraInputsManager;
  104314. /**
  104315. * Add mouse input support to the input manager.
  104316. * @param touchEnabled Enable touch screen support.
  104317. * @returns the new FlyCameraMouseInput().
  104318. */
  104319. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104320. }
  104321. }
  104322. declare module BABYLON {
  104323. /**
  104324. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104325. * such as in a 3D Space Shooter or a Flight Simulator.
  104326. */
  104327. export class FlyCamera extends TargetCamera {
  104328. /**
  104329. * Define the collision ellipsoid of the camera.
  104330. * This is helpful for simulating a camera body, like a player's body.
  104331. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104332. */
  104333. ellipsoid: Vector3;
  104334. /**
  104335. * Define an offset for the position of the ellipsoid around the camera.
  104336. * This can be helpful if the camera is attached away from the player's body center,
  104337. * such as at its head.
  104338. */
  104339. ellipsoidOffset: Vector3;
  104340. /**
  104341. * Enable or disable collisions of the camera with the rest of the scene objects.
  104342. */
  104343. checkCollisions: boolean;
  104344. /**
  104345. * Enable or disable gravity on the camera.
  104346. */
  104347. applyGravity: boolean;
  104348. /**
  104349. * Define the current direction the camera is moving to.
  104350. */
  104351. cameraDirection: Vector3;
  104352. /**
  104353. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104354. * This overrides and empties cameraRotation.
  104355. */
  104356. rotationQuaternion: Quaternion;
  104357. /**
  104358. * Track Roll to maintain the wanted Rolling when looking around.
  104359. */
  104360. _trackRoll: number;
  104361. /**
  104362. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104363. */
  104364. rollCorrect: number;
  104365. /**
  104366. * Mimic a banked turn, Rolling the camera when Yawing.
  104367. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104368. */
  104369. bankedTurn: boolean;
  104370. /**
  104371. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104372. */
  104373. bankedTurnLimit: number;
  104374. /**
  104375. * Value of 0 disables the banked Roll.
  104376. * Value of 1 is equal to the Yaw angle in radians.
  104377. */
  104378. bankedTurnMultiplier: number;
  104379. /**
  104380. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104381. */
  104382. inputs: FlyCameraInputsManager;
  104383. /**
  104384. * Gets the input sensibility for mouse input.
  104385. * Higher values reduce sensitivity.
  104386. */
  104387. /**
  104388. * Sets the input sensibility for a mouse input.
  104389. * Higher values reduce sensitivity.
  104390. */
  104391. angularSensibility: number;
  104392. /**
  104393. * Get the keys for camera movement forward.
  104394. */
  104395. /**
  104396. * Set the keys for camera movement forward.
  104397. */
  104398. keysForward: number[];
  104399. /**
  104400. * Get the keys for camera movement backward.
  104401. */
  104402. keysBackward: number[];
  104403. /**
  104404. * Get the keys for camera movement up.
  104405. */
  104406. /**
  104407. * Set the keys for camera movement up.
  104408. */
  104409. keysUp: number[];
  104410. /**
  104411. * Get the keys for camera movement down.
  104412. */
  104413. /**
  104414. * Set the keys for camera movement down.
  104415. */
  104416. keysDown: number[];
  104417. /**
  104418. * Get the keys for camera movement left.
  104419. */
  104420. /**
  104421. * Set the keys for camera movement left.
  104422. */
  104423. keysLeft: number[];
  104424. /**
  104425. * Set the keys for camera movement right.
  104426. */
  104427. /**
  104428. * Set the keys for camera movement right.
  104429. */
  104430. keysRight: number[];
  104431. /**
  104432. * Event raised when the camera collides with a mesh in the scene.
  104433. */
  104434. onCollide: (collidedMesh: AbstractMesh) => void;
  104435. private _collider;
  104436. private _needMoveForGravity;
  104437. private _oldPosition;
  104438. private _diffPosition;
  104439. private _newPosition;
  104440. /** @hidden */
  104441. _localDirection: Vector3;
  104442. /** @hidden */
  104443. _transformedDirection: Vector3;
  104444. /**
  104445. * Instantiates a FlyCamera.
  104446. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104447. * such as in a 3D Space Shooter or a Flight Simulator.
  104448. * @param name Define the name of the camera in the scene.
  104449. * @param position Define the starting position of the camera in the scene.
  104450. * @param scene Define the scene the camera belongs to.
  104451. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104452. */
  104453. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104454. /**
  104455. * Attach a control to the HTML DOM element.
  104456. * @param element Defines the element that listens to the input events.
  104457. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104458. */
  104459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104460. /**
  104461. * Detach a control from the HTML DOM element.
  104462. * The camera will stop reacting to that input.
  104463. * @param element Defines the element that listens to the input events.
  104464. */
  104465. detachControl(element: HTMLElement): void;
  104466. private _collisionMask;
  104467. /**
  104468. * Get the mask that the camera ignores in collision events.
  104469. */
  104470. /**
  104471. * Set the mask that the camera ignores in collision events.
  104472. */
  104473. collisionMask: number;
  104474. /** @hidden */
  104475. _collideWithWorld(displacement: Vector3): void;
  104476. /** @hidden */
  104477. private _onCollisionPositionChange;
  104478. /** @hidden */
  104479. _checkInputs(): void;
  104480. /** @hidden */
  104481. _decideIfNeedsToMove(): boolean;
  104482. /** @hidden */
  104483. _updatePosition(): void;
  104484. /**
  104485. * Restore the Roll to its target value at the rate specified.
  104486. * @param rate - Higher means slower restoring.
  104487. * @hidden
  104488. */
  104489. restoreRoll(rate: number): void;
  104490. /**
  104491. * Destroy the camera and release the current resources held by it.
  104492. */
  104493. dispose(): void;
  104494. /**
  104495. * Get the current object class name.
  104496. * @returns the class name.
  104497. */
  104498. getClassName(): string;
  104499. }
  104500. }
  104501. declare module BABYLON {
  104502. /**
  104503. * Listen to keyboard events to control the camera.
  104504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104505. */
  104506. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104507. /**
  104508. * Defines the camera the input is attached to.
  104509. */
  104510. camera: FlyCamera;
  104511. /**
  104512. * The list of keyboard keys used to control the forward move of the camera.
  104513. */
  104514. keysForward: number[];
  104515. /**
  104516. * The list of keyboard keys used to control the backward move of the camera.
  104517. */
  104518. keysBackward: number[];
  104519. /**
  104520. * The list of keyboard keys used to control the forward move of the camera.
  104521. */
  104522. keysUp: number[];
  104523. /**
  104524. * The list of keyboard keys used to control the backward move of the camera.
  104525. */
  104526. keysDown: number[];
  104527. /**
  104528. * The list of keyboard keys used to control the right strafe move of the camera.
  104529. */
  104530. keysRight: number[];
  104531. /**
  104532. * The list of keyboard keys used to control the left strafe move of the camera.
  104533. */
  104534. keysLeft: number[];
  104535. private _keys;
  104536. private _onCanvasBlurObserver;
  104537. private _onKeyboardObserver;
  104538. private _engine;
  104539. private _scene;
  104540. /**
  104541. * Attach the input controls to a specific dom element to get the input from.
  104542. * @param element Defines the element the controls should be listened from
  104543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104544. */
  104545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104546. /**
  104547. * Detach the current controls from the specified dom element.
  104548. * @param element Defines the element to stop listening the inputs from
  104549. */
  104550. detachControl(element: Nullable<HTMLElement>): void;
  104551. /**
  104552. * Gets the class name of the current intput.
  104553. * @returns the class name
  104554. */
  104555. getClassName(): string;
  104556. /** @hidden */
  104557. _onLostFocus(e: FocusEvent): void;
  104558. /**
  104559. * Get the friendly name associated with the input class.
  104560. * @returns the input friendly name
  104561. */
  104562. getSimpleName(): string;
  104563. /**
  104564. * Update the current camera state depending on the inputs that have been used this frame.
  104565. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104566. */
  104567. checkInputs(): void;
  104568. }
  104569. }
  104570. declare module BABYLON {
  104571. /**
  104572. * Manage the mouse wheel inputs to control a follow camera.
  104573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104574. */
  104575. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104576. /**
  104577. * Defines the camera the input is attached to.
  104578. */
  104579. camera: FollowCamera;
  104580. /**
  104581. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104582. */
  104583. axisControlRadius: boolean;
  104584. /**
  104585. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104586. */
  104587. axisControlHeight: boolean;
  104588. /**
  104589. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104590. */
  104591. axisControlRotation: boolean;
  104592. /**
  104593. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104594. * relation to mouseWheel events.
  104595. */
  104596. wheelPrecision: number;
  104597. /**
  104598. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104599. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104600. */
  104601. wheelDeltaPercentage: number;
  104602. private _wheel;
  104603. private _observer;
  104604. /**
  104605. * Attach the input controls to a specific dom element to get the input from.
  104606. * @param element Defines the element the controls should be listened from
  104607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104608. */
  104609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104610. /**
  104611. * Detach the current controls from the specified dom element.
  104612. * @param element Defines the element to stop listening the inputs from
  104613. */
  104614. detachControl(element: Nullable<HTMLElement>): void;
  104615. /**
  104616. * Gets the class name of the current intput.
  104617. * @returns the class name
  104618. */
  104619. getClassName(): string;
  104620. /**
  104621. * Get the friendly name associated with the input class.
  104622. * @returns the input friendly name
  104623. */
  104624. getSimpleName(): string;
  104625. }
  104626. }
  104627. declare module BABYLON {
  104628. /**
  104629. * Manage the pointers inputs to control an follow camera.
  104630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104631. */
  104632. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104633. /**
  104634. * Defines the camera the input is attached to.
  104635. */
  104636. camera: FollowCamera;
  104637. /**
  104638. * Gets the class name of the current input.
  104639. * @returns the class name
  104640. */
  104641. getClassName(): string;
  104642. /**
  104643. * Defines the pointer angular sensibility along the X axis or how fast is
  104644. * the camera rotating.
  104645. * A negative number will reverse the axis direction.
  104646. */
  104647. angularSensibilityX: number;
  104648. /**
  104649. * Defines the pointer angular sensibility along the Y axis or how fast is
  104650. * the camera rotating.
  104651. * A negative number will reverse the axis direction.
  104652. */
  104653. angularSensibilityY: number;
  104654. /**
  104655. * Defines the pointer pinch precision or how fast is the camera zooming.
  104656. * A negative number will reverse the axis direction.
  104657. */
  104658. pinchPrecision: number;
  104659. /**
  104660. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104661. * from 0.
  104662. * It defines the percentage of current camera.radius to use as delta when
  104663. * pinch zoom is used.
  104664. */
  104665. pinchDeltaPercentage: number;
  104666. /**
  104667. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104668. */
  104669. axisXControlRadius: boolean;
  104670. /**
  104671. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104672. */
  104673. axisXControlHeight: boolean;
  104674. /**
  104675. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104676. */
  104677. axisXControlRotation: boolean;
  104678. /**
  104679. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104680. */
  104681. axisYControlRadius: boolean;
  104682. /**
  104683. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104684. */
  104685. axisYControlHeight: boolean;
  104686. /**
  104687. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104688. */
  104689. axisYControlRotation: boolean;
  104690. /**
  104691. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104692. */
  104693. axisPinchControlRadius: boolean;
  104694. /**
  104695. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104696. */
  104697. axisPinchControlHeight: boolean;
  104698. /**
  104699. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104700. */
  104701. axisPinchControlRotation: boolean;
  104702. /**
  104703. * Log error messages if basic misconfiguration has occurred.
  104704. */
  104705. warningEnable: boolean;
  104706. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104707. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104708. private _warningCounter;
  104709. private _warning;
  104710. }
  104711. }
  104712. declare module BABYLON {
  104713. /**
  104714. * Default Inputs manager for the FollowCamera.
  104715. * It groups all the default supported inputs for ease of use.
  104716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104717. */
  104718. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104719. /**
  104720. * Instantiates a new FollowCameraInputsManager.
  104721. * @param camera Defines the camera the inputs belong to
  104722. */
  104723. constructor(camera: FollowCamera);
  104724. /**
  104725. * Add keyboard input support to the input manager.
  104726. * @returns the current input manager
  104727. */
  104728. addKeyboard(): FollowCameraInputsManager;
  104729. /**
  104730. * Add mouse wheel input support to the input manager.
  104731. * @returns the current input manager
  104732. */
  104733. addMouseWheel(): FollowCameraInputsManager;
  104734. /**
  104735. * Add pointers input support to the input manager.
  104736. * @returns the current input manager
  104737. */
  104738. addPointers(): FollowCameraInputsManager;
  104739. /**
  104740. * Add orientation input support to the input manager.
  104741. * @returns the current input manager
  104742. */
  104743. addVRDeviceOrientation(): FollowCameraInputsManager;
  104744. }
  104745. }
  104746. declare module BABYLON {
  104747. /**
  104748. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104749. * an arc rotate version arcFollowCamera are available.
  104750. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104751. */
  104752. export class FollowCamera extends TargetCamera {
  104753. /**
  104754. * Distance the follow camera should follow an object at
  104755. */
  104756. radius: number;
  104757. /**
  104758. * Minimum allowed distance of the camera to the axis of rotation
  104759. * (The camera can not get closer).
  104760. * This can help limiting how the Camera is able to move in the scene.
  104761. */
  104762. lowerRadiusLimit: Nullable<number>;
  104763. /**
  104764. * Maximum allowed distance of the camera to the axis of rotation
  104765. * (The camera can not get further).
  104766. * This can help limiting how the Camera is able to move in the scene.
  104767. */
  104768. upperRadiusLimit: Nullable<number>;
  104769. /**
  104770. * Define a rotation offset between the camera and the object it follows
  104771. */
  104772. rotationOffset: number;
  104773. /**
  104774. * Minimum allowed angle to camera position relative to target object.
  104775. * This can help limiting how the Camera is able to move in the scene.
  104776. */
  104777. lowerRotationOffsetLimit: Nullable<number>;
  104778. /**
  104779. * Maximum 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. upperRotationOffsetLimit: Nullable<number>;
  104783. /**
  104784. * Define a height offset between the camera and the object it follows.
  104785. * It can help following an object from the top (like a car chaing a plane)
  104786. */
  104787. heightOffset: number;
  104788. /**
  104789. * Minimum allowed height of camera position relative to target object.
  104790. * This can help limiting how the Camera is able to move in the scene.
  104791. */
  104792. lowerHeightOffsetLimit: Nullable<number>;
  104793. /**
  104794. * Maximum 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. upperHeightOffsetLimit: Nullable<number>;
  104798. /**
  104799. * Define how fast the camera can accelerate to follow it s target.
  104800. */
  104801. cameraAcceleration: number;
  104802. /**
  104803. * Define the speed limit of the camera following an object.
  104804. */
  104805. maxCameraSpeed: number;
  104806. /**
  104807. * Define the target of the camera.
  104808. */
  104809. lockedTarget: Nullable<AbstractMesh>;
  104810. /**
  104811. * Defines the input associated with the camera.
  104812. */
  104813. inputs: FollowCameraInputsManager;
  104814. /**
  104815. * Instantiates the follow camera.
  104816. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104817. * @param name Define the name of the camera in the scene
  104818. * @param position Define the position of the camera
  104819. * @param scene Define the scene the camera belong to
  104820. * @param lockedTarget Define the target of the camera
  104821. */
  104822. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104823. private _follow;
  104824. /**
  104825. * Attached controls to the current camera.
  104826. * @param element Defines the element the controls should be listened from
  104827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104828. */
  104829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104830. /**
  104831. * Detach the current controls from the camera.
  104832. * The camera will stop reacting to inputs.
  104833. * @param element Defines the element to stop listening the inputs from
  104834. */
  104835. detachControl(element: HTMLElement): void;
  104836. /** @hidden */
  104837. _checkInputs(): void;
  104838. private _checkLimits;
  104839. /**
  104840. * Gets the camera class name.
  104841. * @returns the class name
  104842. */
  104843. getClassName(): string;
  104844. }
  104845. /**
  104846. * Arc Rotate version of the follow camera.
  104847. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104848. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104849. */
  104850. export class ArcFollowCamera extends TargetCamera {
  104851. /** The longitudinal angle of the camera */
  104852. alpha: number;
  104853. /** The latitudinal angle of the camera */
  104854. beta: number;
  104855. /** The radius of the camera from its target */
  104856. radius: number;
  104857. /** Define the camera target (the messh it should follow) */
  104858. target: Nullable<AbstractMesh>;
  104859. private _cartesianCoordinates;
  104860. /**
  104861. * Instantiates a new ArcFollowCamera
  104862. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104863. * @param name Define the name of the camera
  104864. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104865. * @param beta Define the rotation angle of the camera around the elevation axis
  104866. * @param radius Define the radius of the camera from its target point
  104867. * @param target Define the target of the camera
  104868. * @param scene Define the scene the camera belongs to
  104869. */
  104870. constructor(name: string,
  104871. /** The longitudinal angle of the camera */
  104872. alpha: number,
  104873. /** The latitudinal angle of the camera */
  104874. beta: number,
  104875. /** The radius of the camera from its target */
  104876. radius: number,
  104877. /** Define the camera target (the messh it should follow) */
  104878. target: Nullable<AbstractMesh>, scene: Scene);
  104879. private _follow;
  104880. /** @hidden */
  104881. _checkInputs(): void;
  104882. /**
  104883. * Returns the class name of the object.
  104884. * It is mostly used internally for serialization purposes.
  104885. */
  104886. getClassName(): string;
  104887. }
  104888. }
  104889. declare module BABYLON {
  104890. /**
  104891. * Manage the keyboard inputs to control the movement of a follow camera.
  104892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104893. */
  104894. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104895. /**
  104896. * Defines the camera the input is attached to.
  104897. */
  104898. camera: FollowCamera;
  104899. /**
  104900. * Defines the list of key codes associated with the up action (increase heightOffset)
  104901. */
  104902. keysHeightOffsetIncr: number[];
  104903. /**
  104904. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104905. */
  104906. keysHeightOffsetDecr: number[];
  104907. /**
  104908. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104909. */
  104910. keysHeightOffsetModifierAlt: boolean;
  104911. /**
  104912. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104913. */
  104914. keysHeightOffsetModifierCtrl: boolean;
  104915. /**
  104916. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104917. */
  104918. keysHeightOffsetModifierShift: boolean;
  104919. /**
  104920. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104921. */
  104922. keysRotationOffsetIncr: number[];
  104923. /**
  104924. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104925. */
  104926. keysRotationOffsetDecr: number[];
  104927. /**
  104928. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104929. */
  104930. keysRotationOffsetModifierAlt: boolean;
  104931. /**
  104932. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104933. */
  104934. keysRotationOffsetModifierCtrl: boolean;
  104935. /**
  104936. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104937. */
  104938. keysRotationOffsetModifierShift: boolean;
  104939. /**
  104940. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104941. */
  104942. keysRadiusIncr: number[];
  104943. /**
  104944. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104945. */
  104946. keysRadiusDecr: number[];
  104947. /**
  104948. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  104949. */
  104950. keysRadiusModifierAlt: boolean;
  104951. /**
  104952. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104953. */
  104954. keysRadiusModifierCtrl: boolean;
  104955. /**
  104956. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104957. */
  104958. keysRadiusModifierShift: boolean;
  104959. /**
  104960. * Defines the rate of change of heightOffset.
  104961. */
  104962. heightSensibility: number;
  104963. /**
  104964. * Defines the rate of change of rotationOffset.
  104965. */
  104966. rotationSensibility: number;
  104967. /**
  104968. * Defines the rate of change of radius.
  104969. */
  104970. radiusSensibility: number;
  104971. private _keys;
  104972. private _ctrlPressed;
  104973. private _altPressed;
  104974. private _shiftPressed;
  104975. private _onCanvasBlurObserver;
  104976. private _onKeyboardObserver;
  104977. private _engine;
  104978. private _scene;
  104979. /**
  104980. * Attach the input controls to a specific dom element to get the input from.
  104981. * @param element Defines the element the controls should be listened from
  104982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104983. */
  104984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104985. /**
  104986. * Detach the current controls from the specified dom element.
  104987. * @param element Defines the element to stop listening the inputs from
  104988. */
  104989. detachControl(element: Nullable<HTMLElement>): void;
  104990. /**
  104991. * Update the current camera state depending on the inputs that have been used this frame.
  104992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104993. */
  104994. checkInputs(): void;
  104995. /**
  104996. * Gets the class name of the current input.
  104997. * @returns the class name
  104998. */
  104999. getClassName(): string;
  105000. /**
  105001. * Get the friendly name associated with the input class.
  105002. * @returns the input friendly name
  105003. */
  105004. getSimpleName(): string;
  105005. /**
  105006. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105007. * allow modification of the heightOffset value.
  105008. */
  105009. private _modifierHeightOffset;
  105010. /**
  105011. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105012. * allow modification of the rotationOffset value.
  105013. */
  105014. private _modifierRotationOffset;
  105015. /**
  105016. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105017. * allow modification of the radius value.
  105018. */
  105019. private _modifierRadius;
  105020. }
  105021. }
  105022. declare module BABYLON {
  105023. interface FreeCameraInputsManager {
  105024. /**
  105025. * @hidden
  105026. */
  105027. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105028. /**
  105029. * Add orientation input support to the input manager.
  105030. * @returns the current input manager
  105031. */
  105032. addDeviceOrientation(): FreeCameraInputsManager;
  105033. }
  105034. /**
  105035. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105036. * Screen rotation is taken into account.
  105037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105038. */
  105039. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105040. private _camera;
  105041. private _screenOrientationAngle;
  105042. private _constantTranform;
  105043. private _screenQuaternion;
  105044. private _alpha;
  105045. private _beta;
  105046. private _gamma;
  105047. /**
  105048. * Can be used to detect if a device orientation sensor is availible on a device
  105049. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105050. * @returns a promise that will resolve on orientation change
  105051. */
  105052. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105053. /**
  105054. * @hidden
  105055. */
  105056. _onDeviceOrientationChangedObservable: Observable<void>;
  105057. /**
  105058. * Instantiates a new input
  105059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105060. */
  105061. constructor();
  105062. /**
  105063. * Define the camera controlled by the input.
  105064. */
  105065. camera: FreeCamera;
  105066. /**
  105067. * Attach the input controls to a specific dom element to get the input from.
  105068. * @param element Defines the element the controls should be listened from
  105069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105070. */
  105071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105072. private _orientationChanged;
  105073. private _deviceOrientation;
  105074. /**
  105075. * Detach the current controls from the specified dom element.
  105076. * @param element Defines the element to stop listening the inputs from
  105077. */
  105078. detachControl(element: Nullable<HTMLElement>): void;
  105079. /**
  105080. * Update the current camera state depending on the inputs that have been used this frame.
  105081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105082. */
  105083. checkInputs(): void;
  105084. /**
  105085. * Gets the class name of the current intput.
  105086. * @returns the class name
  105087. */
  105088. getClassName(): string;
  105089. /**
  105090. * Get the friendly name associated with the input class.
  105091. * @returns the input friendly name
  105092. */
  105093. getSimpleName(): string;
  105094. }
  105095. }
  105096. declare module BABYLON {
  105097. /**
  105098. * Manage the gamepad inputs to control a free camera.
  105099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105100. */
  105101. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105102. /**
  105103. * Define the camera the input is attached to.
  105104. */
  105105. camera: FreeCamera;
  105106. /**
  105107. * Define the Gamepad controlling the input
  105108. */
  105109. gamepad: Nullable<Gamepad>;
  105110. /**
  105111. * Defines the gamepad rotation sensiblity.
  105112. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105113. */
  105114. gamepadAngularSensibility: number;
  105115. /**
  105116. * Defines the gamepad move sensiblity.
  105117. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105118. */
  105119. gamepadMoveSensibility: number;
  105120. private _onGamepadConnectedObserver;
  105121. private _onGamepadDisconnectedObserver;
  105122. private _cameraTransform;
  105123. private _deltaTransform;
  105124. private _vector3;
  105125. private _vector2;
  105126. /**
  105127. * Attach the input controls to a specific dom element to get the input from.
  105128. * @param element Defines the element the controls should be listened from
  105129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105130. */
  105131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105132. /**
  105133. * Detach the current controls from the specified dom element.
  105134. * @param element Defines the element to stop listening the inputs from
  105135. */
  105136. detachControl(element: Nullable<HTMLElement>): void;
  105137. /**
  105138. * Update the current camera state depending on the inputs that have been used this frame.
  105139. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105140. */
  105141. checkInputs(): void;
  105142. /**
  105143. * Gets the class name of the current intput.
  105144. * @returns the class name
  105145. */
  105146. getClassName(): string;
  105147. /**
  105148. * Get the friendly name associated with the input class.
  105149. * @returns the input friendly name
  105150. */
  105151. getSimpleName(): string;
  105152. }
  105153. }
  105154. declare module BABYLON {
  105155. /**
  105156. * Defines the potential axis of a Joystick
  105157. */
  105158. export enum JoystickAxis {
  105159. /** X axis */
  105160. X = 0,
  105161. /** Y axis */
  105162. Y = 1,
  105163. /** Z axis */
  105164. Z = 2
  105165. }
  105166. /**
  105167. * Class used to define virtual joystick (used in touch mode)
  105168. */
  105169. export class VirtualJoystick {
  105170. /**
  105171. * Gets or sets a boolean indicating that left and right values must be inverted
  105172. */
  105173. reverseLeftRight: boolean;
  105174. /**
  105175. * Gets or sets a boolean indicating that up and down values must be inverted
  105176. */
  105177. reverseUpDown: boolean;
  105178. /**
  105179. * Gets the offset value for the position (ie. the change of the position value)
  105180. */
  105181. deltaPosition: Vector3;
  105182. /**
  105183. * Gets a boolean indicating if the virtual joystick was pressed
  105184. */
  105185. pressed: boolean;
  105186. /**
  105187. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105188. */
  105189. static Canvas: Nullable<HTMLCanvasElement>;
  105190. private static _globalJoystickIndex;
  105191. private static vjCanvasContext;
  105192. private static vjCanvasWidth;
  105193. private static vjCanvasHeight;
  105194. private static halfWidth;
  105195. private _action;
  105196. private _axisTargetedByLeftAndRight;
  105197. private _axisTargetedByUpAndDown;
  105198. private _joystickSensibility;
  105199. private _inversedSensibility;
  105200. private _joystickPointerID;
  105201. private _joystickColor;
  105202. private _joystickPointerPos;
  105203. private _joystickPreviousPointerPos;
  105204. private _joystickPointerStartPos;
  105205. private _deltaJoystickVector;
  105206. private _leftJoystick;
  105207. private _touches;
  105208. private _onPointerDownHandlerRef;
  105209. private _onPointerMoveHandlerRef;
  105210. private _onPointerUpHandlerRef;
  105211. private _onResize;
  105212. /**
  105213. * Creates a new virtual joystick
  105214. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105215. */
  105216. constructor(leftJoystick?: boolean);
  105217. /**
  105218. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105219. * @param newJoystickSensibility defines the new sensibility
  105220. */
  105221. setJoystickSensibility(newJoystickSensibility: number): void;
  105222. private _onPointerDown;
  105223. private _onPointerMove;
  105224. private _onPointerUp;
  105225. /**
  105226. * Change the color of the virtual joystick
  105227. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105228. */
  105229. setJoystickColor(newColor: string): void;
  105230. /**
  105231. * Defines a callback to call when the joystick is touched
  105232. * @param action defines the callback
  105233. */
  105234. setActionOnTouch(action: () => any): void;
  105235. /**
  105236. * Defines which axis you'd like to control for left & right
  105237. * @param axis defines the axis to use
  105238. */
  105239. setAxisForLeftRight(axis: JoystickAxis): void;
  105240. /**
  105241. * Defines which axis you'd like to control for up & down
  105242. * @param axis defines the axis to use
  105243. */
  105244. setAxisForUpDown(axis: JoystickAxis): void;
  105245. private _drawVirtualJoystick;
  105246. /**
  105247. * Release internal HTML canvas
  105248. */
  105249. releaseCanvas(): void;
  105250. }
  105251. }
  105252. declare module BABYLON {
  105253. interface FreeCameraInputsManager {
  105254. /**
  105255. * Add virtual joystick input support to the input manager.
  105256. * @returns the current input manager
  105257. */
  105258. addVirtualJoystick(): FreeCameraInputsManager;
  105259. }
  105260. /**
  105261. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105263. */
  105264. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105265. /**
  105266. * Defines the camera the input is attached to.
  105267. */
  105268. camera: FreeCamera;
  105269. private _leftjoystick;
  105270. private _rightjoystick;
  105271. /**
  105272. * Gets the left stick of the virtual joystick.
  105273. * @returns The virtual Joystick
  105274. */
  105275. getLeftJoystick(): VirtualJoystick;
  105276. /**
  105277. * Gets the right stick of the virtual joystick.
  105278. * @returns The virtual Joystick
  105279. */
  105280. getRightJoystick(): VirtualJoystick;
  105281. /**
  105282. * Update the current camera state depending on the inputs that have been used this frame.
  105283. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105284. */
  105285. checkInputs(): void;
  105286. /**
  105287. * Attach the input controls to a specific dom element to get the input from.
  105288. * @param element Defines the element the controls should be listened from
  105289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105290. */
  105291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105292. /**
  105293. * Detach the current controls from the specified dom element.
  105294. * @param element Defines the element to stop listening the inputs from
  105295. */
  105296. detachControl(element: Nullable<HTMLElement>): void;
  105297. /**
  105298. * Gets the class name of the current intput.
  105299. * @returns the class name
  105300. */
  105301. getClassName(): string;
  105302. /**
  105303. * Get the friendly name associated with the input class.
  105304. * @returns the input friendly name
  105305. */
  105306. getSimpleName(): string;
  105307. }
  105308. }
  105309. declare module BABYLON {
  105310. /**
  105311. * This represents a FPS type of camera controlled by touch.
  105312. * This is like a universal camera minus the Gamepad controls.
  105313. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105314. */
  105315. export class TouchCamera extends FreeCamera {
  105316. /**
  105317. * Defines the touch sensibility for rotation.
  105318. * The higher the faster.
  105319. */
  105320. touchAngularSensibility: number;
  105321. /**
  105322. * Defines the touch sensibility for move.
  105323. * The higher the faster.
  105324. */
  105325. touchMoveSensibility: number;
  105326. /**
  105327. * Instantiates a new touch camera.
  105328. * This represents a FPS type of camera controlled by touch.
  105329. * This is like a universal camera minus the Gamepad controls.
  105330. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105331. * @param name Define the name of the camera in the scene
  105332. * @param position Define the start position of the camera in the scene
  105333. * @param scene Define the scene the camera belongs to
  105334. */
  105335. constructor(name: string, position: Vector3, scene: Scene);
  105336. /**
  105337. * Gets the current object class name.
  105338. * @return the class name
  105339. */
  105340. getClassName(): string;
  105341. /** @hidden */
  105342. _setupInputs(): void;
  105343. }
  105344. }
  105345. declare module BABYLON {
  105346. /**
  105347. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105348. * being tilted forward or back and left or right.
  105349. */
  105350. export class DeviceOrientationCamera extends FreeCamera {
  105351. private _initialQuaternion;
  105352. private _quaternionCache;
  105353. private _tmpDragQuaternion;
  105354. private _disablePointerInputWhenUsingDeviceOrientation;
  105355. /**
  105356. * Creates a new device orientation camera
  105357. * @param name The name of the camera
  105358. * @param position The start position camera
  105359. * @param scene The scene the camera belongs to
  105360. */
  105361. constructor(name: string, position: Vector3, scene: Scene);
  105362. /**
  105363. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105364. */
  105365. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105366. private _dragFactor;
  105367. /**
  105368. * Enabled turning on the y axis when the orientation sensor is active
  105369. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105370. */
  105371. enableHorizontalDragging(dragFactor?: number): void;
  105372. /**
  105373. * Gets the current instance class name ("DeviceOrientationCamera").
  105374. * This helps avoiding instanceof at run time.
  105375. * @returns the class name
  105376. */
  105377. getClassName(): string;
  105378. /**
  105379. * @hidden
  105380. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105381. */
  105382. _checkInputs(): void;
  105383. /**
  105384. * Reset the camera to its default orientation on the specified axis only.
  105385. * @param axis The axis to reset
  105386. */
  105387. resetToCurrentRotation(axis?: Axis): void;
  105388. }
  105389. }
  105390. declare module BABYLON {
  105391. /**
  105392. * Defines supported buttons for XBox360 compatible gamepads
  105393. */
  105394. export enum Xbox360Button {
  105395. /** A */
  105396. A = 0,
  105397. /** B */
  105398. B = 1,
  105399. /** X */
  105400. X = 2,
  105401. /** Y */
  105402. Y = 3,
  105403. /** Start */
  105404. Start = 4,
  105405. /** Back */
  105406. Back = 5,
  105407. /** Left button */
  105408. LB = 6,
  105409. /** Right button */
  105410. RB = 7,
  105411. /** Left stick */
  105412. LeftStick = 8,
  105413. /** Right stick */
  105414. RightStick = 9
  105415. }
  105416. /** Defines values for XBox360 DPad */
  105417. export enum Xbox360Dpad {
  105418. /** Up */
  105419. Up = 0,
  105420. /** Down */
  105421. Down = 1,
  105422. /** Left */
  105423. Left = 2,
  105424. /** Right */
  105425. Right = 3
  105426. }
  105427. /**
  105428. * Defines a XBox360 gamepad
  105429. */
  105430. export class Xbox360Pad extends Gamepad {
  105431. private _leftTrigger;
  105432. private _rightTrigger;
  105433. private _onlefttriggerchanged;
  105434. private _onrighttriggerchanged;
  105435. private _onbuttondown;
  105436. private _onbuttonup;
  105437. private _ondpaddown;
  105438. private _ondpadup;
  105439. /** Observable raised when a button is pressed */
  105440. onButtonDownObservable: Observable<Xbox360Button>;
  105441. /** Observable raised when a button is released */
  105442. onButtonUpObservable: Observable<Xbox360Button>;
  105443. /** Observable raised when a pad is pressed */
  105444. onPadDownObservable: Observable<Xbox360Dpad>;
  105445. /** Observable raised when a pad is released */
  105446. onPadUpObservable: Observable<Xbox360Dpad>;
  105447. private _buttonA;
  105448. private _buttonB;
  105449. private _buttonX;
  105450. private _buttonY;
  105451. private _buttonBack;
  105452. private _buttonStart;
  105453. private _buttonLB;
  105454. private _buttonRB;
  105455. private _buttonLeftStick;
  105456. private _buttonRightStick;
  105457. private _dPadUp;
  105458. private _dPadDown;
  105459. private _dPadLeft;
  105460. private _dPadRight;
  105461. private _isXboxOnePad;
  105462. /**
  105463. * Creates a new XBox360 gamepad object
  105464. * @param id defines the id of this gamepad
  105465. * @param index defines its index
  105466. * @param gamepad defines the internal HTML gamepad object
  105467. * @param xboxOne defines if it is a XBox One gamepad
  105468. */
  105469. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105470. /**
  105471. * Defines the callback to call when left trigger is pressed
  105472. * @param callback defines the callback to use
  105473. */
  105474. onlefttriggerchanged(callback: (value: number) => void): void;
  105475. /**
  105476. * Defines the callback to call when right trigger is pressed
  105477. * @param callback defines the callback to use
  105478. */
  105479. onrighttriggerchanged(callback: (value: number) => void): void;
  105480. /**
  105481. * Gets the left trigger value
  105482. */
  105483. /**
  105484. * Sets the left trigger value
  105485. */
  105486. leftTrigger: number;
  105487. /**
  105488. * Gets the right trigger value
  105489. */
  105490. /**
  105491. * Sets the right trigger value
  105492. */
  105493. rightTrigger: number;
  105494. /**
  105495. * Defines the callback to call when a button is pressed
  105496. * @param callback defines the callback to use
  105497. */
  105498. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105499. /**
  105500. * Defines the callback to call when a button is released
  105501. * @param callback defines the callback to use
  105502. */
  105503. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105504. /**
  105505. * Defines the callback to call when a pad is pressed
  105506. * @param callback defines the callback to use
  105507. */
  105508. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105509. /**
  105510. * Defines the callback to call when a pad is released
  105511. * @param callback defines the callback to use
  105512. */
  105513. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105514. private _setButtonValue;
  105515. private _setDPadValue;
  105516. /**
  105517. * Gets the value of the `A` button
  105518. */
  105519. /**
  105520. * Sets the value of the `A` button
  105521. */
  105522. buttonA: number;
  105523. /**
  105524. * Gets the value of the `B` button
  105525. */
  105526. /**
  105527. * Sets the value of the `B` button
  105528. */
  105529. buttonB: number;
  105530. /**
  105531. * Gets the value of the `X` button
  105532. */
  105533. /**
  105534. * Sets the value of the `X` button
  105535. */
  105536. buttonX: number;
  105537. /**
  105538. * Gets the value of the `Y` button
  105539. */
  105540. /**
  105541. * Sets the value of the `Y` button
  105542. */
  105543. buttonY: number;
  105544. /**
  105545. * Gets the value of the `Start` button
  105546. */
  105547. /**
  105548. * Sets the value of the `Start` button
  105549. */
  105550. buttonStart: number;
  105551. /**
  105552. * Gets the value of the `Back` button
  105553. */
  105554. /**
  105555. * Sets the value of the `Back` button
  105556. */
  105557. buttonBack: number;
  105558. /**
  105559. * Gets the value of the `Left` button
  105560. */
  105561. /**
  105562. * Sets the value of the `Left` button
  105563. */
  105564. buttonLB: number;
  105565. /**
  105566. * Gets the value of the `Right` button
  105567. */
  105568. /**
  105569. * Sets the value of the `Right` button
  105570. */
  105571. buttonRB: number;
  105572. /**
  105573. * Gets the value of the Left joystick
  105574. */
  105575. /**
  105576. * Sets the value of the Left joystick
  105577. */
  105578. buttonLeftStick: number;
  105579. /**
  105580. * Gets the value of the Right joystick
  105581. */
  105582. /**
  105583. * Sets the value of the Right joystick
  105584. */
  105585. buttonRightStick: number;
  105586. /**
  105587. * Gets the value of D-pad up
  105588. */
  105589. /**
  105590. * Sets the value of D-pad up
  105591. */
  105592. dPadUp: number;
  105593. /**
  105594. * Gets the value of D-pad down
  105595. */
  105596. /**
  105597. * Sets the value of D-pad down
  105598. */
  105599. dPadDown: number;
  105600. /**
  105601. * Gets the value of D-pad left
  105602. */
  105603. /**
  105604. * Sets the value of D-pad left
  105605. */
  105606. dPadLeft: number;
  105607. /**
  105608. * Gets the value of D-pad right
  105609. */
  105610. /**
  105611. * Sets the value of D-pad right
  105612. */
  105613. dPadRight: number;
  105614. /**
  105615. * Force the gamepad to synchronize with device values
  105616. */
  105617. update(): void;
  105618. /**
  105619. * Disposes the gamepad
  105620. */
  105621. dispose(): void;
  105622. }
  105623. }
  105624. declare module BABYLON {
  105625. /**
  105626. * Defines supported buttons for DualShock compatible gamepads
  105627. */
  105628. export enum DualShockButton {
  105629. /** Cross */
  105630. Cross = 0,
  105631. /** Circle */
  105632. Circle = 1,
  105633. /** Square */
  105634. Square = 2,
  105635. /** Triangle */
  105636. Triangle = 3,
  105637. /** Options */
  105638. Options = 4,
  105639. /** Share */
  105640. Share = 5,
  105641. /** L1 */
  105642. L1 = 6,
  105643. /** R1 */
  105644. R1 = 7,
  105645. /** Left stick */
  105646. LeftStick = 8,
  105647. /** Right stick */
  105648. RightStick = 9
  105649. }
  105650. /** Defines values for DualShock DPad */
  105651. export enum DualShockDpad {
  105652. /** Up */
  105653. Up = 0,
  105654. /** Down */
  105655. Down = 1,
  105656. /** Left */
  105657. Left = 2,
  105658. /** Right */
  105659. Right = 3
  105660. }
  105661. /**
  105662. * Defines a DualShock gamepad
  105663. */
  105664. export class DualShockPad extends Gamepad {
  105665. private _leftTrigger;
  105666. private _rightTrigger;
  105667. private _onlefttriggerchanged;
  105668. private _onrighttriggerchanged;
  105669. private _onbuttondown;
  105670. private _onbuttonup;
  105671. private _ondpaddown;
  105672. private _ondpadup;
  105673. /** Observable raised when a button is pressed */
  105674. onButtonDownObservable: Observable<DualShockButton>;
  105675. /** Observable raised when a button is released */
  105676. onButtonUpObservable: Observable<DualShockButton>;
  105677. /** Observable raised when a pad is pressed */
  105678. onPadDownObservable: Observable<DualShockDpad>;
  105679. /** Observable raised when a pad is released */
  105680. onPadUpObservable: Observable<DualShockDpad>;
  105681. private _buttonCross;
  105682. private _buttonCircle;
  105683. private _buttonSquare;
  105684. private _buttonTriangle;
  105685. private _buttonShare;
  105686. private _buttonOptions;
  105687. private _buttonL1;
  105688. private _buttonR1;
  105689. private _buttonLeftStick;
  105690. private _buttonRightStick;
  105691. private _dPadUp;
  105692. private _dPadDown;
  105693. private _dPadLeft;
  105694. private _dPadRight;
  105695. /**
  105696. * Creates a new DualShock gamepad object
  105697. * @param id defines the id of this gamepad
  105698. * @param index defines its index
  105699. * @param gamepad defines the internal HTML gamepad object
  105700. */
  105701. constructor(id: string, index: number, gamepad: any);
  105702. /**
  105703. * Defines the callback to call when left trigger is pressed
  105704. * @param callback defines the callback to use
  105705. */
  105706. onlefttriggerchanged(callback: (value: number) => void): void;
  105707. /**
  105708. * Defines the callback to call when right trigger is pressed
  105709. * @param callback defines the callback to use
  105710. */
  105711. onrighttriggerchanged(callback: (value: number) => void): void;
  105712. /**
  105713. * Gets the left trigger value
  105714. */
  105715. /**
  105716. * Sets the left trigger value
  105717. */
  105718. leftTrigger: number;
  105719. /**
  105720. * Gets the right trigger value
  105721. */
  105722. /**
  105723. * Sets the right trigger value
  105724. */
  105725. rightTrigger: number;
  105726. /**
  105727. * Defines the callback to call when a button is pressed
  105728. * @param callback defines the callback to use
  105729. */
  105730. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105731. /**
  105732. * Defines the callback to call when a button is released
  105733. * @param callback defines the callback to use
  105734. */
  105735. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105736. /**
  105737. * Defines the callback to call when a pad is pressed
  105738. * @param callback defines the callback to use
  105739. */
  105740. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105741. /**
  105742. * Defines the callback to call when a pad is released
  105743. * @param callback defines the callback to use
  105744. */
  105745. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105746. private _setButtonValue;
  105747. private _setDPadValue;
  105748. /**
  105749. * Gets the value of the `Cross` button
  105750. */
  105751. /**
  105752. * Sets the value of the `Cross` button
  105753. */
  105754. buttonCross: number;
  105755. /**
  105756. * Gets the value of the `Circle` button
  105757. */
  105758. /**
  105759. * Sets the value of the `Circle` button
  105760. */
  105761. buttonCircle: number;
  105762. /**
  105763. * Gets the value of the `Square` button
  105764. */
  105765. /**
  105766. * Sets the value of the `Square` button
  105767. */
  105768. buttonSquare: number;
  105769. /**
  105770. * Gets the value of the `Triangle` button
  105771. */
  105772. /**
  105773. * Sets the value of the `Triangle` button
  105774. */
  105775. buttonTriangle: number;
  105776. /**
  105777. * Gets the value of the `Options` button
  105778. */
  105779. /**
  105780. * Sets the value of the `Options` button
  105781. */
  105782. buttonOptions: number;
  105783. /**
  105784. * Gets the value of the `Share` button
  105785. */
  105786. /**
  105787. * Sets the value of the `Share` button
  105788. */
  105789. buttonShare: number;
  105790. /**
  105791. * Gets the value of the `L1` button
  105792. */
  105793. /**
  105794. * Sets the value of the `L1` button
  105795. */
  105796. buttonL1: number;
  105797. /**
  105798. * Gets the value of the `R1` button
  105799. */
  105800. /**
  105801. * Sets the value of the `R1` button
  105802. */
  105803. buttonR1: number;
  105804. /**
  105805. * Gets the value of the Left joystick
  105806. */
  105807. /**
  105808. * Sets the value of the Left joystick
  105809. */
  105810. buttonLeftStick: number;
  105811. /**
  105812. * Gets the value of the Right joystick
  105813. */
  105814. /**
  105815. * Sets the value of the Right joystick
  105816. */
  105817. buttonRightStick: number;
  105818. /**
  105819. * Gets the value of D-pad up
  105820. */
  105821. /**
  105822. * Sets the value of D-pad up
  105823. */
  105824. dPadUp: number;
  105825. /**
  105826. * Gets the value of D-pad down
  105827. */
  105828. /**
  105829. * Sets the value of D-pad down
  105830. */
  105831. dPadDown: number;
  105832. /**
  105833. * Gets the value of D-pad left
  105834. */
  105835. /**
  105836. * Sets the value of D-pad left
  105837. */
  105838. dPadLeft: number;
  105839. /**
  105840. * Gets the value of D-pad right
  105841. */
  105842. /**
  105843. * Sets the value of D-pad right
  105844. */
  105845. dPadRight: number;
  105846. /**
  105847. * Force the gamepad to synchronize with device values
  105848. */
  105849. update(): void;
  105850. /**
  105851. * Disposes the gamepad
  105852. */
  105853. dispose(): void;
  105854. }
  105855. }
  105856. declare module BABYLON {
  105857. /**
  105858. * Manager for handling gamepads
  105859. */
  105860. export class GamepadManager {
  105861. private _scene?;
  105862. private _babylonGamepads;
  105863. private _oneGamepadConnected;
  105864. /** @hidden */
  105865. _isMonitoring: boolean;
  105866. private _gamepadEventSupported;
  105867. private _gamepadSupport;
  105868. /**
  105869. * observable to be triggered when the gamepad controller has been connected
  105870. */
  105871. onGamepadConnectedObservable: Observable<Gamepad>;
  105872. /**
  105873. * observable to be triggered when the gamepad controller has been disconnected
  105874. */
  105875. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105876. private _onGamepadConnectedEvent;
  105877. private _onGamepadDisconnectedEvent;
  105878. /**
  105879. * Initializes the gamepad manager
  105880. * @param _scene BabylonJS scene
  105881. */
  105882. constructor(_scene?: Scene | undefined);
  105883. /**
  105884. * The gamepads in the game pad manager
  105885. */
  105886. readonly gamepads: Gamepad[];
  105887. /**
  105888. * Get the gamepad controllers based on type
  105889. * @param type The type of gamepad controller
  105890. * @returns Nullable gamepad
  105891. */
  105892. getGamepadByType(type?: number): Nullable<Gamepad>;
  105893. /**
  105894. * Disposes the gamepad manager
  105895. */
  105896. dispose(): void;
  105897. private _addNewGamepad;
  105898. private _startMonitoringGamepads;
  105899. private _stopMonitoringGamepads;
  105900. /** @hidden */
  105901. _checkGamepadsStatus(): void;
  105902. private _updateGamepadObjects;
  105903. }
  105904. }
  105905. declare module BABYLON {
  105906. interface Scene {
  105907. /** @hidden */
  105908. _gamepadManager: Nullable<GamepadManager>;
  105909. /**
  105910. * Gets the gamepad manager associated with the scene
  105911. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105912. */
  105913. gamepadManager: GamepadManager;
  105914. }
  105915. /**
  105916. * Interface representing a free camera inputs manager
  105917. */
  105918. interface FreeCameraInputsManager {
  105919. /**
  105920. * Adds gamepad input support to the FreeCameraInputsManager.
  105921. * @returns the FreeCameraInputsManager
  105922. */
  105923. addGamepad(): FreeCameraInputsManager;
  105924. }
  105925. /**
  105926. * Interface representing an arc rotate camera inputs manager
  105927. */
  105928. interface ArcRotateCameraInputsManager {
  105929. /**
  105930. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105931. * @returns the camera inputs manager
  105932. */
  105933. addGamepad(): ArcRotateCameraInputsManager;
  105934. }
  105935. /**
  105936. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105937. */
  105938. export class GamepadSystemSceneComponent implements ISceneComponent {
  105939. /**
  105940. * The component name helpfull to identify the component in the list of scene components.
  105941. */
  105942. readonly name: string;
  105943. /**
  105944. * The scene the component belongs to.
  105945. */
  105946. scene: Scene;
  105947. /**
  105948. * Creates a new instance of the component for the given scene
  105949. * @param scene Defines the scene to register the component in
  105950. */
  105951. constructor(scene: Scene);
  105952. /**
  105953. * Registers the component in a given scene
  105954. */
  105955. register(): void;
  105956. /**
  105957. * Rebuilds the elements related to this component in case of
  105958. * context lost for instance.
  105959. */
  105960. rebuild(): void;
  105961. /**
  105962. * Disposes the component and the associated ressources
  105963. */
  105964. dispose(): void;
  105965. private _beforeCameraUpdate;
  105966. }
  105967. }
  105968. declare module BABYLON {
  105969. /**
  105970. * 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,
  105971. * which still works and will still be found in many Playgrounds.
  105972. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105973. */
  105974. export class UniversalCamera extends TouchCamera {
  105975. /**
  105976. * Defines the gamepad rotation sensiblity.
  105977. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105978. */
  105979. gamepadAngularSensibility: number;
  105980. /**
  105981. * Defines the gamepad move sensiblity.
  105982. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105983. */
  105984. gamepadMoveSensibility: number;
  105985. /**
  105986. * 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,
  105987. * which still works and will still be found in many Playgrounds.
  105988. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105989. * @param name Define the name of the camera in the scene
  105990. * @param position Define the start position of the camera in the scene
  105991. * @param scene Define the scene the camera belongs to
  105992. */
  105993. constructor(name: string, position: Vector3, scene: Scene);
  105994. /**
  105995. * Gets the current object class name.
  105996. * @return the class name
  105997. */
  105998. getClassName(): string;
  105999. }
  106000. }
  106001. declare module BABYLON {
  106002. /**
  106003. * This represents a FPS type of camera. This is only here for back compat purpose.
  106004. * Please use the UniversalCamera instead as both are identical.
  106005. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106006. */
  106007. export class GamepadCamera extends UniversalCamera {
  106008. /**
  106009. * Instantiates a new Gamepad Camera
  106010. * This represents a FPS type of camera. This is only here for back compat purpose.
  106011. * Please use the UniversalCamera instead as both are identical.
  106012. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106013. * @param name Define the name of the camera in the scene
  106014. * @param position Define the start position of the camera in the scene
  106015. * @param scene Define the scene the camera belongs to
  106016. */
  106017. constructor(name: string, position: Vector3, scene: Scene);
  106018. /**
  106019. * Gets the current object class name.
  106020. * @return the class name
  106021. */
  106022. getClassName(): string;
  106023. }
  106024. }
  106025. declare module BABYLON {
  106026. /** @hidden */
  106027. export var passPixelShader: {
  106028. name: string;
  106029. shader: string;
  106030. };
  106031. }
  106032. declare module BABYLON {
  106033. /** @hidden */
  106034. export var passCubePixelShader: {
  106035. name: string;
  106036. shader: string;
  106037. };
  106038. }
  106039. declare module BABYLON {
  106040. /**
  106041. * PassPostProcess which produces an output the same as it's input
  106042. */
  106043. export class PassPostProcess extends PostProcess {
  106044. /**
  106045. * Creates the PassPostProcess
  106046. * @param name The name of the effect.
  106047. * @param options The required width/height ratio to downsize to before computing the render pass.
  106048. * @param camera The camera to apply the render pass to.
  106049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106050. * @param engine The engine which the post process will be applied. (default: current engine)
  106051. * @param reusable If the post process can be reused on the same frame. (default: false)
  106052. * @param textureType The type of texture to be used when performing the post processing.
  106053. * @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)
  106054. */
  106055. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106056. }
  106057. /**
  106058. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106059. */
  106060. export class PassCubePostProcess extends PostProcess {
  106061. private _face;
  106062. /**
  106063. * Gets or sets the cube face to display.
  106064. * * 0 is +X
  106065. * * 1 is -X
  106066. * * 2 is +Y
  106067. * * 3 is -Y
  106068. * * 4 is +Z
  106069. * * 5 is -Z
  106070. */
  106071. face: number;
  106072. /**
  106073. * Creates the PassCubePostProcess
  106074. * @param name The name of the effect.
  106075. * @param options The required width/height ratio to downsize to before computing the render pass.
  106076. * @param camera The camera to apply the render pass to.
  106077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106078. * @param engine The engine which the post process will be applied. (default: current engine)
  106079. * @param reusable If the post process can be reused on the same frame. (default: false)
  106080. * @param textureType The type of texture to be used when performing the post processing.
  106081. * @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)
  106082. */
  106083. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106084. }
  106085. }
  106086. declare module BABYLON {
  106087. /** @hidden */
  106088. export var anaglyphPixelShader: {
  106089. name: string;
  106090. shader: string;
  106091. };
  106092. }
  106093. declare module BABYLON {
  106094. /**
  106095. * Postprocess used to generate anaglyphic rendering
  106096. */
  106097. export class AnaglyphPostProcess extends PostProcess {
  106098. private _passedProcess;
  106099. /**
  106100. * Creates a new AnaglyphPostProcess
  106101. * @param name defines postprocess name
  106102. * @param options defines creation options or target ratio scale
  106103. * @param rigCameras defines cameras using this postprocess
  106104. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106105. * @param engine defines hosting engine
  106106. * @param reusable defines if the postprocess will be reused multiple times per frame
  106107. */
  106108. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106109. }
  106110. }
  106111. declare module BABYLON {
  106112. /**
  106113. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106114. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106115. */
  106116. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106117. /**
  106118. * Creates a new AnaglyphArcRotateCamera
  106119. * @param name defines camera name
  106120. * @param alpha defines alpha angle (in radians)
  106121. * @param beta defines beta angle (in radians)
  106122. * @param radius defines radius
  106123. * @param target defines camera target
  106124. * @param interaxialDistance defines distance between each color axis
  106125. * @param scene defines the hosting scene
  106126. */
  106127. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106128. /**
  106129. * Gets camera class name
  106130. * @returns AnaglyphArcRotateCamera
  106131. */
  106132. getClassName(): string;
  106133. }
  106134. }
  106135. declare module BABYLON {
  106136. /**
  106137. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106138. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106139. */
  106140. export class AnaglyphFreeCamera extends FreeCamera {
  106141. /**
  106142. * Creates a new AnaglyphFreeCamera
  106143. * @param name defines camera name
  106144. * @param position defines initial position
  106145. * @param interaxialDistance defines distance between each color axis
  106146. * @param scene defines the hosting scene
  106147. */
  106148. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106149. /**
  106150. * Gets camera class name
  106151. * @returns AnaglyphFreeCamera
  106152. */
  106153. getClassName(): string;
  106154. }
  106155. }
  106156. declare module BABYLON {
  106157. /**
  106158. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106159. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106160. */
  106161. export class AnaglyphGamepadCamera extends GamepadCamera {
  106162. /**
  106163. * Creates a new AnaglyphGamepadCamera
  106164. * @param name defines camera name
  106165. * @param position defines initial position
  106166. * @param interaxialDistance defines distance between each color axis
  106167. * @param scene defines the hosting scene
  106168. */
  106169. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106170. /**
  106171. * Gets camera class name
  106172. * @returns AnaglyphGamepadCamera
  106173. */
  106174. getClassName(): string;
  106175. }
  106176. }
  106177. declare module BABYLON {
  106178. /**
  106179. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106180. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106181. */
  106182. export class AnaglyphUniversalCamera extends UniversalCamera {
  106183. /**
  106184. * Creates a new AnaglyphUniversalCamera
  106185. * @param name defines camera name
  106186. * @param position defines initial position
  106187. * @param interaxialDistance defines distance between each color axis
  106188. * @param scene defines the hosting scene
  106189. */
  106190. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106191. /**
  106192. * Gets camera class name
  106193. * @returns AnaglyphUniversalCamera
  106194. */
  106195. getClassName(): string;
  106196. }
  106197. }
  106198. declare module BABYLON {
  106199. /** @hidden */
  106200. export var stereoscopicInterlacePixelShader: {
  106201. name: string;
  106202. shader: string;
  106203. };
  106204. }
  106205. declare module BABYLON {
  106206. /**
  106207. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106208. */
  106209. export class StereoscopicInterlacePostProcess extends PostProcess {
  106210. private _stepSize;
  106211. private _passedProcess;
  106212. /**
  106213. * Initializes a StereoscopicInterlacePostProcess
  106214. * @param name The name of the effect.
  106215. * @param rigCameras The rig cameras to be appled to the post process
  106216. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106218. * @param engine The engine which the post process will be applied. (default: current engine)
  106219. * @param reusable If the post process can be reused on the same frame. (default: false)
  106220. */
  106221. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106222. }
  106223. }
  106224. declare module BABYLON {
  106225. /**
  106226. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106227. * @see http://doc.babylonjs.com/features/cameras
  106228. */
  106229. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106230. /**
  106231. * Creates a new StereoscopicArcRotateCamera
  106232. * @param name defines camera name
  106233. * @param alpha defines alpha angle (in radians)
  106234. * @param beta defines beta angle (in radians)
  106235. * @param radius defines radius
  106236. * @param target defines camera target
  106237. * @param interaxialDistance defines distance between each color axis
  106238. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106239. * @param scene defines the hosting scene
  106240. */
  106241. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106242. /**
  106243. * Gets camera class name
  106244. * @returns StereoscopicArcRotateCamera
  106245. */
  106246. getClassName(): string;
  106247. }
  106248. }
  106249. declare module BABYLON {
  106250. /**
  106251. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106252. * @see http://doc.babylonjs.com/features/cameras
  106253. */
  106254. export class StereoscopicFreeCamera extends FreeCamera {
  106255. /**
  106256. * Creates a new StereoscopicFreeCamera
  106257. * @param name defines camera name
  106258. * @param position defines initial position
  106259. * @param interaxialDistance defines distance between each color axis
  106260. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106261. * @param scene defines the hosting scene
  106262. */
  106263. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106264. /**
  106265. * Gets camera class name
  106266. * @returns StereoscopicFreeCamera
  106267. */
  106268. getClassName(): string;
  106269. }
  106270. }
  106271. declare module BABYLON {
  106272. /**
  106273. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106274. * @see http://doc.babylonjs.com/features/cameras
  106275. */
  106276. export class StereoscopicGamepadCamera extends GamepadCamera {
  106277. /**
  106278. * Creates a new StereoscopicGamepadCamera
  106279. * @param name defines camera name
  106280. * @param position defines initial position
  106281. * @param interaxialDistance defines distance between each color axis
  106282. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106283. * @param scene defines the hosting scene
  106284. */
  106285. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106286. /**
  106287. * Gets camera class name
  106288. * @returns StereoscopicGamepadCamera
  106289. */
  106290. getClassName(): string;
  106291. }
  106292. }
  106293. declare module BABYLON {
  106294. /**
  106295. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106296. * @see http://doc.babylonjs.com/features/cameras
  106297. */
  106298. export class StereoscopicUniversalCamera extends UniversalCamera {
  106299. /**
  106300. * Creates a new StereoscopicUniversalCamera
  106301. * @param name defines camera name
  106302. * @param position defines initial position
  106303. * @param interaxialDistance defines distance between each color axis
  106304. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106305. * @param scene defines the hosting scene
  106306. */
  106307. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106308. /**
  106309. * Gets camera class name
  106310. * @returns StereoscopicUniversalCamera
  106311. */
  106312. getClassName(): string;
  106313. }
  106314. }
  106315. declare module BABYLON {
  106316. /**
  106317. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106318. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106319. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106320. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106321. */
  106322. export class VirtualJoysticksCamera extends FreeCamera {
  106323. /**
  106324. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106325. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106326. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106327. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106328. * @param name Define the name of the camera in the scene
  106329. * @param position Define the start position of the camera in the scene
  106330. * @param scene Define the scene the camera belongs to
  106331. */
  106332. constructor(name: string, position: Vector3, scene: Scene);
  106333. /**
  106334. * Gets the current object class name.
  106335. * @return the class name
  106336. */
  106337. getClassName(): string;
  106338. }
  106339. }
  106340. declare module BABYLON {
  106341. /**
  106342. * This represents all the required metrics to create a VR camera.
  106343. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106344. */
  106345. export class VRCameraMetrics {
  106346. /**
  106347. * Define the horizontal resolution off the screen.
  106348. */
  106349. hResolution: number;
  106350. /**
  106351. * Define the vertical resolution off the screen.
  106352. */
  106353. vResolution: number;
  106354. /**
  106355. * Define the horizontal screen size.
  106356. */
  106357. hScreenSize: number;
  106358. /**
  106359. * Define the vertical screen size.
  106360. */
  106361. vScreenSize: number;
  106362. /**
  106363. * Define the vertical screen center position.
  106364. */
  106365. vScreenCenter: number;
  106366. /**
  106367. * Define the distance of the eyes to the screen.
  106368. */
  106369. eyeToScreenDistance: number;
  106370. /**
  106371. * Define the distance between both lenses
  106372. */
  106373. lensSeparationDistance: number;
  106374. /**
  106375. * Define the distance between both viewer's eyes.
  106376. */
  106377. interpupillaryDistance: number;
  106378. /**
  106379. * Define the distortion factor of the VR postprocess.
  106380. * Please, touch with care.
  106381. */
  106382. distortionK: number[];
  106383. /**
  106384. * Define the chromatic aberration correction factors for the VR post process.
  106385. */
  106386. chromaAbCorrection: number[];
  106387. /**
  106388. * Define the scale factor of the post process.
  106389. * The smaller the better but the slower.
  106390. */
  106391. postProcessScaleFactor: number;
  106392. /**
  106393. * Define an offset for the lens center.
  106394. */
  106395. lensCenterOffset: number;
  106396. /**
  106397. * Define if the current vr camera should compensate the distortion of the lense or not.
  106398. */
  106399. compensateDistortion: boolean;
  106400. /**
  106401. * Defines if multiview should be enabled when rendering (Default: false)
  106402. */
  106403. multiviewEnabled: boolean;
  106404. /**
  106405. * Gets the rendering aspect ratio based on the provided resolutions.
  106406. */
  106407. readonly aspectRatio: number;
  106408. /**
  106409. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106410. */
  106411. readonly aspectRatioFov: number;
  106412. /**
  106413. * @hidden
  106414. */
  106415. readonly leftHMatrix: Matrix;
  106416. /**
  106417. * @hidden
  106418. */
  106419. readonly rightHMatrix: Matrix;
  106420. /**
  106421. * @hidden
  106422. */
  106423. readonly leftPreViewMatrix: Matrix;
  106424. /**
  106425. * @hidden
  106426. */
  106427. readonly rightPreViewMatrix: Matrix;
  106428. /**
  106429. * Get the default VRMetrics based on the most generic setup.
  106430. * @returns the default vr metrics
  106431. */
  106432. static GetDefault(): VRCameraMetrics;
  106433. }
  106434. }
  106435. declare module BABYLON {
  106436. /** @hidden */
  106437. export var vrDistortionCorrectionPixelShader: {
  106438. name: string;
  106439. shader: string;
  106440. };
  106441. }
  106442. declare module BABYLON {
  106443. /**
  106444. * VRDistortionCorrectionPostProcess used for mobile VR
  106445. */
  106446. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106447. private _isRightEye;
  106448. private _distortionFactors;
  106449. private _postProcessScaleFactor;
  106450. private _lensCenterOffset;
  106451. private _scaleIn;
  106452. private _scaleFactor;
  106453. private _lensCenter;
  106454. /**
  106455. * Initializes the VRDistortionCorrectionPostProcess
  106456. * @param name The name of the effect.
  106457. * @param camera The camera to apply the render pass to.
  106458. * @param isRightEye If this is for the right eye distortion
  106459. * @param vrMetrics All the required metrics for the VR camera
  106460. */
  106461. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106462. }
  106463. }
  106464. declare module BABYLON {
  106465. /**
  106466. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106467. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106468. */
  106469. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106470. /**
  106471. * Creates a new VRDeviceOrientationArcRotateCamera
  106472. * @param name defines camera name
  106473. * @param alpha defines the camera rotation along the logitudinal axis
  106474. * @param beta defines the camera rotation along the latitudinal axis
  106475. * @param radius defines the camera distance from its target
  106476. * @param target defines the camera target
  106477. * @param scene defines the scene the camera belongs to
  106478. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106479. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106480. */
  106481. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106482. /**
  106483. * Gets camera class name
  106484. * @returns VRDeviceOrientationArcRotateCamera
  106485. */
  106486. getClassName(): string;
  106487. }
  106488. }
  106489. declare module BABYLON {
  106490. /**
  106491. * Camera used to simulate VR rendering (based on FreeCamera)
  106492. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106493. */
  106494. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106495. /**
  106496. * Creates a new VRDeviceOrientationFreeCamera
  106497. * @param name defines camera name
  106498. * @param position defines the start position of the camera
  106499. * @param scene defines the scene the camera belongs to
  106500. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106501. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106502. */
  106503. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106504. /**
  106505. * Gets camera class name
  106506. * @returns VRDeviceOrientationFreeCamera
  106507. */
  106508. getClassName(): string;
  106509. }
  106510. }
  106511. declare module BABYLON {
  106512. /**
  106513. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106514. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106515. */
  106516. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106517. /**
  106518. * Creates a new VRDeviceOrientationGamepadCamera
  106519. * @param name defines camera name
  106520. * @param position defines the start position of the camera
  106521. * @param scene defines the scene the camera belongs to
  106522. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106523. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106524. */
  106525. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106526. /**
  106527. * Gets camera class name
  106528. * @returns VRDeviceOrientationGamepadCamera
  106529. */
  106530. getClassName(): string;
  106531. }
  106532. }
  106533. declare module BABYLON {
  106534. /**
  106535. * Base class of materials working in push mode in babylon JS
  106536. * @hidden
  106537. */
  106538. export class PushMaterial extends Material {
  106539. protected _activeEffect: Effect;
  106540. protected _normalMatrix: Matrix;
  106541. /**
  106542. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106543. * This means that the material can keep using a previous shader while a new one is being compiled.
  106544. * This is mostly used when shader parallel compilation is supported (true by default)
  106545. */
  106546. allowShaderHotSwapping: boolean;
  106547. constructor(name: string, scene: Scene);
  106548. getEffect(): Effect;
  106549. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106550. /**
  106551. * Binds the given world matrix to the active effect
  106552. *
  106553. * @param world the matrix to bind
  106554. */
  106555. bindOnlyWorldMatrix(world: Matrix): void;
  106556. /**
  106557. * Binds the given normal matrix to the active effect
  106558. *
  106559. * @param normalMatrix the matrix to bind
  106560. */
  106561. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106562. bind(world: Matrix, mesh?: Mesh): void;
  106563. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106564. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106565. }
  106566. }
  106567. declare module BABYLON {
  106568. /**
  106569. * This groups all the flags used to control the materials channel.
  106570. */
  106571. export class MaterialFlags {
  106572. private static _DiffuseTextureEnabled;
  106573. /**
  106574. * Are diffuse textures enabled in the application.
  106575. */
  106576. static DiffuseTextureEnabled: boolean;
  106577. private static _AmbientTextureEnabled;
  106578. /**
  106579. * Are ambient textures enabled in the application.
  106580. */
  106581. static AmbientTextureEnabled: boolean;
  106582. private static _OpacityTextureEnabled;
  106583. /**
  106584. * Are opacity textures enabled in the application.
  106585. */
  106586. static OpacityTextureEnabled: boolean;
  106587. private static _ReflectionTextureEnabled;
  106588. /**
  106589. * Are reflection textures enabled in the application.
  106590. */
  106591. static ReflectionTextureEnabled: boolean;
  106592. private static _EmissiveTextureEnabled;
  106593. /**
  106594. * Are emissive textures enabled in the application.
  106595. */
  106596. static EmissiveTextureEnabled: boolean;
  106597. private static _SpecularTextureEnabled;
  106598. /**
  106599. * Are specular textures enabled in the application.
  106600. */
  106601. static SpecularTextureEnabled: boolean;
  106602. private static _BumpTextureEnabled;
  106603. /**
  106604. * Are bump textures enabled in the application.
  106605. */
  106606. static BumpTextureEnabled: boolean;
  106607. private static _LightmapTextureEnabled;
  106608. /**
  106609. * Are lightmap textures enabled in the application.
  106610. */
  106611. static LightmapTextureEnabled: boolean;
  106612. private static _RefractionTextureEnabled;
  106613. /**
  106614. * Are refraction textures enabled in the application.
  106615. */
  106616. static RefractionTextureEnabled: boolean;
  106617. private static _ColorGradingTextureEnabled;
  106618. /**
  106619. * Are color grading textures enabled in the application.
  106620. */
  106621. static ColorGradingTextureEnabled: boolean;
  106622. private static _FresnelEnabled;
  106623. /**
  106624. * Are fresnels enabled in the application.
  106625. */
  106626. static FresnelEnabled: boolean;
  106627. private static _ClearCoatTextureEnabled;
  106628. /**
  106629. * Are clear coat textures enabled in the application.
  106630. */
  106631. static ClearCoatTextureEnabled: boolean;
  106632. private static _ClearCoatBumpTextureEnabled;
  106633. /**
  106634. * Are clear coat bump textures enabled in the application.
  106635. */
  106636. static ClearCoatBumpTextureEnabled: boolean;
  106637. private static _ClearCoatTintTextureEnabled;
  106638. /**
  106639. * Are clear coat tint textures enabled in the application.
  106640. */
  106641. static ClearCoatTintTextureEnabled: boolean;
  106642. private static _SheenTextureEnabled;
  106643. /**
  106644. * Are sheen textures enabled in the application.
  106645. */
  106646. static SheenTextureEnabled: boolean;
  106647. private static _AnisotropicTextureEnabled;
  106648. /**
  106649. * Are anisotropic textures enabled in the application.
  106650. */
  106651. static AnisotropicTextureEnabled: boolean;
  106652. private static _ThicknessTextureEnabled;
  106653. /**
  106654. * Are thickness textures enabled in the application.
  106655. */
  106656. static ThicknessTextureEnabled: boolean;
  106657. }
  106658. }
  106659. declare module BABYLON {
  106660. /** @hidden */
  106661. export var defaultFragmentDeclaration: {
  106662. name: string;
  106663. shader: string;
  106664. };
  106665. }
  106666. declare module BABYLON {
  106667. /** @hidden */
  106668. export var defaultUboDeclaration: {
  106669. name: string;
  106670. shader: string;
  106671. };
  106672. }
  106673. declare module BABYLON {
  106674. /** @hidden */
  106675. export var lightFragmentDeclaration: {
  106676. name: string;
  106677. shader: string;
  106678. };
  106679. }
  106680. declare module BABYLON {
  106681. /** @hidden */
  106682. export var lightUboDeclaration: {
  106683. name: string;
  106684. shader: string;
  106685. };
  106686. }
  106687. declare module BABYLON {
  106688. /** @hidden */
  106689. export var lightsFragmentFunctions: {
  106690. name: string;
  106691. shader: string;
  106692. };
  106693. }
  106694. declare module BABYLON {
  106695. /** @hidden */
  106696. export var shadowsFragmentFunctions: {
  106697. name: string;
  106698. shader: string;
  106699. };
  106700. }
  106701. declare module BABYLON {
  106702. /** @hidden */
  106703. export var fresnelFunction: {
  106704. name: string;
  106705. shader: string;
  106706. };
  106707. }
  106708. declare module BABYLON {
  106709. /** @hidden */
  106710. export var reflectionFunction: {
  106711. name: string;
  106712. shader: string;
  106713. };
  106714. }
  106715. declare module BABYLON {
  106716. /** @hidden */
  106717. export var bumpFragmentFunctions: {
  106718. name: string;
  106719. shader: string;
  106720. };
  106721. }
  106722. declare module BABYLON {
  106723. /** @hidden */
  106724. export var logDepthDeclaration: {
  106725. name: string;
  106726. shader: string;
  106727. };
  106728. }
  106729. declare module BABYLON {
  106730. /** @hidden */
  106731. export var bumpFragment: {
  106732. name: string;
  106733. shader: string;
  106734. };
  106735. }
  106736. declare module BABYLON {
  106737. /** @hidden */
  106738. export var depthPrePass: {
  106739. name: string;
  106740. shader: string;
  106741. };
  106742. }
  106743. declare module BABYLON {
  106744. /** @hidden */
  106745. export var lightFragment: {
  106746. name: string;
  106747. shader: string;
  106748. };
  106749. }
  106750. declare module BABYLON {
  106751. /** @hidden */
  106752. export var logDepthFragment: {
  106753. name: string;
  106754. shader: string;
  106755. };
  106756. }
  106757. declare module BABYLON {
  106758. /** @hidden */
  106759. export var defaultPixelShader: {
  106760. name: string;
  106761. shader: string;
  106762. };
  106763. }
  106764. declare module BABYLON {
  106765. /** @hidden */
  106766. export var defaultVertexDeclaration: {
  106767. name: string;
  106768. shader: string;
  106769. };
  106770. }
  106771. declare module BABYLON {
  106772. /** @hidden */
  106773. export var bumpVertexDeclaration: {
  106774. name: string;
  106775. shader: string;
  106776. };
  106777. }
  106778. declare module BABYLON {
  106779. /** @hidden */
  106780. export var bumpVertex: {
  106781. name: string;
  106782. shader: string;
  106783. };
  106784. }
  106785. declare module BABYLON {
  106786. /** @hidden */
  106787. export var fogVertex: {
  106788. name: string;
  106789. shader: string;
  106790. };
  106791. }
  106792. declare module BABYLON {
  106793. /** @hidden */
  106794. export var shadowsVertex: {
  106795. name: string;
  106796. shader: string;
  106797. };
  106798. }
  106799. declare module BABYLON {
  106800. /** @hidden */
  106801. export var pointCloudVertex: {
  106802. name: string;
  106803. shader: string;
  106804. };
  106805. }
  106806. declare module BABYLON {
  106807. /** @hidden */
  106808. export var logDepthVertex: {
  106809. name: string;
  106810. shader: string;
  106811. };
  106812. }
  106813. declare module BABYLON {
  106814. /** @hidden */
  106815. export var defaultVertexShader: {
  106816. name: string;
  106817. shader: string;
  106818. };
  106819. }
  106820. declare module BABYLON {
  106821. /** @hidden */
  106822. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106823. MAINUV1: boolean;
  106824. MAINUV2: boolean;
  106825. DIFFUSE: boolean;
  106826. DIFFUSEDIRECTUV: number;
  106827. AMBIENT: boolean;
  106828. AMBIENTDIRECTUV: number;
  106829. OPACITY: boolean;
  106830. OPACITYDIRECTUV: number;
  106831. OPACITYRGB: boolean;
  106832. REFLECTION: boolean;
  106833. EMISSIVE: boolean;
  106834. EMISSIVEDIRECTUV: number;
  106835. SPECULAR: boolean;
  106836. SPECULARDIRECTUV: number;
  106837. BUMP: boolean;
  106838. BUMPDIRECTUV: number;
  106839. PARALLAX: boolean;
  106840. PARALLAXOCCLUSION: boolean;
  106841. SPECULAROVERALPHA: boolean;
  106842. CLIPPLANE: boolean;
  106843. CLIPPLANE2: boolean;
  106844. CLIPPLANE3: boolean;
  106845. CLIPPLANE4: boolean;
  106846. ALPHATEST: boolean;
  106847. DEPTHPREPASS: boolean;
  106848. ALPHAFROMDIFFUSE: boolean;
  106849. POINTSIZE: boolean;
  106850. FOG: boolean;
  106851. SPECULARTERM: boolean;
  106852. DIFFUSEFRESNEL: boolean;
  106853. OPACITYFRESNEL: boolean;
  106854. REFLECTIONFRESNEL: boolean;
  106855. REFRACTIONFRESNEL: boolean;
  106856. EMISSIVEFRESNEL: boolean;
  106857. FRESNEL: boolean;
  106858. NORMAL: boolean;
  106859. UV1: boolean;
  106860. UV2: boolean;
  106861. VERTEXCOLOR: boolean;
  106862. VERTEXALPHA: boolean;
  106863. NUM_BONE_INFLUENCERS: number;
  106864. BonesPerMesh: number;
  106865. BONETEXTURE: boolean;
  106866. INSTANCES: boolean;
  106867. GLOSSINESS: boolean;
  106868. ROUGHNESS: boolean;
  106869. EMISSIVEASILLUMINATION: boolean;
  106870. LINKEMISSIVEWITHDIFFUSE: boolean;
  106871. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106872. LIGHTMAP: boolean;
  106873. LIGHTMAPDIRECTUV: number;
  106874. OBJECTSPACE_NORMALMAP: boolean;
  106875. USELIGHTMAPASSHADOWMAP: boolean;
  106876. REFLECTIONMAP_3D: boolean;
  106877. REFLECTIONMAP_SPHERICAL: boolean;
  106878. REFLECTIONMAP_PLANAR: boolean;
  106879. REFLECTIONMAP_CUBIC: boolean;
  106880. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106881. REFLECTIONMAP_PROJECTION: boolean;
  106882. REFLECTIONMAP_SKYBOX: boolean;
  106883. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106884. REFLECTIONMAP_EXPLICIT: boolean;
  106885. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106886. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106887. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106888. INVERTCUBICMAP: boolean;
  106889. LOGARITHMICDEPTH: boolean;
  106890. REFRACTION: boolean;
  106891. REFRACTIONMAP_3D: boolean;
  106892. REFLECTIONOVERALPHA: boolean;
  106893. TWOSIDEDLIGHTING: boolean;
  106894. SHADOWFLOAT: boolean;
  106895. MORPHTARGETS: boolean;
  106896. MORPHTARGETS_NORMAL: boolean;
  106897. MORPHTARGETS_TANGENT: boolean;
  106898. MORPHTARGETS_UV: boolean;
  106899. NUM_MORPH_INFLUENCERS: number;
  106900. NONUNIFORMSCALING: boolean;
  106901. PREMULTIPLYALPHA: boolean;
  106902. IMAGEPROCESSING: boolean;
  106903. VIGNETTE: boolean;
  106904. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106905. VIGNETTEBLENDMODEOPAQUE: boolean;
  106906. TONEMAPPING: boolean;
  106907. TONEMAPPING_ACES: boolean;
  106908. CONTRAST: boolean;
  106909. COLORCURVES: boolean;
  106910. COLORGRADING: boolean;
  106911. COLORGRADING3D: boolean;
  106912. SAMPLER3DGREENDEPTH: boolean;
  106913. SAMPLER3DBGRMAP: boolean;
  106914. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106915. MULTIVIEW: boolean;
  106916. /**
  106917. * If the reflection texture on this material is in linear color space
  106918. * @hidden
  106919. */
  106920. IS_REFLECTION_LINEAR: boolean;
  106921. /**
  106922. * If the refraction texture on this material is in linear color space
  106923. * @hidden
  106924. */
  106925. IS_REFRACTION_LINEAR: boolean;
  106926. EXPOSURE: boolean;
  106927. constructor();
  106928. setReflectionMode(modeToEnable: string): void;
  106929. }
  106930. /**
  106931. * This is the default material used in Babylon. It is the best trade off between quality
  106932. * and performances.
  106933. * @see http://doc.babylonjs.com/babylon101/materials
  106934. */
  106935. export class StandardMaterial extends PushMaterial {
  106936. private _diffuseTexture;
  106937. /**
  106938. * The basic texture of the material as viewed under a light.
  106939. */
  106940. diffuseTexture: Nullable<BaseTexture>;
  106941. private _ambientTexture;
  106942. /**
  106943. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106944. */
  106945. ambientTexture: Nullable<BaseTexture>;
  106946. private _opacityTexture;
  106947. /**
  106948. * Define the transparency of the material from a texture.
  106949. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106950. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106951. */
  106952. opacityTexture: Nullable<BaseTexture>;
  106953. private _reflectionTexture;
  106954. /**
  106955. * Define the texture used to display the reflection.
  106956. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106957. */
  106958. reflectionTexture: Nullable<BaseTexture>;
  106959. private _emissiveTexture;
  106960. /**
  106961. * Define texture of the material as if self lit.
  106962. * This will be mixed in the final result even in the absence of light.
  106963. */
  106964. emissiveTexture: Nullable<BaseTexture>;
  106965. private _specularTexture;
  106966. /**
  106967. * Define how the color and intensity of the highlight given by the light in the material.
  106968. */
  106969. specularTexture: Nullable<BaseTexture>;
  106970. private _bumpTexture;
  106971. /**
  106972. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106973. * 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.
  106974. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106975. */
  106976. bumpTexture: Nullable<BaseTexture>;
  106977. private _lightmapTexture;
  106978. /**
  106979. * Complex lighting can be computationally expensive to compute at runtime.
  106980. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106981. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106982. */
  106983. lightmapTexture: Nullable<BaseTexture>;
  106984. private _refractionTexture;
  106985. /**
  106986. * Define the texture used to display the refraction.
  106987. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106988. */
  106989. refractionTexture: Nullable<BaseTexture>;
  106990. /**
  106991. * The color of the material lit by the environmental background lighting.
  106992. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106993. */
  106994. ambientColor: Color3;
  106995. /**
  106996. * The basic color of the material as viewed under a light.
  106997. */
  106998. diffuseColor: Color3;
  106999. /**
  107000. * Define how the color and intensity of the highlight given by the light in the material.
  107001. */
  107002. specularColor: Color3;
  107003. /**
  107004. * Define the color of the material as if self lit.
  107005. * This will be mixed in the final result even in the absence of light.
  107006. */
  107007. emissiveColor: Color3;
  107008. /**
  107009. * Defines how sharp are the highlights in the material.
  107010. * The bigger the value the sharper giving a more glossy feeling to the result.
  107011. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107012. */
  107013. specularPower: number;
  107014. private _useAlphaFromDiffuseTexture;
  107015. /**
  107016. * Does the transparency come from the diffuse texture alpha channel.
  107017. */
  107018. useAlphaFromDiffuseTexture: boolean;
  107019. private _useEmissiveAsIllumination;
  107020. /**
  107021. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107022. */
  107023. useEmissiveAsIllumination: boolean;
  107024. private _linkEmissiveWithDiffuse;
  107025. /**
  107026. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107027. * the emissive level when the final color is close to one.
  107028. */
  107029. linkEmissiveWithDiffuse: boolean;
  107030. private _useSpecularOverAlpha;
  107031. /**
  107032. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107033. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107034. */
  107035. useSpecularOverAlpha: boolean;
  107036. private _useReflectionOverAlpha;
  107037. /**
  107038. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107039. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107040. */
  107041. useReflectionOverAlpha: boolean;
  107042. private _disableLighting;
  107043. /**
  107044. * Does lights from the scene impacts this material.
  107045. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107046. */
  107047. disableLighting: boolean;
  107048. private _useObjectSpaceNormalMap;
  107049. /**
  107050. * Allows using an object space normal map (instead of tangent space).
  107051. */
  107052. useObjectSpaceNormalMap: boolean;
  107053. private _useParallax;
  107054. /**
  107055. * Is parallax enabled or not.
  107056. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107057. */
  107058. useParallax: boolean;
  107059. private _useParallaxOcclusion;
  107060. /**
  107061. * Is parallax occlusion enabled or not.
  107062. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107063. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107064. */
  107065. useParallaxOcclusion: boolean;
  107066. /**
  107067. * 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.
  107068. */
  107069. parallaxScaleBias: number;
  107070. private _roughness;
  107071. /**
  107072. * Helps to define how blurry the reflections should appears in the material.
  107073. */
  107074. roughness: number;
  107075. /**
  107076. * In case of refraction, define the value of the index of refraction.
  107077. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107078. */
  107079. indexOfRefraction: number;
  107080. /**
  107081. * Invert the refraction texture alongside the y axis.
  107082. * It can be useful with procedural textures or probe for instance.
  107083. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107084. */
  107085. invertRefractionY: boolean;
  107086. /**
  107087. * Defines the alpha limits in alpha test mode.
  107088. */
  107089. alphaCutOff: number;
  107090. private _useLightmapAsShadowmap;
  107091. /**
  107092. * In case of light mapping, define whether the map contains light or shadow informations.
  107093. */
  107094. useLightmapAsShadowmap: boolean;
  107095. private _diffuseFresnelParameters;
  107096. /**
  107097. * Define the diffuse fresnel parameters of the material.
  107098. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107099. */
  107100. diffuseFresnelParameters: FresnelParameters;
  107101. private _opacityFresnelParameters;
  107102. /**
  107103. * Define the opacity fresnel parameters of the material.
  107104. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107105. */
  107106. opacityFresnelParameters: FresnelParameters;
  107107. private _reflectionFresnelParameters;
  107108. /**
  107109. * Define the reflection fresnel parameters of the material.
  107110. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107111. */
  107112. reflectionFresnelParameters: FresnelParameters;
  107113. private _refractionFresnelParameters;
  107114. /**
  107115. * Define the refraction fresnel parameters of the material.
  107116. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107117. */
  107118. refractionFresnelParameters: FresnelParameters;
  107119. private _emissiveFresnelParameters;
  107120. /**
  107121. * Define the emissive fresnel parameters of the material.
  107122. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107123. */
  107124. emissiveFresnelParameters: FresnelParameters;
  107125. private _useReflectionFresnelFromSpecular;
  107126. /**
  107127. * If true automatically deducts the fresnels values from the material specularity.
  107128. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107129. */
  107130. useReflectionFresnelFromSpecular: boolean;
  107131. private _useGlossinessFromSpecularMapAlpha;
  107132. /**
  107133. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107134. */
  107135. useGlossinessFromSpecularMapAlpha: boolean;
  107136. private _maxSimultaneousLights;
  107137. /**
  107138. * Defines the maximum number of lights that can be used in the material
  107139. */
  107140. maxSimultaneousLights: number;
  107141. private _invertNormalMapX;
  107142. /**
  107143. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107144. */
  107145. invertNormalMapX: boolean;
  107146. private _invertNormalMapY;
  107147. /**
  107148. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107149. */
  107150. invertNormalMapY: boolean;
  107151. private _twoSidedLighting;
  107152. /**
  107153. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107154. */
  107155. twoSidedLighting: boolean;
  107156. /**
  107157. * Default configuration related to image processing available in the standard Material.
  107158. */
  107159. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107160. /**
  107161. * Gets the image processing configuration used either in this material.
  107162. */
  107163. /**
  107164. * Sets the Default image processing configuration used either in the this material.
  107165. *
  107166. * If sets to null, the scene one is in use.
  107167. */
  107168. imageProcessingConfiguration: ImageProcessingConfiguration;
  107169. /**
  107170. * Keep track of the image processing observer to allow dispose and replace.
  107171. */
  107172. private _imageProcessingObserver;
  107173. /**
  107174. * Attaches a new image processing configuration to the Standard Material.
  107175. * @param configuration
  107176. */
  107177. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107178. /**
  107179. * Gets wether the color curves effect is enabled.
  107180. */
  107181. /**
  107182. * Sets wether the color curves effect is enabled.
  107183. */
  107184. cameraColorCurvesEnabled: boolean;
  107185. /**
  107186. * Gets wether the color grading effect is enabled.
  107187. */
  107188. /**
  107189. * Gets wether the color grading effect is enabled.
  107190. */
  107191. cameraColorGradingEnabled: boolean;
  107192. /**
  107193. * Gets wether tonemapping is enabled or not.
  107194. */
  107195. /**
  107196. * Sets wether tonemapping is enabled or not
  107197. */
  107198. cameraToneMappingEnabled: boolean;
  107199. /**
  107200. * The camera exposure used on this material.
  107201. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107202. * This corresponds to a photographic exposure.
  107203. */
  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. cameraExposure: number;
  107210. /**
  107211. * Gets The camera contrast used on this material.
  107212. */
  107213. /**
  107214. * Sets The camera contrast used on this material.
  107215. */
  107216. cameraContrast: number;
  107217. /**
  107218. * Gets the Color Grading 2D Lookup Texture.
  107219. */
  107220. /**
  107221. * Sets the Color Grading 2D Lookup Texture.
  107222. */
  107223. cameraColorGradingTexture: Nullable<BaseTexture>;
  107224. /**
  107225. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107226. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107227. * 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;
  107228. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107229. */
  107230. /**
  107231. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107232. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107233. * 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;
  107234. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107235. */
  107236. cameraColorCurves: Nullable<ColorCurves>;
  107237. /**
  107238. * Custom callback helping to override the default shader used in the material.
  107239. */
  107240. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107241. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107242. protected _worldViewProjectionMatrix: Matrix;
  107243. protected _globalAmbientColor: Color3;
  107244. protected _useLogarithmicDepth: boolean;
  107245. protected _rebuildInParallel: boolean;
  107246. /**
  107247. * Instantiates a new standard material.
  107248. * This is the default material used in Babylon. It is the best trade off between quality
  107249. * and performances.
  107250. * @see http://doc.babylonjs.com/babylon101/materials
  107251. * @param name Define the name of the material in the scene
  107252. * @param scene Define the scene the material belong to
  107253. */
  107254. constructor(name: string, scene: Scene);
  107255. /**
  107256. * Gets a boolean indicating that current material needs to register RTT
  107257. */
  107258. readonly hasRenderTargetTextures: boolean;
  107259. /**
  107260. * Gets the current class name of the material e.g. "StandardMaterial"
  107261. * Mainly use in serialization.
  107262. * @returns the class name
  107263. */
  107264. getClassName(): string;
  107265. /**
  107266. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107267. * You can try switching to logarithmic depth.
  107268. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107269. */
  107270. useLogarithmicDepth: boolean;
  107271. /**
  107272. * Specifies if the material will require alpha blending
  107273. * @returns a boolean specifying if alpha blending is needed
  107274. */
  107275. needAlphaBlending(): boolean;
  107276. /**
  107277. * Specifies if this material should be rendered in alpha test mode
  107278. * @returns a boolean specifying if an alpha test is needed.
  107279. */
  107280. needAlphaTesting(): boolean;
  107281. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107282. /**
  107283. * Get the texture used for alpha test purpose.
  107284. * @returns the diffuse texture in case of the standard material.
  107285. */
  107286. getAlphaTestTexture(): Nullable<BaseTexture>;
  107287. /**
  107288. * Get if the submesh is ready to be used and all its information available.
  107289. * Child classes can use it to update shaders
  107290. * @param mesh defines the mesh to check
  107291. * @param subMesh defines which submesh to check
  107292. * @param useInstances specifies that instances should be used
  107293. * @returns a boolean indicating that the submesh is ready or not
  107294. */
  107295. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107296. /**
  107297. * Builds the material UBO layouts.
  107298. * Used internally during the effect preparation.
  107299. */
  107300. buildUniformLayout(): void;
  107301. /**
  107302. * Unbinds the material from the mesh
  107303. */
  107304. unbind(): void;
  107305. /**
  107306. * Binds the submesh to this material by preparing the effect and shader to draw
  107307. * @param world defines the world transformation matrix
  107308. * @param mesh defines the mesh containing the submesh
  107309. * @param subMesh defines the submesh to bind the material to
  107310. */
  107311. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107312. /**
  107313. * Get the list of animatables in the material.
  107314. * @returns the list of animatables object used in the material
  107315. */
  107316. getAnimatables(): IAnimatable[];
  107317. /**
  107318. * Gets the active textures from the material
  107319. * @returns an array of textures
  107320. */
  107321. getActiveTextures(): BaseTexture[];
  107322. /**
  107323. * Specifies if the material uses a texture
  107324. * @param texture defines the texture to check against the material
  107325. * @returns a boolean specifying if the material uses the texture
  107326. */
  107327. hasTexture(texture: BaseTexture): boolean;
  107328. /**
  107329. * Disposes the material
  107330. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107331. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107332. */
  107333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107334. /**
  107335. * Makes a duplicate of the material, and gives it a new name
  107336. * @param name defines the new name for the duplicated material
  107337. * @returns the cloned material
  107338. */
  107339. clone(name: string): StandardMaterial;
  107340. /**
  107341. * Serializes this material in a JSON representation
  107342. * @returns the serialized material object
  107343. */
  107344. serialize(): any;
  107345. /**
  107346. * Creates a standard material from parsed material data
  107347. * @param source defines the JSON representation of the material
  107348. * @param scene defines the hosting scene
  107349. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107350. * @returns a new standard material
  107351. */
  107352. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107353. /**
  107354. * Are diffuse textures enabled in the application.
  107355. */
  107356. static DiffuseTextureEnabled: boolean;
  107357. /**
  107358. * Are ambient textures enabled in the application.
  107359. */
  107360. static AmbientTextureEnabled: boolean;
  107361. /**
  107362. * Are opacity textures enabled in the application.
  107363. */
  107364. static OpacityTextureEnabled: boolean;
  107365. /**
  107366. * Are reflection textures enabled in the application.
  107367. */
  107368. static ReflectionTextureEnabled: boolean;
  107369. /**
  107370. * Are emissive textures enabled in the application.
  107371. */
  107372. static EmissiveTextureEnabled: boolean;
  107373. /**
  107374. * Are specular textures enabled in the application.
  107375. */
  107376. static SpecularTextureEnabled: boolean;
  107377. /**
  107378. * Are bump textures enabled in the application.
  107379. */
  107380. static BumpTextureEnabled: boolean;
  107381. /**
  107382. * Are lightmap textures enabled in the application.
  107383. */
  107384. static LightmapTextureEnabled: boolean;
  107385. /**
  107386. * Are refraction textures enabled in the application.
  107387. */
  107388. static RefractionTextureEnabled: boolean;
  107389. /**
  107390. * Are color grading textures enabled in the application.
  107391. */
  107392. static ColorGradingTextureEnabled: boolean;
  107393. /**
  107394. * Are fresnels enabled in the application.
  107395. */
  107396. static FresnelEnabled: boolean;
  107397. }
  107398. }
  107399. declare module BABYLON {
  107400. /** @hidden */
  107401. export var imageProcessingPixelShader: {
  107402. name: string;
  107403. shader: string;
  107404. };
  107405. }
  107406. declare module BABYLON {
  107407. /**
  107408. * ImageProcessingPostProcess
  107409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107410. */
  107411. export class ImageProcessingPostProcess extends PostProcess {
  107412. /**
  107413. * Default configuration related to image processing available in the PBR Material.
  107414. */
  107415. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107416. /**
  107417. * Gets the image processing configuration used either in this material.
  107418. */
  107419. /**
  107420. * Sets the Default image processing configuration used either in the this material.
  107421. *
  107422. * If sets to null, the scene one is in use.
  107423. */
  107424. imageProcessingConfiguration: ImageProcessingConfiguration;
  107425. /**
  107426. * Keep track of the image processing observer to allow dispose and replace.
  107427. */
  107428. private _imageProcessingObserver;
  107429. /**
  107430. * Attaches a new image processing configuration to the PBR Material.
  107431. * @param configuration
  107432. */
  107433. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107434. /**
  107435. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107436. */
  107437. /**
  107438. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107439. */
  107440. colorCurves: Nullable<ColorCurves>;
  107441. /**
  107442. * Gets wether the color curves effect is enabled.
  107443. */
  107444. /**
  107445. * Sets wether the color curves effect is enabled.
  107446. */
  107447. colorCurvesEnabled: boolean;
  107448. /**
  107449. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107450. */
  107451. /**
  107452. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107453. */
  107454. colorGradingTexture: Nullable<BaseTexture>;
  107455. /**
  107456. * Gets wether the color grading effect is enabled.
  107457. */
  107458. /**
  107459. * Gets wether the color grading effect is enabled.
  107460. */
  107461. colorGradingEnabled: boolean;
  107462. /**
  107463. * Gets exposure used in the effect.
  107464. */
  107465. /**
  107466. * Sets exposure used in the effect.
  107467. */
  107468. exposure: number;
  107469. /**
  107470. * Gets wether tonemapping is enabled or not.
  107471. */
  107472. /**
  107473. * Sets wether tonemapping is enabled or not
  107474. */
  107475. toneMappingEnabled: boolean;
  107476. /**
  107477. * Gets the type of tone mapping effect.
  107478. */
  107479. /**
  107480. * Sets the type of tone mapping effect.
  107481. */
  107482. toneMappingType: number;
  107483. /**
  107484. * Gets contrast used in the effect.
  107485. */
  107486. /**
  107487. * Sets contrast used in the effect.
  107488. */
  107489. contrast: number;
  107490. /**
  107491. * Gets Vignette stretch size.
  107492. */
  107493. /**
  107494. * Sets Vignette stretch size.
  107495. */
  107496. vignetteStretch: number;
  107497. /**
  107498. * Gets Vignette centre X Offset.
  107499. */
  107500. /**
  107501. * Sets Vignette centre X Offset.
  107502. */
  107503. vignetteCentreX: number;
  107504. /**
  107505. * Gets Vignette centre Y Offset.
  107506. */
  107507. /**
  107508. * Sets Vignette centre Y Offset.
  107509. */
  107510. vignetteCentreY: number;
  107511. /**
  107512. * Gets Vignette weight or intensity of the vignette effect.
  107513. */
  107514. /**
  107515. * Sets Vignette weight or intensity of the vignette effect.
  107516. */
  107517. vignetteWeight: number;
  107518. /**
  107519. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107520. * if vignetteEnabled is set to true.
  107521. */
  107522. /**
  107523. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107524. * if vignetteEnabled is set to true.
  107525. */
  107526. vignetteColor: Color4;
  107527. /**
  107528. * Gets Camera field of view used by the Vignette effect.
  107529. */
  107530. /**
  107531. * Sets Camera field of view used by the Vignette effect.
  107532. */
  107533. vignetteCameraFov: number;
  107534. /**
  107535. * Gets the vignette blend mode allowing different kind of effect.
  107536. */
  107537. /**
  107538. * Sets the vignette blend mode allowing different kind of effect.
  107539. */
  107540. vignetteBlendMode: number;
  107541. /**
  107542. * Gets wether the vignette effect is enabled.
  107543. */
  107544. /**
  107545. * Sets wether the vignette effect is enabled.
  107546. */
  107547. vignetteEnabled: boolean;
  107548. private _fromLinearSpace;
  107549. /**
  107550. * Gets wether the input of the processing is in Gamma or Linear Space.
  107551. */
  107552. /**
  107553. * Sets wether the input of the processing is in Gamma or Linear Space.
  107554. */
  107555. fromLinearSpace: boolean;
  107556. /**
  107557. * Defines cache preventing GC.
  107558. */
  107559. private _defines;
  107560. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107561. /**
  107562. * "ImageProcessingPostProcess"
  107563. * @returns "ImageProcessingPostProcess"
  107564. */
  107565. getClassName(): string;
  107566. protected _updateParameters(): void;
  107567. dispose(camera?: Camera): void;
  107568. }
  107569. }
  107570. declare module BABYLON {
  107571. /**
  107572. * Class containing static functions to help procedurally build meshes
  107573. */
  107574. export class GroundBuilder {
  107575. /**
  107576. * Creates a ground mesh
  107577. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107578. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107580. * @param name defines the name of the mesh
  107581. * @param options defines the options used to create the mesh
  107582. * @param scene defines the hosting scene
  107583. * @returns the ground mesh
  107584. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107585. */
  107586. static CreateGround(name: string, options: {
  107587. width?: number;
  107588. height?: number;
  107589. subdivisions?: number;
  107590. subdivisionsX?: number;
  107591. subdivisionsY?: number;
  107592. updatable?: boolean;
  107593. }, scene: any): Mesh;
  107594. /**
  107595. * Creates a tiled ground mesh
  107596. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107597. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107598. * * 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
  107599. * * 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
  107600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107601. * @param name defines the name of the mesh
  107602. * @param options defines the options used to create the mesh
  107603. * @param scene defines the hosting scene
  107604. * @returns the tiled ground mesh
  107605. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107606. */
  107607. static CreateTiledGround(name: string, options: {
  107608. xmin: number;
  107609. zmin: number;
  107610. xmax: number;
  107611. zmax: number;
  107612. subdivisions?: {
  107613. w: number;
  107614. h: number;
  107615. };
  107616. precision?: {
  107617. w: number;
  107618. h: number;
  107619. };
  107620. updatable?: boolean;
  107621. }, scene?: Nullable<Scene>): Mesh;
  107622. /**
  107623. * Creates a ground mesh from a height map
  107624. * * The parameter `url` sets the URL of the height map image resource.
  107625. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107626. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107627. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107628. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107629. * * 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.
  107630. * * 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).
  107631. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107633. * @param name defines the name of the mesh
  107634. * @param url defines the url to the height map
  107635. * @param options defines the options used to create the mesh
  107636. * @param scene defines the hosting scene
  107637. * @returns the ground mesh
  107638. * @see https://doc.babylonjs.com/babylon101/height_map
  107639. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107640. */
  107641. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107642. width?: number;
  107643. height?: number;
  107644. subdivisions?: number;
  107645. minHeight?: number;
  107646. maxHeight?: number;
  107647. colorFilter?: Color3;
  107648. alphaFilter?: number;
  107649. updatable?: boolean;
  107650. onReady?: (mesh: GroundMesh) => void;
  107651. }, scene?: Nullable<Scene>): GroundMesh;
  107652. }
  107653. }
  107654. declare module BABYLON {
  107655. /**
  107656. * Class containing static functions to help procedurally build meshes
  107657. */
  107658. export class TorusBuilder {
  107659. /**
  107660. * Creates a torus mesh
  107661. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107662. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107663. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107667. * @param name defines the name of the mesh
  107668. * @param options defines the options used to create the mesh
  107669. * @param scene defines the hosting scene
  107670. * @returns the torus mesh
  107671. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107672. */
  107673. static CreateTorus(name: string, options: {
  107674. diameter?: number;
  107675. thickness?: number;
  107676. tessellation?: number;
  107677. updatable?: boolean;
  107678. sideOrientation?: number;
  107679. frontUVs?: Vector4;
  107680. backUVs?: Vector4;
  107681. }, scene: any): Mesh;
  107682. }
  107683. }
  107684. declare module BABYLON {
  107685. /**
  107686. * Class containing static functions to help procedurally build meshes
  107687. */
  107688. export class CylinderBuilder {
  107689. /**
  107690. * Creates a cylinder or a cone mesh
  107691. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107692. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107693. * * 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.
  107694. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107695. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107696. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107697. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107698. * * 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).
  107699. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107700. * * 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).
  107701. * * 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
  107702. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107703. * * 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
  107704. * * 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.
  107705. * * If `enclose` is false, a ring surface is one element.
  107706. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107707. * * 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
  107708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107711. * @param name defines the name of the mesh
  107712. * @param options defines the options used to create the mesh
  107713. * @param scene defines the hosting scene
  107714. * @returns the cylinder mesh
  107715. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107716. */
  107717. static CreateCylinder(name: string, options: {
  107718. height?: number;
  107719. diameterTop?: number;
  107720. diameterBottom?: number;
  107721. diameter?: number;
  107722. tessellation?: number;
  107723. subdivisions?: number;
  107724. arc?: number;
  107725. faceColors?: Color4[];
  107726. faceUV?: Vector4[];
  107727. updatable?: boolean;
  107728. hasRings?: boolean;
  107729. enclose?: boolean;
  107730. cap?: number;
  107731. sideOrientation?: number;
  107732. frontUVs?: Vector4;
  107733. backUVs?: Vector4;
  107734. }, scene: any): Mesh;
  107735. }
  107736. }
  107737. declare module BABYLON {
  107738. /**
  107739. * Options to modify the vr teleportation behavior.
  107740. */
  107741. export interface VRTeleportationOptions {
  107742. /**
  107743. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107744. */
  107745. floorMeshName?: string;
  107746. /**
  107747. * A list of meshes to be used as the teleportation floor. (default: empty)
  107748. */
  107749. floorMeshes?: Mesh[];
  107750. }
  107751. /**
  107752. * Options to modify the vr experience helper's behavior.
  107753. */
  107754. export interface VRExperienceHelperOptions extends WebVROptions {
  107755. /**
  107756. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107757. */
  107758. createDeviceOrientationCamera?: boolean;
  107759. /**
  107760. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107761. */
  107762. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107763. /**
  107764. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107765. */
  107766. laserToggle?: boolean;
  107767. /**
  107768. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107769. */
  107770. floorMeshes?: Mesh[];
  107771. /**
  107772. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107773. */
  107774. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107775. }
  107776. /**
  107777. * Event containing information after VR has been entered
  107778. */
  107779. export class OnAfterEnteringVRObservableEvent {
  107780. /**
  107781. * If entering vr was successful
  107782. */
  107783. success: boolean;
  107784. }
  107785. /**
  107786. * Helps to quickly add VR support to an existing scene.
  107787. * See http://doc.babylonjs.com/how_to/webvr_helper
  107788. */
  107789. export class VRExperienceHelper {
  107790. /** Options to modify the vr experience helper's behavior. */
  107791. webVROptions: VRExperienceHelperOptions;
  107792. private _scene;
  107793. private _position;
  107794. private _btnVR;
  107795. private _btnVRDisplayed;
  107796. private _webVRsupported;
  107797. private _webVRready;
  107798. private _webVRrequesting;
  107799. private _webVRpresenting;
  107800. private _hasEnteredVR;
  107801. private _fullscreenVRpresenting;
  107802. private _canvas;
  107803. private _webVRCamera;
  107804. private _vrDeviceOrientationCamera;
  107805. private _deviceOrientationCamera;
  107806. private _existingCamera;
  107807. private _onKeyDown;
  107808. private _onVrDisplayPresentChange;
  107809. private _onVRDisplayChanged;
  107810. private _onVRRequestPresentStart;
  107811. private _onVRRequestPresentComplete;
  107812. /**
  107813. * 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)
  107814. */
  107815. enableGazeEvenWhenNoPointerLock: boolean;
  107816. /**
  107817. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107818. */
  107819. exitVROnDoubleTap: boolean;
  107820. /**
  107821. * Observable raised right before entering VR.
  107822. */
  107823. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107824. /**
  107825. * Observable raised when entering VR has completed.
  107826. */
  107827. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107828. /**
  107829. * Observable raised when exiting VR.
  107830. */
  107831. onExitingVRObservable: Observable<VRExperienceHelper>;
  107832. /**
  107833. * Observable raised when controller mesh is loaded.
  107834. */
  107835. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107836. /** Return this.onEnteringVRObservable
  107837. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107838. */
  107839. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107840. /** Return this.onExitingVRObservable
  107841. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107842. */
  107843. readonly onExitingVR: Observable<VRExperienceHelper>;
  107844. /** Return this.onControllerMeshLoadedObservable
  107845. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107846. */
  107847. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107848. private _rayLength;
  107849. private _useCustomVRButton;
  107850. private _teleportationRequested;
  107851. private _teleportActive;
  107852. private _floorMeshName;
  107853. private _floorMeshesCollection;
  107854. private _rotationAllowed;
  107855. private _teleportBackwardsVector;
  107856. private _teleportationTarget;
  107857. private _isDefaultTeleportationTarget;
  107858. private _postProcessMove;
  107859. private _teleportationFillColor;
  107860. private _teleportationBorderColor;
  107861. private _rotationAngle;
  107862. private _haloCenter;
  107863. private _cameraGazer;
  107864. private _padSensibilityUp;
  107865. private _padSensibilityDown;
  107866. private _leftController;
  107867. private _rightController;
  107868. /**
  107869. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107870. */
  107871. onNewMeshSelected: Observable<AbstractMesh>;
  107872. /**
  107873. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107874. * This observable will provide the mesh and the controller used to select the mesh
  107875. */
  107876. onMeshSelectedWithController: Observable<{
  107877. mesh: AbstractMesh;
  107878. controller: WebVRController;
  107879. }>;
  107880. /**
  107881. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107882. */
  107883. onNewMeshPicked: Observable<PickingInfo>;
  107884. private _circleEase;
  107885. /**
  107886. * Observable raised before camera teleportation
  107887. */
  107888. onBeforeCameraTeleport: Observable<Vector3>;
  107889. /**
  107890. * Observable raised after camera teleportation
  107891. */
  107892. onAfterCameraTeleport: Observable<Vector3>;
  107893. /**
  107894. * Observable raised when current selected mesh gets unselected
  107895. */
  107896. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107897. private _raySelectionPredicate;
  107898. /**
  107899. * To be optionaly changed by user to define custom ray selection
  107900. */
  107901. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107902. /**
  107903. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107904. */
  107905. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107906. /**
  107907. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107908. */
  107909. teleportationEnabled: boolean;
  107910. private _defaultHeight;
  107911. private _teleportationInitialized;
  107912. private _interactionsEnabled;
  107913. private _interactionsRequested;
  107914. private _displayGaze;
  107915. private _displayLaserPointer;
  107916. /**
  107917. * The mesh used to display where the user is going to teleport.
  107918. */
  107919. /**
  107920. * Sets the mesh to be used to display where the user is going to teleport.
  107921. */
  107922. teleportationTarget: Mesh;
  107923. /**
  107924. * 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
  107925. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107926. * See http://doc.babylonjs.com/resources/baking_transformations
  107927. */
  107928. gazeTrackerMesh: Mesh;
  107929. /**
  107930. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107931. */
  107932. updateGazeTrackerScale: boolean;
  107933. /**
  107934. * If the gaze trackers color should be updated when selecting meshes
  107935. */
  107936. updateGazeTrackerColor: boolean;
  107937. /**
  107938. * If the controller laser color should be updated when selecting meshes
  107939. */
  107940. updateControllerLaserColor: boolean;
  107941. /**
  107942. * The gaze tracking mesh corresponding to the left controller
  107943. */
  107944. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  107945. /**
  107946. * The gaze tracking mesh corresponding to the right controller
  107947. */
  107948. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  107949. /**
  107950. * If the ray of the gaze should be displayed.
  107951. */
  107952. /**
  107953. * Sets if the ray of the gaze should be displayed.
  107954. */
  107955. displayGaze: boolean;
  107956. /**
  107957. * If the ray of the LaserPointer should be displayed.
  107958. */
  107959. /**
  107960. * Sets if the ray of the LaserPointer should be displayed.
  107961. */
  107962. displayLaserPointer: boolean;
  107963. /**
  107964. * The deviceOrientationCamera used as the camera when not in VR.
  107965. */
  107966. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107967. /**
  107968. * Based on the current WebVR support, returns the current VR camera used.
  107969. */
  107970. readonly currentVRCamera: Nullable<Camera>;
  107971. /**
  107972. * The webVRCamera which is used when in VR.
  107973. */
  107974. readonly webVRCamera: WebVRFreeCamera;
  107975. /**
  107976. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107977. */
  107978. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107979. /**
  107980. * The html button that is used to trigger entering into VR.
  107981. */
  107982. readonly vrButton: Nullable<HTMLButtonElement>;
  107983. private readonly _teleportationRequestInitiated;
  107984. /**
  107985. * Defines wether or not Pointer lock should be requested when switching to
  107986. * full screen.
  107987. */
  107988. requestPointerLockOnFullScreen: boolean;
  107989. /**
  107990. * Instantiates a VRExperienceHelper.
  107991. * Helps to quickly add VR support to an existing scene.
  107992. * @param scene The scene the VRExperienceHelper belongs to.
  107993. * @param webVROptions Options to modify the vr experience helper's behavior.
  107994. */
  107995. constructor(scene: Scene,
  107996. /** Options to modify the vr experience helper's behavior. */
  107997. webVROptions?: VRExperienceHelperOptions);
  107998. private _onDefaultMeshLoaded;
  107999. private _onResize;
  108000. private _onFullscreenChange;
  108001. /**
  108002. * Gets a value indicating if we are currently in VR mode.
  108003. */
  108004. readonly isInVRMode: boolean;
  108005. private onVrDisplayPresentChange;
  108006. private onVRDisplayChanged;
  108007. private moveButtonToBottomRight;
  108008. private displayVRButton;
  108009. private updateButtonVisibility;
  108010. private _cachedAngularSensibility;
  108011. /**
  108012. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108013. * Otherwise, will use the fullscreen API.
  108014. */
  108015. enterVR(): void;
  108016. /**
  108017. * Attempt to exit VR, or fullscreen.
  108018. */
  108019. exitVR(): void;
  108020. /**
  108021. * The position of the vr experience helper.
  108022. */
  108023. /**
  108024. * Sets the position of the vr experience helper.
  108025. */
  108026. position: Vector3;
  108027. /**
  108028. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108029. */
  108030. enableInteractions(): void;
  108031. private readonly _noControllerIsActive;
  108032. private beforeRender;
  108033. private _isTeleportationFloor;
  108034. /**
  108035. * Adds a floor mesh to be used for teleportation.
  108036. * @param floorMesh the mesh to be used for teleportation.
  108037. */
  108038. addFloorMesh(floorMesh: Mesh): void;
  108039. /**
  108040. * Removes a floor mesh from being used for teleportation.
  108041. * @param floorMesh the mesh to be removed.
  108042. */
  108043. removeFloorMesh(floorMesh: Mesh): void;
  108044. /**
  108045. * Enables interactions and teleportation using the VR controllers and gaze.
  108046. * @param vrTeleportationOptions options to modify teleportation behavior.
  108047. */
  108048. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108049. private _onNewGamepadConnected;
  108050. private _tryEnableInteractionOnController;
  108051. private _onNewGamepadDisconnected;
  108052. private _enableInteractionOnController;
  108053. private _checkTeleportWithRay;
  108054. private _checkRotate;
  108055. private _checkTeleportBackwards;
  108056. private _enableTeleportationOnController;
  108057. private _createTeleportationCircles;
  108058. private _displayTeleportationTarget;
  108059. private _hideTeleportationTarget;
  108060. private _rotateCamera;
  108061. private _moveTeleportationSelectorTo;
  108062. private _workingVector;
  108063. private _workingQuaternion;
  108064. private _workingMatrix;
  108065. /**
  108066. * Teleports the users feet to the desired location
  108067. * @param location The location where the user's feet should be placed
  108068. */
  108069. teleportCamera(location: Vector3): void;
  108070. private _convertNormalToDirectionOfRay;
  108071. private _castRayAndSelectObject;
  108072. private _notifySelectedMeshUnselected;
  108073. /**
  108074. * Sets the color of the laser ray from the vr controllers.
  108075. * @param color new color for the ray.
  108076. */
  108077. changeLaserColor(color: Color3): void;
  108078. /**
  108079. * Sets the color of the ray from the vr headsets gaze.
  108080. * @param color new color for the ray.
  108081. */
  108082. changeGazeColor(color: Color3): void;
  108083. /**
  108084. * Exits VR and disposes of the vr experience helper
  108085. */
  108086. dispose(): void;
  108087. /**
  108088. * Gets the name of the VRExperienceHelper class
  108089. * @returns "VRExperienceHelper"
  108090. */
  108091. getClassName(): string;
  108092. }
  108093. }
  108094. declare module BABYLON {
  108095. /**
  108096. * Manages an XRSession to work with Babylon's engine
  108097. * @see https://doc.babylonjs.com/how_to/webxr
  108098. */
  108099. export class WebXRSessionManager implements IDisposable {
  108100. private scene;
  108101. /**
  108102. * Fires every time a new xrFrame arrives which can be used to update the camera
  108103. */
  108104. onXRFrameObservable: Observable<any>;
  108105. /**
  108106. * Fires when the xr session is ended either by the device or manually done
  108107. */
  108108. onXRSessionEnded: Observable<any>;
  108109. /**
  108110. * Underlying xr session
  108111. */
  108112. session: XRSession;
  108113. /**
  108114. * Type of reference space used when creating the session
  108115. */
  108116. referenceSpace: XRReferenceSpace;
  108117. /** @hidden */
  108118. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108119. /**
  108120. * Current XR frame
  108121. */
  108122. currentFrame: Nullable<XRFrame>;
  108123. private _xrNavigator;
  108124. private baseLayer;
  108125. /**
  108126. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108127. * @param scene The scene which the session should be created for
  108128. */
  108129. constructor(scene: Scene);
  108130. /**
  108131. * Initializes the manager
  108132. * After initialization enterXR can be called to start an XR session
  108133. * @returns Promise which resolves after it is initialized
  108134. */
  108135. initializeAsync(): Promise<void>;
  108136. /**
  108137. * Initializes an xr session
  108138. * @param xrSessionMode mode to initialize
  108139. * @returns a promise which will resolve once the session has been initialized
  108140. */
  108141. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108142. /**
  108143. * Sets the reference space on the xr session
  108144. * @param referenceSpace space to set
  108145. * @returns a promise that will resolve once the reference space has been set
  108146. */
  108147. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108148. /**
  108149. * Updates the render state of the session
  108150. * @param state state to set
  108151. * @returns a promise that resolves once the render state has been updated
  108152. */
  108153. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108154. /**
  108155. * Starts rendering to the xr layer
  108156. * @returns a promise that will resolve once rendering has started
  108157. */
  108158. startRenderingToXRAsync(): Promise<void>;
  108159. /**
  108160. * Stops the xrSession and restores the renderloop
  108161. * @returns Promise which resolves after it exits XR
  108162. */
  108163. exitXRAsync(): Promise<unknown>;
  108164. /**
  108165. * Checks if a session would be supported for the creation options specified
  108166. * @param sessionMode session mode to check if supported eg. immersive-vr
  108167. * @returns true if supported
  108168. */
  108169. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108170. /**
  108171. * @hidden
  108172. * Converts the render layer of xrSession to a render target
  108173. * @param session session to create render target for
  108174. * @param scene scene the new render target should be created for
  108175. */
  108176. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108177. /**
  108178. * Disposes of the session manager
  108179. */
  108180. dispose(): void;
  108181. }
  108182. }
  108183. declare module BABYLON {
  108184. /**
  108185. * WebXR Camera which holds the views for the xrSession
  108186. * @see https://doc.babylonjs.com/how_to/webxr
  108187. */
  108188. export class WebXRCamera extends FreeCamera {
  108189. private static _TmpMatrix;
  108190. /**
  108191. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108192. * @param name the name of the camera
  108193. * @param scene the scene to add the camera to
  108194. */
  108195. constructor(name: string, scene: Scene);
  108196. private _updateNumberOfRigCameras;
  108197. /** @hidden */
  108198. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108199. /**
  108200. * Updates the cameras position from the current pose information of the XR session
  108201. * @param xrSessionManager the session containing pose information
  108202. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108203. */
  108204. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108205. }
  108206. }
  108207. declare module BABYLON {
  108208. /**
  108209. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108210. */
  108211. export class WebXRManagedOutputCanvas implements IDisposable {
  108212. private helper;
  108213. private _canvas;
  108214. /**
  108215. * xrpresent context of the canvas which can be used to display/mirror xr content
  108216. */
  108217. canvasContext: WebGLRenderingContext;
  108218. /**
  108219. * xr layer for the canvas
  108220. */
  108221. xrLayer: Nullable<XRWebGLLayer>;
  108222. /**
  108223. * Initializes the xr layer for the session
  108224. * @param xrSession xr session
  108225. * @returns a promise that will resolve once the XR Layer has been created
  108226. */
  108227. initializeXRLayerAsync(xrSession: any): any;
  108228. /**
  108229. * Initializes the canvas to be added/removed upon entering/exiting xr
  108230. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108231. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108232. */
  108233. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108234. /**
  108235. * Disposes of the object
  108236. */
  108237. dispose(): void;
  108238. private _setManagedOutputCanvas;
  108239. private _addCanvas;
  108240. private _removeCanvas;
  108241. }
  108242. }
  108243. declare module BABYLON {
  108244. /**
  108245. * States of the webXR experience
  108246. */
  108247. export enum WebXRState {
  108248. /**
  108249. * Transitioning to being in XR mode
  108250. */
  108251. ENTERING_XR = 0,
  108252. /**
  108253. * Transitioning to non XR mode
  108254. */
  108255. EXITING_XR = 1,
  108256. /**
  108257. * In XR mode and presenting
  108258. */
  108259. IN_XR = 2,
  108260. /**
  108261. * Not entered XR mode
  108262. */
  108263. NOT_IN_XR = 3
  108264. }
  108265. /**
  108266. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108267. * @see https://doc.babylonjs.com/how_to/webxr
  108268. */
  108269. export class WebXRExperienceHelper implements IDisposable {
  108270. private scene;
  108271. /**
  108272. * 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
  108273. */
  108274. container: AbstractMesh;
  108275. /**
  108276. * Camera used to render xr content
  108277. */
  108278. camera: WebXRCamera;
  108279. /**
  108280. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108281. */
  108282. state: WebXRState;
  108283. private _setState;
  108284. private static _TmpVector;
  108285. /**
  108286. * Fires when the state of the experience helper has changed
  108287. */
  108288. onStateChangedObservable: Observable<WebXRState>;
  108289. /** Session manager used to keep track of xr session */
  108290. sessionManager: WebXRSessionManager;
  108291. private _nonVRCamera;
  108292. private _originalSceneAutoClear;
  108293. private _supported;
  108294. /**
  108295. * Creates the experience helper
  108296. * @param scene the scene to attach the experience helper to
  108297. * @returns a promise for the experience helper
  108298. */
  108299. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108300. /**
  108301. * Creates a WebXRExperienceHelper
  108302. * @param scene The scene the helper should be created in
  108303. */
  108304. private constructor();
  108305. /**
  108306. * Exits XR mode and returns the scene to its original state
  108307. * @returns promise that resolves after xr mode has exited
  108308. */
  108309. exitXRAsync(): Promise<unknown>;
  108310. /**
  108311. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108312. * @param sessionCreationOptions options for the XR session
  108313. * @param referenceSpaceType frame of reference of the XR session
  108314. * @param outputCanvas the output canvas that will be used to enter XR mode
  108315. * @returns promise that resolves after xr mode has entered
  108316. */
  108317. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108318. /**
  108319. * Updates the global position of the camera by moving the camera's container
  108320. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108321. * @param position The desired global position of the camera
  108322. */
  108323. setPositionOfCameraUsingContainer(position: Vector3): void;
  108324. /**
  108325. * Rotates the xr camera by rotating the camera's container around the camera's position
  108326. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108327. * @param rotation the desired quaternion rotation to apply to the camera
  108328. */
  108329. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108330. /**
  108331. * Disposes of the experience helper
  108332. */
  108333. dispose(): void;
  108334. }
  108335. }
  108336. declare module BABYLON {
  108337. /**
  108338. * Button which can be used to enter a different mode of XR
  108339. */
  108340. export class WebXREnterExitUIButton {
  108341. /** button element */
  108342. element: HTMLElement;
  108343. /** XR initialization options for the button */
  108344. sessionMode: XRSessionMode;
  108345. /** Reference space type */
  108346. referenceSpaceType: XRReferenceSpaceType;
  108347. /**
  108348. * Creates a WebXREnterExitUIButton
  108349. * @param element button element
  108350. * @param sessionMode XR initialization session mode
  108351. * @param referenceSpaceType the type of reference space to be used
  108352. */
  108353. constructor(
  108354. /** button element */
  108355. element: HTMLElement,
  108356. /** XR initialization options for the button */
  108357. sessionMode: XRSessionMode,
  108358. /** Reference space type */
  108359. referenceSpaceType: XRReferenceSpaceType);
  108360. /**
  108361. * Overwritable function which can be used to update the button's visuals when the state changes
  108362. * @param activeButton the current active button in the UI
  108363. */
  108364. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108365. }
  108366. /**
  108367. * Options to create the webXR UI
  108368. */
  108369. export class WebXREnterExitUIOptions {
  108370. /**
  108371. * Context to enter xr with
  108372. */
  108373. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108374. /**
  108375. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108376. */
  108377. customButtons?: Array<WebXREnterExitUIButton>;
  108378. }
  108379. /**
  108380. * UI to allow the user to enter/exit XR mode
  108381. */
  108382. export class WebXREnterExitUI implements IDisposable {
  108383. private scene;
  108384. private _overlay;
  108385. private _buttons;
  108386. private _activeButton;
  108387. /**
  108388. * Fired every time the active button is changed.
  108389. *
  108390. * When xr is entered via a button that launches xr that button will be the callback parameter
  108391. *
  108392. * When exiting xr the callback parameter will be null)
  108393. */
  108394. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108395. /**
  108396. * Creates UI to allow the user to enter/exit XR mode
  108397. * @param scene the scene to add the ui to
  108398. * @param helper the xr experience helper to enter/exit xr with
  108399. * @param options options to configure the UI
  108400. * @returns the created ui
  108401. */
  108402. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108403. private constructor();
  108404. private _updateButtons;
  108405. /**
  108406. * Disposes of the object
  108407. */
  108408. dispose(): void;
  108409. }
  108410. }
  108411. declare module BABYLON {
  108412. /**
  108413. * Represents an XR input
  108414. */
  108415. export class WebXRController {
  108416. private scene;
  108417. /** The underlying input source for the controller */
  108418. inputSource: XRInputSource;
  108419. private parentContainer;
  108420. /**
  108421. * 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
  108422. */
  108423. grip?: AbstractMesh;
  108424. /**
  108425. * Pointer which can be used to select objects or attach a visible laser to
  108426. */
  108427. pointer: AbstractMesh;
  108428. /**
  108429. * Event that fires when the controller is removed/disposed
  108430. */
  108431. onDisposeObservable: Observable<{}>;
  108432. private _tmpMatrix;
  108433. private _tmpQuaternion;
  108434. private _tmpVector;
  108435. /**
  108436. * Creates the controller
  108437. * @see https://doc.babylonjs.com/how_to/webxr
  108438. * @param scene the scene which the controller should be associated to
  108439. * @param inputSource the underlying input source for the controller
  108440. * @param parentContainer parent that the controller meshes should be children of
  108441. */
  108442. constructor(scene: Scene,
  108443. /** The underlying input source for the controller */
  108444. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108445. /**
  108446. * Updates the controller pose based on the given XRFrame
  108447. * @param xrFrame xr frame to update the pose with
  108448. * @param referenceSpace reference space to use
  108449. */
  108450. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108451. /**
  108452. * Gets a world space ray coming from the controller
  108453. * @param result the resulting ray
  108454. */
  108455. getWorldPointerRayToRef(result: Ray): void;
  108456. /**
  108457. * Disposes of the object
  108458. */
  108459. dispose(): void;
  108460. }
  108461. }
  108462. declare module BABYLON {
  108463. /**
  108464. * XR input used to track XR inputs such as controllers/rays
  108465. */
  108466. export class WebXRInput implements IDisposable {
  108467. /**
  108468. * Base experience the input listens to
  108469. */
  108470. baseExperience: WebXRExperienceHelper;
  108471. /**
  108472. * XR controllers being tracked
  108473. */
  108474. controllers: Array<WebXRController>;
  108475. private _frameObserver;
  108476. private _stateObserver;
  108477. /**
  108478. * Event when a controller has been connected/added
  108479. */
  108480. onControllerAddedObservable: Observable<WebXRController>;
  108481. /**
  108482. * Event when a controller has been removed/disconnected
  108483. */
  108484. onControllerRemovedObservable: Observable<WebXRController>;
  108485. /**
  108486. * Initializes the WebXRInput
  108487. * @param baseExperience experience helper which the input should be created for
  108488. */
  108489. constructor(
  108490. /**
  108491. * Base experience the input listens to
  108492. */
  108493. baseExperience: WebXRExperienceHelper);
  108494. private _onInputSourcesChange;
  108495. private _addAndRemoveControllers;
  108496. /**
  108497. * Disposes of the object
  108498. */
  108499. dispose(): void;
  108500. }
  108501. }
  108502. declare module BABYLON {
  108503. /**
  108504. * Enables teleportation
  108505. */
  108506. export class WebXRControllerTeleportation {
  108507. private _teleportationFillColor;
  108508. private _teleportationBorderColor;
  108509. private _tmpRay;
  108510. private _tmpVector;
  108511. /**
  108512. * Creates a WebXRControllerTeleportation
  108513. * @param input input manager to add teleportation to
  108514. * @param floorMeshes floormeshes which can be teleported to
  108515. */
  108516. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108517. }
  108518. }
  108519. declare module BABYLON {
  108520. /**
  108521. * Handles pointer input automatically for the pointer of XR controllers
  108522. */
  108523. export class WebXRControllerPointerSelection {
  108524. private static _idCounter;
  108525. private _tmpRay;
  108526. /**
  108527. * Creates a WebXRControllerPointerSelection
  108528. * @param input input manager to setup pointer selection
  108529. */
  108530. constructor(input: WebXRInput);
  108531. private _convertNormalToDirectionOfRay;
  108532. private _updatePointerDistance;
  108533. }
  108534. }
  108535. declare module BABYLON {
  108536. /**
  108537. * Class used to represent data loading progression
  108538. */
  108539. export class SceneLoaderProgressEvent {
  108540. /** defines if data length to load can be evaluated */
  108541. readonly lengthComputable: boolean;
  108542. /** defines the loaded data length */
  108543. readonly loaded: number;
  108544. /** defines the data length to load */
  108545. readonly total: number;
  108546. /**
  108547. * Create a new progress event
  108548. * @param lengthComputable defines if data length to load can be evaluated
  108549. * @param loaded defines the loaded data length
  108550. * @param total defines the data length to load
  108551. */
  108552. constructor(
  108553. /** defines if data length to load can be evaluated */
  108554. lengthComputable: boolean,
  108555. /** defines the loaded data length */
  108556. loaded: number,
  108557. /** defines the data length to load */
  108558. total: number);
  108559. /**
  108560. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108561. * @param event defines the source event
  108562. * @returns a new SceneLoaderProgressEvent
  108563. */
  108564. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108565. }
  108566. /**
  108567. * Interface used by SceneLoader plugins to define supported file extensions
  108568. */
  108569. export interface ISceneLoaderPluginExtensions {
  108570. /**
  108571. * Defines the list of supported extensions
  108572. */
  108573. [extension: string]: {
  108574. isBinary: boolean;
  108575. };
  108576. }
  108577. /**
  108578. * Interface used by SceneLoader plugin factory
  108579. */
  108580. export interface ISceneLoaderPluginFactory {
  108581. /**
  108582. * Defines the name of the factory
  108583. */
  108584. name: string;
  108585. /**
  108586. * Function called to create a new plugin
  108587. * @return the new plugin
  108588. */
  108589. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108590. /**
  108591. * Boolean indicating if the plugin can direct load specific data
  108592. */
  108593. canDirectLoad?: (data: string) => boolean;
  108594. }
  108595. /**
  108596. * Interface used to define a SceneLoader plugin
  108597. */
  108598. export interface ISceneLoaderPlugin {
  108599. /**
  108600. * The friendly name of this plugin.
  108601. */
  108602. name: string;
  108603. /**
  108604. * The file extensions supported by this plugin.
  108605. */
  108606. extensions: string | ISceneLoaderPluginExtensions;
  108607. /**
  108608. * Import meshes into a scene.
  108609. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108610. * @param scene The scene to import into
  108611. * @param data The data to import
  108612. * @param rootUrl The root url for scene and resources
  108613. * @param meshes The meshes array to import into
  108614. * @param particleSystems The particle systems array to import into
  108615. * @param skeletons The skeletons array to import into
  108616. * @param onError The callback when import fails
  108617. * @returns True if successful or false otherwise
  108618. */
  108619. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108620. /**
  108621. * Load into a scene.
  108622. * @param scene The scene to load into
  108623. * @param data The data to import
  108624. * @param rootUrl The root url for scene and resources
  108625. * @param onError The callback when import fails
  108626. * @returns true if successful or false otherwise
  108627. */
  108628. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108629. /**
  108630. * The callback that returns true if the data can be directly loaded.
  108631. */
  108632. canDirectLoad?: (data: string) => boolean;
  108633. /**
  108634. * The callback that allows custom handling of the root url based on the response url.
  108635. */
  108636. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108637. /**
  108638. * Load into an asset container.
  108639. * @param scene The scene to load into
  108640. * @param data The data to import
  108641. * @param rootUrl The root url for scene and resources
  108642. * @param onError The callback when import fails
  108643. * @returns The loaded asset container
  108644. */
  108645. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108646. }
  108647. /**
  108648. * Interface used to define an async SceneLoader plugin
  108649. */
  108650. export interface ISceneLoaderPluginAsync {
  108651. /**
  108652. * The friendly name of this plugin.
  108653. */
  108654. name: string;
  108655. /**
  108656. * The file extensions supported by this plugin.
  108657. */
  108658. extensions: string | ISceneLoaderPluginExtensions;
  108659. /**
  108660. * Import meshes into a scene.
  108661. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108662. * @param scene The scene to import into
  108663. * @param data The data to import
  108664. * @param rootUrl The root url for scene and resources
  108665. * @param onProgress The callback when the load progresses
  108666. * @param fileName Defines the name of the file to load
  108667. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108668. */
  108669. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108670. meshes: AbstractMesh[];
  108671. particleSystems: IParticleSystem[];
  108672. skeletons: Skeleton[];
  108673. animationGroups: AnimationGroup[];
  108674. }>;
  108675. /**
  108676. * Load into a scene.
  108677. * @param scene The scene to load into
  108678. * @param data The data to import
  108679. * @param rootUrl The root url for scene and resources
  108680. * @param onProgress The callback when the load progresses
  108681. * @param fileName Defines the name of the file to load
  108682. * @returns Nothing
  108683. */
  108684. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108685. /**
  108686. * The callback that returns true if the data can be directly loaded.
  108687. */
  108688. canDirectLoad?: (data: string) => boolean;
  108689. /**
  108690. * The callback that allows custom handling of the root url based on the response url.
  108691. */
  108692. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108693. /**
  108694. * Load into an asset container.
  108695. * @param scene The scene to load into
  108696. * @param data The data to import
  108697. * @param rootUrl The root url for scene and resources
  108698. * @param onProgress The callback when the load progresses
  108699. * @param fileName Defines the name of the file to load
  108700. * @returns The loaded asset container
  108701. */
  108702. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108703. }
  108704. /**
  108705. * Class used to load scene from various file formats using registered plugins
  108706. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108707. */
  108708. export class SceneLoader {
  108709. /**
  108710. * No logging while loading
  108711. */
  108712. static readonly NO_LOGGING: number;
  108713. /**
  108714. * Minimal logging while loading
  108715. */
  108716. static readonly MINIMAL_LOGGING: number;
  108717. /**
  108718. * Summary logging while loading
  108719. */
  108720. static readonly SUMMARY_LOGGING: number;
  108721. /**
  108722. * Detailled logging while loading
  108723. */
  108724. static readonly DETAILED_LOGGING: number;
  108725. /**
  108726. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108727. */
  108728. static ForceFullSceneLoadingForIncremental: boolean;
  108729. /**
  108730. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108731. */
  108732. static ShowLoadingScreen: boolean;
  108733. /**
  108734. * Defines the current logging level (while loading the scene)
  108735. * @ignorenaming
  108736. */
  108737. static loggingLevel: number;
  108738. /**
  108739. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108740. */
  108741. static CleanBoneMatrixWeights: boolean;
  108742. /**
  108743. * Event raised when a plugin is used to load a scene
  108744. */
  108745. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108746. private static _registeredPlugins;
  108747. private static _getDefaultPlugin;
  108748. private static _getPluginForExtension;
  108749. private static _getPluginForDirectLoad;
  108750. private static _getPluginForFilename;
  108751. private static _getDirectLoad;
  108752. private static _loadData;
  108753. private static _getFileInfo;
  108754. /**
  108755. * Gets a plugin that can load the given extension
  108756. * @param extension defines the extension to load
  108757. * @returns a plugin or null if none works
  108758. */
  108759. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108760. /**
  108761. * Gets a boolean indicating that the given extension can be loaded
  108762. * @param extension defines the extension to load
  108763. * @returns true if the extension is supported
  108764. */
  108765. static IsPluginForExtensionAvailable(extension: string): boolean;
  108766. /**
  108767. * Adds a new plugin to the list of registered plugins
  108768. * @param plugin defines the plugin to add
  108769. */
  108770. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108771. /**
  108772. * Import meshes into a scene
  108773. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108774. * @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)
  108775. * @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)
  108776. * @param scene the instance of BABYLON.Scene to append to
  108777. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108778. * @param onProgress a callback with a progress event for each file being loaded
  108779. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108780. * @param pluginExtension the extension used to determine the plugin
  108781. * @returns The loaded plugin
  108782. */
  108783. 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>;
  108784. /**
  108785. * Import meshes into a scene
  108786. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108787. * @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)
  108788. * @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)
  108789. * @param scene the instance of BABYLON.Scene to append to
  108790. * @param onProgress a callback with a progress event for each file being loaded
  108791. * @param pluginExtension the extension used to determine the plugin
  108792. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108793. */
  108794. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108795. meshes: AbstractMesh[];
  108796. particleSystems: IParticleSystem[];
  108797. skeletons: Skeleton[];
  108798. animationGroups: AnimationGroup[];
  108799. }>;
  108800. /**
  108801. * Load a scene
  108802. * @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)
  108803. * @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)
  108804. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108805. * @param onSuccess a callback with the scene when import succeeds
  108806. * @param onProgress a callback with a progress event for each file being loaded
  108807. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108808. * @param pluginExtension the extension used to determine the plugin
  108809. * @returns The loaded plugin
  108810. */
  108811. 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>;
  108812. /**
  108813. * Load a scene
  108814. * @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)
  108815. * @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)
  108816. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108817. * @param onProgress a callback with a progress event for each file being loaded
  108818. * @param pluginExtension the extension used to determine the plugin
  108819. * @returns The loaded scene
  108820. */
  108821. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108822. /**
  108823. * Append a scene
  108824. * @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)
  108825. * @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)
  108826. * @param scene is the instance of BABYLON.Scene to append to
  108827. * @param onSuccess a callback with the scene when import succeeds
  108828. * @param onProgress a callback with a progress event for each file being loaded
  108829. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108830. * @param pluginExtension the extension used to determine the plugin
  108831. * @returns The loaded plugin
  108832. */
  108833. 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>;
  108834. /**
  108835. * Append a scene
  108836. * @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)
  108837. * @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)
  108838. * @param scene is the instance of BABYLON.Scene to append to
  108839. * @param onProgress a callback with a progress event for each file being loaded
  108840. * @param pluginExtension the extension used to determine the plugin
  108841. * @returns The given scene
  108842. */
  108843. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108844. /**
  108845. * Load a scene into an asset container
  108846. * @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)
  108847. * @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)
  108848. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108849. * @param onSuccess a callback with the scene when import succeeds
  108850. * @param onProgress a callback with a progress event for each file being loaded
  108851. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108852. * @param pluginExtension the extension used to determine the plugin
  108853. * @returns The loaded plugin
  108854. */
  108855. 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>;
  108856. /**
  108857. * Load a scene into an asset container
  108858. * @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)
  108859. * @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)
  108860. * @param scene is the instance of Scene to append to
  108861. * @param onProgress a callback with a progress event for each file being loaded
  108862. * @param pluginExtension the extension used to determine the plugin
  108863. * @returns The loaded asset container
  108864. */
  108865. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108866. }
  108867. }
  108868. declare module BABYLON {
  108869. /**
  108870. * Generic Controller
  108871. */
  108872. export class GenericController extends WebVRController {
  108873. /**
  108874. * Base Url for the controller model.
  108875. */
  108876. static readonly MODEL_BASE_URL: string;
  108877. /**
  108878. * File name for the controller model.
  108879. */
  108880. static readonly MODEL_FILENAME: string;
  108881. /**
  108882. * Creates a new GenericController from a gamepad
  108883. * @param vrGamepad the gamepad that the controller should be created from
  108884. */
  108885. constructor(vrGamepad: any);
  108886. /**
  108887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108888. * @param scene scene in which to add meshes
  108889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108890. */
  108891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108892. /**
  108893. * Called once for each button that changed state since the last frame
  108894. * @param buttonIdx Which button index changed
  108895. * @param state New state of the button
  108896. * @param changes Which properties on the state changed since last frame
  108897. */
  108898. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108899. }
  108900. }
  108901. declare module BABYLON {
  108902. /**
  108903. * Defines the WindowsMotionController object that the state of the windows motion controller
  108904. */
  108905. export class WindowsMotionController extends WebVRController {
  108906. /**
  108907. * The base url used to load the left and right controller models
  108908. */
  108909. static MODEL_BASE_URL: string;
  108910. /**
  108911. * The name of the left controller model file
  108912. */
  108913. static MODEL_LEFT_FILENAME: string;
  108914. /**
  108915. * The name of the right controller model file
  108916. */
  108917. static MODEL_RIGHT_FILENAME: string;
  108918. /**
  108919. * The controller name prefix for this controller type
  108920. */
  108921. static readonly GAMEPAD_ID_PREFIX: string;
  108922. /**
  108923. * The controller id pattern for this controller type
  108924. */
  108925. private static readonly GAMEPAD_ID_PATTERN;
  108926. private _loadedMeshInfo;
  108927. private readonly _mapping;
  108928. /**
  108929. * Fired when the trackpad on this controller is clicked
  108930. */
  108931. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108932. /**
  108933. * Fired when the trackpad on this controller is modified
  108934. */
  108935. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108936. /**
  108937. * The current x and y values of this controller's trackpad
  108938. */
  108939. trackpad: StickValues;
  108940. /**
  108941. * Creates a new WindowsMotionController from a gamepad
  108942. * @param vrGamepad the gamepad that the controller should be created from
  108943. */
  108944. constructor(vrGamepad: any);
  108945. /**
  108946. * Fired when the trigger on this controller is modified
  108947. */
  108948. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108949. /**
  108950. * Fired when the menu button on this controller is modified
  108951. */
  108952. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108953. /**
  108954. * Fired when the grip button on this controller is modified
  108955. */
  108956. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108957. /**
  108958. * Fired when the thumbstick button on this controller is modified
  108959. */
  108960. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108961. /**
  108962. * Fired when the touchpad button on this controller is modified
  108963. */
  108964. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108965. /**
  108966. * Fired when the touchpad values on this controller are modified
  108967. */
  108968. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108969. private _updateTrackpad;
  108970. /**
  108971. * Called once per frame by the engine.
  108972. */
  108973. update(): void;
  108974. /**
  108975. * Called once for each button that changed state since the last frame
  108976. * @param buttonIdx Which button index changed
  108977. * @param state New state of the button
  108978. * @param changes Which properties on the state changed since last frame
  108979. */
  108980. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108981. /**
  108982. * Moves the buttons on the controller mesh based on their current state
  108983. * @param buttonName the name of the button to move
  108984. * @param buttonValue the value of the button which determines the buttons new position
  108985. */
  108986. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108987. /**
  108988. * Moves the axis on the controller mesh based on its current state
  108989. * @param axis the index of the axis
  108990. * @param axisValue the value of the axis which determines the meshes new position
  108991. * @hidden
  108992. */
  108993. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108994. /**
  108995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108996. * @param scene scene in which to add meshes
  108997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108998. */
  108999. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109000. /**
  109001. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109002. * can be transformed by button presses and axes values, based on this._mapping.
  109003. *
  109004. * @param scene scene in which the meshes exist
  109005. * @param meshes list of meshes that make up the controller model to process
  109006. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109007. */
  109008. private processModel;
  109009. private createMeshInfo;
  109010. /**
  109011. * Gets the ray of the controller in the direction the controller is pointing
  109012. * @param length the length the resulting ray should be
  109013. * @returns a ray in the direction the controller is pointing
  109014. */
  109015. getForwardRay(length?: number): Ray;
  109016. /**
  109017. * Disposes of the controller
  109018. */
  109019. dispose(): void;
  109020. }
  109021. }
  109022. declare module BABYLON {
  109023. /**
  109024. * Oculus Touch Controller
  109025. */
  109026. export class OculusTouchController extends WebVRController {
  109027. /**
  109028. * Base Url for the controller model.
  109029. */
  109030. static MODEL_BASE_URL: string;
  109031. /**
  109032. * File name for the left controller model.
  109033. */
  109034. static MODEL_LEFT_FILENAME: string;
  109035. /**
  109036. * File name for the right controller model.
  109037. */
  109038. static MODEL_RIGHT_FILENAME: string;
  109039. /**
  109040. * Base Url for the Quest controller model.
  109041. */
  109042. static QUEST_MODEL_BASE_URL: string;
  109043. /**
  109044. * @hidden
  109045. * If the controllers are running on a device that needs the updated Quest controller models
  109046. */
  109047. static _IsQuest: boolean;
  109048. /**
  109049. * Fired when the secondary trigger on this controller is modified
  109050. */
  109051. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109052. /**
  109053. * Fired when the thumb rest on this controller is modified
  109054. */
  109055. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109056. /**
  109057. * Creates a new OculusTouchController from a gamepad
  109058. * @param vrGamepad the gamepad that the controller should be created from
  109059. */
  109060. constructor(vrGamepad: any);
  109061. /**
  109062. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109063. * @param scene scene in which to add meshes
  109064. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109065. */
  109066. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109067. /**
  109068. * Fired when the A button on this controller is modified
  109069. */
  109070. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109071. /**
  109072. * Fired when the B button on this controller is modified
  109073. */
  109074. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109075. /**
  109076. * Fired when the X button on this controller is modified
  109077. */
  109078. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109079. /**
  109080. * Fired when the Y button on this controller is modified
  109081. */
  109082. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109083. /**
  109084. * Called once for each button that changed state since the last frame
  109085. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109086. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109087. * 2) secondary trigger (same)
  109088. * 3) A (right) X (left), touch, pressed = value
  109089. * 4) B / Y
  109090. * 5) thumb rest
  109091. * @param buttonIdx Which button index changed
  109092. * @param state New state of the button
  109093. * @param changes Which properties on the state changed since last frame
  109094. */
  109095. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109096. }
  109097. }
  109098. declare module BABYLON {
  109099. /**
  109100. * Vive Controller
  109101. */
  109102. export class ViveController extends WebVRController {
  109103. /**
  109104. * Base Url for the controller model.
  109105. */
  109106. static MODEL_BASE_URL: string;
  109107. /**
  109108. * File name for the controller model.
  109109. */
  109110. static MODEL_FILENAME: string;
  109111. /**
  109112. * Creates a new ViveController from a gamepad
  109113. * @param vrGamepad the gamepad that the controller should be created from
  109114. */
  109115. constructor(vrGamepad: any);
  109116. /**
  109117. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109118. * @param scene scene in which to add meshes
  109119. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109120. */
  109121. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109122. /**
  109123. * Fired when the left button on this controller is modified
  109124. */
  109125. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109126. /**
  109127. * Fired when the right button on this controller is modified
  109128. */
  109129. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109130. /**
  109131. * Fired when the menu button on this controller is modified
  109132. */
  109133. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109134. /**
  109135. * Called once for each button that changed state since the last frame
  109136. * Vive mapping:
  109137. * 0: touchpad
  109138. * 1: trigger
  109139. * 2: left AND right buttons
  109140. * 3: menu button
  109141. * @param buttonIdx Which button index changed
  109142. * @param state New state of the button
  109143. * @param changes Which properties on the state changed since last frame
  109144. */
  109145. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109146. }
  109147. }
  109148. declare module BABYLON {
  109149. /**
  109150. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109151. */
  109152. export class WebXRControllerModelLoader {
  109153. /**
  109154. * Creates the WebXRControllerModelLoader
  109155. * @param input xr input that creates the controllers
  109156. */
  109157. constructor(input: WebXRInput);
  109158. }
  109159. }
  109160. declare module BABYLON {
  109161. /**
  109162. * Contains an array of blocks representing the octree
  109163. */
  109164. export interface IOctreeContainer<T> {
  109165. /**
  109166. * Blocks within the octree
  109167. */
  109168. blocks: Array<OctreeBlock<T>>;
  109169. }
  109170. /**
  109171. * Class used to store a cell in an octree
  109172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109173. */
  109174. export class OctreeBlock<T> {
  109175. /**
  109176. * Gets the content of the current block
  109177. */
  109178. entries: T[];
  109179. /**
  109180. * Gets the list of block children
  109181. */
  109182. blocks: Array<OctreeBlock<T>>;
  109183. private _depth;
  109184. private _maxDepth;
  109185. private _capacity;
  109186. private _minPoint;
  109187. private _maxPoint;
  109188. private _boundingVectors;
  109189. private _creationFunc;
  109190. /**
  109191. * Creates a new block
  109192. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109193. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109194. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109195. * @param depth defines the current depth of this block in the octree
  109196. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109197. * @param creationFunc defines a callback to call when an element is added to the block
  109198. */
  109199. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109200. /**
  109201. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109202. */
  109203. readonly capacity: number;
  109204. /**
  109205. * Gets the minimum vector (in world space) of the block's bounding box
  109206. */
  109207. readonly minPoint: Vector3;
  109208. /**
  109209. * Gets the maximum vector (in world space) of the block's bounding box
  109210. */
  109211. readonly maxPoint: Vector3;
  109212. /**
  109213. * Add a new element to this block
  109214. * @param entry defines the element to add
  109215. */
  109216. addEntry(entry: T): void;
  109217. /**
  109218. * Remove an element from this block
  109219. * @param entry defines the element to remove
  109220. */
  109221. removeEntry(entry: T): void;
  109222. /**
  109223. * Add an array of elements to this block
  109224. * @param entries defines the array of elements to add
  109225. */
  109226. addEntries(entries: T[]): void;
  109227. /**
  109228. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109229. * @param frustumPlanes defines the frustum planes to test
  109230. * @param selection defines the array to store current content if selection is positive
  109231. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109232. */
  109233. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109234. /**
  109235. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109236. * @param sphereCenter defines the bounding sphere center
  109237. * @param sphereRadius defines the bounding sphere radius
  109238. * @param selection defines the array to store current content if selection is positive
  109239. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109240. */
  109241. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109242. /**
  109243. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109244. * @param ray defines the ray to test with
  109245. * @param selection defines the array to store current content if selection is positive
  109246. */
  109247. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109248. /**
  109249. * Subdivide the content into child blocks (this block will then be empty)
  109250. */
  109251. createInnerBlocks(): void;
  109252. /**
  109253. * @hidden
  109254. */
  109255. 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;
  109256. }
  109257. }
  109258. declare module BABYLON {
  109259. /**
  109260. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109261. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109262. */
  109263. export class Octree<T> {
  109264. /** 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.) */
  109265. maxDepth: number;
  109266. /**
  109267. * Blocks within the octree containing objects
  109268. */
  109269. blocks: Array<OctreeBlock<T>>;
  109270. /**
  109271. * Content stored in the octree
  109272. */
  109273. dynamicContent: T[];
  109274. private _maxBlockCapacity;
  109275. private _selectionContent;
  109276. private _creationFunc;
  109277. /**
  109278. * Creates a octree
  109279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109280. * @param creationFunc function to be used to instatiate the octree
  109281. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109282. * @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.)
  109283. */
  109284. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109285. /** 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.) */
  109286. maxDepth?: number);
  109287. /**
  109288. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109289. * @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);
  109290. * @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);
  109291. * @param entries meshes to be added to the octree blocks
  109292. */
  109293. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109294. /**
  109295. * Adds a mesh to the octree
  109296. * @param entry Mesh to add to the octree
  109297. */
  109298. addMesh(entry: T): void;
  109299. /**
  109300. * Remove an element from the octree
  109301. * @param entry defines the element to remove
  109302. */
  109303. removeMesh(entry: T): void;
  109304. /**
  109305. * Selects an array of meshes within the frustum
  109306. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109307. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109308. * @returns array of meshes within the frustum
  109309. */
  109310. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109311. /**
  109312. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109313. * @param sphereCenter defines the bounding sphere center
  109314. * @param sphereRadius defines the bounding sphere radius
  109315. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109316. * @returns an array of objects that intersect the sphere
  109317. */
  109318. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109319. /**
  109320. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109321. * @param ray defines the ray to test with
  109322. * @returns array of intersected objects
  109323. */
  109324. intersectsRay(ray: Ray): SmartArray<T>;
  109325. /**
  109326. * Adds a mesh into the octree block if it intersects the block
  109327. */
  109328. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109329. /**
  109330. * Adds a submesh into the octree block if it intersects the block
  109331. */
  109332. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109333. }
  109334. }
  109335. declare module BABYLON {
  109336. interface Scene {
  109337. /**
  109338. * @hidden
  109339. * Backing Filed
  109340. */
  109341. _selectionOctree: Octree<AbstractMesh>;
  109342. /**
  109343. * Gets the octree used to boost mesh selection (picking)
  109344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109345. */
  109346. selectionOctree: Octree<AbstractMesh>;
  109347. /**
  109348. * Creates or updates the octree used to boost selection (picking)
  109349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109350. * @param maxCapacity defines the maximum capacity per leaf
  109351. * @param maxDepth defines the maximum depth of the octree
  109352. * @returns an octree of AbstractMesh
  109353. */
  109354. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109355. }
  109356. interface AbstractMesh {
  109357. /**
  109358. * @hidden
  109359. * Backing Field
  109360. */
  109361. _submeshesOctree: Octree<SubMesh>;
  109362. /**
  109363. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109364. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109365. * @param maxCapacity defines the maximum size of each block (64 by default)
  109366. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109367. * @returns the new octree
  109368. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109370. */
  109371. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109372. }
  109373. /**
  109374. * Defines the octree scene component responsible to manage any octrees
  109375. * in a given scene.
  109376. */
  109377. export class OctreeSceneComponent {
  109378. /**
  109379. * The component name help to identify the component in the list of scene components.
  109380. */
  109381. readonly name: string;
  109382. /**
  109383. * The scene the component belongs to.
  109384. */
  109385. scene: Scene;
  109386. /**
  109387. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109388. */
  109389. readonly checksIsEnabled: boolean;
  109390. /**
  109391. * Creates a new instance of the component for the given scene
  109392. * @param scene Defines the scene to register the component in
  109393. */
  109394. constructor(scene: Scene);
  109395. /**
  109396. * Registers the component in a given scene
  109397. */
  109398. register(): void;
  109399. /**
  109400. * Return the list of active meshes
  109401. * @returns the list of active meshes
  109402. */
  109403. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109404. /**
  109405. * Return the list of active sub meshes
  109406. * @param mesh The mesh to get the candidates sub meshes from
  109407. * @returns the list of active sub meshes
  109408. */
  109409. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109410. private _tempRay;
  109411. /**
  109412. * Return the list of sub meshes intersecting with a given local ray
  109413. * @param mesh defines the mesh to find the submesh for
  109414. * @param localRay defines the ray in local space
  109415. * @returns the list of intersecting sub meshes
  109416. */
  109417. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109418. /**
  109419. * Return the list of sub meshes colliding with a collider
  109420. * @param mesh defines the mesh to find the submesh for
  109421. * @param collider defines the collider to evaluate the collision against
  109422. * @returns the list of colliding sub meshes
  109423. */
  109424. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109425. /**
  109426. * Rebuilds the elements related to this component in case of
  109427. * context lost for instance.
  109428. */
  109429. rebuild(): void;
  109430. /**
  109431. * Disposes the component and the associated ressources.
  109432. */
  109433. dispose(): void;
  109434. }
  109435. }
  109436. declare module BABYLON {
  109437. /**
  109438. * Renders a layer on top of an existing scene
  109439. */
  109440. export class UtilityLayerRenderer implements IDisposable {
  109441. /** the original scene that will be rendered on top of */
  109442. originalScene: Scene;
  109443. private _pointerCaptures;
  109444. private _lastPointerEvents;
  109445. private static _DefaultUtilityLayer;
  109446. private static _DefaultKeepDepthUtilityLayer;
  109447. private _sharedGizmoLight;
  109448. private _renderCamera;
  109449. /**
  109450. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109451. * @returns the camera that is used when rendering the utility layer
  109452. */
  109453. getRenderCamera(): Nullable<Camera>;
  109454. /**
  109455. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109456. * @param cam the camera that should be used when rendering the utility layer
  109457. */
  109458. setRenderCamera(cam: Nullable<Camera>): void;
  109459. /**
  109460. * @hidden
  109461. * Light which used by gizmos to get light shading
  109462. */
  109463. _getSharedGizmoLight(): HemisphericLight;
  109464. /**
  109465. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109466. */
  109467. pickUtilitySceneFirst: boolean;
  109468. /**
  109469. * 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)
  109470. */
  109471. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109472. /**
  109473. * 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)
  109474. */
  109475. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109476. /**
  109477. * The scene that is rendered on top of the original scene
  109478. */
  109479. utilityLayerScene: Scene;
  109480. /**
  109481. * If the utility layer should automatically be rendered on top of existing scene
  109482. */
  109483. shouldRender: boolean;
  109484. /**
  109485. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109486. */
  109487. onlyCheckPointerDownEvents: boolean;
  109488. /**
  109489. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109490. */
  109491. processAllEvents: boolean;
  109492. /**
  109493. * Observable raised when the pointer move from the utility layer scene to the main scene
  109494. */
  109495. onPointerOutObservable: Observable<number>;
  109496. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109497. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109498. private _afterRenderObserver;
  109499. private _sceneDisposeObserver;
  109500. private _originalPointerObserver;
  109501. /**
  109502. * Instantiates a UtilityLayerRenderer
  109503. * @param originalScene the original scene that will be rendered on top of
  109504. * @param handleEvents boolean indicating if the utility layer should handle events
  109505. */
  109506. constructor(
  109507. /** the original scene that will be rendered on top of */
  109508. originalScene: Scene, handleEvents?: boolean);
  109509. private _notifyObservers;
  109510. /**
  109511. * Renders the utility layers scene on top of the original scene
  109512. */
  109513. render(): void;
  109514. /**
  109515. * Disposes of the renderer
  109516. */
  109517. dispose(): void;
  109518. private _updateCamera;
  109519. }
  109520. }
  109521. declare module BABYLON {
  109522. /**
  109523. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109524. */
  109525. export class Gizmo implements IDisposable {
  109526. /** The utility layer the gizmo will be added to */
  109527. gizmoLayer: UtilityLayerRenderer;
  109528. /**
  109529. * The root mesh of the gizmo
  109530. */
  109531. _rootMesh: Mesh;
  109532. private _attachedMesh;
  109533. /**
  109534. * Ratio for the scale of the gizmo (Default: 1)
  109535. */
  109536. scaleRatio: number;
  109537. /**
  109538. * If a custom mesh has been set (Default: false)
  109539. */
  109540. protected _customMeshSet: boolean;
  109541. /**
  109542. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109543. * * When set, interactions will be enabled
  109544. */
  109545. attachedMesh: Nullable<AbstractMesh>;
  109546. /**
  109547. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109548. * @param mesh The mesh to replace the default mesh of the gizmo
  109549. */
  109550. setCustomMesh(mesh: Mesh): void;
  109551. /**
  109552. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109553. */
  109554. updateGizmoRotationToMatchAttachedMesh: boolean;
  109555. /**
  109556. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109557. */
  109558. updateGizmoPositionToMatchAttachedMesh: boolean;
  109559. /**
  109560. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109561. */
  109562. updateScale: boolean;
  109563. protected _interactionsEnabled: boolean;
  109564. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109565. private _beforeRenderObserver;
  109566. private _tempVector;
  109567. /**
  109568. * Creates a gizmo
  109569. * @param gizmoLayer The utility layer the gizmo will be added to
  109570. */
  109571. constructor(
  109572. /** The utility layer the gizmo will be added to */
  109573. gizmoLayer?: UtilityLayerRenderer);
  109574. /**
  109575. * Updates the gizmo to match the attached mesh's position/rotation
  109576. */
  109577. protected _update(): void;
  109578. /**
  109579. * Disposes of the gizmo
  109580. */
  109581. dispose(): void;
  109582. }
  109583. }
  109584. declare module BABYLON {
  109585. /**
  109586. * Single plane drag gizmo
  109587. */
  109588. export class PlaneDragGizmo extends Gizmo {
  109589. /**
  109590. * Drag behavior responsible for the gizmos dragging interactions
  109591. */
  109592. dragBehavior: PointerDragBehavior;
  109593. private _pointerObserver;
  109594. /**
  109595. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109596. */
  109597. snapDistance: number;
  109598. /**
  109599. * Event that fires each time the gizmo snaps to a new location.
  109600. * * snapDistance is the the change in distance
  109601. */
  109602. onSnapObservable: Observable<{
  109603. snapDistance: number;
  109604. }>;
  109605. private _plane;
  109606. private _coloredMaterial;
  109607. private _hoverMaterial;
  109608. private _isEnabled;
  109609. private _parent;
  109610. /** @hidden */
  109611. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109612. /** @hidden */
  109613. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109614. /**
  109615. * Creates a PlaneDragGizmo
  109616. * @param gizmoLayer The utility layer the gizmo will be added to
  109617. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109618. * @param color The color of the gizmo
  109619. */
  109620. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109621. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109622. /**
  109623. * If the gizmo is enabled
  109624. */
  109625. isEnabled: boolean;
  109626. /**
  109627. * Disposes of the gizmo
  109628. */
  109629. dispose(): void;
  109630. }
  109631. }
  109632. declare module BABYLON {
  109633. /**
  109634. * Gizmo that enables dragging a mesh along 3 axis
  109635. */
  109636. export class PositionGizmo extends Gizmo {
  109637. /**
  109638. * Internal gizmo used for interactions on the x axis
  109639. */
  109640. xGizmo: AxisDragGizmo;
  109641. /**
  109642. * Internal gizmo used for interactions on the y axis
  109643. */
  109644. yGizmo: AxisDragGizmo;
  109645. /**
  109646. * Internal gizmo used for interactions on the z axis
  109647. */
  109648. zGizmo: AxisDragGizmo;
  109649. /**
  109650. * Internal gizmo used for interactions on the yz plane
  109651. */
  109652. xPlaneGizmo: PlaneDragGizmo;
  109653. /**
  109654. * Internal gizmo used for interactions on the xz plane
  109655. */
  109656. yPlaneGizmo: PlaneDragGizmo;
  109657. /**
  109658. * Internal gizmo used for interactions on the xy plane
  109659. */
  109660. zPlaneGizmo: PlaneDragGizmo;
  109661. /**
  109662. * private variables
  109663. */
  109664. private _meshAttached;
  109665. private _updateGizmoRotationToMatchAttachedMesh;
  109666. private _snapDistance;
  109667. private _scaleRatio;
  109668. /** Fires an event when any of it's sub gizmos are dragged */
  109669. onDragStartObservable: Observable<unknown>;
  109670. /** Fires an event when any of it's sub gizmos are released from dragging */
  109671. onDragEndObservable: Observable<unknown>;
  109672. /**
  109673. * If set to true, planar drag is enabled
  109674. */
  109675. private _planarGizmoEnabled;
  109676. attachedMesh: Nullable<AbstractMesh>;
  109677. /**
  109678. * Creates a PositionGizmo
  109679. * @param gizmoLayer The utility layer the gizmo will be added to
  109680. */
  109681. constructor(gizmoLayer?: UtilityLayerRenderer);
  109682. /**
  109683. * If the planar drag gizmo is enabled
  109684. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109685. */
  109686. planarGizmoEnabled: boolean;
  109687. updateGizmoRotationToMatchAttachedMesh: boolean;
  109688. /**
  109689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109690. */
  109691. snapDistance: number;
  109692. /**
  109693. * Ratio for the scale of the gizmo (Default: 1)
  109694. */
  109695. scaleRatio: number;
  109696. /**
  109697. * Disposes of the gizmo
  109698. */
  109699. dispose(): void;
  109700. /**
  109701. * CustomMeshes are not supported by this gizmo
  109702. * @param mesh The mesh to replace the default mesh of the gizmo
  109703. */
  109704. setCustomMesh(mesh: Mesh): void;
  109705. }
  109706. }
  109707. declare module BABYLON {
  109708. /**
  109709. * Single axis drag gizmo
  109710. */
  109711. export class AxisDragGizmo extends Gizmo {
  109712. /**
  109713. * Drag behavior responsible for the gizmos dragging interactions
  109714. */
  109715. dragBehavior: PointerDragBehavior;
  109716. private _pointerObserver;
  109717. /**
  109718. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109719. */
  109720. snapDistance: number;
  109721. /**
  109722. * Event that fires each time the gizmo snaps to a new location.
  109723. * * snapDistance is the the change in distance
  109724. */
  109725. onSnapObservable: Observable<{
  109726. snapDistance: number;
  109727. }>;
  109728. private _isEnabled;
  109729. private _parent;
  109730. private _arrow;
  109731. private _coloredMaterial;
  109732. private _hoverMaterial;
  109733. /** @hidden */
  109734. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109735. /** @hidden */
  109736. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109737. /**
  109738. * Creates an AxisDragGizmo
  109739. * @param gizmoLayer The utility layer the gizmo will be added to
  109740. * @param dragAxis The axis which the gizmo will be able to drag on
  109741. * @param color The color of the gizmo
  109742. */
  109743. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109744. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109745. /**
  109746. * If the gizmo is enabled
  109747. */
  109748. isEnabled: boolean;
  109749. /**
  109750. * Disposes of the gizmo
  109751. */
  109752. dispose(): void;
  109753. }
  109754. }
  109755. declare module BABYLON.Debug {
  109756. /**
  109757. * The Axes viewer will show 3 axes in a specific point in space
  109758. */
  109759. export class AxesViewer {
  109760. private _xAxis;
  109761. private _yAxis;
  109762. private _zAxis;
  109763. private _scaleLinesFactor;
  109764. private _instanced;
  109765. /**
  109766. * Gets the hosting scene
  109767. */
  109768. scene: Scene;
  109769. /**
  109770. * Gets or sets a number used to scale line length
  109771. */
  109772. scaleLines: number;
  109773. /** Gets the node hierarchy used to render x-axis */
  109774. readonly xAxis: TransformNode;
  109775. /** Gets the node hierarchy used to render y-axis */
  109776. readonly yAxis: TransformNode;
  109777. /** Gets the node hierarchy used to render z-axis */
  109778. readonly zAxis: TransformNode;
  109779. /**
  109780. * Creates a new AxesViewer
  109781. * @param scene defines the hosting scene
  109782. * @param scaleLines defines a number used to scale line length (1 by default)
  109783. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109784. * @param xAxis defines the node hierarchy used to render the x-axis
  109785. * @param yAxis defines the node hierarchy used to render the y-axis
  109786. * @param zAxis defines the node hierarchy used to render the z-axis
  109787. */
  109788. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109789. /**
  109790. * Force the viewer to update
  109791. * @param position defines the position of the viewer
  109792. * @param xaxis defines the x axis of the viewer
  109793. * @param yaxis defines the y axis of the viewer
  109794. * @param zaxis defines the z axis of the viewer
  109795. */
  109796. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109797. /**
  109798. * Creates an instance of this axes viewer.
  109799. * @returns a new axes viewer with instanced meshes
  109800. */
  109801. createInstance(): AxesViewer;
  109802. /** Releases resources */
  109803. dispose(): void;
  109804. private static _SetRenderingGroupId;
  109805. }
  109806. }
  109807. declare module BABYLON.Debug {
  109808. /**
  109809. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109810. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109811. */
  109812. export class BoneAxesViewer extends AxesViewer {
  109813. /**
  109814. * Gets or sets the target mesh where to display the axes viewer
  109815. */
  109816. mesh: Nullable<Mesh>;
  109817. /**
  109818. * Gets or sets the target bone where to display the axes viewer
  109819. */
  109820. bone: Nullable<Bone>;
  109821. /** Gets current position */
  109822. pos: Vector3;
  109823. /** Gets direction of X axis */
  109824. xaxis: Vector3;
  109825. /** Gets direction of Y axis */
  109826. yaxis: Vector3;
  109827. /** Gets direction of Z axis */
  109828. zaxis: Vector3;
  109829. /**
  109830. * Creates a new BoneAxesViewer
  109831. * @param scene defines the hosting scene
  109832. * @param bone defines the target bone
  109833. * @param mesh defines the target mesh
  109834. * @param scaleLines defines a scaling factor for line length (1 by default)
  109835. */
  109836. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109837. /**
  109838. * Force the viewer to update
  109839. */
  109840. update(): void;
  109841. /** Releases resources */
  109842. dispose(): void;
  109843. }
  109844. }
  109845. declare module BABYLON {
  109846. /**
  109847. * Interface used to define scene explorer extensibility option
  109848. */
  109849. export interface IExplorerExtensibilityOption {
  109850. /**
  109851. * Define the option label
  109852. */
  109853. label: string;
  109854. /**
  109855. * Defines the action to execute on click
  109856. */
  109857. action: (entity: any) => void;
  109858. }
  109859. /**
  109860. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109861. */
  109862. export interface IExplorerExtensibilityGroup {
  109863. /**
  109864. * Defines a predicate to test if a given type mut be extended
  109865. */
  109866. predicate: (entity: any) => boolean;
  109867. /**
  109868. * Gets the list of options added to a type
  109869. */
  109870. entries: IExplorerExtensibilityOption[];
  109871. }
  109872. /**
  109873. * Interface used to define the options to use to create the Inspector
  109874. */
  109875. export interface IInspectorOptions {
  109876. /**
  109877. * Display in overlay mode (default: false)
  109878. */
  109879. overlay?: boolean;
  109880. /**
  109881. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109882. */
  109883. globalRoot?: HTMLElement;
  109884. /**
  109885. * Display the Scene explorer
  109886. */
  109887. showExplorer?: boolean;
  109888. /**
  109889. * Display the property inspector
  109890. */
  109891. showInspector?: boolean;
  109892. /**
  109893. * Display in embed mode (both panes on the right)
  109894. */
  109895. embedMode?: boolean;
  109896. /**
  109897. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109898. */
  109899. handleResize?: boolean;
  109900. /**
  109901. * Allow the panes to popup (default: true)
  109902. */
  109903. enablePopup?: boolean;
  109904. /**
  109905. * Allow the panes to be closed by users (default: true)
  109906. */
  109907. enableClose?: boolean;
  109908. /**
  109909. * Optional list of extensibility entries
  109910. */
  109911. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109912. /**
  109913. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109914. */
  109915. inspectorURL?: string;
  109916. }
  109917. interface Scene {
  109918. /**
  109919. * @hidden
  109920. * Backing field
  109921. */
  109922. _debugLayer: DebugLayer;
  109923. /**
  109924. * Gets the debug layer (aka Inspector) associated with the scene
  109925. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109926. */
  109927. debugLayer: DebugLayer;
  109928. }
  109929. /**
  109930. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109931. * what is happening in your scene
  109932. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109933. */
  109934. export class DebugLayer {
  109935. /**
  109936. * Define the url to get the inspector script from.
  109937. * By default it uses the babylonjs CDN.
  109938. * @ignoreNaming
  109939. */
  109940. static InspectorURL: string;
  109941. private _scene;
  109942. private BJSINSPECTOR;
  109943. private _onPropertyChangedObservable?;
  109944. /**
  109945. * Observable triggered when a property is changed through the inspector.
  109946. */
  109947. readonly onPropertyChangedObservable: any;
  109948. /**
  109949. * Instantiates a new debug layer.
  109950. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109951. * what is happening in your scene
  109952. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109953. * @param scene Defines the scene to inspect
  109954. */
  109955. constructor(scene: Scene);
  109956. /** Creates the inspector window. */
  109957. private _createInspector;
  109958. /**
  109959. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109960. * @param entity defines the entity to select
  109961. * @param lineContainerTitle defines the specific block to highlight
  109962. */
  109963. select(entity: any, lineContainerTitle?: string): void;
  109964. /** Get the inspector from bundle or global */
  109965. private _getGlobalInspector;
  109966. /**
  109967. * Get if the inspector is visible or not.
  109968. * @returns true if visible otherwise, false
  109969. */
  109970. isVisible(): boolean;
  109971. /**
  109972. * Hide the inspector and close its window.
  109973. */
  109974. hide(): void;
  109975. /**
  109976. * Launch the debugLayer.
  109977. * @param config Define the configuration of the inspector
  109978. * @return a promise fulfilled when the debug layer is visible
  109979. */
  109980. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109981. }
  109982. }
  109983. declare module BABYLON {
  109984. /**
  109985. * Class containing static functions to help procedurally build meshes
  109986. */
  109987. export class BoxBuilder {
  109988. /**
  109989. * Creates a box mesh
  109990. * * The parameter `size` sets the size (float) of each box side (default 1)
  109991. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109992. * * 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)
  109993. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109997. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109998. * @param name defines the name of the mesh
  109999. * @param options defines the options used to create the mesh
  110000. * @param scene defines the hosting scene
  110001. * @returns the box mesh
  110002. */
  110003. static CreateBox(name: string, options: {
  110004. size?: number;
  110005. width?: number;
  110006. height?: number;
  110007. depth?: number;
  110008. faceUV?: Vector4[];
  110009. faceColors?: Color4[];
  110010. sideOrientation?: number;
  110011. frontUVs?: Vector4;
  110012. backUVs?: Vector4;
  110013. wrap?: boolean;
  110014. topBaseAt?: number;
  110015. bottomBaseAt?: number;
  110016. updatable?: boolean;
  110017. }, scene?: Nullable<Scene>): Mesh;
  110018. }
  110019. }
  110020. declare module BABYLON {
  110021. /**
  110022. * Class containing static functions to help procedurally build meshes
  110023. */
  110024. export class SphereBuilder {
  110025. /**
  110026. * Creates a sphere mesh
  110027. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110028. * * 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`)
  110029. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110030. * * 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
  110031. * * 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)
  110032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110035. * @param name defines the name of the mesh
  110036. * @param options defines the options used to create the mesh
  110037. * @param scene defines the hosting scene
  110038. * @returns the sphere mesh
  110039. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110040. */
  110041. static CreateSphere(name: string, options: {
  110042. segments?: number;
  110043. diameter?: number;
  110044. diameterX?: number;
  110045. diameterY?: number;
  110046. diameterZ?: number;
  110047. arc?: number;
  110048. slice?: number;
  110049. sideOrientation?: number;
  110050. frontUVs?: Vector4;
  110051. backUVs?: Vector4;
  110052. updatable?: boolean;
  110053. }, scene?: Nullable<Scene>): Mesh;
  110054. }
  110055. }
  110056. declare module BABYLON.Debug {
  110057. /**
  110058. * Used to show the physics impostor around the specific mesh
  110059. */
  110060. export class PhysicsViewer {
  110061. /** @hidden */
  110062. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110063. /** @hidden */
  110064. protected _meshes: Array<Nullable<AbstractMesh>>;
  110065. /** @hidden */
  110066. protected _scene: Nullable<Scene>;
  110067. /** @hidden */
  110068. protected _numMeshes: number;
  110069. /** @hidden */
  110070. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110071. private _renderFunction;
  110072. private _utilityLayer;
  110073. private _debugBoxMesh;
  110074. private _debugSphereMesh;
  110075. private _debugCylinderMesh;
  110076. private _debugMaterial;
  110077. private _debugMeshMeshes;
  110078. /**
  110079. * Creates a new PhysicsViewer
  110080. * @param scene defines the hosting scene
  110081. */
  110082. constructor(scene: Scene);
  110083. /** @hidden */
  110084. protected _updateDebugMeshes(): void;
  110085. /**
  110086. * Renders a specified physic impostor
  110087. * @param impostor defines the impostor to render
  110088. * @param targetMesh defines the mesh represented by the impostor
  110089. * @returns the new debug mesh used to render the impostor
  110090. */
  110091. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110092. /**
  110093. * Hides a specified physic impostor
  110094. * @param impostor defines the impostor to hide
  110095. */
  110096. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110097. private _getDebugMaterial;
  110098. private _getDebugBoxMesh;
  110099. private _getDebugSphereMesh;
  110100. private _getDebugCylinderMesh;
  110101. private _getDebugMeshMesh;
  110102. private _getDebugMesh;
  110103. /** Releases all resources */
  110104. dispose(): void;
  110105. }
  110106. }
  110107. declare module BABYLON {
  110108. /**
  110109. * Class containing static functions to help procedurally build meshes
  110110. */
  110111. export class LinesBuilder {
  110112. /**
  110113. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110114. * * 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
  110115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110116. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110117. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110118. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110119. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110120. * * 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
  110121. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110124. * @param name defines the name of the new line system
  110125. * @param options defines the options used to create the line system
  110126. * @param scene defines the hosting scene
  110127. * @returns a new line system mesh
  110128. */
  110129. static CreateLineSystem(name: string, options: {
  110130. lines: Vector3[][];
  110131. updatable?: boolean;
  110132. instance?: Nullable<LinesMesh>;
  110133. colors?: Nullable<Color4[][]>;
  110134. useVertexAlpha?: boolean;
  110135. }, scene: Nullable<Scene>): LinesMesh;
  110136. /**
  110137. * Creates a line mesh
  110138. * 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
  110139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110140. * * The parameter `points` is an array successive Vector3
  110141. * * 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
  110142. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110143. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110144. * * When updating an instance, remember that only point positions can change, not the number of points
  110145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110146. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110147. * @param name defines the name of the new line system
  110148. * @param options defines the options used to create the line system
  110149. * @param scene defines the hosting scene
  110150. * @returns a new line mesh
  110151. */
  110152. static CreateLines(name: string, options: {
  110153. points: Vector3[];
  110154. updatable?: boolean;
  110155. instance?: Nullable<LinesMesh>;
  110156. colors?: Color4[];
  110157. useVertexAlpha?: boolean;
  110158. }, scene?: Nullable<Scene>): LinesMesh;
  110159. /**
  110160. * Creates a dashed line mesh
  110161. * * 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
  110162. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110163. * * The parameter `points` is an array successive Vector3
  110164. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110165. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110166. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110167. * * 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
  110168. * * When updating an instance, remember that only point positions can change, not the number of points
  110169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110170. * @param name defines the name of the mesh
  110171. * @param options defines the options used to create the mesh
  110172. * @param scene defines the hosting scene
  110173. * @returns the dashed line mesh
  110174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110175. */
  110176. static CreateDashedLines(name: string, options: {
  110177. points: Vector3[];
  110178. dashSize?: number;
  110179. gapSize?: number;
  110180. dashNb?: number;
  110181. updatable?: boolean;
  110182. instance?: LinesMesh;
  110183. }, scene?: Nullable<Scene>): LinesMesh;
  110184. }
  110185. }
  110186. declare module BABYLON {
  110187. /**
  110188. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110189. * in order to better appreciate the issue one might have.
  110190. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110191. */
  110192. export class RayHelper {
  110193. /**
  110194. * Defines the ray we are currently tryin to visualize.
  110195. */
  110196. ray: Nullable<Ray>;
  110197. private _renderPoints;
  110198. private _renderLine;
  110199. private _renderFunction;
  110200. private _scene;
  110201. private _updateToMeshFunction;
  110202. private _attachedToMesh;
  110203. private _meshSpaceDirection;
  110204. private _meshSpaceOrigin;
  110205. /**
  110206. * Helper function to create a colored helper in a scene in one line.
  110207. * @param ray Defines the ray we are currently tryin to visualize
  110208. * @param scene Defines the scene the ray is used in
  110209. * @param color Defines the color we want to see the ray in
  110210. * @returns The newly created ray helper.
  110211. */
  110212. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110213. /**
  110214. * Instantiate a new ray helper.
  110215. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110216. * in order to better appreciate the issue one might have.
  110217. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110218. * @param ray Defines the ray we are currently tryin to visualize
  110219. */
  110220. constructor(ray: Ray);
  110221. /**
  110222. * Shows the ray we are willing to debug.
  110223. * @param scene Defines the scene the ray needs to be rendered in
  110224. * @param color Defines the color the ray needs to be rendered in
  110225. */
  110226. show(scene: Scene, color?: Color3): void;
  110227. /**
  110228. * Hides the ray we are debugging.
  110229. */
  110230. hide(): void;
  110231. private _render;
  110232. /**
  110233. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110234. * @param mesh Defines the mesh we want the helper attached to
  110235. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110236. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110237. * @param length Defines the length of the ray
  110238. */
  110239. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110240. /**
  110241. * Detach the ray helper from the mesh it has previously been attached to.
  110242. */
  110243. detachFromMesh(): void;
  110244. private _updateToMesh;
  110245. /**
  110246. * Dispose the helper and release its associated resources.
  110247. */
  110248. dispose(): void;
  110249. }
  110250. }
  110251. declare module BABYLON.Debug {
  110252. /**
  110253. * Class used to render a debug view of a given skeleton
  110254. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110255. */
  110256. export class SkeletonViewer {
  110257. /** defines the skeleton to render */
  110258. skeleton: Skeleton;
  110259. /** defines the mesh attached to the skeleton */
  110260. mesh: AbstractMesh;
  110261. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110262. autoUpdateBonesMatrices: boolean;
  110263. /** defines the rendering group id to use with the viewer */
  110264. renderingGroupId: number;
  110265. /** Gets or sets the color used to render the skeleton */
  110266. color: Color3;
  110267. private _scene;
  110268. private _debugLines;
  110269. private _debugMesh;
  110270. private _isEnabled;
  110271. private _renderFunction;
  110272. private _utilityLayer;
  110273. /**
  110274. * Returns the mesh used to render the bones
  110275. */
  110276. readonly debugMesh: Nullable<LinesMesh>;
  110277. /**
  110278. * Creates a new SkeletonViewer
  110279. * @param skeleton defines the skeleton to render
  110280. * @param mesh defines the mesh attached to the skeleton
  110281. * @param scene defines the hosting scene
  110282. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110283. * @param renderingGroupId defines the rendering group id to use with the viewer
  110284. */
  110285. constructor(
  110286. /** defines the skeleton to render */
  110287. skeleton: Skeleton,
  110288. /** defines the mesh attached to the skeleton */
  110289. mesh: AbstractMesh, scene: Scene,
  110290. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110291. autoUpdateBonesMatrices?: boolean,
  110292. /** defines the rendering group id to use with the viewer */
  110293. renderingGroupId?: number);
  110294. /** Gets or sets a boolean indicating if the viewer is enabled */
  110295. isEnabled: boolean;
  110296. private _getBonePosition;
  110297. private _getLinesForBonesWithLength;
  110298. private _getLinesForBonesNoLength;
  110299. /** Update the viewer to sync with current skeleton state */
  110300. update(): void;
  110301. /** Release associated resources */
  110302. dispose(): void;
  110303. }
  110304. }
  110305. declare module BABYLON {
  110306. /**
  110307. * Options to create the null engine
  110308. */
  110309. export class NullEngineOptions {
  110310. /**
  110311. * Render width (Default: 512)
  110312. */
  110313. renderWidth: number;
  110314. /**
  110315. * Render height (Default: 256)
  110316. */
  110317. renderHeight: number;
  110318. /**
  110319. * Texture size (Default: 512)
  110320. */
  110321. textureSize: number;
  110322. /**
  110323. * If delta time between frames should be constant
  110324. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110325. */
  110326. deterministicLockstep: boolean;
  110327. /**
  110328. * Maximum about of steps between frames (Default: 4)
  110329. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110330. */
  110331. lockstepMaxSteps: number;
  110332. }
  110333. /**
  110334. * The null engine class provides support for headless version of babylon.js.
  110335. * This can be used in server side scenario or for testing purposes
  110336. */
  110337. export class NullEngine extends Engine {
  110338. private _options;
  110339. /**
  110340. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110341. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110342. * @returns true if engine is in deterministic lock step mode
  110343. */
  110344. isDeterministicLockStep(): boolean;
  110345. /**
  110346. * Gets the max steps when engine is running in deterministic lock step
  110347. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110348. * @returns the max steps
  110349. */
  110350. getLockstepMaxSteps(): number;
  110351. /**
  110352. * Gets the current hardware scaling level.
  110353. * By default the hardware scaling level is computed from the window device ratio.
  110354. * 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.
  110355. * @returns a number indicating the current hardware scaling level
  110356. */
  110357. getHardwareScalingLevel(): number;
  110358. constructor(options?: NullEngineOptions);
  110359. /**
  110360. * Creates a vertex buffer
  110361. * @param vertices the data for the vertex buffer
  110362. * @returns the new WebGL static buffer
  110363. */
  110364. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110365. /**
  110366. * Creates a new index buffer
  110367. * @param indices defines the content of the index buffer
  110368. * @param updatable defines if the index buffer must be updatable
  110369. * @returns a new webGL buffer
  110370. */
  110371. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110372. /**
  110373. * Clear the current render buffer or the current render target (if any is set up)
  110374. * @param color defines the color to use
  110375. * @param backBuffer defines if the back buffer must be cleared
  110376. * @param depth defines if the depth buffer must be cleared
  110377. * @param stencil defines if the stencil buffer must be cleared
  110378. */
  110379. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110380. /**
  110381. * Gets the current render width
  110382. * @param useScreen defines if screen size must be used (or the current render target if any)
  110383. * @returns a number defining the current render width
  110384. */
  110385. getRenderWidth(useScreen?: boolean): number;
  110386. /**
  110387. * Gets the current render height
  110388. * @param useScreen defines if screen size must be used (or the current render target if any)
  110389. * @returns a number defining the current render height
  110390. */
  110391. getRenderHeight(useScreen?: boolean): number;
  110392. /**
  110393. * Set the WebGL's viewport
  110394. * @param viewport defines the viewport element to be used
  110395. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110396. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110397. */
  110398. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110399. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110400. /**
  110401. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110402. * @param pipelineContext defines the pipeline context to use
  110403. * @param uniformsNames defines the list of uniform names
  110404. * @returns an array of webGL uniform locations
  110405. */
  110406. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110407. /**
  110408. * Gets the lsit of active attributes for a given webGL program
  110409. * @param pipelineContext defines the pipeline context to use
  110410. * @param attributesNames defines the list of attribute names to get
  110411. * @returns an array of indices indicating the offset of each attribute
  110412. */
  110413. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110414. /**
  110415. * Binds an effect to the webGL context
  110416. * @param effect defines the effect to bind
  110417. */
  110418. bindSamplers(effect: Effect): void;
  110419. /**
  110420. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110421. * @param effect defines the effect to activate
  110422. */
  110423. enableEffect(effect: Effect): void;
  110424. /**
  110425. * Set various states to the webGL context
  110426. * @param culling defines backface culling state
  110427. * @param zOffset defines the value to apply to zOffset (0 by default)
  110428. * @param force defines if states must be applied even if cache is up to date
  110429. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110430. */
  110431. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110432. /**
  110433. * Set the value of an uniform to an array of int32
  110434. * @param uniform defines the webGL uniform location where to store the value
  110435. * @param array defines the array of int32 to store
  110436. */
  110437. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110438. /**
  110439. * Set the value of an uniform to an array of int32 (stored as vec2)
  110440. * @param uniform defines the webGL uniform location where to store the value
  110441. * @param array defines the array of int32 to store
  110442. */
  110443. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110444. /**
  110445. * Set the value of an uniform to an array of int32 (stored as vec3)
  110446. * @param uniform defines the webGL uniform location where to store the value
  110447. * @param array defines the array of int32 to store
  110448. */
  110449. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110450. /**
  110451. * Set the value of an uniform to an array of int32 (stored as vec4)
  110452. * @param uniform defines the webGL uniform location where to store the value
  110453. * @param array defines the array of int32 to store
  110454. */
  110455. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110456. /**
  110457. * Set the value of an uniform to an array of float32
  110458. * @param uniform defines the webGL uniform location where to store the value
  110459. * @param array defines the array of float32 to store
  110460. */
  110461. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110462. /**
  110463. * Set the value of an uniform to an array of float32 (stored as vec2)
  110464. * @param uniform defines the webGL uniform location where to store the value
  110465. * @param array defines the array of float32 to store
  110466. */
  110467. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110468. /**
  110469. * Set the value of an uniform to an array of float32 (stored as vec3)
  110470. * @param uniform defines the webGL uniform location where to store the value
  110471. * @param array defines the array of float32 to store
  110472. */
  110473. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110474. /**
  110475. * Set the value of an uniform to an array of float32 (stored as vec4)
  110476. * @param uniform defines the webGL uniform location where to store the value
  110477. * @param array defines the array of float32 to store
  110478. */
  110479. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110480. /**
  110481. * Set the value of an uniform to an array of number
  110482. * @param uniform defines the webGL uniform location where to store the value
  110483. * @param array defines the array of number to store
  110484. */
  110485. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110486. /**
  110487. * Set the value of an uniform to an array of number (stored as vec2)
  110488. * @param uniform defines the webGL uniform location where to store the value
  110489. * @param array defines the array of number to store
  110490. */
  110491. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110492. /**
  110493. * Set the value of an uniform to an array of number (stored as vec3)
  110494. * @param uniform defines the webGL uniform location where to store the value
  110495. * @param array defines the array of number to store
  110496. */
  110497. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110498. /**
  110499. * Set the value of an uniform to an array of number (stored as vec4)
  110500. * @param uniform defines the webGL uniform location where to store the value
  110501. * @param array defines the array of number to store
  110502. */
  110503. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110504. /**
  110505. * Set the value of an uniform to an array of float32 (stored as matrices)
  110506. * @param uniform defines the webGL uniform location where to store the value
  110507. * @param matrices defines the array of float32 to store
  110508. */
  110509. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110510. /**
  110511. * Set the value of an uniform to a matrix (3x3)
  110512. * @param uniform defines the webGL uniform location where to store the value
  110513. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110514. */
  110515. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110516. /**
  110517. * Set the value of an uniform to a matrix (2x2)
  110518. * @param uniform defines the webGL uniform location where to store the value
  110519. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110520. */
  110521. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110522. /**
  110523. * Set the value of an uniform to a number (float)
  110524. * @param uniform defines the webGL uniform location where to store the value
  110525. * @param value defines the float number to store
  110526. */
  110527. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110528. /**
  110529. * Set the value of an uniform to a vec2
  110530. * @param uniform defines the webGL uniform location where to store the value
  110531. * @param x defines the 1st component of the value
  110532. * @param y defines the 2nd component of the value
  110533. */
  110534. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110535. /**
  110536. * Set the value of an uniform to a vec3
  110537. * @param uniform defines the webGL uniform location where to store the value
  110538. * @param x defines the 1st component of the value
  110539. * @param y defines the 2nd component of the value
  110540. * @param z defines the 3rd component of the value
  110541. */
  110542. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110543. /**
  110544. * Set the value of an uniform to a boolean
  110545. * @param uniform defines the webGL uniform location where to store the value
  110546. * @param bool defines the boolean to store
  110547. */
  110548. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110549. /**
  110550. * Set the value of an uniform to a vec4
  110551. * @param uniform defines the webGL uniform location where to store the value
  110552. * @param x defines the 1st component of the value
  110553. * @param y defines the 2nd component of the value
  110554. * @param z defines the 3rd component of the value
  110555. * @param w defines the 4th component of the value
  110556. */
  110557. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110558. /**
  110559. * Sets the current alpha mode
  110560. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110561. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110562. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110563. */
  110564. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110565. /**
  110566. * Bind webGl buffers directly to the webGL context
  110567. * @param vertexBuffers defines the vertex buffer to bind
  110568. * @param indexBuffer defines the index buffer to bind
  110569. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110570. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110571. * @param effect defines the effect associated with the vertex buffer
  110572. */
  110573. bindBuffers(vertexBuffers: {
  110574. [key: string]: VertexBuffer;
  110575. }, indexBuffer: DataBuffer, effect: Effect): void;
  110576. /**
  110577. * Force the entire cache to be cleared
  110578. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110579. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110580. */
  110581. wipeCaches(bruteForce?: boolean): void;
  110582. /**
  110583. * Send a draw order
  110584. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110585. * @param indexStart defines the starting index
  110586. * @param indexCount defines the number of index to draw
  110587. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110588. */
  110589. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110590. /**
  110591. * Draw a list of indexed primitives
  110592. * @param fillMode defines the primitive to use
  110593. * @param indexStart defines the starting index
  110594. * @param indexCount defines the number of index to draw
  110595. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110596. */
  110597. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110598. /**
  110599. * Draw a list of unindexed primitives
  110600. * @param fillMode defines the primitive to use
  110601. * @param verticesStart defines the index of first vertex to draw
  110602. * @param verticesCount defines the count of vertices to draw
  110603. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110604. */
  110605. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110606. /** @hidden */
  110607. _createTexture(): WebGLTexture;
  110608. /** @hidden */
  110609. _releaseTexture(texture: InternalTexture): void;
  110610. /**
  110611. * Usually called from Texture.ts.
  110612. * Passed information to create a WebGLTexture
  110613. * @param urlArg defines a value which contains one of the following:
  110614. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110615. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110616. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110617. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110618. * @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)
  110619. * @param scene needed for loading to the correct scene
  110620. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110621. * @param onLoad optional callback to be called upon successful completion
  110622. * @param onError optional callback to be called upon failure
  110623. * @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
  110624. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110625. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110626. * @param forcedExtension defines the extension to use to pick the right loader
  110627. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110628. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110629. */
  110630. 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;
  110631. /**
  110632. * Creates a new render target texture
  110633. * @param size defines the size of the texture
  110634. * @param options defines the options used to create the texture
  110635. * @returns a new render target texture stored in an InternalTexture
  110636. */
  110637. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110638. /**
  110639. * Update the sampling mode of a given texture
  110640. * @param samplingMode defines the required sampling mode
  110641. * @param texture defines the texture to update
  110642. */
  110643. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110644. /**
  110645. * Binds the frame buffer to the specified texture.
  110646. * @param texture The texture to render to or null for the default canvas
  110647. * @param faceIndex The face of the texture to render to in case of cube texture
  110648. * @param requiredWidth The width of the target to render to
  110649. * @param requiredHeight The height of the target to render to
  110650. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110651. * @param depthStencilTexture The depth stencil texture to use to render
  110652. * @param lodLevel defines le lod level to bind to the frame buffer
  110653. */
  110654. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110655. /**
  110656. * Unbind the current render target texture from the webGL context
  110657. * @param texture defines the render target texture to unbind
  110658. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110659. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110660. */
  110661. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110662. /**
  110663. * Creates a dynamic vertex buffer
  110664. * @param vertices the data for the dynamic vertex buffer
  110665. * @returns the new WebGL dynamic buffer
  110666. */
  110667. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110668. /**
  110669. * Update the content of a dynamic texture
  110670. * @param texture defines the texture to update
  110671. * @param canvas defines the canvas containing the source
  110672. * @param invertY defines if data must be stored with Y axis inverted
  110673. * @param premulAlpha defines if alpha is stored as premultiplied
  110674. * @param format defines the format of the data
  110675. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110676. */
  110677. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110678. /**
  110679. * Gets a boolean indicating if all created effects are ready
  110680. * @returns true if all effects are ready
  110681. */
  110682. areAllEffectsReady(): boolean;
  110683. /**
  110684. * @hidden
  110685. * Get the current error code of the webGL context
  110686. * @returns the error code
  110687. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110688. */
  110689. getError(): number;
  110690. /** @hidden */
  110691. _getUnpackAlignement(): number;
  110692. /** @hidden */
  110693. _unpackFlipY(value: boolean): void;
  110694. /**
  110695. * Update a dynamic index buffer
  110696. * @param indexBuffer defines the target index buffer
  110697. * @param indices defines the data to update
  110698. * @param offset defines the offset in the target index buffer where update should start
  110699. */
  110700. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110701. /**
  110702. * Updates a dynamic vertex buffer.
  110703. * @param vertexBuffer the vertex buffer to update
  110704. * @param vertices the data used to update the vertex buffer
  110705. * @param byteOffset the byte offset of the data (optional)
  110706. * @param byteLength the byte length of the data (optional)
  110707. */
  110708. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110709. /** @hidden */
  110710. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110711. /** @hidden */
  110712. _bindTexture(channel: number, texture: InternalTexture): void;
  110713. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110714. /**
  110715. * 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
  110716. */
  110717. releaseEffects(): void;
  110718. displayLoadingUI(): void;
  110719. hideLoadingUI(): void;
  110720. /** @hidden */
  110721. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110722. /** @hidden */
  110723. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110724. /** @hidden */
  110725. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110726. /** @hidden */
  110727. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110728. }
  110729. }
  110730. declare module BABYLON {
  110731. /** @hidden */
  110732. export class _OcclusionDataStorage {
  110733. /** @hidden */
  110734. occlusionInternalRetryCounter: number;
  110735. /** @hidden */
  110736. isOcclusionQueryInProgress: boolean;
  110737. /** @hidden */
  110738. isOccluded: boolean;
  110739. /** @hidden */
  110740. occlusionRetryCount: number;
  110741. /** @hidden */
  110742. occlusionType: number;
  110743. /** @hidden */
  110744. occlusionQueryAlgorithmType: number;
  110745. }
  110746. interface Engine {
  110747. /**
  110748. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110749. * @return the new query
  110750. */
  110751. createQuery(): WebGLQuery;
  110752. /**
  110753. * Delete and release a webGL query
  110754. * @param query defines the query to delete
  110755. * @return the current engine
  110756. */
  110757. deleteQuery(query: WebGLQuery): Engine;
  110758. /**
  110759. * Check if a given query has resolved and got its value
  110760. * @param query defines the query to check
  110761. * @returns true if the query got its value
  110762. */
  110763. isQueryResultAvailable(query: WebGLQuery): boolean;
  110764. /**
  110765. * Gets the value of a given query
  110766. * @param query defines the query to check
  110767. * @returns the value of the query
  110768. */
  110769. getQueryResult(query: WebGLQuery): number;
  110770. /**
  110771. * Initiates an occlusion query
  110772. * @param algorithmType defines the algorithm to use
  110773. * @param query defines the query to use
  110774. * @returns the current engine
  110775. * @see http://doc.babylonjs.com/features/occlusionquery
  110776. */
  110777. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110778. /**
  110779. * Ends an occlusion query
  110780. * @see http://doc.babylonjs.com/features/occlusionquery
  110781. * @param algorithmType defines the algorithm to use
  110782. * @returns the current engine
  110783. */
  110784. endOcclusionQuery(algorithmType: number): Engine;
  110785. /**
  110786. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110787. * Please note that only one query can be issued at a time
  110788. * @returns a time token used to track the time span
  110789. */
  110790. startTimeQuery(): Nullable<_TimeToken>;
  110791. /**
  110792. * Ends a time query
  110793. * @param token defines the token used to measure the time span
  110794. * @returns the time spent (in ns)
  110795. */
  110796. endTimeQuery(token: _TimeToken): int;
  110797. /** @hidden */
  110798. _currentNonTimestampToken: Nullable<_TimeToken>;
  110799. /** @hidden */
  110800. _createTimeQuery(): WebGLQuery;
  110801. /** @hidden */
  110802. _deleteTimeQuery(query: WebGLQuery): void;
  110803. /** @hidden */
  110804. _getGlAlgorithmType(algorithmType: number): number;
  110805. /** @hidden */
  110806. _getTimeQueryResult(query: WebGLQuery): any;
  110807. /** @hidden */
  110808. _getTimeQueryAvailability(query: WebGLQuery): any;
  110809. }
  110810. interface AbstractMesh {
  110811. /**
  110812. * Backing filed
  110813. * @hidden
  110814. */
  110815. __occlusionDataStorage: _OcclusionDataStorage;
  110816. /**
  110817. * Access property
  110818. * @hidden
  110819. */
  110820. _occlusionDataStorage: _OcclusionDataStorage;
  110821. /**
  110822. * 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.
  110823. * The default value is -1 which means don't break the query and wait till the result
  110824. * @see http://doc.babylonjs.com/features/occlusionquery
  110825. */
  110826. occlusionRetryCount: number;
  110827. /**
  110828. * 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:
  110829. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110830. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110831. * * 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.
  110832. * @see http://doc.babylonjs.com/features/occlusionquery
  110833. */
  110834. occlusionType: number;
  110835. /**
  110836. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110837. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110838. * * 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.
  110839. * @see http://doc.babylonjs.com/features/occlusionquery
  110840. */
  110841. occlusionQueryAlgorithmType: number;
  110842. /**
  110843. * 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
  110844. * @see http://doc.babylonjs.com/features/occlusionquery
  110845. */
  110846. isOccluded: boolean;
  110847. /**
  110848. * Flag to check the progress status of the query
  110849. * @see http://doc.babylonjs.com/features/occlusionquery
  110850. */
  110851. isOcclusionQueryInProgress: boolean;
  110852. }
  110853. }
  110854. declare module BABYLON {
  110855. /** @hidden */
  110856. export var _forceTransformFeedbackToBundle: boolean;
  110857. interface Engine {
  110858. /**
  110859. * Creates a webGL transform feedback object
  110860. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110861. * @returns the webGL transform feedback object
  110862. */
  110863. createTransformFeedback(): WebGLTransformFeedback;
  110864. /**
  110865. * Delete a webGL transform feedback object
  110866. * @param value defines the webGL transform feedback object to delete
  110867. */
  110868. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110869. /**
  110870. * Bind a webGL transform feedback object to the webgl context
  110871. * @param value defines the webGL transform feedback object to bind
  110872. */
  110873. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110874. /**
  110875. * Begins a transform feedback operation
  110876. * @param usePoints defines if points or triangles must be used
  110877. */
  110878. beginTransformFeedback(usePoints: boolean): void;
  110879. /**
  110880. * Ends a transform feedback operation
  110881. */
  110882. endTransformFeedback(): void;
  110883. /**
  110884. * Specify the varyings to use with transform feedback
  110885. * @param program defines the associated webGL program
  110886. * @param value defines the list of strings representing the varying names
  110887. */
  110888. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110889. /**
  110890. * Bind a webGL buffer for a transform feedback operation
  110891. * @param value defines the webGL buffer to bind
  110892. */
  110893. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110894. }
  110895. }
  110896. declare module BABYLON {
  110897. /**
  110898. * Creation options of the multi render target texture.
  110899. */
  110900. export interface IMultiRenderTargetOptions {
  110901. /**
  110902. * Define if the texture needs to create mip maps after render.
  110903. */
  110904. generateMipMaps?: boolean;
  110905. /**
  110906. * Define the types of all the draw buffers we want to create
  110907. */
  110908. types?: number[];
  110909. /**
  110910. * Define the sampling modes of all the draw buffers we want to create
  110911. */
  110912. samplingModes?: number[];
  110913. /**
  110914. * Define if a depth buffer is required
  110915. */
  110916. generateDepthBuffer?: boolean;
  110917. /**
  110918. * Define if a stencil buffer is required
  110919. */
  110920. generateStencilBuffer?: boolean;
  110921. /**
  110922. * Define if a depth texture is required instead of a depth buffer
  110923. */
  110924. generateDepthTexture?: boolean;
  110925. /**
  110926. * Define the number of desired draw buffers
  110927. */
  110928. textureCount?: number;
  110929. /**
  110930. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110931. */
  110932. doNotChangeAspectRatio?: boolean;
  110933. /**
  110934. * Define the default type of the buffers we are creating
  110935. */
  110936. defaultType?: number;
  110937. }
  110938. /**
  110939. * A multi render target, like a render target provides the ability to render to a texture.
  110940. * Unlike the render target, it can render to several draw buffers in one draw.
  110941. * This is specially interesting in deferred rendering or for any effects requiring more than
  110942. * just one color from a single pass.
  110943. */
  110944. export class MultiRenderTarget extends RenderTargetTexture {
  110945. private _internalTextures;
  110946. private _textures;
  110947. private _multiRenderTargetOptions;
  110948. /**
  110949. * Get if draw buffers are currently supported by the used hardware and browser.
  110950. */
  110951. readonly isSupported: boolean;
  110952. /**
  110953. * Get the list of textures generated by the multi render target.
  110954. */
  110955. readonly textures: Texture[];
  110956. /**
  110957. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  110958. */
  110959. readonly depthTexture: Texture;
  110960. /**
  110961. * Set the wrapping mode on U of all the textures we are rendering to.
  110962. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110963. */
  110964. wrapU: number;
  110965. /**
  110966. * Set the wrapping mode on V of all the textures we are rendering to.
  110967. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110968. */
  110969. wrapV: number;
  110970. /**
  110971. * Instantiate a new multi render target texture.
  110972. * A multi render target, like a render target provides the ability to render to a texture.
  110973. * Unlike the render target, it can render to several draw buffers in one draw.
  110974. * This is specially interesting in deferred rendering or for any effects requiring more than
  110975. * just one color from a single pass.
  110976. * @param name Define the name of the texture
  110977. * @param size Define the size of the buffers to render to
  110978. * @param count Define the number of target we are rendering into
  110979. * @param scene Define the scene the texture belongs to
  110980. * @param options Define the options used to create the multi render target
  110981. */
  110982. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  110983. /** @hidden */
  110984. _rebuild(): void;
  110985. private _createInternalTextures;
  110986. private _createTextures;
  110987. /**
  110988. * Define the number of samples used if MSAA is enabled.
  110989. */
  110990. samples: number;
  110991. /**
  110992. * Resize all the textures in the multi render target.
  110993. * Be carrefull as it will recreate all the data in the new texture.
  110994. * @param size Define the new size
  110995. */
  110996. resize(size: any): void;
  110997. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110998. /**
  110999. * Dispose the render targets and their associated resources
  111000. */
  111001. dispose(): void;
  111002. /**
  111003. * Release all the underlying texture used as draw buffers.
  111004. */
  111005. releaseInternalTextures(): void;
  111006. }
  111007. }
  111008. declare module BABYLON {
  111009. interface ThinEngine {
  111010. /**
  111011. * Unbind a list of render target textures from the webGL context
  111012. * This is used only when drawBuffer extension or webGL2 are active
  111013. * @param textures defines the render target textures to unbind
  111014. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111015. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111016. */
  111017. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111018. /**
  111019. * Create a multi render target texture
  111020. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111021. * @param size defines the size of the texture
  111022. * @param options defines the creation options
  111023. * @returns the cube texture as an InternalTexture
  111024. */
  111025. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111026. /**
  111027. * Update the sample count for a given multiple render target texture
  111028. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111029. * @param textures defines the textures to update
  111030. * @param samples defines the sample count to set
  111031. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111032. */
  111033. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111034. }
  111035. }
  111036. declare module BABYLON {
  111037. /** @hidden */
  111038. export var rgbdEncodePixelShader: {
  111039. name: string;
  111040. shader: string;
  111041. };
  111042. }
  111043. declare module BABYLON {
  111044. /** @hidden */
  111045. export var rgbdDecodePixelShader: {
  111046. name: string;
  111047. shader: string;
  111048. };
  111049. }
  111050. declare module BABYLON {
  111051. /**
  111052. * Raw texture data and descriptor sufficient for WebGL texture upload
  111053. */
  111054. export interface EnvironmentTextureInfo {
  111055. /**
  111056. * Version of the environment map
  111057. */
  111058. version: number;
  111059. /**
  111060. * Width of image
  111061. */
  111062. width: number;
  111063. /**
  111064. * Irradiance information stored in the file.
  111065. */
  111066. irradiance: any;
  111067. /**
  111068. * Specular information stored in the file.
  111069. */
  111070. specular: any;
  111071. }
  111072. /**
  111073. * Defines One Image in the file. It requires only the position in the file
  111074. * as well as the length.
  111075. */
  111076. interface BufferImageData {
  111077. /**
  111078. * Length of the image data.
  111079. */
  111080. length: number;
  111081. /**
  111082. * Position of the data from the null terminator delimiting the end of the JSON.
  111083. */
  111084. position: number;
  111085. }
  111086. /**
  111087. * Defines the specular data enclosed in the file.
  111088. * This corresponds to the version 1 of the data.
  111089. */
  111090. export interface EnvironmentTextureSpecularInfoV1 {
  111091. /**
  111092. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111093. */
  111094. specularDataPosition?: number;
  111095. /**
  111096. * This contains all the images data needed to reconstruct the cubemap.
  111097. */
  111098. mipmaps: Array<BufferImageData>;
  111099. /**
  111100. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111101. */
  111102. lodGenerationScale: number;
  111103. }
  111104. /**
  111105. * Sets of helpers addressing the serialization and deserialization of environment texture
  111106. * stored in a BabylonJS env file.
  111107. * Those files are usually stored as .env files.
  111108. */
  111109. export class EnvironmentTextureTools {
  111110. /**
  111111. * Magic number identifying the env file.
  111112. */
  111113. private static _MagicBytes;
  111114. /**
  111115. * Gets the environment info from an env file.
  111116. * @param data The array buffer containing the .env bytes.
  111117. * @returns the environment file info (the json header) if successfully parsed.
  111118. */
  111119. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111120. /**
  111121. * Creates an environment texture from a loaded cube texture.
  111122. * @param texture defines the cube texture to convert in env file
  111123. * @return a promise containing the environment data if succesfull.
  111124. */
  111125. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111126. /**
  111127. * Creates a JSON representation of the spherical data.
  111128. * @param texture defines the texture containing the polynomials
  111129. * @return the JSON representation of the spherical info
  111130. */
  111131. private static _CreateEnvTextureIrradiance;
  111132. /**
  111133. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111134. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111135. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111136. * @return the views described by info providing access to the underlying buffer
  111137. */
  111138. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111139. /**
  111140. * Uploads the texture info contained in the env file to the GPU.
  111141. * @param texture defines the internal texture to upload to
  111142. * @param arrayBuffer defines the buffer cotaining the data to load
  111143. * @param info defines the texture info retrieved through the GetEnvInfo method
  111144. * @returns a promise
  111145. */
  111146. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111147. /**
  111148. * Uploads the levels of image data to the GPU.
  111149. * @param texture defines the internal texture to upload to
  111150. * @param imageData defines the array buffer views of image data [mipmap][face]
  111151. * @returns a promise
  111152. */
  111153. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111154. /**
  111155. * Uploads spherical polynomials information to the texture.
  111156. * @param texture defines the texture we are trying to upload the information to
  111157. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111158. */
  111159. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111160. /** @hidden */
  111161. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111162. }
  111163. }
  111164. declare module BABYLON {
  111165. /**
  111166. * Contains position and normal vectors for a vertex
  111167. */
  111168. export class PositionNormalVertex {
  111169. /** the position of the vertex (defaut: 0,0,0) */
  111170. position: Vector3;
  111171. /** the normal of the vertex (defaut: 0,1,0) */
  111172. normal: Vector3;
  111173. /**
  111174. * Creates a PositionNormalVertex
  111175. * @param position the position of the vertex (defaut: 0,0,0)
  111176. * @param normal the normal of the vertex (defaut: 0,1,0)
  111177. */
  111178. constructor(
  111179. /** the position of the vertex (defaut: 0,0,0) */
  111180. position?: Vector3,
  111181. /** the normal of the vertex (defaut: 0,1,0) */
  111182. normal?: Vector3);
  111183. /**
  111184. * Clones the PositionNormalVertex
  111185. * @returns the cloned PositionNormalVertex
  111186. */
  111187. clone(): PositionNormalVertex;
  111188. }
  111189. /**
  111190. * Contains position, normal and uv vectors for a vertex
  111191. */
  111192. export class PositionNormalTextureVertex {
  111193. /** the position of the vertex (defaut: 0,0,0) */
  111194. position: Vector3;
  111195. /** the normal of the vertex (defaut: 0,1,0) */
  111196. normal: Vector3;
  111197. /** the uv of the vertex (default: 0,0) */
  111198. uv: Vector2;
  111199. /**
  111200. * Creates a PositionNormalTextureVertex
  111201. * @param position the position of the vertex (defaut: 0,0,0)
  111202. * @param normal the normal of the vertex (defaut: 0,1,0)
  111203. * @param uv the uv of the vertex (default: 0,0)
  111204. */
  111205. constructor(
  111206. /** the position of the vertex (defaut: 0,0,0) */
  111207. position?: Vector3,
  111208. /** the normal of the vertex (defaut: 0,1,0) */
  111209. normal?: Vector3,
  111210. /** the uv of the vertex (default: 0,0) */
  111211. uv?: Vector2);
  111212. /**
  111213. * Clones the PositionNormalTextureVertex
  111214. * @returns the cloned PositionNormalTextureVertex
  111215. */
  111216. clone(): PositionNormalTextureVertex;
  111217. }
  111218. }
  111219. declare module BABYLON {
  111220. /** @hidden */
  111221. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111222. private _genericAttributeLocation;
  111223. private _varyingLocationCount;
  111224. private _varyingLocationMap;
  111225. private _replacements;
  111226. private _textureCount;
  111227. private _uniforms;
  111228. lineProcessor(line: string): string;
  111229. attributeProcessor(attribute: string): string;
  111230. varyingProcessor(varying: string, isFragment: boolean): string;
  111231. uniformProcessor(uniform: string): string;
  111232. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111233. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111234. }
  111235. }
  111236. declare module BABYLON {
  111237. /**
  111238. * Container for accessors for natively-stored mesh data buffers.
  111239. */
  111240. class NativeDataBuffer extends DataBuffer {
  111241. /**
  111242. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111243. */
  111244. nativeIndexBuffer?: any;
  111245. /**
  111246. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111247. */
  111248. nativeVertexBuffer?: any;
  111249. }
  111250. /** @hidden */
  111251. export class NativeEngine extends Engine {
  111252. private readonly _native;
  111253. getHardwareScalingLevel(): number;
  111254. constructor();
  111255. /**
  111256. * Can be used to override the current requestAnimationFrame requester.
  111257. * @hidden
  111258. */
  111259. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111260. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111261. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111262. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111263. recordVertexArrayObject(vertexBuffers: {
  111264. [key: string]: VertexBuffer;
  111265. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111266. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111267. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111268. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111269. /**
  111270. * Draw a list of indexed primitives
  111271. * @param fillMode defines the primitive to use
  111272. * @param indexStart defines the starting index
  111273. * @param indexCount defines the number of index to draw
  111274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111275. */
  111276. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111277. /**
  111278. * Draw a list of unindexed primitives
  111279. * @param fillMode defines the primitive to use
  111280. * @param verticesStart defines the index of first vertex to draw
  111281. * @param verticesCount defines the count of vertices to draw
  111282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111283. */
  111284. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111285. createPipelineContext(): IPipelineContext;
  111286. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111287. /** @hidden */
  111288. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111289. /** @hidden */
  111290. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111291. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111292. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111293. protected _setProgram(program: WebGLProgram): void;
  111294. _releaseEffect(effect: Effect): void;
  111295. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111296. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111297. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111298. bindSamplers(effect: Effect): void;
  111299. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111300. getRenderWidth(useScreen?: boolean): number;
  111301. getRenderHeight(useScreen?: boolean): number;
  111302. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111303. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111304. /**
  111305. * Set the z offset to apply to current rendering
  111306. * @param value defines the offset to apply
  111307. */
  111308. setZOffset(value: number): void;
  111309. /**
  111310. * Gets the current value of the zOffset
  111311. * @returns the current zOffset state
  111312. */
  111313. getZOffset(): number;
  111314. /**
  111315. * Enable or disable depth buffering
  111316. * @param enable defines the state to set
  111317. */
  111318. setDepthBuffer(enable: boolean): void;
  111319. /**
  111320. * Gets a boolean indicating if depth writing is enabled
  111321. * @returns the current depth writing state
  111322. */
  111323. getDepthWrite(): boolean;
  111324. /**
  111325. * Enable or disable depth writing
  111326. * @param enable defines the state to set
  111327. */
  111328. setDepthWrite(enable: boolean): void;
  111329. /**
  111330. * Enable or disable color writing
  111331. * @param enable defines the state to set
  111332. */
  111333. setColorWrite(enable: boolean): void;
  111334. /**
  111335. * Gets a boolean indicating if color writing is enabled
  111336. * @returns the current color writing state
  111337. */
  111338. getColorWrite(): boolean;
  111339. /**
  111340. * Sets alpha constants used by some alpha blending modes
  111341. * @param r defines the red component
  111342. * @param g defines the green component
  111343. * @param b defines the blue component
  111344. * @param a defines the alpha component
  111345. */
  111346. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111347. /**
  111348. * Sets the current alpha mode
  111349. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111350. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111351. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111352. */
  111353. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111354. /**
  111355. * Gets the current alpha mode
  111356. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111357. * @returns the current alpha mode
  111358. */
  111359. getAlphaMode(): number;
  111360. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111361. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111362. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111363. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111364. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111365. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111366. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111367. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111368. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111369. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111370. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111371. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111372. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111373. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111374. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111375. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111376. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111377. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111378. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111379. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111380. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111381. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111382. wipeCaches(bruteForce?: boolean): void;
  111383. _createTexture(): WebGLTexture;
  111384. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111385. /**
  111386. * Usually called from BABYLON.Texture.ts.
  111387. * Passed information to create a WebGLTexture
  111388. * @param urlArg defines a value which contains one of the following:
  111389. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111390. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111391. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111392. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111393. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111394. * @param scene needed for loading to the correct scene
  111395. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111396. * @param onLoad optional callback to be called upon successful completion
  111397. * @param onError optional callback to be called upon failure
  111398. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111399. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111400. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111401. * @param forcedExtension defines the extension to use to pick the right loader
  111402. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111403. */
  111404. 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;
  111405. /**
  111406. * Creates a cube texture
  111407. * @param rootUrl defines the url where the files to load is located
  111408. * @param scene defines the current scene
  111409. * @param files defines the list of files to load (1 per face)
  111410. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111411. * @param onLoad defines an optional callback raised when the texture is loaded
  111412. * @param onError defines an optional callback raised if there is an issue to load the texture
  111413. * @param format defines the format of the data
  111414. * @param forcedExtension defines the extension to use to pick the right loader
  111415. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111416. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111417. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111418. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111419. * @returns the cube texture as an InternalTexture
  111420. */
  111421. 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;
  111422. private _getSamplingFilter;
  111423. private static _GetNativeTextureFormat;
  111424. createRenderTargetTexture(size: number | {
  111425. width: number;
  111426. height: number;
  111427. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111428. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111429. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111430. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111431. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111432. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111433. /**
  111434. * Updates a dynamic vertex buffer.
  111435. * @param vertexBuffer the vertex buffer to update
  111436. * @param data the data used to update the vertex buffer
  111437. * @param byteOffset the byte offset of the data (optional)
  111438. * @param byteLength the byte length of the data (optional)
  111439. */
  111440. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111441. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111442. private _updateAnisotropicLevel;
  111443. private _getAddressMode;
  111444. /** @hidden */
  111445. _bindTexture(channel: number, texture: InternalTexture): void;
  111446. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111447. releaseEffects(): void;
  111448. /** @hidden */
  111449. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111450. /** @hidden */
  111451. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111452. /** @hidden */
  111453. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111454. /** @hidden */
  111455. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111456. }
  111457. }
  111458. declare module BABYLON {
  111459. /**
  111460. * Gather the list of clipboard event types as constants.
  111461. */
  111462. export class ClipboardEventTypes {
  111463. /**
  111464. * The clipboard event is fired when a copy command is active (pressed).
  111465. */
  111466. static readonly COPY: number;
  111467. /**
  111468. * The clipboard event is fired when a cut command is active (pressed).
  111469. */
  111470. static readonly CUT: number;
  111471. /**
  111472. * The clipboard event is fired when a paste command is active (pressed).
  111473. */
  111474. static readonly PASTE: number;
  111475. }
  111476. /**
  111477. * This class is used to store clipboard related info for the onClipboardObservable event.
  111478. */
  111479. export class ClipboardInfo {
  111480. /**
  111481. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111482. */
  111483. type: number;
  111484. /**
  111485. * Defines the related dom event
  111486. */
  111487. event: ClipboardEvent;
  111488. /**
  111489. *Creates an instance of ClipboardInfo.
  111490. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111491. * @param event Defines the related dom event
  111492. */
  111493. constructor(
  111494. /**
  111495. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111496. */
  111497. type: number,
  111498. /**
  111499. * Defines the related dom event
  111500. */
  111501. event: ClipboardEvent);
  111502. /**
  111503. * Get the clipboard event's type from the keycode.
  111504. * @param keyCode Defines the keyCode for the current keyboard event.
  111505. * @return {number}
  111506. */
  111507. static GetTypeFromCharacter(keyCode: number): number;
  111508. }
  111509. }
  111510. declare module BABYLON {
  111511. /**
  111512. * Google Daydream controller
  111513. */
  111514. export class DaydreamController extends WebVRController {
  111515. /**
  111516. * Base Url for the controller model.
  111517. */
  111518. static MODEL_BASE_URL: string;
  111519. /**
  111520. * File name for the controller model.
  111521. */
  111522. static MODEL_FILENAME: string;
  111523. /**
  111524. * Gamepad Id prefix used to identify Daydream Controller.
  111525. */
  111526. static readonly GAMEPAD_ID_PREFIX: string;
  111527. /**
  111528. * Creates a new DaydreamController from a gamepad
  111529. * @param vrGamepad the gamepad that the controller should be created from
  111530. */
  111531. constructor(vrGamepad: any);
  111532. /**
  111533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111534. * @param scene scene in which to add meshes
  111535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111536. */
  111537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111538. /**
  111539. * Called once for each button that changed state since the last frame
  111540. * @param buttonIdx Which button index changed
  111541. * @param state New state of the button
  111542. * @param changes Which properties on the state changed since last frame
  111543. */
  111544. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111545. }
  111546. }
  111547. declare module BABYLON {
  111548. /**
  111549. * Gear VR Controller
  111550. */
  111551. export class GearVRController extends WebVRController {
  111552. /**
  111553. * Base Url for the controller model.
  111554. */
  111555. static MODEL_BASE_URL: string;
  111556. /**
  111557. * File name for the controller model.
  111558. */
  111559. static MODEL_FILENAME: string;
  111560. /**
  111561. * Gamepad Id prefix used to identify this controller.
  111562. */
  111563. static readonly GAMEPAD_ID_PREFIX: string;
  111564. private readonly _buttonIndexToObservableNameMap;
  111565. /**
  111566. * Creates a new GearVRController from a gamepad
  111567. * @param vrGamepad the gamepad that the controller should be created from
  111568. */
  111569. constructor(vrGamepad: any);
  111570. /**
  111571. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111572. * @param scene scene in which to add meshes
  111573. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111574. */
  111575. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111576. /**
  111577. * Called once for each button that changed state since the last frame
  111578. * @param buttonIdx Which button index changed
  111579. * @param state New state of the button
  111580. * @param changes Which properties on the state changed since last frame
  111581. */
  111582. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111583. }
  111584. }
  111585. declare module BABYLON {
  111586. /**
  111587. * Class containing static functions to help procedurally build meshes
  111588. */
  111589. export class PolyhedronBuilder {
  111590. /**
  111591. * Creates a polyhedron mesh
  111592. * * 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
  111593. * * The parameter `size` (positive float, default 1) sets the polygon size
  111594. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111595. * * 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`
  111596. * * 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
  111597. * * 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)`)
  111598. * * 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
  111599. * * 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
  111600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111603. * @param name defines the name of the mesh
  111604. * @param options defines the options used to create the mesh
  111605. * @param scene defines the hosting scene
  111606. * @returns the polyhedron mesh
  111607. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111608. */
  111609. static CreatePolyhedron(name: string, options: {
  111610. type?: number;
  111611. size?: number;
  111612. sizeX?: number;
  111613. sizeY?: number;
  111614. sizeZ?: number;
  111615. custom?: any;
  111616. faceUV?: Vector4[];
  111617. faceColors?: Color4[];
  111618. flat?: boolean;
  111619. updatable?: boolean;
  111620. sideOrientation?: number;
  111621. frontUVs?: Vector4;
  111622. backUVs?: Vector4;
  111623. }, scene?: Nullable<Scene>): Mesh;
  111624. }
  111625. }
  111626. declare module BABYLON {
  111627. /**
  111628. * Gizmo that enables scaling a mesh along 3 axis
  111629. */
  111630. export class ScaleGizmo extends Gizmo {
  111631. /**
  111632. * Internal gizmo used for interactions on the x axis
  111633. */
  111634. xGizmo: AxisScaleGizmo;
  111635. /**
  111636. * Internal gizmo used for interactions on the y axis
  111637. */
  111638. yGizmo: AxisScaleGizmo;
  111639. /**
  111640. * Internal gizmo used for interactions on the z axis
  111641. */
  111642. zGizmo: AxisScaleGizmo;
  111643. /**
  111644. * Internal gizmo used to scale all axis equally
  111645. */
  111646. uniformScaleGizmo: AxisScaleGizmo;
  111647. private _meshAttached;
  111648. private _updateGizmoRotationToMatchAttachedMesh;
  111649. private _snapDistance;
  111650. private _scaleRatio;
  111651. private _uniformScalingMesh;
  111652. private _octahedron;
  111653. /** Fires an event when any of it's sub gizmos are dragged */
  111654. onDragStartObservable: Observable<unknown>;
  111655. /** Fires an event when any of it's sub gizmos are released from dragging */
  111656. onDragEndObservable: Observable<unknown>;
  111657. attachedMesh: Nullable<AbstractMesh>;
  111658. /**
  111659. * Creates a ScaleGizmo
  111660. * @param gizmoLayer The utility layer the gizmo will be added to
  111661. */
  111662. constructor(gizmoLayer?: UtilityLayerRenderer);
  111663. updateGizmoRotationToMatchAttachedMesh: boolean;
  111664. /**
  111665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111666. */
  111667. snapDistance: number;
  111668. /**
  111669. * Ratio for the scale of the gizmo (Default: 1)
  111670. */
  111671. scaleRatio: number;
  111672. /**
  111673. * Disposes of the gizmo
  111674. */
  111675. dispose(): void;
  111676. }
  111677. }
  111678. declare module BABYLON {
  111679. /**
  111680. * Single axis scale gizmo
  111681. */
  111682. export class AxisScaleGizmo extends Gizmo {
  111683. /**
  111684. * Drag behavior responsible for the gizmos dragging interactions
  111685. */
  111686. dragBehavior: PointerDragBehavior;
  111687. private _pointerObserver;
  111688. /**
  111689. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111690. */
  111691. snapDistance: number;
  111692. /**
  111693. * Event that fires each time the gizmo snaps to a new location.
  111694. * * snapDistance is the the change in distance
  111695. */
  111696. onSnapObservable: Observable<{
  111697. snapDistance: number;
  111698. }>;
  111699. /**
  111700. * If the scaling operation should be done on all axis (default: false)
  111701. */
  111702. uniformScaling: boolean;
  111703. private _isEnabled;
  111704. private _parent;
  111705. private _arrow;
  111706. private _coloredMaterial;
  111707. private _hoverMaterial;
  111708. /**
  111709. * Creates an AxisScaleGizmo
  111710. * @param gizmoLayer The utility layer the gizmo will be added to
  111711. * @param dragAxis The axis which the gizmo will be able to scale on
  111712. * @param color The color of the gizmo
  111713. */
  111714. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111715. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111716. /**
  111717. * If the gizmo is enabled
  111718. */
  111719. isEnabled: boolean;
  111720. /**
  111721. * Disposes of the gizmo
  111722. */
  111723. dispose(): void;
  111724. /**
  111725. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111726. * @param mesh The mesh to replace the default mesh of the gizmo
  111727. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111728. */
  111729. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111730. }
  111731. }
  111732. declare module BABYLON {
  111733. /**
  111734. * Bounding box gizmo
  111735. */
  111736. export class BoundingBoxGizmo extends Gizmo {
  111737. private _lineBoundingBox;
  111738. private _rotateSpheresParent;
  111739. private _scaleBoxesParent;
  111740. private _boundingDimensions;
  111741. private _renderObserver;
  111742. private _pointerObserver;
  111743. private _scaleDragSpeed;
  111744. private _tmpQuaternion;
  111745. private _tmpVector;
  111746. private _tmpRotationMatrix;
  111747. /**
  111748. * 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)
  111749. */
  111750. ignoreChildren: boolean;
  111751. /**
  111752. * 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)
  111753. */
  111754. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111755. /**
  111756. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111757. */
  111758. rotationSphereSize: number;
  111759. /**
  111760. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111761. */
  111762. scaleBoxSize: number;
  111763. /**
  111764. * 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)
  111765. */
  111766. fixedDragMeshScreenSize: boolean;
  111767. /**
  111768. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111769. */
  111770. fixedDragMeshScreenSizeDistanceFactor: number;
  111771. /**
  111772. * Fired when a rotation sphere or scale box is dragged
  111773. */
  111774. onDragStartObservable: Observable<{}>;
  111775. /**
  111776. * Fired when a scale box is dragged
  111777. */
  111778. onScaleBoxDragObservable: Observable<{}>;
  111779. /**
  111780. * Fired when a scale box drag is ended
  111781. */
  111782. onScaleBoxDragEndObservable: Observable<{}>;
  111783. /**
  111784. * Fired when a rotation sphere is dragged
  111785. */
  111786. onRotationSphereDragObservable: Observable<{}>;
  111787. /**
  111788. * Fired when a rotation sphere drag is ended
  111789. */
  111790. onRotationSphereDragEndObservable: Observable<{}>;
  111791. /**
  111792. * 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)
  111793. */
  111794. scalePivot: Nullable<Vector3>;
  111795. /**
  111796. * Mesh used as a pivot to rotate the attached mesh
  111797. */
  111798. private _anchorMesh;
  111799. private _existingMeshScale;
  111800. private _dragMesh;
  111801. private pointerDragBehavior;
  111802. private coloredMaterial;
  111803. private hoverColoredMaterial;
  111804. /**
  111805. * Sets the color of the bounding box gizmo
  111806. * @param color the color to set
  111807. */
  111808. setColor(color: Color3): void;
  111809. /**
  111810. * Creates an BoundingBoxGizmo
  111811. * @param gizmoLayer The utility layer the gizmo will be added to
  111812. * @param color The color of the gizmo
  111813. */
  111814. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111815. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111816. private _selectNode;
  111817. /**
  111818. * Updates the bounding box information for the Gizmo
  111819. */
  111820. updateBoundingBox(): void;
  111821. private _updateRotationSpheres;
  111822. private _updateScaleBoxes;
  111823. /**
  111824. * Enables rotation on the specified axis and disables rotation on the others
  111825. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111826. */
  111827. setEnabledRotationAxis(axis: string): void;
  111828. /**
  111829. * Enables/disables scaling
  111830. * @param enable if scaling should be enabled
  111831. */
  111832. setEnabledScaling(enable: boolean): void;
  111833. private _updateDummy;
  111834. /**
  111835. * Enables a pointer drag behavior on the bounding box of the gizmo
  111836. */
  111837. enableDragBehavior(): void;
  111838. /**
  111839. * Disposes of the gizmo
  111840. */
  111841. dispose(): void;
  111842. /**
  111843. * 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)
  111844. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111845. * @returns the bounding box mesh with the passed in mesh as a child
  111846. */
  111847. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111848. /**
  111849. * CustomMeshes are not supported by this gizmo
  111850. * @param mesh The mesh to replace the default mesh of the gizmo
  111851. */
  111852. setCustomMesh(mesh: Mesh): void;
  111853. }
  111854. }
  111855. declare module BABYLON {
  111856. /**
  111857. * Single plane rotation gizmo
  111858. */
  111859. export class PlaneRotationGizmo extends Gizmo {
  111860. /**
  111861. * Drag behavior responsible for the gizmos dragging interactions
  111862. */
  111863. dragBehavior: PointerDragBehavior;
  111864. private _pointerObserver;
  111865. /**
  111866. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111867. */
  111868. snapDistance: number;
  111869. /**
  111870. * Event that fires each time the gizmo snaps to a new location.
  111871. * * snapDistance is the the change in distance
  111872. */
  111873. onSnapObservable: Observable<{
  111874. snapDistance: number;
  111875. }>;
  111876. private _isEnabled;
  111877. private _parent;
  111878. /**
  111879. * Creates a PlaneRotationGizmo
  111880. * @param gizmoLayer The utility layer the gizmo will be added to
  111881. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111882. * @param color The color of the gizmo
  111883. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111884. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111885. */
  111886. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111887. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111888. /**
  111889. * If the gizmo is enabled
  111890. */
  111891. isEnabled: boolean;
  111892. /**
  111893. * Disposes of the gizmo
  111894. */
  111895. dispose(): void;
  111896. }
  111897. }
  111898. declare module BABYLON {
  111899. /**
  111900. * Gizmo that enables rotating a mesh along 3 axis
  111901. */
  111902. export class RotationGizmo extends Gizmo {
  111903. /**
  111904. * Internal gizmo used for interactions on the x axis
  111905. */
  111906. xGizmo: PlaneRotationGizmo;
  111907. /**
  111908. * Internal gizmo used for interactions on the y axis
  111909. */
  111910. yGizmo: PlaneRotationGizmo;
  111911. /**
  111912. * Internal gizmo used for interactions on the z axis
  111913. */
  111914. zGizmo: PlaneRotationGizmo;
  111915. /** Fires an event when any of it's sub gizmos are dragged */
  111916. onDragStartObservable: Observable<unknown>;
  111917. /** Fires an event when any of it's sub gizmos are released from dragging */
  111918. onDragEndObservable: Observable<unknown>;
  111919. private _meshAttached;
  111920. attachedMesh: Nullable<AbstractMesh>;
  111921. /**
  111922. * Creates a RotationGizmo
  111923. * @param gizmoLayer The utility layer the gizmo will be added to
  111924. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111925. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111926. */
  111927. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  111928. updateGizmoRotationToMatchAttachedMesh: boolean;
  111929. /**
  111930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111931. */
  111932. snapDistance: number;
  111933. /**
  111934. * Ratio for the scale of the gizmo (Default: 1)
  111935. */
  111936. scaleRatio: number;
  111937. /**
  111938. * Disposes of the gizmo
  111939. */
  111940. dispose(): void;
  111941. /**
  111942. * CustomMeshes are not supported by this gizmo
  111943. * @param mesh The mesh to replace the default mesh of the gizmo
  111944. */
  111945. setCustomMesh(mesh: Mesh): void;
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /**
  111950. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  111951. */
  111952. export class GizmoManager implements IDisposable {
  111953. private scene;
  111954. /**
  111955. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  111956. */
  111957. gizmos: {
  111958. positionGizmo: Nullable<PositionGizmo>;
  111959. rotationGizmo: Nullable<RotationGizmo>;
  111960. scaleGizmo: Nullable<ScaleGizmo>;
  111961. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  111962. };
  111963. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  111964. clearGizmoOnEmptyPointerEvent: boolean;
  111965. /** Fires an event when the manager is attached to a mesh */
  111966. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  111967. private _gizmosEnabled;
  111968. private _pointerObserver;
  111969. private _attachedMesh;
  111970. private _boundingBoxColor;
  111971. private _defaultUtilityLayer;
  111972. private _defaultKeepDepthUtilityLayer;
  111973. /**
  111974. * When bounding box gizmo is enabled, this can be used to track drag/end events
  111975. */
  111976. boundingBoxDragBehavior: SixDofDragBehavior;
  111977. /**
  111978. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  111979. */
  111980. attachableMeshes: Nullable<Array<AbstractMesh>>;
  111981. /**
  111982. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  111983. */
  111984. usePointerToAttachGizmos: boolean;
  111985. /**
  111986. * Utility layer that the bounding box gizmo belongs to
  111987. */
  111988. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  111989. /**
  111990. * Utility layer that all gizmos besides bounding box belong to
  111991. */
  111992. readonly utilityLayer: UtilityLayerRenderer;
  111993. /**
  111994. * Instatiates a gizmo manager
  111995. * @param scene the scene to overlay the gizmos on top of
  111996. */
  111997. constructor(scene: Scene);
  111998. /**
  111999. * Attaches a set of gizmos to the specified mesh
  112000. * @param mesh The mesh the gizmo's should be attached to
  112001. */
  112002. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112003. /**
  112004. * If the position gizmo is enabled
  112005. */
  112006. positionGizmoEnabled: boolean;
  112007. /**
  112008. * If the rotation gizmo is enabled
  112009. */
  112010. rotationGizmoEnabled: boolean;
  112011. /**
  112012. * If the scale gizmo is enabled
  112013. */
  112014. scaleGizmoEnabled: boolean;
  112015. /**
  112016. * If the boundingBox gizmo is enabled
  112017. */
  112018. boundingBoxGizmoEnabled: boolean;
  112019. /**
  112020. * Disposes of the gizmo manager
  112021. */
  112022. dispose(): void;
  112023. }
  112024. }
  112025. declare module BABYLON {
  112026. /**
  112027. * A directional light is defined by a direction (what a surprise!).
  112028. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112029. * 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.
  112030. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112031. */
  112032. export class DirectionalLight extends ShadowLight {
  112033. private _shadowFrustumSize;
  112034. /**
  112035. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112036. */
  112037. /**
  112038. * Specifies a fix frustum size for the shadow generation.
  112039. */
  112040. shadowFrustumSize: number;
  112041. private _shadowOrthoScale;
  112042. /**
  112043. * Gets the shadow projection scale against the optimal computed one.
  112044. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112045. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112046. */
  112047. /**
  112048. * Sets 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. shadowOrthoScale: number;
  112053. /**
  112054. * Automatically compute the projection matrix to best fit (including all the casters)
  112055. * on each frame.
  112056. */
  112057. autoUpdateExtends: boolean;
  112058. private _orthoLeft;
  112059. private _orthoRight;
  112060. private _orthoTop;
  112061. private _orthoBottom;
  112062. /**
  112063. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112064. * The directional light is emitted from everywhere in the given direction.
  112065. * It can cast shadows.
  112066. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112067. * @param name The friendly name of the light
  112068. * @param direction The direction of the light
  112069. * @param scene The scene the light belongs to
  112070. */
  112071. constructor(name: string, direction: Vector3, scene: Scene);
  112072. /**
  112073. * Returns the string "DirectionalLight".
  112074. * @return The class name
  112075. */
  112076. getClassName(): string;
  112077. /**
  112078. * Returns the integer 1.
  112079. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112080. */
  112081. getTypeID(): number;
  112082. /**
  112083. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112084. * Returns the DirectionalLight Shadow projection matrix.
  112085. */
  112086. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112087. /**
  112088. * Sets the passed matrix "matrix" as fixed frustum 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 _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112092. /**
  112093. * Sets the passed matrix "matrix" as auto extend 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 _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112097. protected _buildUniformLayout(): void;
  112098. /**
  112099. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112100. * @param effect The effect to update
  112101. * @param lightIndex The index of the light in the effect to update
  112102. * @returns The directional light
  112103. */
  112104. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112105. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112106. /**
  112107. * Gets the minZ used for shadow according to both the scene and the light.
  112108. *
  112109. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112110. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112111. * @param activeCamera The camera we are returning the min for
  112112. * @returns the depth min z
  112113. */
  112114. getDepthMinZ(activeCamera: Camera): number;
  112115. /**
  112116. * Gets the maxZ used for shadow according to both the scene and the light.
  112117. *
  112118. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112119. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112120. * @param activeCamera The camera we are returning the max for
  112121. * @returns the depth max z
  112122. */
  112123. getDepthMaxZ(activeCamera: Camera): number;
  112124. /**
  112125. * Prepares the list of defines specific to the light type.
  112126. * @param defines the list of defines
  112127. * @param lightIndex defines the index of the light for the effect
  112128. */
  112129. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112130. }
  112131. }
  112132. declare module BABYLON {
  112133. /**
  112134. * Class containing static functions to help procedurally build meshes
  112135. */
  112136. export class HemisphereBuilder {
  112137. /**
  112138. * Creates a hemisphere mesh
  112139. * @param name defines the name of the mesh
  112140. * @param options defines the options used to create the mesh
  112141. * @param scene defines the hosting scene
  112142. * @returns the hemisphere mesh
  112143. */
  112144. static CreateHemisphere(name: string, options: {
  112145. segments?: number;
  112146. diameter?: number;
  112147. sideOrientation?: number;
  112148. }, scene: any): Mesh;
  112149. }
  112150. }
  112151. declare module BABYLON {
  112152. /**
  112153. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112154. * These values define a cone of light starting from the position, emitting toward the direction.
  112155. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112156. * and the exponent defines the speed of the decay of the light with distance (reach).
  112157. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112158. */
  112159. export class SpotLight extends ShadowLight {
  112160. private _angle;
  112161. private _innerAngle;
  112162. private _cosHalfAngle;
  112163. private _lightAngleScale;
  112164. private _lightAngleOffset;
  112165. /**
  112166. * Gets the cone angle of the spot light in Radians.
  112167. */
  112168. /**
  112169. * Sets the cone angle of the spot light in Radians.
  112170. */
  112171. angle: number;
  112172. /**
  112173. * Only used in gltf falloff mode, this defines the angle where
  112174. * the directional falloff will start before cutting at angle which could be seen
  112175. * as outer angle.
  112176. */
  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. innerAngle: number;
  112183. private _shadowAngleScale;
  112184. /**
  112185. * Allows scaling the angle of the light for shadow generation only.
  112186. */
  112187. /**
  112188. * Allows scaling the angle of the light for shadow generation only.
  112189. */
  112190. shadowAngleScale: number;
  112191. /**
  112192. * The light decay speed with the distance from the emission spot.
  112193. */
  112194. exponent: number;
  112195. private _projectionTextureMatrix;
  112196. /**
  112197. * Allows reading the projecton texture
  112198. */
  112199. readonly projectionTextureMatrix: Matrix;
  112200. protected _projectionTextureLightNear: number;
  112201. /**
  112202. * Gets the near clip of the Spotlight for texture projection.
  112203. */
  112204. /**
  112205. * Sets the near clip of the Spotlight for texture projection.
  112206. */
  112207. projectionTextureLightNear: number;
  112208. protected _projectionTextureLightFar: number;
  112209. /**
  112210. * Gets the far clip of the Spotlight for texture projection.
  112211. */
  112212. /**
  112213. * Sets the far clip of the Spotlight for texture projection.
  112214. */
  112215. projectionTextureLightFar: number;
  112216. protected _projectionTextureUpDirection: Vector3;
  112217. /**
  112218. * Gets the Up vector of the Spotlight for texture projection.
  112219. */
  112220. /**
  112221. * Sets the Up vector of the Spotlight for texture projection.
  112222. */
  112223. projectionTextureUpDirection: Vector3;
  112224. private _projectionTexture;
  112225. /**
  112226. * Gets the projection texture of the light.
  112227. */
  112228. /**
  112229. * Sets the projection texture of the light.
  112230. */
  112231. projectionTexture: Nullable<BaseTexture>;
  112232. private _projectionTextureViewLightDirty;
  112233. private _projectionTextureProjectionLightDirty;
  112234. private _projectionTextureDirty;
  112235. private _projectionTextureViewTargetVector;
  112236. private _projectionTextureViewLightMatrix;
  112237. private _projectionTextureProjectionLightMatrix;
  112238. private _projectionTextureScalingMatrix;
  112239. /**
  112240. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112241. * It can cast shadows.
  112242. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112243. * @param name The light friendly name
  112244. * @param position The position of the spot light in the scene
  112245. * @param direction The direction of the light in the scene
  112246. * @param angle The cone angle of the light in Radians
  112247. * @param exponent The light decay speed with the distance from the emission spot
  112248. * @param scene The scene the lights belongs to
  112249. */
  112250. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112251. /**
  112252. * Returns the string "SpotLight".
  112253. * @returns the class name
  112254. */
  112255. getClassName(): string;
  112256. /**
  112257. * Returns the integer 2.
  112258. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112259. */
  112260. getTypeID(): number;
  112261. /**
  112262. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112263. */
  112264. protected _setDirection(value: Vector3): void;
  112265. /**
  112266. * Overrides the position setter to recompute the projection texture view light Matrix.
  112267. */
  112268. protected _setPosition(value: Vector3): void;
  112269. /**
  112270. * 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.
  112271. * Returns the SpotLight.
  112272. */
  112273. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112274. protected _computeProjectionTextureViewLightMatrix(): void;
  112275. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112276. /**
  112277. * Main function for light texture projection matrix computing.
  112278. */
  112279. protected _computeProjectionTextureMatrix(): void;
  112280. protected _buildUniformLayout(): void;
  112281. private _computeAngleValues;
  112282. /**
  112283. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112284. * @param effect The effect to update
  112285. * @param lightIndex The index of the light in the effect to update
  112286. * @returns The spot light
  112287. */
  112288. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112289. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112290. /**
  112291. * Disposes the light and the associated resources.
  112292. */
  112293. dispose(): void;
  112294. /**
  112295. * Prepares the list of defines specific to the light type.
  112296. * @param defines the list of defines
  112297. * @param lightIndex defines the index of the light for the effect
  112298. */
  112299. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112300. }
  112301. }
  112302. declare module BABYLON {
  112303. /**
  112304. * Gizmo that enables viewing a light
  112305. */
  112306. export class LightGizmo extends Gizmo {
  112307. private _lightMesh;
  112308. private _material;
  112309. private cachedPosition;
  112310. private cachedForward;
  112311. /**
  112312. * Creates a LightGizmo
  112313. * @param gizmoLayer The utility layer the gizmo will be added to
  112314. */
  112315. constructor(gizmoLayer?: UtilityLayerRenderer);
  112316. private _light;
  112317. /**
  112318. * The light that the gizmo is attached to
  112319. */
  112320. light: Nullable<Light>;
  112321. /**
  112322. * Gets the material used to render the light gizmo
  112323. */
  112324. readonly material: StandardMaterial;
  112325. /**
  112326. * @hidden
  112327. * Updates the gizmo to match the attached mesh's position/rotation
  112328. */
  112329. protected _update(): void;
  112330. private static _Scale;
  112331. /**
  112332. * Creates the lines for a light mesh
  112333. */
  112334. private static _createLightLines;
  112335. /**
  112336. * Disposes of the light gizmo
  112337. */
  112338. dispose(): void;
  112339. private static _CreateHemisphericLightMesh;
  112340. private static _CreatePointLightMesh;
  112341. private static _CreateSpotLightMesh;
  112342. private static _CreateDirectionalLightMesh;
  112343. }
  112344. }
  112345. declare module BABYLON {
  112346. /** @hidden */
  112347. export var backgroundFragmentDeclaration: {
  112348. name: string;
  112349. shader: string;
  112350. };
  112351. }
  112352. declare module BABYLON {
  112353. /** @hidden */
  112354. export var backgroundUboDeclaration: {
  112355. name: string;
  112356. shader: string;
  112357. };
  112358. }
  112359. declare module BABYLON {
  112360. /** @hidden */
  112361. export var backgroundPixelShader: {
  112362. name: string;
  112363. shader: string;
  112364. };
  112365. }
  112366. declare module BABYLON {
  112367. /** @hidden */
  112368. export var backgroundVertexDeclaration: {
  112369. name: string;
  112370. shader: string;
  112371. };
  112372. }
  112373. declare module BABYLON {
  112374. /** @hidden */
  112375. export var backgroundVertexShader: {
  112376. name: string;
  112377. shader: string;
  112378. };
  112379. }
  112380. declare module BABYLON {
  112381. /**
  112382. * Background material used to create an efficient environement around your scene.
  112383. */
  112384. export class BackgroundMaterial extends PushMaterial {
  112385. /**
  112386. * Standard reflectance value at parallel view angle.
  112387. */
  112388. static StandardReflectance0: number;
  112389. /**
  112390. * Standard reflectance value at grazing angle.
  112391. */
  112392. static StandardReflectance90: number;
  112393. protected _primaryColor: Color3;
  112394. /**
  112395. * Key light Color (multiply against the environement texture)
  112396. */
  112397. primaryColor: Color3;
  112398. protected __perceptualColor: Nullable<Color3>;
  112399. /**
  112400. * Experimental Internal Use Only.
  112401. *
  112402. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112403. * This acts as a helper to set the primary color to a more "human friendly" value.
  112404. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112405. * output color as close as possible from the chosen value.
  112406. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112407. * part of lighting setup.)
  112408. */
  112409. _perceptualColor: Nullable<Color3>;
  112410. protected _primaryColorShadowLevel: float;
  112411. /**
  112412. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112413. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112414. */
  112415. primaryColorShadowLevel: float;
  112416. protected _primaryColorHighlightLevel: float;
  112417. /**
  112418. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112419. * The primary color is used at the level chosen to define what the white area would look.
  112420. */
  112421. primaryColorHighlightLevel: float;
  112422. protected _reflectionTexture: Nullable<BaseTexture>;
  112423. /**
  112424. * Reflection Texture used in the material.
  112425. * Should be author in a specific way for the best result (refer to the documentation).
  112426. */
  112427. reflectionTexture: Nullable<BaseTexture>;
  112428. protected _reflectionBlur: float;
  112429. /**
  112430. * Reflection Texture level of blur.
  112431. *
  112432. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112433. * texture twice.
  112434. */
  112435. reflectionBlur: float;
  112436. protected _diffuseTexture: Nullable<BaseTexture>;
  112437. /**
  112438. * Diffuse Texture used in the material.
  112439. * Should be author in a specific way for the best result (refer to the documentation).
  112440. */
  112441. diffuseTexture: Nullable<BaseTexture>;
  112442. protected _shadowLights: Nullable<IShadowLight[]>;
  112443. /**
  112444. * Specify the list of lights casting shadow on the material.
  112445. * All scene shadow lights will be included if null.
  112446. */
  112447. shadowLights: Nullable<IShadowLight[]>;
  112448. protected _shadowLevel: float;
  112449. /**
  112450. * Helps adjusting the shadow to a softer level if required.
  112451. * 0 means black shadows and 1 means no shadows.
  112452. */
  112453. shadowLevel: float;
  112454. protected _sceneCenter: Vector3;
  112455. /**
  112456. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112457. * It is usually zero but might be interesting to modify according to your setup.
  112458. */
  112459. sceneCenter: Vector3;
  112460. protected _opacityFresnel: boolean;
  112461. /**
  112462. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112463. * This helps ensuring a nice transition when the camera goes under the ground.
  112464. */
  112465. opacityFresnel: boolean;
  112466. protected _reflectionFresnel: boolean;
  112467. /**
  112468. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112469. * This helps adding a mirror texture on the ground.
  112470. */
  112471. reflectionFresnel: boolean;
  112472. protected _reflectionFalloffDistance: number;
  112473. /**
  112474. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112475. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112476. */
  112477. reflectionFalloffDistance: number;
  112478. protected _reflectionAmount: number;
  112479. /**
  112480. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112481. */
  112482. reflectionAmount: number;
  112483. protected _reflectionReflectance0: number;
  112484. /**
  112485. * This specifies the weight of the reflection at grazing angle.
  112486. */
  112487. reflectionReflectance0: number;
  112488. protected _reflectionReflectance90: number;
  112489. /**
  112490. * This specifies the weight of the reflection at a perpendicular point of view.
  112491. */
  112492. reflectionReflectance90: number;
  112493. /**
  112494. * Sets the reflection reflectance fresnel values according to the default standard
  112495. * empirically know to work well :-)
  112496. */
  112497. reflectionStandardFresnelWeight: number;
  112498. protected _useRGBColor: boolean;
  112499. /**
  112500. * Helps to directly use the maps channels instead of their level.
  112501. */
  112502. useRGBColor: boolean;
  112503. protected _enableNoise: boolean;
  112504. /**
  112505. * This helps reducing the banding effect that could occur on the background.
  112506. */
  112507. enableNoise: boolean;
  112508. /**
  112509. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112510. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112511. * Recommended to be keep at 1.0 except for special cases.
  112512. */
  112513. fovMultiplier: number;
  112514. private _fovMultiplier;
  112515. /**
  112516. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112517. */
  112518. useEquirectangularFOV: boolean;
  112519. private _maxSimultaneousLights;
  112520. /**
  112521. * Number of Simultaneous lights allowed on the material.
  112522. */
  112523. maxSimultaneousLights: int;
  112524. /**
  112525. * Default configuration related to image processing available in the Background Material.
  112526. */
  112527. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112528. /**
  112529. * Keep track of the image processing observer to allow dispose and replace.
  112530. */
  112531. private _imageProcessingObserver;
  112532. /**
  112533. * Attaches a new image processing configuration to the PBR Material.
  112534. * @param configuration (if null the scene configuration will be use)
  112535. */
  112536. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112537. /**
  112538. * Gets the image processing configuration used either in this material.
  112539. */
  112540. /**
  112541. * Sets the Default image processing configuration used either in the this material.
  112542. *
  112543. * If sets to null, the scene one is in use.
  112544. */
  112545. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112546. /**
  112547. * Gets wether the color curves effect is enabled.
  112548. */
  112549. /**
  112550. * Sets wether the color curves effect is enabled.
  112551. */
  112552. cameraColorCurvesEnabled: boolean;
  112553. /**
  112554. * Gets wether the color grading effect is enabled.
  112555. */
  112556. /**
  112557. * Gets wether the color grading effect is enabled.
  112558. */
  112559. cameraColorGradingEnabled: boolean;
  112560. /**
  112561. * Gets wether tonemapping is enabled or not.
  112562. */
  112563. /**
  112564. * Sets wether tonemapping is enabled or not
  112565. */
  112566. cameraToneMappingEnabled: boolean;
  112567. /**
  112568. * The camera exposure used on this material.
  112569. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112570. * This corresponds to a photographic exposure.
  112571. */
  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. cameraExposure: float;
  112578. /**
  112579. * Gets The camera contrast used on this material.
  112580. */
  112581. /**
  112582. * Sets The camera contrast used on this material.
  112583. */
  112584. cameraContrast: float;
  112585. /**
  112586. * Gets the Color Grading 2D Lookup Texture.
  112587. */
  112588. /**
  112589. * Sets the Color Grading 2D Lookup Texture.
  112590. */
  112591. cameraColorGradingTexture: Nullable<BaseTexture>;
  112592. /**
  112593. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112594. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112595. * 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;
  112596. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112597. */
  112598. /**
  112599. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112600. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112601. * 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;
  112602. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112603. */
  112604. cameraColorCurves: Nullable<ColorCurves>;
  112605. /**
  112606. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112607. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112608. */
  112609. switchToBGR: boolean;
  112610. private _renderTargets;
  112611. private _reflectionControls;
  112612. private _white;
  112613. private _primaryShadowColor;
  112614. private _primaryHighlightColor;
  112615. /**
  112616. * Instantiates a Background Material in the given scene
  112617. * @param name The friendly name of the material
  112618. * @param scene The scene to add the material to
  112619. */
  112620. constructor(name: string, scene: Scene);
  112621. /**
  112622. * Gets a boolean indicating that current material needs to register RTT
  112623. */
  112624. readonly hasRenderTargetTextures: boolean;
  112625. /**
  112626. * The entire material has been created in order to prevent overdraw.
  112627. * @returns false
  112628. */
  112629. needAlphaTesting(): boolean;
  112630. /**
  112631. * The entire material has been created in order to prevent overdraw.
  112632. * @returns true if blending is enable
  112633. */
  112634. needAlphaBlending(): boolean;
  112635. /**
  112636. * Checks wether the material is ready to be rendered for a given mesh.
  112637. * @param mesh The mesh to render
  112638. * @param subMesh The submesh to check against
  112639. * @param useInstances Specify wether or not the material is used with instances
  112640. * @returns true if all the dependencies are ready (Textures, Effects...)
  112641. */
  112642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112643. /**
  112644. * Compute the primary color according to the chosen perceptual color.
  112645. */
  112646. private _computePrimaryColorFromPerceptualColor;
  112647. /**
  112648. * Compute the highlights and shadow colors according to their chosen levels.
  112649. */
  112650. private _computePrimaryColors;
  112651. /**
  112652. * Build the uniform buffer used in the material.
  112653. */
  112654. buildUniformLayout(): void;
  112655. /**
  112656. * Unbind the material.
  112657. */
  112658. unbind(): void;
  112659. /**
  112660. * Bind only the world matrix to the material.
  112661. * @param world The world matrix to bind.
  112662. */
  112663. bindOnlyWorldMatrix(world: Matrix): void;
  112664. /**
  112665. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112666. * @param world The world matrix to bind.
  112667. * @param subMesh The submesh to bind for.
  112668. */
  112669. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112670. /**
  112671. * Checks to see if a texture is used in the material.
  112672. * @param texture - Base texture to use.
  112673. * @returns - Boolean specifying if a texture is used in the material.
  112674. */
  112675. hasTexture(texture: BaseTexture): boolean;
  112676. /**
  112677. * Dispose the material.
  112678. * @param forceDisposeEffect Force disposal of the associated effect.
  112679. * @param forceDisposeTextures Force disposal of the associated textures.
  112680. */
  112681. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112682. /**
  112683. * Clones the material.
  112684. * @param name The cloned name.
  112685. * @returns The cloned material.
  112686. */
  112687. clone(name: string): BackgroundMaterial;
  112688. /**
  112689. * Serializes the current material to its JSON representation.
  112690. * @returns The JSON representation.
  112691. */
  112692. serialize(): any;
  112693. /**
  112694. * Gets the class name of the material
  112695. * @returns "BackgroundMaterial"
  112696. */
  112697. getClassName(): string;
  112698. /**
  112699. * Parse a JSON input to create back a background material.
  112700. * @param source The JSON data to parse
  112701. * @param scene The scene to create the parsed material in
  112702. * @param rootUrl The root url of the assets the material depends upon
  112703. * @returns the instantiated BackgroundMaterial.
  112704. */
  112705. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112706. }
  112707. }
  112708. declare module BABYLON {
  112709. /**
  112710. * Represents the different options available during the creation of
  112711. * a Environment helper.
  112712. *
  112713. * This can control the default ground, skybox and image processing setup of your scene.
  112714. */
  112715. export interface IEnvironmentHelperOptions {
  112716. /**
  112717. * Specifies wether or not to create a ground.
  112718. * True by default.
  112719. */
  112720. createGround: boolean;
  112721. /**
  112722. * Specifies the ground size.
  112723. * 15 by default.
  112724. */
  112725. groundSize: number;
  112726. /**
  112727. * The texture used on the ground for the main color.
  112728. * Comes from the BabylonJS CDN by default.
  112729. *
  112730. * Remarks: Can be either a texture or a url.
  112731. */
  112732. groundTexture: string | BaseTexture;
  112733. /**
  112734. * The color mixed in the ground texture by default.
  112735. * BabylonJS clearColor by default.
  112736. */
  112737. groundColor: Color3;
  112738. /**
  112739. * Specifies the ground opacity.
  112740. * 1 by default.
  112741. */
  112742. groundOpacity: number;
  112743. /**
  112744. * Enables the ground to receive shadows.
  112745. * True by default.
  112746. */
  112747. enableGroundShadow: boolean;
  112748. /**
  112749. * Helps preventing the shadow to be fully black on the ground.
  112750. * 0.5 by default.
  112751. */
  112752. groundShadowLevel: number;
  112753. /**
  112754. * Creates a mirror texture attach to the ground.
  112755. * false by default.
  112756. */
  112757. enableGroundMirror: boolean;
  112758. /**
  112759. * Specifies the ground mirror size ratio.
  112760. * 0.3 by default as the default kernel is 64.
  112761. */
  112762. groundMirrorSizeRatio: number;
  112763. /**
  112764. * Specifies the ground mirror blur kernel size.
  112765. * 64 by default.
  112766. */
  112767. groundMirrorBlurKernel: number;
  112768. /**
  112769. * Specifies the ground mirror visibility amount.
  112770. * 1 by default
  112771. */
  112772. groundMirrorAmount: number;
  112773. /**
  112774. * Specifies the ground mirror reflectance weight.
  112775. * This uses the standard weight of the background material to setup the fresnel effect
  112776. * of the mirror.
  112777. * 1 by default.
  112778. */
  112779. groundMirrorFresnelWeight: number;
  112780. /**
  112781. * Specifies the ground mirror Falloff distance.
  112782. * This can helps reducing the size of the reflection.
  112783. * 0 by Default.
  112784. */
  112785. groundMirrorFallOffDistance: number;
  112786. /**
  112787. * Specifies the ground mirror texture type.
  112788. * Unsigned Int by Default.
  112789. */
  112790. groundMirrorTextureType: number;
  112791. /**
  112792. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112793. * the shown objects.
  112794. */
  112795. groundYBias: number;
  112796. /**
  112797. * Specifies wether or not to create a skybox.
  112798. * True by default.
  112799. */
  112800. createSkybox: boolean;
  112801. /**
  112802. * Specifies the skybox size.
  112803. * 20 by default.
  112804. */
  112805. skyboxSize: number;
  112806. /**
  112807. * The texture used on the skybox for the main color.
  112808. * Comes from the BabylonJS CDN by default.
  112809. *
  112810. * Remarks: Can be either a texture or a url.
  112811. */
  112812. skyboxTexture: string | BaseTexture;
  112813. /**
  112814. * The color mixed in the skybox texture by default.
  112815. * BabylonJS clearColor by default.
  112816. */
  112817. skyboxColor: Color3;
  112818. /**
  112819. * The background rotation around the Y axis of the scene.
  112820. * This helps aligning the key lights of your scene with the background.
  112821. * 0 by default.
  112822. */
  112823. backgroundYRotation: number;
  112824. /**
  112825. * Compute automatically the size of the elements to best fit with the scene.
  112826. */
  112827. sizeAuto: boolean;
  112828. /**
  112829. * Default position of the rootMesh if autoSize is not true.
  112830. */
  112831. rootPosition: Vector3;
  112832. /**
  112833. * Sets up the image processing in the scene.
  112834. * true by default.
  112835. */
  112836. setupImageProcessing: boolean;
  112837. /**
  112838. * The texture used as your environment texture in the scene.
  112839. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112840. *
  112841. * Remarks: Can be either a texture or a url.
  112842. */
  112843. environmentTexture: string | BaseTexture;
  112844. /**
  112845. * The value of the exposure to apply to the scene.
  112846. * 0.6 by default if setupImageProcessing is true.
  112847. */
  112848. cameraExposure: number;
  112849. /**
  112850. * The value of the contrast to apply to the scene.
  112851. * 1.6 by default if setupImageProcessing is true.
  112852. */
  112853. cameraContrast: number;
  112854. /**
  112855. * Specifies wether or not tonemapping should be enabled in the scene.
  112856. * true by default if setupImageProcessing is true.
  112857. */
  112858. toneMappingEnabled: boolean;
  112859. }
  112860. /**
  112861. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112862. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112863. * It also helps with the default setup of your imageProcessing configuration.
  112864. */
  112865. export class EnvironmentHelper {
  112866. /**
  112867. * Default ground texture URL.
  112868. */
  112869. private static _groundTextureCDNUrl;
  112870. /**
  112871. * Default skybox texture URL.
  112872. */
  112873. private static _skyboxTextureCDNUrl;
  112874. /**
  112875. * Default environment texture URL.
  112876. */
  112877. private static _environmentTextureCDNUrl;
  112878. /**
  112879. * Creates the default options for the helper.
  112880. */
  112881. private static _getDefaultOptions;
  112882. private _rootMesh;
  112883. /**
  112884. * Gets the root mesh created by the helper.
  112885. */
  112886. readonly rootMesh: Mesh;
  112887. private _skybox;
  112888. /**
  112889. * Gets the skybox created by the helper.
  112890. */
  112891. readonly skybox: Nullable<Mesh>;
  112892. private _skyboxTexture;
  112893. /**
  112894. * Gets the skybox texture created by the helper.
  112895. */
  112896. readonly skyboxTexture: Nullable<BaseTexture>;
  112897. private _skyboxMaterial;
  112898. /**
  112899. * Gets the skybox material created by the helper.
  112900. */
  112901. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  112902. private _ground;
  112903. /**
  112904. * Gets the ground mesh created by the helper.
  112905. */
  112906. readonly ground: Nullable<Mesh>;
  112907. private _groundTexture;
  112908. /**
  112909. * Gets the ground texture created by the helper.
  112910. */
  112911. readonly groundTexture: Nullable<BaseTexture>;
  112912. private _groundMirror;
  112913. /**
  112914. * Gets the ground mirror created by the helper.
  112915. */
  112916. readonly groundMirror: Nullable<MirrorTexture>;
  112917. /**
  112918. * Gets the ground mirror render list to helps pushing the meshes
  112919. * you wish in the ground reflection.
  112920. */
  112921. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  112922. private _groundMaterial;
  112923. /**
  112924. * Gets the ground material created by the helper.
  112925. */
  112926. readonly groundMaterial: Nullable<BackgroundMaterial>;
  112927. /**
  112928. * Stores the creation options.
  112929. */
  112930. private readonly _scene;
  112931. private _options;
  112932. /**
  112933. * This observable will be notified with any error during the creation of the environment,
  112934. * mainly texture creation errors.
  112935. */
  112936. onErrorObservable: Observable<{
  112937. message?: string;
  112938. exception?: any;
  112939. }>;
  112940. /**
  112941. * constructor
  112942. * @param options Defines the options we want to customize the helper
  112943. * @param scene The scene to add the material to
  112944. */
  112945. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  112946. /**
  112947. * Updates the background according to the new options
  112948. * @param options
  112949. */
  112950. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  112951. /**
  112952. * Sets the primary color of all the available elements.
  112953. * @param color the main color to affect to the ground and the background
  112954. */
  112955. setMainColor(color: Color3): void;
  112956. /**
  112957. * Setup the image processing according to the specified options.
  112958. */
  112959. private _setupImageProcessing;
  112960. /**
  112961. * Setup the environment texture according to the specified options.
  112962. */
  112963. private _setupEnvironmentTexture;
  112964. /**
  112965. * Setup the background according to the specified options.
  112966. */
  112967. private _setupBackground;
  112968. /**
  112969. * Get the scene sizes according to the setup.
  112970. */
  112971. private _getSceneSize;
  112972. /**
  112973. * Setup the ground according to the specified options.
  112974. */
  112975. private _setupGround;
  112976. /**
  112977. * Setup the ground material according to the specified options.
  112978. */
  112979. private _setupGroundMaterial;
  112980. /**
  112981. * Setup the ground diffuse texture according to the specified options.
  112982. */
  112983. private _setupGroundDiffuseTexture;
  112984. /**
  112985. * Setup the ground mirror texture according to the specified options.
  112986. */
  112987. private _setupGroundMirrorTexture;
  112988. /**
  112989. * Setup the ground to receive the mirror texture.
  112990. */
  112991. private _setupMirrorInGroundMaterial;
  112992. /**
  112993. * Setup the skybox according to the specified options.
  112994. */
  112995. private _setupSkybox;
  112996. /**
  112997. * Setup the skybox material according to the specified options.
  112998. */
  112999. private _setupSkyboxMaterial;
  113000. /**
  113001. * Setup the skybox reflection texture according to the specified options.
  113002. */
  113003. private _setupSkyboxReflectionTexture;
  113004. private _errorHandler;
  113005. /**
  113006. * Dispose all the elements created by the Helper.
  113007. */
  113008. dispose(): void;
  113009. }
  113010. }
  113011. declare module BABYLON {
  113012. /**
  113013. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113014. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113015. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113016. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113017. */
  113018. export class PhotoDome extends TransformNode {
  113019. /**
  113020. * Define the image as a Monoscopic panoramic 360 image.
  113021. */
  113022. static readonly MODE_MONOSCOPIC: number;
  113023. /**
  113024. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113025. */
  113026. static readonly MODE_TOPBOTTOM: number;
  113027. /**
  113028. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113029. */
  113030. static readonly MODE_SIDEBYSIDE: number;
  113031. private _useDirectMapping;
  113032. /**
  113033. * The texture being displayed on the sphere
  113034. */
  113035. protected _photoTexture: Texture;
  113036. /**
  113037. * Gets or sets the texture being displayed on the sphere
  113038. */
  113039. photoTexture: Texture;
  113040. /**
  113041. * Observable raised when an error occured while loading the 360 image
  113042. */
  113043. onLoadErrorObservable: Observable<string>;
  113044. /**
  113045. * The skybox material
  113046. */
  113047. protected _material: BackgroundMaterial;
  113048. /**
  113049. * The surface used for the skybox
  113050. */
  113051. protected _mesh: Mesh;
  113052. /**
  113053. * Gets the mesh used for the skybox.
  113054. */
  113055. readonly mesh: Mesh;
  113056. /**
  113057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113058. * Also see the options.resolution property.
  113059. */
  113060. fovMultiplier: number;
  113061. private _imageMode;
  113062. /**
  113063. * Gets or set the current video mode for the video. It can be:
  113064. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113065. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113066. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113067. */
  113068. imageMode: number;
  113069. /**
  113070. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113071. * @param name Element's name, child elements will append suffixes for their own names.
  113072. * @param urlsOfPhoto defines the url of the photo to display
  113073. * @param options defines an object containing optional or exposed sub element properties
  113074. * @param onError defines a callback called when an error occured while loading the texture
  113075. */
  113076. constructor(name: string, urlOfPhoto: string, options: {
  113077. resolution?: number;
  113078. size?: number;
  113079. useDirectMapping?: boolean;
  113080. faceForward?: boolean;
  113081. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113082. private _onBeforeCameraRenderObserver;
  113083. private _changeImageMode;
  113084. /**
  113085. * Releases resources associated with this node.
  113086. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113087. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113088. */
  113089. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113090. }
  113091. }
  113092. declare module BABYLON {
  113093. /**
  113094. * Class used to host RGBD texture specific utilities
  113095. */
  113096. export class RGBDTextureTools {
  113097. /**
  113098. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113099. * @param texture the texture to expand.
  113100. */
  113101. static ExpandRGBDTexture(texture: Texture): void;
  113102. }
  113103. }
  113104. declare module BABYLON {
  113105. /**
  113106. * Class used to host texture specific utilities
  113107. */
  113108. export class BRDFTextureTools {
  113109. /**
  113110. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113111. * @param scene defines the hosting scene
  113112. * @returns the environment BRDF texture
  113113. */
  113114. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113115. private static _environmentBRDFBase64Texture;
  113116. }
  113117. }
  113118. declare module BABYLON {
  113119. /**
  113120. * @hidden
  113121. */
  113122. export interface IMaterialClearCoatDefines {
  113123. CLEARCOAT: boolean;
  113124. CLEARCOAT_DEFAULTIOR: boolean;
  113125. CLEARCOAT_TEXTURE: boolean;
  113126. CLEARCOAT_TEXTUREDIRECTUV: number;
  113127. CLEARCOAT_BUMP: boolean;
  113128. CLEARCOAT_BUMPDIRECTUV: number;
  113129. CLEARCOAT_TINT: boolean;
  113130. CLEARCOAT_TINT_TEXTURE: boolean;
  113131. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113132. /** @hidden */
  113133. _areTexturesDirty: boolean;
  113134. }
  113135. /**
  113136. * Define the code related to the clear coat parameters of the pbr material.
  113137. */
  113138. export class PBRClearCoatConfiguration {
  113139. /**
  113140. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113141. * The default fits with a polyurethane material.
  113142. */
  113143. private static readonly _DefaultIndexOfRefraction;
  113144. private _isEnabled;
  113145. /**
  113146. * Defines if the clear coat is enabled in the material.
  113147. */
  113148. isEnabled: boolean;
  113149. /**
  113150. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113151. */
  113152. intensity: number;
  113153. /**
  113154. * Defines the clear coat layer roughness.
  113155. */
  113156. roughness: number;
  113157. private _indexOfRefraction;
  113158. /**
  113159. * Defines the index of refraction of the clear coat.
  113160. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113161. * The default fits with a polyurethane material.
  113162. * Changing the default value is more performance intensive.
  113163. */
  113164. indexOfRefraction: number;
  113165. private _texture;
  113166. /**
  113167. * Stores the clear coat values in a texture.
  113168. */
  113169. texture: Nullable<BaseTexture>;
  113170. private _bumpTexture;
  113171. /**
  113172. * Define the clear coat specific bump texture.
  113173. */
  113174. bumpTexture: Nullable<BaseTexture>;
  113175. private _isTintEnabled;
  113176. /**
  113177. * Defines if the clear coat tint is enabled in the material.
  113178. */
  113179. isTintEnabled: boolean;
  113180. /**
  113181. * Defines the clear coat tint of the material.
  113182. * This is only use if tint is enabled
  113183. */
  113184. tintColor: Color3;
  113185. /**
  113186. * Defines the distance at which the tint color should be found in the
  113187. * clear coat media.
  113188. * This is only use if tint is enabled
  113189. */
  113190. tintColorAtDistance: number;
  113191. /**
  113192. * Defines the clear coat layer thickness.
  113193. * This is only use if tint is enabled
  113194. */
  113195. tintThickness: number;
  113196. private _tintTexture;
  113197. /**
  113198. * Stores the clear tint values in a texture.
  113199. * rgb is tint
  113200. * a is a thickness factor
  113201. */
  113202. tintTexture: Nullable<BaseTexture>;
  113203. /** @hidden */
  113204. private _internalMarkAllSubMeshesAsTexturesDirty;
  113205. /** @hidden */
  113206. _markAllSubMeshesAsTexturesDirty(): void;
  113207. /**
  113208. * Instantiate a new istance of clear coat configuration.
  113209. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113210. */
  113211. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113212. /**
  113213. * Gets wehter the submesh is ready to be used or not.
  113214. * @param defines the list of "defines" to update.
  113215. * @param scene defines the scene the material belongs to.
  113216. * @param engine defines the engine the material belongs to.
  113217. * @param disableBumpMap defines wether the material disables bump or not.
  113218. * @returns - boolean indicating that the submesh is ready or not.
  113219. */
  113220. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113221. /**
  113222. * Checks to see if a texture is used in the material.
  113223. * @param defines the list of "defines" to update.
  113224. * @param scene defines the scene to the material belongs to.
  113225. */
  113226. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113227. /**
  113228. * Binds the material data.
  113229. * @param uniformBuffer defines the Uniform buffer to fill in.
  113230. * @param scene defines the scene the material belongs to.
  113231. * @param engine defines the engine the material belongs to.
  113232. * @param disableBumpMap defines wether the material disables bump or not.
  113233. * @param isFrozen defines wether the material is frozen or not.
  113234. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113235. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113236. */
  113237. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113238. /**
  113239. * Checks to see if a texture is used in the material.
  113240. * @param texture - Base texture to use.
  113241. * @returns - Boolean specifying if a texture is used in the material.
  113242. */
  113243. hasTexture(texture: BaseTexture): boolean;
  113244. /**
  113245. * Returns an array of the actively used textures.
  113246. * @param activeTextures Array of BaseTextures
  113247. */
  113248. getActiveTextures(activeTextures: BaseTexture[]): void;
  113249. /**
  113250. * Returns the animatable textures.
  113251. * @param animatables Array of animatable textures.
  113252. */
  113253. getAnimatables(animatables: IAnimatable[]): void;
  113254. /**
  113255. * Disposes the resources of the material.
  113256. * @param forceDisposeTextures - Forces the disposal of all textures.
  113257. */
  113258. dispose(forceDisposeTextures?: boolean): void;
  113259. /**
  113260. * Get the current class name of the texture useful for serialization or dynamic coding.
  113261. * @returns "PBRClearCoatConfiguration"
  113262. */
  113263. getClassName(): string;
  113264. /**
  113265. * Add fallbacks to the effect fallbacks list.
  113266. * @param defines defines the Base texture to use.
  113267. * @param fallbacks defines the current fallback list.
  113268. * @param currentRank defines the current fallback rank.
  113269. * @returns the new fallback rank.
  113270. */
  113271. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113272. /**
  113273. * Add the required uniforms to the current list.
  113274. * @param uniforms defines the current uniform list.
  113275. */
  113276. static AddUniforms(uniforms: string[]): void;
  113277. /**
  113278. * Add the required samplers to the current list.
  113279. * @param samplers defines the current sampler list.
  113280. */
  113281. static AddSamplers(samplers: string[]): void;
  113282. /**
  113283. * Add the required uniforms to the current buffer.
  113284. * @param uniformBuffer defines the current uniform buffer.
  113285. */
  113286. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113287. /**
  113288. * Makes a duplicate of the current configuration into another one.
  113289. * @param clearCoatConfiguration define the config where to copy the info
  113290. */
  113291. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113292. /**
  113293. * Serializes this clear coat configuration.
  113294. * @returns - An object with the serialized config.
  113295. */
  113296. serialize(): any;
  113297. /**
  113298. * Parses a anisotropy Configuration from a serialized object.
  113299. * @param source - Serialized object.
  113300. * @param scene Defines the scene we are parsing for
  113301. * @param rootUrl Defines the rootUrl to load from
  113302. */
  113303. parse(source: any, scene: Scene, rootUrl: string): void;
  113304. }
  113305. }
  113306. declare module BABYLON {
  113307. /**
  113308. * @hidden
  113309. */
  113310. export interface IMaterialAnisotropicDefines {
  113311. ANISOTROPIC: boolean;
  113312. ANISOTROPIC_TEXTURE: boolean;
  113313. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113314. MAINUV1: boolean;
  113315. _areTexturesDirty: boolean;
  113316. _needUVs: boolean;
  113317. }
  113318. /**
  113319. * Define the code related to the anisotropic parameters of the pbr material.
  113320. */
  113321. export class PBRAnisotropicConfiguration {
  113322. private _isEnabled;
  113323. /**
  113324. * Defines if the anisotropy is enabled in the material.
  113325. */
  113326. isEnabled: boolean;
  113327. /**
  113328. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113329. */
  113330. intensity: number;
  113331. /**
  113332. * Defines if the effect is along the tangents, bitangents or in between.
  113333. * By default, the effect is "strectching" the highlights along the tangents.
  113334. */
  113335. direction: Vector2;
  113336. private _texture;
  113337. /**
  113338. * Stores the anisotropy values in a texture.
  113339. * rg is direction (like normal from -1 to 1)
  113340. * b is a intensity
  113341. */
  113342. texture: Nullable<BaseTexture>;
  113343. /** @hidden */
  113344. private _internalMarkAllSubMeshesAsTexturesDirty;
  113345. /** @hidden */
  113346. _markAllSubMeshesAsTexturesDirty(): void;
  113347. /**
  113348. * Instantiate a new istance of anisotropy configuration.
  113349. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113350. */
  113351. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113352. /**
  113353. * Specifies that the submesh is ready to be used.
  113354. * @param defines the list of "defines" to update.
  113355. * @param scene defines the scene the material belongs to.
  113356. * @returns - boolean indicating that the submesh is ready or not.
  113357. */
  113358. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113359. /**
  113360. * Checks to see if a texture is used in the material.
  113361. * @param defines the list of "defines" to update.
  113362. * @param mesh the mesh we are preparing the defines for.
  113363. * @param scene defines the scene the material belongs to.
  113364. */
  113365. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113366. /**
  113367. * Binds the material data.
  113368. * @param uniformBuffer defines the Uniform buffer to fill in.
  113369. * @param scene defines the scene the material belongs to.
  113370. * @param isFrozen defines wether the material is frozen or not.
  113371. */
  113372. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113373. /**
  113374. * Checks to see if a texture is used in the material.
  113375. * @param texture - Base texture to use.
  113376. * @returns - Boolean specifying if a texture is used in the material.
  113377. */
  113378. hasTexture(texture: BaseTexture): boolean;
  113379. /**
  113380. * Returns an array of the actively used textures.
  113381. * @param activeTextures Array of BaseTextures
  113382. */
  113383. getActiveTextures(activeTextures: BaseTexture[]): void;
  113384. /**
  113385. * Returns the animatable textures.
  113386. * @param animatables Array of animatable textures.
  113387. */
  113388. getAnimatables(animatables: IAnimatable[]): void;
  113389. /**
  113390. * Disposes the resources of the material.
  113391. * @param forceDisposeTextures - Forces the disposal of all textures.
  113392. */
  113393. dispose(forceDisposeTextures?: boolean): void;
  113394. /**
  113395. * Get the current class name of the texture useful for serialization or dynamic coding.
  113396. * @returns "PBRAnisotropicConfiguration"
  113397. */
  113398. getClassName(): string;
  113399. /**
  113400. * Add fallbacks to the effect fallbacks list.
  113401. * @param defines defines the Base texture to use.
  113402. * @param fallbacks defines the current fallback list.
  113403. * @param currentRank defines the current fallback rank.
  113404. * @returns the new fallback rank.
  113405. */
  113406. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113407. /**
  113408. * Add the required uniforms to the current list.
  113409. * @param uniforms defines the current uniform list.
  113410. */
  113411. static AddUniforms(uniforms: string[]): void;
  113412. /**
  113413. * Add the required uniforms to the current buffer.
  113414. * @param uniformBuffer defines the current uniform buffer.
  113415. */
  113416. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113417. /**
  113418. * Add the required samplers to the current list.
  113419. * @param samplers defines the current sampler list.
  113420. */
  113421. static AddSamplers(samplers: string[]): void;
  113422. /**
  113423. * Makes a duplicate of the current configuration into another one.
  113424. * @param anisotropicConfiguration define the config where to copy the info
  113425. */
  113426. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113427. /**
  113428. * Serializes this anisotropy configuration.
  113429. * @returns - An object with the serialized config.
  113430. */
  113431. serialize(): any;
  113432. /**
  113433. * Parses a anisotropy Configuration from a serialized object.
  113434. * @param source - Serialized object.
  113435. * @param scene Defines the scene we are parsing for
  113436. * @param rootUrl Defines the rootUrl to load from
  113437. */
  113438. parse(source: any, scene: Scene, rootUrl: string): void;
  113439. }
  113440. }
  113441. declare module BABYLON {
  113442. /**
  113443. * @hidden
  113444. */
  113445. export interface IMaterialBRDFDefines {
  113446. BRDF_V_HEIGHT_CORRELATED: boolean;
  113447. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113448. SPHERICAL_HARMONICS: boolean;
  113449. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113450. /** @hidden */
  113451. _areMiscDirty: boolean;
  113452. }
  113453. /**
  113454. * Define the code related to the BRDF parameters of the pbr material.
  113455. */
  113456. export class PBRBRDFConfiguration {
  113457. /**
  113458. * Default value used for the energy conservation.
  113459. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113460. */
  113461. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113462. /**
  113463. * Default value used for the Smith Visibility Height Correlated mode.
  113464. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113465. */
  113466. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113467. /**
  113468. * Default value used for the IBL diffuse part.
  113469. * This can help switching back to the polynomials mode globally which is a tiny bit
  113470. * less GPU intensive at the drawback of a lower quality.
  113471. */
  113472. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113473. /**
  113474. * Default value used for activating energy conservation for the specular workflow.
  113475. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113476. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113477. */
  113478. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113479. private _useEnergyConservation;
  113480. /**
  113481. * Defines if the material uses energy conservation.
  113482. */
  113483. useEnergyConservation: boolean;
  113484. private _useSmithVisibilityHeightCorrelated;
  113485. /**
  113486. * LEGACY Mode set to false
  113487. * Defines if the material uses height smith correlated visibility term.
  113488. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113489. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113490. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113491. * Not relying on height correlated will also disable energy conservation.
  113492. */
  113493. useSmithVisibilityHeightCorrelated: boolean;
  113494. private _useSphericalHarmonics;
  113495. /**
  113496. * LEGACY Mode set to false
  113497. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113498. * diffuse part of the IBL.
  113499. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113500. * to the ground truth.
  113501. */
  113502. useSphericalHarmonics: boolean;
  113503. private _useSpecularGlossinessInputEnergyConservation;
  113504. /**
  113505. * Defines if the material uses energy conservation, when the specular workflow is active.
  113506. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113507. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113508. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113509. */
  113510. useSpecularGlossinessInputEnergyConservation: boolean;
  113511. /** @hidden */
  113512. private _internalMarkAllSubMeshesAsMiscDirty;
  113513. /** @hidden */
  113514. _markAllSubMeshesAsMiscDirty(): void;
  113515. /**
  113516. * Instantiate a new istance of clear coat configuration.
  113517. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113518. */
  113519. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113520. /**
  113521. * Checks to see if a texture is used in the material.
  113522. * @param defines the list of "defines" to update.
  113523. */
  113524. prepareDefines(defines: IMaterialBRDFDefines): void;
  113525. /**
  113526. * Get the current class name of the texture useful for serialization or dynamic coding.
  113527. * @returns "PBRClearCoatConfiguration"
  113528. */
  113529. getClassName(): string;
  113530. /**
  113531. * Makes a duplicate of the current configuration into another one.
  113532. * @param brdfConfiguration define the config where to copy the info
  113533. */
  113534. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113535. /**
  113536. * Serializes this BRDF configuration.
  113537. * @returns - An object with the serialized config.
  113538. */
  113539. serialize(): any;
  113540. /**
  113541. * Parses a anisotropy Configuration from a serialized object.
  113542. * @param source - Serialized object.
  113543. * @param scene Defines the scene we are parsing for
  113544. * @param rootUrl Defines the rootUrl to load from
  113545. */
  113546. parse(source: any, scene: Scene, rootUrl: string): void;
  113547. }
  113548. }
  113549. declare module BABYLON {
  113550. /**
  113551. * @hidden
  113552. */
  113553. export interface IMaterialSheenDefines {
  113554. SHEEN: boolean;
  113555. SHEEN_TEXTURE: boolean;
  113556. SHEEN_TEXTUREDIRECTUV: number;
  113557. SHEEN_LINKWITHALBEDO: boolean;
  113558. /** @hidden */
  113559. _areTexturesDirty: boolean;
  113560. }
  113561. /**
  113562. * Define the code related to the Sheen parameters of the pbr material.
  113563. */
  113564. export class PBRSheenConfiguration {
  113565. private _isEnabled;
  113566. /**
  113567. * Defines if the material uses sheen.
  113568. */
  113569. isEnabled: boolean;
  113570. private _linkSheenWithAlbedo;
  113571. /**
  113572. * Defines if the sheen is linked to the sheen color.
  113573. */
  113574. linkSheenWithAlbedo: boolean;
  113575. /**
  113576. * Defines the sheen intensity.
  113577. */
  113578. intensity: number;
  113579. /**
  113580. * Defines the sheen color.
  113581. */
  113582. color: Color3;
  113583. private _texture;
  113584. /**
  113585. * Stores the sheen tint values in a texture.
  113586. * rgb is tint
  113587. * a is a intensity
  113588. */
  113589. texture: Nullable<BaseTexture>;
  113590. /** @hidden */
  113591. private _internalMarkAllSubMeshesAsTexturesDirty;
  113592. /** @hidden */
  113593. _markAllSubMeshesAsTexturesDirty(): void;
  113594. /**
  113595. * Instantiate a new istance of clear coat configuration.
  113596. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113597. */
  113598. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113599. /**
  113600. * Specifies that the submesh is ready to be used.
  113601. * @param defines the list of "defines" to update.
  113602. * @param scene defines the scene the material belongs to.
  113603. * @returns - boolean indicating that the submesh is ready or not.
  113604. */
  113605. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113606. /**
  113607. * Checks to see if a texture is used in the material.
  113608. * @param defines the list of "defines" to update.
  113609. * @param scene defines the scene the material belongs to.
  113610. */
  113611. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113612. /**
  113613. * Binds the material data.
  113614. * @param uniformBuffer defines the Uniform buffer to fill in.
  113615. * @param scene defines the scene the material belongs to.
  113616. * @param isFrozen defines wether the material is frozen or not.
  113617. */
  113618. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113619. /**
  113620. * Checks to see if a texture is used in the material.
  113621. * @param texture - Base texture to use.
  113622. * @returns - Boolean specifying if a texture is used in the material.
  113623. */
  113624. hasTexture(texture: BaseTexture): boolean;
  113625. /**
  113626. * Returns an array of the actively used textures.
  113627. * @param activeTextures Array of BaseTextures
  113628. */
  113629. getActiveTextures(activeTextures: BaseTexture[]): void;
  113630. /**
  113631. * Returns the animatable textures.
  113632. * @param animatables Array of animatable textures.
  113633. */
  113634. getAnimatables(animatables: IAnimatable[]): void;
  113635. /**
  113636. * Disposes the resources of the material.
  113637. * @param forceDisposeTextures - Forces the disposal of all textures.
  113638. */
  113639. dispose(forceDisposeTextures?: boolean): void;
  113640. /**
  113641. * Get the current class name of the texture useful for serialization or dynamic coding.
  113642. * @returns "PBRSheenConfiguration"
  113643. */
  113644. getClassName(): string;
  113645. /**
  113646. * Add fallbacks to the effect fallbacks list.
  113647. * @param defines defines the Base texture to use.
  113648. * @param fallbacks defines the current fallback list.
  113649. * @param currentRank defines the current fallback rank.
  113650. * @returns the new fallback rank.
  113651. */
  113652. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113653. /**
  113654. * Add the required uniforms to the current list.
  113655. * @param uniforms defines the current uniform list.
  113656. */
  113657. static AddUniforms(uniforms: string[]): void;
  113658. /**
  113659. * Add the required uniforms to the current buffer.
  113660. * @param uniformBuffer defines the current uniform buffer.
  113661. */
  113662. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113663. /**
  113664. * Add the required samplers to the current list.
  113665. * @param samplers defines the current sampler list.
  113666. */
  113667. static AddSamplers(samplers: string[]): void;
  113668. /**
  113669. * Makes a duplicate of the current configuration into another one.
  113670. * @param sheenConfiguration define the config where to copy the info
  113671. */
  113672. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113673. /**
  113674. * Serializes this BRDF configuration.
  113675. * @returns - An object with the serialized config.
  113676. */
  113677. serialize(): any;
  113678. /**
  113679. * Parses a anisotropy Configuration from a serialized object.
  113680. * @param source - Serialized object.
  113681. * @param scene Defines the scene we are parsing for
  113682. * @param rootUrl Defines the rootUrl to load from
  113683. */
  113684. parse(source: any, scene: Scene, rootUrl: string): void;
  113685. }
  113686. }
  113687. declare module BABYLON {
  113688. /**
  113689. * @hidden
  113690. */
  113691. export interface IMaterialSubSurfaceDefines {
  113692. SUBSURFACE: boolean;
  113693. SS_REFRACTION: boolean;
  113694. SS_TRANSLUCENCY: boolean;
  113695. SS_SCATERRING: boolean;
  113696. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113697. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113698. SS_REFRACTIONMAP_3D: boolean;
  113699. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113700. SS_LODINREFRACTIONALPHA: boolean;
  113701. SS_GAMMAREFRACTION: boolean;
  113702. SS_RGBDREFRACTION: boolean;
  113703. SS_LINEARSPECULARREFRACTION: boolean;
  113704. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113705. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113706. /** @hidden */
  113707. _areTexturesDirty: boolean;
  113708. }
  113709. /**
  113710. * Define the code related to the sub surface parameters of the pbr material.
  113711. */
  113712. export class PBRSubSurfaceConfiguration {
  113713. private _isRefractionEnabled;
  113714. /**
  113715. * Defines if the refraction is enabled in the material.
  113716. */
  113717. isRefractionEnabled: boolean;
  113718. private _isTranslucencyEnabled;
  113719. /**
  113720. * Defines if the translucency is enabled in the material.
  113721. */
  113722. isTranslucencyEnabled: boolean;
  113723. private _isScatteringEnabled;
  113724. /**
  113725. * Defines the refraction intensity of the material.
  113726. * The refraction when enabled replaces the Diffuse part of the material.
  113727. * The intensity helps transitionning between diffuse and refraction.
  113728. */
  113729. refractionIntensity: number;
  113730. /**
  113731. * Defines the translucency intensity of the material.
  113732. * When translucency has been enabled, this defines how much of the "translucency"
  113733. * is addded to the diffuse part of the material.
  113734. */
  113735. translucencyIntensity: number;
  113736. /**
  113737. * Defines the scattering intensity of the material.
  113738. * When scattering has been enabled, this defines how much of the "scattered light"
  113739. * is addded to the diffuse part of the material.
  113740. */
  113741. scatteringIntensity: number;
  113742. private _thicknessTexture;
  113743. /**
  113744. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113745. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113746. * 0 would mean minimumThickness
  113747. * 1 would mean maximumThickness
  113748. * The other channels might be use as a mask to vary the different effects intensity.
  113749. */
  113750. thicknessTexture: Nullable<BaseTexture>;
  113751. private _refractionTexture;
  113752. /**
  113753. * Defines the texture to use for refraction.
  113754. */
  113755. refractionTexture: Nullable<BaseTexture>;
  113756. private _indexOfRefraction;
  113757. /**
  113758. * Defines the index of refraction used in the material.
  113759. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113760. */
  113761. indexOfRefraction: number;
  113762. private _invertRefractionY;
  113763. /**
  113764. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113765. */
  113766. invertRefractionY: boolean;
  113767. private _linkRefractionWithTransparency;
  113768. /**
  113769. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113770. * Materials half opaque for instance using refraction could benefit from this control.
  113771. */
  113772. linkRefractionWithTransparency: boolean;
  113773. /**
  113774. * Defines the minimum thickness stored in the thickness map.
  113775. * If no thickness map is defined, this value will be used to simulate thickness.
  113776. */
  113777. minimumThickness: number;
  113778. /**
  113779. * Defines the maximum thickness stored in the thickness map.
  113780. */
  113781. maximumThickness: number;
  113782. /**
  113783. * Defines the volume tint of the material.
  113784. * This is used for both translucency and scattering.
  113785. */
  113786. tintColor: Color3;
  113787. /**
  113788. * Defines the distance at which the tint color should be found in the media.
  113789. * This is used for refraction only.
  113790. */
  113791. tintColorAtDistance: number;
  113792. /**
  113793. * Defines how far each channel transmit through the media.
  113794. * It is defined as a color to simplify it selection.
  113795. */
  113796. diffusionDistance: Color3;
  113797. private _useMaskFromThicknessTexture;
  113798. /**
  113799. * Stores the intensity of the different subsurface effects in the thickness texture.
  113800. * * the green channel is the translucency intensity.
  113801. * * the blue channel is the scattering intensity.
  113802. * * the alpha channel is the refraction intensity.
  113803. */
  113804. useMaskFromThicknessTexture: boolean;
  113805. /** @hidden */
  113806. private _internalMarkAllSubMeshesAsTexturesDirty;
  113807. /** @hidden */
  113808. _markAllSubMeshesAsTexturesDirty(): void;
  113809. /**
  113810. * Instantiate a new istance of sub surface configuration.
  113811. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113812. */
  113813. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113814. /**
  113815. * Gets wehter the submesh is ready to be used or not.
  113816. * @param defines the list of "defines" to update.
  113817. * @param scene defines the scene the material belongs to.
  113818. * @returns - boolean indicating that the submesh is ready or not.
  113819. */
  113820. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113821. /**
  113822. * Checks to see if a texture is used in the material.
  113823. * @param defines the list of "defines" to update.
  113824. * @param scene defines the scene to the material belongs to.
  113825. */
  113826. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113827. /**
  113828. * Binds the material data.
  113829. * @param uniformBuffer defines the Uniform buffer to fill in.
  113830. * @param scene defines the scene the material belongs to.
  113831. * @param engine defines the engine the material belongs to.
  113832. * @param isFrozen defines wether the material is frozen or not.
  113833. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113834. */
  113835. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113836. /**
  113837. * Unbinds the material from the mesh.
  113838. * @param activeEffect defines the effect that should be unbound from.
  113839. * @returns true if unbound, otherwise false
  113840. */
  113841. unbind(activeEffect: Effect): boolean;
  113842. /**
  113843. * Returns the texture used for refraction or null if none is used.
  113844. * @param scene defines the scene the material belongs to.
  113845. * @returns - Refraction texture if present. If no refraction texture and refraction
  113846. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113847. */
  113848. private _getRefractionTexture;
  113849. /**
  113850. * Returns true if alpha blending should be disabled.
  113851. */
  113852. readonly disableAlphaBlending: boolean;
  113853. /**
  113854. * Fills the list of render target textures.
  113855. * @param renderTargets the list of render targets to update
  113856. */
  113857. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113858. /**
  113859. * Checks to see if a texture is used in the material.
  113860. * @param texture - Base texture to use.
  113861. * @returns - Boolean specifying if a texture is used in the material.
  113862. */
  113863. hasTexture(texture: BaseTexture): boolean;
  113864. /**
  113865. * Gets a boolean indicating that current material needs to register RTT
  113866. * @returns true if this uses a render target otherwise false.
  113867. */
  113868. hasRenderTargetTextures(): boolean;
  113869. /**
  113870. * Returns an array of the actively used textures.
  113871. * @param activeTextures Array of BaseTextures
  113872. */
  113873. getActiveTextures(activeTextures: BaseTexture[]): void;
  113874. /**
  113875. * Returns the animatable textures.
  113876. * @param animatables Array of animatable textures.
  113877. */
  113878. getAnimatables(animatables: IAnimatable[]): void;
  113879. /**
  113880. * Disposes the resources of the material.
  113881. * @param forceDisposeTextures - Forces the disposal of all textures.
  113882. */
  113883. dispose(forceDisposeTextures?: boolean): void;
  113884. /**
  113885. * Get the current class name of the texture useful for serialization or dynamic coding.
  113886. * @returns "PBRSubSurfaceConfiguration"
  113887. */
  113888. getClassName(): string;
  113889. /**
  113890. * Add fallbacks to the effect fallbacks list.
  113891. * @param defines defines the Base texture to use.
  113892. * @param fallbacks defines the current fallback list.
  113893. * @param currentRank defines the current fallback rank.
  113894. * @returns the new fallback rank.
  113895. */
  113896. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113897. /**
  113898. * Add the required uniforms to the current list.
  113899. * @param uniforms defines the current uniform list.
  113900. */
  113901. static AddUniforms(uniforms: string[]): void;
  113902. /**
  113903. * Add the required samplers to the current list.
  113904. * @param samplers defines the current sampler list.
  113905. */
  113906. static AddSamplers(samplers: string[]): void;
  113907. /**
  113908. * Add the required uniforms to the current buffer.
  113909. * @param uniformBuffer defines the current uniform buffer.
  113910. */
  113911. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113912. /**
  113913. * Makes a duplicate of the current configuration into another one.
  113914. * @param configuration define the config where to copy the info
  113915. */
  113916. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  113917. /**
  113918. * Serializes this Sub Surface configuration.
  113919. * @returns - An object with the serialized config.
  113920. */
  113921. serialize(): any;
  113922. /**
  113923. * Parses a anisotropy Configuration from a serialized object.
  113924. * @param source - Serialized object.
  113925. * @param scene Defines the scene we are parsing for
  113926. * @param rootUrl Defines the rootUrl to load from
  113927. */
  113928. parse(source: any, scene: Scene, rootUrl: string): void;
  113929. }
  113930. }
  113931. declare module BABYLON {
  113932. /** @hidden */
  113933. export var pbrFragmentDeclaration: {
  113934. name: string;
  113935. shader: string;
  113936. };
  113937. }
  113938. declare module BABYLON {
  113939. /** @hidden */
  113940. export var pbrUboDeclaration: {
  113941. name: string;
  113942. shader: string;
  113943. };
  113944. }
  113945. declare module BABYLON {
  113946. /** @hidden */
  113947. export var pbrFragmentExtraDeclaration: {
  113948. name: string;
  113949. shader: string;
  113950. };
  113951. }
  113952. declare module BABYLON {
  113953. /** @hidden */
  113954. export var pbrFragmentSamplersDeclaration: {
  113955. name: string;
  113956. shader: string;
  113957. };
  113958. }
  113959. declare module BABYLON {
  113960. /** @hidden */
  113961. export var pbrHelperFunctions: {
  113962. name: string;
  113963. shader: string;
  113964. };
  113965. }
  113966. declare module BABYLON {
  113967. /** @hidden */
  113968. export var harmonicsFunctions: {
  113969. name: string;
  113970. shader: string;
  113971. };
  113972. }
  113973. declare module BABYLON {
  113974. /** @hidden */
  113975. export var pbrDirectLightingSetupFunctions: {
  113976. name: string;
  113977. shader: string;
  113978. };
  113979. }
  113980. declare module BABYLON {
  113981. /** @hidden */
  113982. export var pbrDirectLightingFalloffFunctions: {
  113983. name: string;
  113984. shader: string;
  113985. };
  113986. }
  113987. declare module BABYLON {
  113988. /** @hidden */
  113989. export var pbrBRDFFunctions: {
  113990. name: string;
  113991. shader: string;
  113992. };
  113993. }
  113994. declare module BABYLON {
  113995. /** @hidden */
  113996. export var pbrDirectLightingFunctions: {
  113997. name: string;
  113998. shader: string;
  113999. };
  114000. }
  114001. declare module BABYLON {
  114002. /** @hidden */
  114003. export var pbrIBLFunctions: {
  114004. name: string;
  114005. shader: string;
  114006. };
  114007. }
  114008. declare module BABYLON {
  114009. /** @hidden */
  114010. export var pbrDebug: {
  114011. name: string;
  114012. shader: string;
  114013. };
  114014. }
  114015. declare module BABYLON {
  114016. /** @hidden */
  114017. export var pbrPixelShader: {
  114018. name: string;
  114019. shader: string;
  114020. };
  114021. }
  114022. declare module BABYLON {
  114023. /** @hidden */
  114024. export var pbrVertexDeclaration: {
  114025. name: string;
  114026. shader: string;
  114027. };
  114028. }
  114029. declare module BABYLON {
  114030. /** @hidden */
  114031. export var pbrVertexShader: {
  114032. name: string;
  114033. shader: string;
  114034. };
  114035. }
  114036. declare module BABYLON {
  114037. /**
  114038. * Manages the defines for the PBR Material.
  114039. * @hidden
  114040. */
  114041. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114042. PBR: boolean;
  114043. MAINUV1: boolean;
  114044. MAINUV2: boolean;
  114045. UV1: boolean;
  114046. UV2: boolean;
  114047. ALBEDO: boolean;
  114048. ALBEDODIRECTUV: number;
  114049. VERTEXCOLOR: boolean;
  114050. AMBIENT: boolean;
  114051. AMBIENTDIRECTUV: number;
  114052. AMBIENTINGRAYSCALE: boolean;
  114053. OPACITY: boolean;
  114054. VERTEXALPHA: boolean;
  114055. OPACITYDIRECTUV: number;
  114056. OPACITYRGB: boolean;
  114057. ALPHATEST: boolean;
  114058. DEPTHPREPASS: boolean;
  114059. ALPHABLEND: boolean;
  114060. ALPHAFROMALBEDO: boolean;
  114061. ALPHATESTVALUE: string;
  114062. SPECULAROVERALPHA: boolean;
  114063. RADIANCEOVERALPHA: boolean;
  114064. ALPHAFRESNEL: boolean;
  114065. LINEARALPHAFRESNEL: boolean;
  114066. PREMULTIPLYALPHA: boolean;
  114067. EMISSIVE: boolean;
  114068. EMISSIVEDIRECTUV: number;
  114069. REFLECTIVITY: boolean;
  114070. REFLECTIVITYDIRECTUV: number;
  114071. SPECULARTERM: boolean;
  114072. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114073. MICROSURFACEAUTOMATIC: boolean;
  114074. LODBASEDMICROSFURACE: boolean;
  114075. MICROSURFACEMAP: boolean;
  114076. MICROSURFACEMAPDIRECTUV: number;
  114077. METALLICWORKFLOW: boolean;
  114078. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114079. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114080. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114081. AOSTOREINMETALMAPRED: boolean;
  114082. ENVIRONMENTBRDF: boolean;
  114083. ENVIRONMENTBRDF_RGBD: boolean;
  114084. NORMAL: boolean;
  114085. TANGENT: boolean;
  114086. BUMP: boolean;
  114087. BUMPDIRECTUV: number;
  114088. OBJECTSPACE_NORMALMAP: boolean;
  114089. PARALLAX: boolean;
  114090. PARALLAXOCCLUSION: boolean;
  114091. NORMALXYSCALE: boolean;
  114092. LIGHTMAP: boolean;
  114093. LIGHTMAPDIRECTUV: number;
  114094. USELIGHTMAPASSHADOWMAP: boolean;
  114095. GAMMALIGHTMAP: boolean;
  114096. RGBDLIGHTMAP: boolean;
  114097. REFLECTION: boolean;
  114098. REFLECTIONMAP_3D: boolean;
  114099. REFLECTIONMAP_SPHERICAL: boolean;
  114100. REFLECTIONMAP_PLANAR: boolean;
  114101. REFLECTIONMAP_CUBIC: boolean;
  114102. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114103. REFLECTIONMAP_PROJECTION: boolean;
  114104. REFLECTIONMAP_SKYBOX: boolean;
  114105. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114106. REFLECTIONMAP_EXPLICIT: boolean;
  114107. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114108. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114109. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114110. INVERTCUBICMAP: boolean;
  114111. USESPHERICALFROMREFLECTIONMAP: boolean;
  114112. USEIRRADIANCEMAP: boolean;
  114113. SPHERICAL_HARMONICS: boolean;
  114114. USESPHERICALINVERTEX: boolean;
  114115. REFLECTIONMAP_OPPOSITEZ: boolean;
  114116. LODINREFLECTIONALPHA: boolean;
  114117. GAMMAREFLECTION: boolean;
  114118. RGBDREFLECTION: boolean;
  114119. LINEARSPECULARREFLECTION: boolean;
  114120. RADIANCEOCCLUSION: boolean;
  114121. HORIZONOCCLUSION: boolean;
  114122. INSTANCES: boolean;
  114123. NUM_BONE_INFLUENCERS: number;
  114124. BonesPerMesh: number;
  114125. BONETEXTURE: boolean;
  114126. NONUNIFORMSCALING: boolean;
  114127. MORPHTARGETS: boolean;
  114128. MORPHTARGETS_NORMAL: boolean;
  114129. MORPHTARGETS_TANGENT: boolean;
  114130. MORPHTARGETS_UV: boolean;
  114131. NUM_MORPH_INFLUENCERS: number;
  114132. IMAGEPROCESSING: boolean;
  114133. VIGNETTE: boolean;
  114134. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114135. VIGNETTEBLENDMODEOPAQUE: boolean;
  114136. TONEMAPPING: boolean;
  114137. TONEMAPPING_ACES: boolean;
  114138. CONTRAST: boolean;
  114139. COLORCURVES: boolean;
  114140. COLORGRADING: boolean;
  114141. COLORGRADING3D: boolean;
  114142. SAMPLER3DGREENDEPTH: boolean;
  114143. SAMPLER3DBGRMAP: boolean;
  114144. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114145. EXPOSURE: boolean;
  114146. MULTIVIEW: boolean;
  114147. USEPHYSICALLIGHTFALLOFF: boolean;
  114148. USEGLTFLIGHTFALLOFF: boolean;
  114149. TWOSIDEDLIGHTING: boolean;
  114150. SHADOWFLOAT: boolean;
  114151. CLIPPLANE: boolean;
  114152. CLIPPLANE2: boolean;
  114153. CLIPPLANE3: boolean;
  114154. CLIPPLANE4: boolean;
  114155. POINTSIZE: boolean;
  114156. FOG: boolean;
  114157. LOGARITHMICDEPTH: boolean;
  114158. FORCENORMALFORWARD: boolean;
  114159. SPECULARAA: boolean;
  114160. CLEARCOAT: boolean;
  114161. CLEARCOAT_DEFAULTIOR: boolean;
  114162. CLEARCOAT_TEXTURE: boolean;
  114163. CLEARCOAT_TEXTUREDIRECTUV: number;
  114164. CLEARCOAT_BUMP: boolean;
  114165. CLEARCOAT_BUMPDIRECTUV: number;
  114166. CLEARCOAT_TINT: boolean;
  114167. CLEARCOAT_TINT_TEXTURE: boolean;
  114168. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114169. ANISOTROPIC: boolean;
  114170. ANISOTROPIC_TEXTURE: boolean;
  114171. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114172. BRDF_V_HEIGHT_CORRELATED: boolean;
  114173. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114174. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114175. SHEEN: boolean;
  114176. SHEEN_TEXTURE: boolean;
  114177. SHEEN_TEXTUREDIRECTUV: number;
  114178. SHEEN_LINKWITHALBEDO: boolean;
  114179. SUBSURFACE: boolean;
  114180. SS_REFRACTION: boolean;
  114181. SS_TRANSLUCENCY: boolean;
  114182. SS_SCATERRING: boolean;
  114183. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114184. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114185. SS_REFRACTIONMAP_3D: boolean;
  114186. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114187. SS_LODINREFRACTIONALPHA: boolean;
  114188. SS_GAMMAREFRACTION: boolean;
  114189. SS_RGBDREFRACTION: boolean;
  114190. SS_LINEARSPECULARREFRACTION: boolean;
  114191. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114192. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114193. UNLIT: boolean;
  114194. DEBUGMODE: number;
  114195. /**
  114196. * Initializes the PBR Material defines.
  114197. */
  114198. constructor();
  114199. /**
  114200. * Resets the PBR Material defines.
  114201. */
  114202. reset(): void;
  114203. }
  114204. /**
  114205. * The Physically based material base class of BJS.
  114206. *
  114207. * This offers the main features of a standard PBR material.
  114208. * For more information, please refer to the documentation :
  114209. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114210. */
  114211. export abstract class PBRBaseMaterial extends PushMaterial {
  114212. /**
  114213. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114214. */
  114215. static readonly PBRMATERIAL_OPAQUE: number;
  114216. /**
  114217. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114218. */
  114219. static readonly PBRMATERIAL_ALPHATEST: number;
  114220. /**
  114221. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114222. */
  114223. static readonly PBRMATERIAL_ALPHABLEND: number;
  114224. /**
  114225. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114226. * They are also discarded below the alpha cutoff threshold to improve performances.
  114227. */
  114228. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114229. /**
  114230. * Defines the default value of how much AO map is occluding the analytical lights
  114231. * (point spot...).
  114232. */
  114233. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114234. /**
  114235. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114236. */
  114237. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114238. /**
  114239. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114240. * to enhance interoperability with other engines.
  114241. */
  114242. static readonly LIGHTFALLOFF_GLTF: number;
  114243. /**
  114244. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114245. * to enhance interoperability with other materials.
  114246. */
  114247. static readonly LIGHTFALLOFF_STANDARD: number;
  114248. /**
  114249. * Intensity of the direct lights e.g. the four lights available in your scene.
  114250. * This impacts both the direct diffuse and specular highlights.
  114251. */
  114252. protected _directIntensity: number;
  114253. /**
  114254. * Intensity of the emissive part of the material.
  114255. * This helps controlling the emissive effect without modifying the emissive color.
  114256. */
  114257. protected _emissiveIntensity: number;
  114258. /**
  114259. * Intensity of the environment e.g. how much the environment will light the object
  114260. * either through harmonics for rough material or through the refelction for shiny ones.
  114261. */
  114262. protected _environmentIntensity: number;
  114263. /**
  114264. * This is a special control allowing the reduction of the specular highlights coming from the
  114265. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114266. */
  114267. protected _specularIntensity: number;
  114268. /**
  114269. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114270. */
  114271. private _lightingInfos;
  114272. /**
  114273. * Debug Control allowing disabling the bump map on this material.
  114274. */
  114275. protected _disableBumpMap: boolean;
  114276. /**
  114277. * AKA Diffuse Texture in standard nomenclature.
  114278. */
  114279. protected _albedoTexture: Nullable<BaseTexture>;
  114280. /**
  114281. * AKA Occlusion Texture in other nomenclature.
  114282. */
  114283. protected _ambientTexture: Nullable<BaseTexture>;
  114284. /**
  114285. * AKA Occlusion Texture Intensity in other nomenclature.
  114286. */
  114287. protected _ambientTextureStrength: number;
  114288. /**
  114289. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114290. * 1 means it completely occludes it
  114291. * 0 mean it has no impact
  114292. */
  114293. protected _ambientTextureImpactOnAnalyticalLights: number;
  114294. /**
  114295. * Stores the alpha values in a texture.
  114296. */
  114297. protected _opacityTexture: Nullable<BaseTexture>;
  114298. /**
  114299. * Stores the reflection values in a texture.
  114300. */
  114301. protected _reflectionTexture: Nullable<BaseTexture>;
  114302. /**
  114303. * Stores the emissive values in a texture.
  114304. */
  114305. protected _emissiveTexture: Nullable<BaseTexture>;
  114306. /**
  114307. * AKA Specular texture in other nomenclature.
  114308. */
  114309. protected _reflectivityTexture: Nullable<BaseTexture>;
  114310. /**
  114311. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114312. */
  114313. protected _metallicTexture: Nullable<BaseTexture>;
  114314. /**
  114315. * Specifies the metallic scalar of the metallic/roughness workflow.
  114316. * Can also be used to scale the metalness values of the metallic texture.
  114317. */
  114318. protected _metallic: Nullable<number>;
  114319. /**
  114320. * Specifies the roughness scalar of the metallic/roughness workflow.
  114321. * Can also be used to scale the roughness values of the metallic texture.
  114322. */
  114323. protected _roughness: Nullable<number>;
  114324. /**
  114325. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114326. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114327. */
  114328. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114329. /**
  114330. * Stores surface normal data used to displace a mesh in a texture.
  114331. */
  114332. protected _bumpTexture: Nullable<BaseTexture>;
  114333. /**
  114334. * Stores the pre-calculated light information of a mesh in a texture.
  114335. */
  114336. protected _lightmapTexture: Nullable<BaseTexture>;
  114337. /**
  114338. * The color of a material in ambient lighting.
  114339. */
  114340. protected _ambientColor: Color3;
  114341. /**
  114342. * AKA Diffuse Color in other nomenclature.
  114343. */
  114344. protected _albedoColor: Color3;
  114345. /**
  114346. * AKA Specular Color in other nomenclature.
  114347. */
  114348. protected _reflectivityColor: Color3;
  114349. /**
  114350. * The color applied when light is reflected from a material.
  114351. */
  114352. protected _reflectionColor: Color3;
  114353. /**
  114354. * The color applied when light is emitted from a material.
  114355. */
  114356. protected _emissiveColor: Color3;
  114357. /**
  114358. * AKA Glossiness in other nomenclature.
  114359. */
  114360. protected _microSurface: number;
  114361. /**
  114362. * Specifies that the material will use the light map as a show map.
  114363. */
  114364. protected _useLightmapAsShadowmap: boolean;
  114365. /**
  114366. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114367. * makes the reflect vector face the model (under horizon).
  114368. */
  114369. protected _useHorizonOcclusion: boolean;
  114370. /**
  114371. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114372. * too much the area relying on ambient texture to define their ambient occlusion.
  114373. */
  114374. protected _useRadianceOcclusion: boolean;
  114375. /**
  114376. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114377. */
  114378. protected _useAlphaFromAlbedoTexture: boolean;
  114379. /**
  114380. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114381. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114382. */
  114383. protected _useSpecularOverAlpha: boolean;
  114384. /**
  114385. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114386. */
  114387. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114388. /**
  114389. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114390. */
  114391. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114392. /**
  114393. * Specifies if the metallic texture contains the roughness information in its green channel.
  114394. */
  114395. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114396. /**
  114397. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114398. */
  114399. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114400. /**
  114401. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114402. */
  114403. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114404. /**
  114405. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114406. */
  114407. protected _useAmbientInGrayScale: boolean;
  114408. /**
  114409. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114410. * The material will try to infer what glossiness each pixel should be.
  114411. */
  114412. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114413. /**
  114414. * Defines the falloff type used in this material.
  114415. * It by default is Physical.
  114416. */
  114417. protected _lightFalloff: number;
  114418. /**
  114419. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114420. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114421. */
  114422. protected _useRadianceOverAlpha: boolean;
  114423. /**
  114424. * Allows using an object space normal map (instead of tangent space).
  114425. */
  114426. protected _useObjectSpaceNormalMap: boolean;
  114427. /**
  114428. * Allows using the bump map in parallax mode.
  114429. */
  114430. protected _useParallax: boolean;
  114431. /**
  114432. * Allows using the bump map in parallax occlusion mode.
  114433. */
  114434. protected _useParallaxOcclusion: boolean;
  114435. /**
  114436. * Controls the scale bias of the parallax mode.
  114437. */
  114438. protected _parallaxScaleBias: number;
  114439. /**
  114440. * If sets to true, disables all the lights affecting the material.
  114441. */
  114442. protected _disableLighting: boolean;
  114443. /**
  114444. * Number of Simultaneous lights allowed on the material.
  114445. */
  114446. protected _maxSimultaneousLights: number;
  114447. /**
  114448. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114449. */
  114450. protected _invertNormalMapX: boolean;
  114451. /**
  114452. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114453. */
  114454. protected _invertNormalMapY: boolean;
  114455. /**
  114456. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114457. */
  114458. protected _twoSidedLighting: boolean;
  114459. /**
  114460. * Defines the alpha limits in alpha test mode.
  114461. */
  114462. protected _alphaCutOff: number;
  114463. /**
  114464. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114465. */
  114466. protected _forceAlphaTest: boolean;
  114467. /**
  114468. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114469. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114470. */
  114471. protected _useAlphaFresnel: 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 stays linear to compute the fresnel)
  114475. */
  114476. protected _useLinearAlphaFresnel: boolean;
  114477. /**
  114478. * The transparency mode of the material.
  114479. */
  114480. protected _transparencyMode: Nullable<number>;
  114481. /**
  114482. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114483. * from cos thetav and roughness:
  114484. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114485. */
  114486. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114487. /**
  114488. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114489. */
  114490. protected _forceIrradianceInFragment: boolean;
  114491. /**
  114492. * Force normal to face away from face.
  114493. */
  114494. protected _forceNormalForward: boolean;
  114495. /**
  114496. * Enables specular anti aliasing in the PBR shader.
  114497. * It will both interacts on the Geometry for analytical and IBL lighting.
  114498. * It also prefilter the roughness map based on the bump values.
  114499. */
  114500. protected _enableSpecularAntiAliasing: boolean;
  114501. /**
  114502. * Default configuration related to image processing available in the PBR Material.
  114503. */
  114504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114505. /**
  114506. * Keep track of the image processing observer to allow dispose and replace.
  114507. */
  114508. private _imageProcessingObserver;
  114509. /**
  114510. * Attaches a new image processing configuration to the PBR Material.
  114511. * @param configuration
  114512. */
  114513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114514. /**
  114515. * Stores the available render targets.
  114516. */
  114517. private _renderTargets;
  114518. /**
  114519. * Sets the global ambient color for the material used in lighting calculations.
  114520. */
  114521. private _globalAmbientColor;
  114522. /**
  114523. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114524. */
  114525. private _useLogarithmicDepth;
  114526. /**
  114527. * If set to true, no lighting calculations will be applied.
  114528. */
  114529. private _unlit;
  114530. private _debugMode;
  114531. /**
  114532. * @hidden
  114533. * This is reserved for the inspector.
  114534. * Defines the material debug mode.
  114535. * It helps seeing only some components of the material while troubleshooting.
  114536. */
  114537. debugMode: number;
  114538. /**
  114539. * @hidden
  114540. * This is reserved for the inspector.
  114541. * Specify from where on screen the debug mode should start.
  114542. * The value goes from -1 (full screen) to 1 (not visible)
  114543. * It helps with side by side comparison against the final render
  114544. * This defaults to -1
  114545. */
  114546. private debugLimit;
  114547. /**
  114548. * @hidden
  114549. * This is reserved for the inspector.
  114550. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114551. * You can use the factor to better multiply the final value.
  114552. */
  114553. private debugFactor;
  114554. /**
  114555. * Defines the clear coat layer parameters for the material.
  114556. */
  114557. readonly clearCoat: PBRClearCoatConfiguration;
  114558. /**
  114559. * Defines the anisotropic parameters for the material.
  114560. */
  114561. readonly anisotropy: PBRAnisotropicConfiguration;
  114562. /**
  114563. * Defines the BRDF parameters for the material.
  114564. */
  114565. readonly brdf: PBRBRDFConfiguration;
  114566. /**
  114567. * Defines the Sheen parameters for the material.
  114568. */
  114569. readonly sheen: PBRSheenConfiguration;
  114570. /**
  114571. * Defines the SubSurface parameters for the material.
  114572. */
  114573. readonly subSurface: PBRSubSurfaceConfiguration;
  114574. /**
  114575. * Custom callback helping to override the default shader used in the material.
  114576. */
  114577. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114578. protected _rebuildInParallel: boolean;
  114579. /**
  114580. * Instantiates a new PBRMaterial instance.
  114581. *
  114582. * @param name The material name
  114583. * @param scene The scene the material will be use in.
  114584. */
  114585. constructor(name: string, scene: Scene);
  114586. /**
  114587. * Gets a boolean indicating that current material needs to register RTT
  114588. */
  114589. readonly hasRenderTargetTextures: boolean;
  114590. /**
  114591. * Gets the name of the material class.
  114592. */
  114593. getClassName(): string;
  114594. /**
  114595. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114596. */
  114597. /**
  114598. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114599. */
  114600. useLogarithmicDepth: boolean;
  114601. /**
  114602. * Gets the current transparency mode.
  114603. */
  114604. /**
  114605. * Sets the transparency mode of the material.
  114606. *
  114607. * | Value | Type | Description |
  114608. * | ----- | ----------------------------------- | ----------- |
  114609. * | 0 | OPAQUE | |
  114610. * | 1 | ALPHATEST | |
  114611. * | 2 | ALPHABLEND | |
  114612. * | 3 | ALPHATESTANDBLEND | |
  114613. *
  114614. */
  114615. transparencyMode: Nullable<number>;
  114616. /**
  114617. * Returns true if alpha blending should be disabled.
  114618. */
  114619. private readonly _disableAlphaBlending;
  114620. /**
  114621. * Specifies whether or not this material should be rendered in alpha blend mode.
  114622. */
  114623. needAlphaBlending(): boolean;
  114624. /**
  114625. * Specifies if the mesh will require alpha blending.
  114626. * @param mesh - BJS mesh.
  114627. */
  114628. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114629. /**
  114630. * Specifies whether or not this material should be rendered in alpha test mode.
  114631. */
  114632. needAlphaTesting(): boolean;
  114633. /**
  114634. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114635. */
  114636. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114637. /**
  114638. * Gets the texture used for the alpha test.
  114639. */
  114640. getAlphaTestTexture(): Nullable<BaseTexture>;
  114641. /**
  114642. * Specifies that the submesh is ready to be used.
  114643. * @param mesh - BJS mesh.
  114644. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114645. * @param useInstances - Specifies that instances should be used.
  114646. * @returns - boolean indicating that the submesh is ready or not.
  114647. */
  114648. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114649. /**
  114650. * Specifies if the material uses metallic roughness workflow.
  114651. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114652. */
  114653. isMetallicWorkflow(): boolean;
  114654. private _prepareEffect;
  114655. private _prepareDefines;
  114656. /**
  114657. * Force shader compilation
  114658. */
  114659. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114660. clipPlane: boolean;
  114661. }>): void;
  114662. /**
  114663. * Initializes the uniform buffer layout for the shader.
  114664. */
  114665. buildUniformLayout(): void;
  114666. /**
  114667. * Unbinds the material from the mesh
  114668. */
  114669. unbind(): void;
  114670. /**
  114671. * Binds the submesh data.
  114672. * @param world - The world matrix.
  114673. * @param mesh - The BJS mesh.
  114674. * @param subMesh - A submesh of the BJS mesh.
  114675. */
  114676. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114677. /**
  114678. * Returns the animatable textures.
  114679. * @returns - Array of animatable textures.
  114680. */
  114681. getAnimatables(): IAnimatable[];
  114682. /**
  114683. * Returns the texture used for reflections.
  114684. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114685. */
  114686. private _getReflectionTexture;
  114687. /**
  114688. * Returns an array of the actively used textures.
  114689. * @returns - Array of BaseTextures
  114690. */
  114691. getActiveTextures(): BaseTexture[];
  114692. /**
  114693. * Checks to see if a texture is used in the material.
  114694. * @param texture - Base texture to use.
  114695. * @returns - Boolean specifying if a texture is used in the material.
  114696. */
  114697. hasTexture(texture: BaseTexture): boolean;
  114698. /**
  114699. * Disposes the resources of the material.
  114700. * @param forceDisposeEffect - Forces the disposal of effects.
  114701. * @param forceDisposeTextures - Forces the disposal of all textures.
  114702. */
  114703. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114704. }
  114705. }
  114706. declare module BABYLON {
  114707. /**
  114708. * The Physically based material of BJS.
  114709. *
  114710. * This offers the main features of a standard PBR material.
  114711. * For more information, please refer to the documentation :
  114712. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114713. */
  114714. export class PBRMaterial extends PBRBaseMaterial {
  114715. /**
  114716. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114717. */
  114718. static readonly PBRMATERIAL_OPAQUE: number;
  114719. /**
  114720. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114721. */
  114722. static readonly PBRMATERIAL_ALPHATEST: number;
  114723. /**
  114724. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114725. */
  114726. static readonly PBRMATERIAL_ALPHABLEND: number;
  114727. /**
  114728. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114729. * They are also discarded below the alpha cutoff threshold to improve performances.
  114730. */
  114731. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114732. /**
  114733. * Defines the default value of how much AO map is occluding the analytical lights
  114734. * (point spot...).
  114735. */
  114736. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114737. /**
  114738. * Intensity of the direct lights e.g. the four lights available in your scene.
  114739. * This impacts both the direct diffuse and specular highlights.
  114740. */
  114741. directIntensity: number;
  114742. /**
  114743. * Intensity of the emissive part of the material.
  114744. * This helps controlling the emissive effect without modifying the emissive color.
  114745. */
  114746. emissiveIntensity: number;
  114747. /**
  114748. * Intensity of the environment e.g. how much the environment will light the object
  114749. * either through harmonics for rough material or through the refelction for shiny ones.
  114750. */
  114751. environmentIntensity: number;
  114752. /**
  114753. * This is a special control allowing the reduction of the specular highlights coming from the
  114754. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114755. */
  114756. specularIntensity: number;
  114757. /**
  114758. * Debug Control allowing disabling the bump map on this material.
  114759. */
  114760. disableBumpMap: boolean;
  114761. /**
  114762. * AKA Diffuse Texture in standard nomenclature.
  114763. */
  114764. albedoTexture: BaseTexture;
  114765. /**
  114766. * AKA Occlusion Texture in other nomenclature.
  114767. */
  114768. ambientTexture: BaseTexture;
  114769. /**
  114770. * AKA Occlusion Texture Intensity in other nomenclature.
  114771. */
  114772. ambientTextureStrength: number;
  114773. /**
  114774. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114775. * 1 means it completely occludes it
  114776. * 0 mean it has no impact
  114777. */
  114778. ambientTextureImpactOnAnalyticalLights: number;
  114779. /**
  114780. * Stores the alpha values in a texture.
  114781. */
  114782. opacityTexture: BaseTexture;
  114783. /**
  114784. * Stores the reflection values in a texture.
  114785. */
  114786. reflectionTexture: Nullable<BaseTexture>;
  114787. /**
  114788. * Stores the emissive values in a texture.
  114789. */
  114790. emissiveTexture: BaseTexture;
  114791. /**
  114792. * AKA Specular texture in other nomenclature.
  114793. */
  114794. reflectivityTexture: BaseTexture;
  114795. /**
  114796. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114797. */
  114798. metallicTexture: BaseTexture;
  114799. /**
  114800. * Specifies the metallic scalar of the metallic/roughness workflow.
  114801. * Can also be used to scale the metalness values of the metallic texture.
  114802. */
  114803. metallic: Nullable<number>;
  114804. /**
  114805. * Specifies the roughness scalar of the metallic/roughness workflow.
  114806. * Can also be used to scale the roughness values of the metallic texture.
  114807. */
  114808. roughness: Nullable<number>;
  114809. /**
  114810. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114811. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114812. */
  114813. microSurfaceTexture: BaseTexture;
  114814. /**
  114815. * Stores surface normal data used to displace a mesh in a texture.
  114816. */
  114817. bumpTexture: BaseTexture;
  114818. /**
  114819. * Stores the pre-calculated light information of a mesh in a texture.
  114820. */
  114821. lightmapTexture: BaseTexture;
  114822. /**
  114823. * Stores the refracted light information in a texture.
  114824. */
  114825. refractionTexture: Nullable<BaseTexture>;
  114826. /**
  114827. * The color of a material in ambient lighting.
  114828. */
  114829. ambientColor: Color3;
  114830. /**
  114831. * AKA Diffuse Color in other nomenclature.
  114832. */
  114833. albedoColor: Color3;
  114834. /**
  114835. * AKA Specular Color in other nomenclature.
  114836. */
  114837. reflectivityColor: Color3;
  114838. /**
  114839. * The color reflected from the material.
  114840. */
  114841. reflectionColor: Color3;
  114842. /**
  114843. * The color emitted from the material.
  114844. */
  114845. emissiveColor: Color3;
  114846. /**
  114847. * AKA Glossiness in other nomenclature.
  114848. */
  114849. microSurface: number;
  114850. /**
  114851. * source material index of refraction (IOR)' / 'destination material IOR.
  114852. */
  114853. indexOfRefraction: number;
  114854. /**
  114855. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114856. */
  114857. invertRefractionY: boolean;
  114858. /**
  114859. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114860. * Materials half opaque for instance using refraction could benefit from this control.
  114861. */
  114862. linkRefractionWithTransparency: boolean;
  114863. /**
  114864. * If true, the light map contains occlusion information instead of lighting info.
  114865. */
  114866. useLightmapAsShadowmap: boolean;
  114867. /**
  114868. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114869. */
  114870. useAlphaFromAlbedoTexture: boolean;
  114871. /**
  114872. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114873. */
  114874. forceAlphaTest: boolean;
  114875. /**
  114876. * Defines the alpha limits in alpha test mode.
  114877. */
  114878. alphaCutOff: number;
  114879. /**
  114880. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114881. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114882. */
  114883. useSpecularOverAlpha: boolean;
  114884. /**
  114885. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114886. */
  114887. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114888. /**
  114889. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114890. */
  114891. useRoughnessFromMetallicTextureAlpha: boolean;
  114892. /**
  114893. * Specifies if the metallic texture contains the roughness information in its green channel.
  114894. */
  114895. useRoughnessFromMetallicTextureGreen: boolean;
  114896. /**
  114897. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114898. */
  114899. useMetallnessFromMetallicTextureBlue: boolean;
  114900. /**
  114901. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114902. */
  114903. useAmbientOcclusionFromMetallicTextureRed: boolean;
  114904. /**
  114905. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114906. */
  114907. useAmbientInGrayScale: boolean;
  114908. /**
  114909. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114910. * The material will try to infer what glossiness each pixel should be.
  114911. */
  114912. useAutoMicroSurfaceFromReflectivityMap: boolean;
  114913. /**
  114914. * BJS is using an harcoded light falloff based on a manually sets up range.
  114915. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114916. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114917. */
  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. usePhysicalLightFalloff: boolean;
  114924. /**
  114925. * In order to support the falloff compatibility with gltf, a special mode has been added
  114926. * to reproduce the gltf light falloff.
  114927. */
  114928. /**
  114929. * In order to support the falloff compatibility with gltf, a special mode has been added
  114930. * to reproduce the gltf light falloff.
  114931. */
  114932. useGLTFLightFalloff: boolean;
  114933. /**
  114934. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114935. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114936. */
  114937. useRadianceOverAlpha: boolean;
  114938. /**
  114939. * Allows using an object space normal map (instead of tangent space).
  114940. */
  114941. useObjectSpaceNormalMap: boolean;
  114942. /**
  114943. * Allows using the bump map in parallax mode.
  114944. */
  114945. useParallax: boolean;
  114946. /**
  114947. * Allows using the bump map in parallax occlusion mode.
  114948. */
  114949. useParallaxOcclusion: boolean;
  114950. /**
  114951. * Controls the scale bias of the parallax mode.
  114952. */
  114953. parallaxScaleBias: number;
  114954. /**
  114955. * If sets to true, disables all the lights affecting the material.
  114956. */
  114957. disableLighting: boolean;
  114958. /**
  114959. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114960. */
  114961. forceIrradianceInFragment: boolean;
  114962. /**
  114963. * Number of Simultaneous lights allowed on the material.
  114964. */
  114965. maxSimultaneousLights: number;
  114966. /**
  114967. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114968. */
  114969. invertNormalMapX: boolean;
  114970. /**
  114971. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114972. */
  114973. invertNormalMapY: boolean;
  114974. /**
  114975. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114976. */
  114977. twoSidedLighting: boolean;
  114978. /**
  114979. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114980. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114981. */
  114982. useAlphaFresnel: 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 stays linear to compute the fresnel)
  114986. */
  114987. useLinearAlphaFresnel: boolean;
  114988. /**
  114989. * Let user defines the brdf lookup texture used for IBL.
  114990. * A default 8bit version is embedded but you could point at :
  114991. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  114992. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  114993. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  114994. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  114995. */
  114996. environmentBRDFTexture: Nullable<BaseTexture>;
  114997. /**
  114998. * Force normal to face away from face.
  114999. */
  115000. forceNormalForward: boolean;
  115001. /**
  115002. * Enables specular anti aliasing in the PBR shader.
  115003. * It will both interacts on the Geometry for analytical and IBL lighting.
  115004. * It also prefilter the roughness map based on the bump values.
  115005. */
  115006. enableSpecularAntiAliasing: boolean;
  115007. /**
  115008. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115009. * makes the reflect vector face the model (under horizon).
  115010. */
  115011. useHorizonOcclusion: boolean;
  115012. /**
  115013. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115014. * too much the area relying on ambient texture to define their ambient occlusion.
  115015. */
  115016. useRadianceOcclusion: boolean;
  115017. /**
  115018. * If set to true, no lighting calculations will be applied.
  115019. */
  115020. unlit: boolean;
  115021. /**
  115022. * Gets the image processing configuration used either in this material.
  115023. */
  115024. /**
  115025. * Sets the Default image processing configuration used either in the this material.
  115026. *
  115027. * If sets to null, the scene one is in use.
  115028. */
  115029. imageProcessingConfiguration: ImageProcessingConfiguration;
  115030. /**
  115031. * Gets wether the color curves effect is enabled.
  115032. */
  115033. /**
  115034. * Sets wether the color curves effect is enabled.
  115035. */
  115036. cameraColorCurvesEnabled: boolean;
  115037. /**
  115038. * Gets wether the color grading effect is enabled.
  115039. */
  115040. /**
  115041. * Gets wether the color grading effect is enabled.
  115042. */
  115043. cameraColorGradingEnabled: boolean;
  115044. /**
  115045. * Gets wether tonemapping is enabled or not.
  115046. */
  115047. /**
  115048. * Sets wether tonemapping is enabled or not
  115049. */
  115050. cameraToneMappingEnabled: boolean;
  115051. /**
  115052. * The camera exposure used on this material.
  115053. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115054. * This corresponds to a photographic exposure.
  115055. */
  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. cameraExposure: number;
  115062. /**
  115063. * Gets The camera contrast used on this material.
  115064. */
  115065. /**
  115066. * Sets The camera contrast used on this material.
  115067. */
  115068. cameraContrast: number;
  115069. /**
  115070. * Gets the Color Grading 2D Lookup Texture.
  115071. */
  115072. /**
  115073. * Sets the Color Grading 2D Lookup Texture.
  115074. */
  115075. cameraColorGradingTexture: Nullable<BaseTexture>;
  115076. /**
  115077. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115078. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115079. * 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;
  115080. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115081. */
  115082. /**
  115083. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115084. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115085. * 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;
  115086. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115087. */
  115088. cameraColorCurves: Nullable<ColorCurves>;
  115089. /**
  115090. * Instantiates a new PBRMaterial instance.
  115091. *
  115092. * @param name The material name
  115093. * @param scene The scene the material will be use in.
  115094. */
  115095. constructor(name: string, scene: Scene);
  115096. /**
  115097. * Returns the name of this material class.
  115098. */
  115099. getClassName(): string;
  115100. /**
  115101. * Makes a duplicate of the current material.
  115102. * @param name - name to use for the new material.
  115103. */
  115104. clone(name: string): PBRMaterial;
  115105. /**
  115106. * Serializes this PBR Material.
  115107. * @returns - An object with the serialized material.
  115108. */
  115109. serialize(): any;
  115110. /**
  115111. * Parses a PBR Material from a serialized object.
  115112. * @param source - Serialized object.
  115113. * @param scene - BJS scene instance.
  115114. * @param rootUrl - url for the scene object
  115115. * @returns - PBRMaterial
  115116. */
  115117. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115118. }
  115119. }
  115120. declare module BABYLON {
  115121. /**
  115122. * Direct draw surface info
  115123. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115124. */
  115125. export interface DDSInfo {
  115126. /**
  115127. * Width of the texture
  115128. */
  115129. width: number;
  115130. /**
  115131. * Width of the texture
  115132. */
  115133. height: number;
  115134. /**
  115135. * Number of Mipmaps for the texture
  115136. * @see https://en.wikipedia.org/wiki/Mipmap
  115137. */
  115138. mipmapCount: number;
  115139. /**
  115140. * If the textures format is a known fourCC format
  115141. * @see https://www.fourcc.org/
  115142. */
  115143. isFourCC: boolean;
  115144. /**
  115145. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115146. */
  115147. isRGB: boolean;
  115148. /**
  115149. * If the texture is a lumincance format
  115150. */
  115151. isLuminance: boolean;
  115152. /**
  115153. * If this is a cube texture
  115154. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115155. */
  115156. isCube: boolean;
  115157. /**
  115158. * If the texture is a compressed format eg. FOURCC_DXT1
  115159. */
  115160. isCompressed: boolean;
  115161. /**
  115162. * The dxgiFormat of the texture
  115163. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115164. */
  115165. dxgiFormat: number;
  115166. /**
  115167. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115168. */
  115169. textureType: number;
  115170. /**
  115171. * Sphericle polynomial created for the dds texture
  115172. */
  115173. sphericalPolynomial?: SphericalPolynomial;
  115174. }
  115175. /**
  115176. * Class used to provide DDS decompression tools
  115177. */
  115178. export class DDSTools {
  115179. /**
  115180. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115181. */
  115182. static StoreLODInAlphaChannel: boolean;
  115183. /**
  115184. * Gets DDS information from an array buffer
  115185. * @param arrayBuffer defines the array buffer to read data from
  115186. * @returns the DDS information
  115187. */
  115188. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115189. private static _FloatView;
  115190. private static _Int32View;
  115191. private static _ToHalfFloat;
  115192. private static _FromHalfFloat;
  115193. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115194. private static _GetHalfFloatRGBAArrayBuffer;
  115195. private static _GetFloatRGBAArrayBuffer;
  115196. private static _GetFloatAsUIntRGBAArrayBuffer;
  115197. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115198. private static _GetRGBAArrayBuffer;
  115199. private static _ExtractLongWordOrder;
  115200. private static _GetRGBArrayBuffer;
  115201. private static _GetLuminanceArrayBuffer;
  115202. /**
  115203. * Uploads DDS Levels to a Babylon Texture
  115204. * @hidden
  115205. */
  115206. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115207. }
  115208. interface ThinEngine {
  115209. /**
  115210. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115211. * @param rootUrl defines the url where the file to load is located
  115212. * @param scene defines the current scene
  115213. * @param lodScale defines scale to apply to the mip map selection
  115214. * @param lodOffset defines offset to apply to the mip map selection
  115215. * @param onLoad defines an optional callback raised when the texture is loaded
  115216. * @param onError defines an optional callback raised if there is an issue to load the texture
  115217. * @param format defines the format of the data
  115218. * @param forcedExtension defines the extension to use to pick the right loader
  115219. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115220. * @returns the cube texture as an InternalTexture
  115221. */
  115222. 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;
  115223. }
  115224. }
  115225. declare module BABYLON {
  115226. /**
  115227. * Implementation of the DDS Texture Loader.
  115228. * @hidden
  115229. */
  115230. export class _DDSTextureLoader implements IInternalTextureLoader {
  115231. /**
  115232. * Defines wether the loader supports cascade loading the different faces.
  115233. */
  115234. readonly supportCascades: boolean;
  115235. /**
  115236. * This returns if the loader support the current file information.
  115237. * @param extension defines the file extension of the file being loaded
  115238. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115239. * @param fallback defines the fallback internal texture if any
  115240. * @param isBase64 defines whether the texture is encoded as a base64
  115241. * @param isBuffer defines whether the texture data are stored as a buffer
  115242. * @returns true if the loader can load the specified file
  115243. */
  115244. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115245. /**
  115246. * Transform the url before loading if required.
  115247. * @param rootUrl the url of the texture
  115248. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115249. * @returns the transformed texture
  115250. */
  115251. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115252. /**
  115253. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115254. * @param rootUrl the url of the texture
  115255. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115256. * @returns the fallback texture
  115257. */
  115258. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115259. /**
  115260. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115261. * @param data contains the texture data
  115262. * @param texture defines the BabylonJS internal texture
  115263. * @param createPolynomials will be true if polynomials have been requested
  115264. * @param onLoad defines the callback to trigger once the texture is ready
  115265. * @param onError defines the callback to trigger in case of error
  115266. */
  115267. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115268. /**
  115269. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115270. * @param data contains the texture data
  115271. * @param texture defines the BabylonJS internal texture
  115272. * @param callback defines the method to call once ready to upload
  115273. */
  115274. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115275. }
  115276. }
  115277. declare module BABYLON {
  115278. /**
  115279. * Implementation of the ENV Texture Loader.
  115280. * @hidden
  115281. */
  115282. export class _ENVTextureLoader implements IInternalTextureLoader {
  115283. /**
  115284. * Defines wether the loader supports cascade loading the different faces.
  115285. */
  115286. readonly supportCascades: boolean;
  115287. /**
  115288. * This returns if the loader support the current file information.
  115289. * @param extension defines the file extension of the file being loaded
  115290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115291. * @param fallback defines the fallback internal texture if any
  115292. * @param isBase64 defines whether the texture is encoded as a base64
  115293. * @param isBuffer defines whether the texture data are stored as a buffer
  115294. * @returns true if the loader can load the specified file
  115295. */
  115296. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115297. /**
  115298. * Transform the url before loading if required.
  115299. * @param rootUrl the url of the texture
  115300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115301. * @returns the transformed texture
  115302. */
  115303. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115304. /**
  115305. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115306. * @param rootUrl the url of the texture
  115307. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115308. * @returns the fallback texture
  115309. */
  115310. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115311. /**
  115312. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115313. * @param data contains the texture data
  115314. * @param texture defines the BabylonJS internal texture
  115315. * @param createPolynomials will be true if polynomials have been requested
  115316. * @param onLoad defines the callback to trigger once the texture is ready
  115317. * @param onError defines the callback to trigger in case of error
  115318. */
  115319. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115320. /**
  115321. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115322. * @param data contains the texture data
  115323. * @param texture defines the BabylonJS internal texture
  115324. * @param callback defines the method to call once ready to upload
  115325. */
  115326. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115327. }
  115328. }
  115329. declare module BABYLON {
  115330. /**
  115331. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115332. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115333. */
  115334. export class KhronosTextureContainer {
  115335. /** contents of the KTX container file */
  115336. arrayBuffer: any;
  115337. private static HEADER_LEN;
  115338. private static COMPRESSED_2D;
  115339. private static COMPRESSED_3D;
  115340. private static TEX_2D;
  115341. private static TEX_3D;
  115342. /**
  115343. * Gets the openGL type
  115344. */
  115345. glType: number;
  115346. /**
  115347. * Gets the openGL type size
  115348. */
  115349. glTypeSize: number;
  115350. /**
  115351. * Gets the openGL format
  115352. */
  115353. glFormat: number;
  115354. /**
  115355. * Gets the openGL internal format
  115356. */
  115357. glInternalFormat: number;
  115358. /**
  115359. * Gets the base internal format
  115360. */
  115361. glBaseInternalFormat: number;
  115362. /**
  115363. * Gets image width in pixel
  115364. */
  115365. pixelWidth: number;
  115366. /**
  115367. * Gets image height in pixel
  115368. */
  115369. pixelHeight: number;
  115370. /**
  115371. * Gets image depth in pixels
  115372. */
  115373. pixelDepth: number;
  115374. /**
  115375. * Gets the number of array elements
  115376. */
  115377. numberOfArrayElements: number;
  115378. /**
  115379. * Gets the number of faces
  115380. */
  115381. numberOfFaces: number;
  115382. /**
  115383. * Gets the number of mipmap levels
  115384. */
  115385. numberOfMipmapLevels: number;
  115386. /**
  115387. * Gets the bytes of key value data
  115388. */
  115389. bytesOfKeyValueData: number;
  115390. /**
  115391. * Gets the load type
  115392. */
  115393. loadType: number;
  115394. /**
  115395. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115396. */
  115397. isInvalid: boolean;
  115398. /**
  115399. * Creates a new KhronosTextureContainer
  115400. * @param arrayBuffer contents of the KTX container file
  115401. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115402. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115403. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115404. */
  115405. constructor(
  115406. /** contents of the KTX container file */
  115407. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115408. /**
  115409. * Uploads KTX content to a Babylon Texture.
  115410. * It is assumed that the texture has already been created & is currently bound
  115411. * @hidden
  115412. */
  115413. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115414. private _upload2DCompressedLevels;
  115415. }
  115416. }
  115417. declare module BABYLON {
  115418. /**
  115419. * Implementation of the KTX Texture Loader.
  115420. * @hidden
  115421. */
  115422. export class _KTXTextureLoader implements IInternalTextureLoader {
  115423. /**
  115424. * Defines wether the loader supports cascade loading the different faces.
  115425. */
  115426. readonly supportCascades: boolean;
  115427. /**
  115428. * This returns if the loader support the current file information.
  115429. * @param extension defines the file extension of the file being loaded
  115430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115431. * @param fallback defines the fallback internal texture if any
  115432. * @param isBase64 defines whether the texture is encoded as a base64
  115433. * @param isBuffer defines whether the texture data are stored as a buffer
  115434. * @returns true if the loader can load the specified file
  115435. */
  115436. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115437. /**
  115438. * Transform the url before loading if required.
  115439. * @param rootUrl the url of the texture
  115440. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115441. * @returns the transformed texture
  115442. */
  115443. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115444. /**
  115445. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115446. * @param rootUrl the url of the texture
  115447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115448. * @returns the fallback texture
  115449. */
  115450. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115451. /**
  115452. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115453. * @param data contains the texture data
  115454. * @param texture defines the BabylonJS internal texture
  115455. * @param createPolynomials will be true if polynomials have been requested
  115456. * @param onLoad defines the callback to trigger once the texture is ready
  115457. * @param onError defines the callback to trigger in case of error
  115458. */
  115459. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115460. /**
  115461. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115462. * @param data contains the texture data
  115463. * @param texture defines the BabylonJS internal texture
  115464. * @param callback defines the method to call once ready to upload
  115465. */
  115466. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115467. }
  115468. }
  115469. declare module BABYLON {
  115470. /**
  115471. * Options for the default xr helper
  115472. */
  115473. export class WebXRDefaultExperienceOptions {
  115474. /**
  115475. * Floor meshes that should be used for teleporting
  115476. */
  115477. floorMeshes: Array<AbstractMesh>;
  115478. }
  115479. /**
  115480. * Default experience which provides a similar setup to the previous webVRExperience
  115481. */
  115482. export class WebXRDefaultExperience {
  115483. /**
  115484. * Base experience
  115485. */
  115486. baseExperience: WebXRExperienceHelper;
  115487. /**
  115488. * Input experience extension
  115489. */
  115490. input: WebXRInput;
  115491. /**
  115492. * Loads the controller models
  115493. */
  115494. controllerModelLoader: WebXRControllerModelLoader;
  115495. /**
  115496. * Enables laser pointer and selection
  115497. */
  115498. pointerSelection: WebXRControllerPointerSelection;
  115499. /**
  115500. * Enables teleportation
  115501. */
  115502. teleportation: WebXRControllerTeleportation;
  115503. /**
  115504. * Enables ui for enetering/exiting xr
  115505. */
  115506. enterExitUI: WebXREnterExitUI;
  115507. /**
  115508. * Default output canvas xr should render to
  115509. */
  115510. outputCanvas: WebXRManagedOutputCanvas;
  115511. /**
  115512. * Creates the default xr experience
  115513. * @param scene scene
  115514. * @param options options for basic configuration
  115515. * @returns resulting WebXRDefaultExperience
  115516. */
  115517. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115518. private constructor();
  115519. /**
  115520. * DIsposes of the experience helper
  115521. */
  115522. dispose(): void;
  115523. }
  115524. }
  115525. declare module BABYLON {
  115526. /** @hidden */
  115527. export var _forceSceneHelpersToBundle: boolean;
  115528. interface Scene {
  115529. /**
  115530. * Creates a default light for the scene.
  115531. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115532. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115533. */
  115534. createDefaultLight(replace?: boolean): void;
  115535. /**
  115536. * Creates a default camera for the scene.
  115537. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115538. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115539. * @param replace has default false, when true replaces the active camera in the scene
  115540. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115541. */
  115542. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115543. /**
  115544. * Creates a default camera and a default light.
  115545. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115546. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115547. * @param replace has the default false, when true replaces the active camera/light in the scene
  115548. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115549. */
  115550. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115551. /**
  115552. * Creates a new sky box
  115553. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115554. * @param environmentTexture defines the texture to use as environment texture
  115555. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115556. * @param scale defines the overall scale of the skybox
  115557. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115558. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115559. * @returns a new mesh holding the sky box
  115560. */
  115561. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115562. /**
  115563. * Creates a new environment
  115564. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115565. * @param options defines the options you can use to configure the environment
  115566. * @returns the new EnvironmentHelper
  115567. */
  115568. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115569. /**
  115570. * Creates a new VREXperienceHelper
  115571. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115572. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115573. * @returns a new VREXperienceHelper
  115574. */
  115575. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115576. /**
  115577. * Creates a new WebXRDefaultExperience
  115578. * @see http://doc.babylonjs.com/how_to/webxr
  115579. * @param options experience options
  115580. * @returns a promise for a new WebXRDefaultExperience
  115581. */
  115582. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115583. }
  115584. }
  115585. declare module BABYLON {
  115586. /**
  115587. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115588. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115589. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115590. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115591. */
  115592. export class VideoDome extends TransformNode {
  115593. /**
  115594. * Define the video source as a Monoscopic panoramic 360 video.
  115595. */
  115596. static readonly MODE_MONOSCOPIC: number;
  115597. /**
  115598. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115599. */
  115600. static readonly MODE_TOPBOTTOM: number;
  115601. /**
  115602. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115603. */
  115604. static readonly MODE_SIDEBYSIDE: number;
  115605. private _halfDome;
  115606. private _useDirectMapping;
  115607. /**
  115608. * The video texture being displayed on the sphere
  115609. */
  115610. protected _videoTexture: VideoTexture;
  115611. /**
  115612. * Gets the video texture being displayed on the sphere
  115613. */
  115614. readonly videoTexture: VideoTexture;
  115615. /**
  115616. * The skybox material
  115617. */
  115618. protected _material: BackgroundMaterial;
  115619. /**
  115620. * The surface used for the skybox
  115621. */
  115622. protected _mesh: Mesh;
  115623. /**
  115624. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115625. */
  115626. private _halfDomeMask;
  115627. /**
  115628. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115629. * Also see the options.resolution property.
  115630. */
  115631. fovMultiplier: number;
  115632. private _videoMode;
  115633. /**
  115634. * Gets or set the current video mode for the video. It can be:
  115635. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115636. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115637. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115638. */
  115639. videoMode: number;
  115640. /**
  115641. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115642. *
  115643. */
  115644. /**
  115645. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115646. */
  115647. halfDome: boolean;
  115648. /**
  115649. * Oberserver used in Stereoscopic VR Mode.
  115650. */
  115651. private _onBeforeCameraRenderObserver;
  115652. /**
  115653. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115654. * @param name Element's name, child elements will append suffixes for their own names.
  115655. * @param urlsOrVideo defines the url(s) or the video element to use
  115656. * @param options An object containing optional or exposed sub element properties
  115657. */
  115658. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115659. resolution?: number;
  115660. clickToPlay?: boolean;
  115661. autoPlay?: boolean;
  115662. loop?: boolean;
  115663. size?: number;
  115664. poster?: string;
  115665. faceForward?: boolean;
  115666. useDirectMapping?: boolean;
  115667. halfDomeMode?: boolean;
  115668. }, scene: Scene);
  115669. private _changeVideoMode;
  115670. /**
  115671. * Releases resources associated with this node.
  115672. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115673. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115674. */
  115675. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115676. }
  115677. }
  115678. declare module BABYLON {
  115679. /**
  115680. * This class can be used to get instrumentation data from a Babylon engine
  115681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115682. */
  115683. export class EngineInstrumentation implements IDisposable {
  115684. /**
  115685. * Define the instrumented engine.
  115686. */
  115687. engine: Engine;
  115688. private _captureGPUFrameTime;
  115689. private _gpuFrameTimeToken;
  115690. private _gpuFrameTime;
  115691. private _captureShaderCompilationTime;
  115692. private _shaderCompilationTime;
  115693. private _onBeginFrameObserver;
  115694. private _onEndFrameObserver;
  115695. private _onBeforeShaderCompilationObserver;
  115696. private _onAfterShaderCompilationObserver;
  115697. /**
  115698. * Gets the perf counter used for GPU frame time
  115699. */
  115700. readonly gpuFrameTimeCounter: PerfCounter;
  115701. /**
  115702. * Gets the GPU frame time capture status
  115703. */
  115704. /**
  115705. * Enable or disable the GPU frame time capture
  115706. */
  115707. captureGPUFrameTime: boolean;
  115708. /**
  115709. * Gets the perf counter used for shader compilation time
  115710. */
  115711. readonly shaderCompilationTimeCounter: PerfCounter;
  115712. /**
  115713. * Gets the shader compilation time capture status
  115714. */
  115715. /**
  115716. * Enable or disable the shader compilation time capture
  115717. */
  115718. captureShaderCompilationTime: boolean;
  115719. /**
  115720. * Instantiates a new engine instrumentation.
  115721. * This class can be used to get instrumentation data from a Babylon engine
  115722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115723. * @param engine Defines the engine to instrument
  115724. */
  115725. constructor(
  115726. /**
  115727. * Define the instrumented engine.
  115728. */
  115729. engine: Engine);
  115730. /**
  115731. * Dispose and release associated resources.
  115732. */
  115733. dispose(): void;
  115734. }
  115735. }
  115736. declare module BABYLON {
  115737. /**
  115738. * This class can be used to get instrumentation data from a Babylon engine
  115739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115740. */
  115741. export class SceneInstrumentation implements IDisposable {
  115742. /**
  115743. * Defines the scene to instrument
  115744. */
  115745. scene: Scene;
  115746. private _captureActiveMeshesEvaluationTime;
  115747. private _activeMeshesEvaluationTime;
  115748. private _captureRenderTargetsRenderTime;
  115749. private _renderTargetsRenderTime;
  115750. private _captureFrameTime;
  115751. private _frameTime;
  115752. private _captureRenderTime;
  115753. private _renderTime;
  115754. private _captureInterFrameTime;
  115755. private _interFrameTime;
  115756. private _captureParticlesRenderTime;
  115757. private _particlesRenderTime;
  115758. private _captureSpritesRenderTime;
  115759. private _spritesRenderTime;
  115760. private _capturePhysicsTime;
  115761. private _physicsTime;
  115762. private _captureAnimationsTime;
  115763. private _animationsTime;
  115764. private _captureCameraRenderTime;
  115765. private _cameraRenderTime;
  115766. private _onBeforeActiveMeshesEvaluationObserver;
  115767. private _onAfterActiveMeshesEvaluationObserver;
  115768. private _onBeforeRenderTargetsRenderObserver;
  115769. private _onAfterRenderTargetsRenderObserver;
  115770. private _onAfterRenderObserver;
  115771. private _onBeforeDrawPhaseObserver;
  115772. private _onAfterDrawPhaseObserver;
  115773. private _onBeforeAnimationsObserver;
  115774. private _onBeforeParticlesRenderingObserver;
  115775. private _onAfterParticlesRenderingObserver;
  115776. private _onBeforeSpritesRenderingObserver;
  115777. private _onAfterSpritesRenderingObserver;
  115778. private _onBeforePhysicsObserver;
  115779. private _onAfterPhysicsObserver;
  115780. private _onAfterAnimationsObserver;
  115781. private _onBeforeCameraRenderObserver;
  115782. private _onAfterCameraRenderObserver;
  115783. /**
  115784. * Gets the perf counter used for active meshes evaluation time
  115785. */
  115786. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115787. /**
  115788. * Gets the active meshes evaluation time capture status
  115789. */
  115790. /**
  115791. * Enable or disable the active meshes evaluation time capture
  115792. */
  115793. captureActiveMeshesEvaluationTime: boolean;
  115794. /**
  115795. * Gets the perf counter used for render targets render time
  115796. */
  115797. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115798. /**
  115799. * Gets the render targets render time capture status
  115800. */
  115801. /**
  115802. * Enable or disable the render targets render time capture
  115803. */
  115804. captureRenderTargetsRenderTime: boolean;
  115805. /**
  115806. * Gets the perf counter used for particles render time
  115807. */
  115808. readonly particlesRenderTimeCounter: PerfCounter;
  115809. /**
  115810. * Gets the particles render time capture status
  115811. */
  115812. /**
  115813. * Enable or disable the particles render time capture
  115814. */
  115815. captureParticlesRenderTime: boolean;
  115816. /**
  115817. * Gets the perf counter used for sprites render time
  115818. */
  115819. readonly spritesRenderTimeCounter: PerfCounter;
  115820. /**
  115821. * Gets the sprites render time capture status
  115822. */
  115823. /**
  115824. * Enable or disable the sprites render time capture
  115825. */
  115826. captureSpritesRenderTime: boolean;
  115827. /**
  115828. * Gets the perf counter used for physics time
  115829. */
  115830. readonly physicsTimeCounter: PerfCounter;
  115831. /**
  115832. * Gets the physics time capture status
  115833. */
  115834. /**
  115835. * Enable or disable the physics time capture
  115836. */
  115837. capturePhysicsTime: boolean;
  115838. /**
  115839. * Gets the perf counter used for animations time
  115840. */
  115841. readonly animationsTimeCounter: PerfCounter;
  115842. /**
  115843. * Gets the animations time capture status
  115844. */
  115845. /**
  115846. * Enable or disable the animations time capture
  115847. */
  115848. captureAnimationsTime: boolean;
  115849. /**
  115850. * Gets the perf counter used for frame time capture
  115851. */
  115852. readonly frameTimeCounter: PerfCounter;
  115853. /**
  115854. * Gets the frame time capture status
  115855. */
  115856. /**
  115857. * Enable or disable the frame time capture
  115858. */
  115859. captureFrameTime: boolean;
  115860. /**
  115861. * Gets the perf counter used for inter-frames time capture
  115862. */
  115863. readonly interFrameTimeCounter: PerfCounter;
  115864. /**
  115865. * Gets the inter-frames time capture status
  115866. */
  115867. /**
  115868. * Enable or disable the inter-frames time capture
  115869. */
  115870. captureInterFrameTime: boolean;
  115871. /**
  115872. * Gets the perf counter used for render time capture
  115873. */
  115874. readonly renderTimeCounter: PerfCounter;
  115875. /**
  115876. * Gets the render time capture status
  115877. */
  115878. /**
  115879. * Enable or disable the render time capture
  115880. */
  115881. captureRenderTime: boolean;
  115882. /**
  115883. * Gets the perf counter used for camera render time capture
  115884. */
  115885. readonly cameraRenderTimeCounter: PerfCounter;
  115886. /**
  115887. * Gets the camera render time capture status
  115888. */
  115889. /**
  115890. * Enable or disable the camera render time capture
  115891. */
  115892. captureCameraRenderTime: boolean;
  115893. /**
  115894. * Gets the perf counter used for draw calls
  115895. */
  115896. readonly drawCallsCounter: PerfCounter;
  115897. /**
  115898. * Instantiates a new scene instrumentation.
  115899. * This class can be used to get instrumentation data from a Babylon engine
  115900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115901. * @param scene Defines the scene to instrument
  115902. */
  115903. constructor(
  115904. /**
  115905. * Defines the scene to instrument
  115906. */
  115907. scene: Scene);
  115908. /**
  115909. * Dispose and release associated resources.
  115910. */
  115911. dispose(): void;
  115912. }
  115913. }
  115914. declare module BABYLON {
  115915. /** @hidden */
  115916. export var glowMapGenerationPixelShader: {
  115917. name: string;
  115918. shader: string;
  115919. };
  115920. }
  115921. declare module BABYLON {
  115922. /** @hidden */
  115923. export var glowMapGenerationVertexShader: {
  115924. name: string;
  115925. shader: string;
  115926. };
  115927. }
  115928. declare module BABYLON {
  115929. /**
  115930. * Effect layer options. This helps customizing the behaviour
  115931. * of the effect layer.
  115932. */
  115933. export interface IEffectLayerOptions {
  115934. /**
  115935. * Multiplication factor apply to the canvas size to compute the render target size
  115936. * used to generated the objects (the smaller the faster).
  115937. */
  115938. mainTextureRatio: number;
  115939. /**
  115940. * Enforces a fixed size texture to ensure effect stability across devices.
  115941. */
  115942. mainTextureFixedSize?: number;
  115943. /**
  115944. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  115945. */
  115946. alphaBlendingMode: number;
  115947. /**
  115948. * The camera attached to the layer.
  115949. */
  115950. camera: Nullable<Camera>;
  115951. /**
  115952. * The rendering group to draw the layer in.
  115953. */
  115954. renderingGroupId: number;
  115955. }
  115956. /**
  115957. * The effect layer Helps adding post process effect blended with the main pass.
  115958. *
  115959. * This can be for instance use to generate glow or higlight effects on the scene.
  115960. *
  115961. * The effect layer class can not be used directly and is intented to inherited from to be
  115962. * customized per effects.
  115963. */
  115964. export abstract class EffectLayer {
  115965. private _vertexBuffers;
  115966. private _indexBuffer;
  115967. private _cachedDefines;
  115968. private _effectLayerMapGenerationEffect;
  115969. private _effectLayerOptions;
  115970. private _mergeEffect;
  115971. protected _scene: Scene;
  115972. protected _engine: Engine;
  115973. protected _maxSize: number;
  115974. protected _mainTextureDesiredSize: ISize;
  115975. protected _mainTexture: RenderTargetTexture;
  115976. protected _shouldRender: boolean;
  115977. protected _postProcesses: PostProcess[];
  115978. protected _textures: BaseTexture[];
  115979. protected _emissiveTextureAndColor: {
  115980. texture: Nullable<BaseTexture>;
  115981. color: Color4;
  115982. };
  115983. /**
  115984. * The name of the layer
  115985. */
  115986. name: string;
  115987. /**
  115988. * The clear color of the texture used to generate the glow map.
  115989. */
  115990. neutralColor: Color4;
  115991. /**
  115992. * Specifies wether the highlight layer is enabled or not.
  115993. */
  115994. isEnabled: boolean;
  115995. /**
  115996. * Gets the camera attached to the layer.
  115997. */
  115998. readonly camera: Nullable<Camera>;
  115999. /**
  116000. * Gets the rendering group id the layer should render in.
  116001. */
  116002. renderingGroupId: number;
  116003. /**
  116004. * An event triggered when the effect layer has been disposed.
  116005. */
  116006. onDisposeObservable: Observable<EffectLayer>;
  116007. /**
  116008. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116009. */
  116010. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116011. /**
  116012. * An event triggered when the generated texture is being merged in the scene.
  116013. */
  116014. onBeforeComposeObservable: Observable<EffectLayer>;
  116015. /**
  116016. * An event triggered when the generated texture has been merged in the scene.
  116017. */
  116018. onAfterComposeObservable: Observable<EffectLayer>;
  116019. /**
  116020. * An event triggered when the efffect layer changes its size.
  116021. */
  116022. onSizeChangedObservable: Observable<EffectLayer>;
  116023. /** @hidden */
  116024. static _SceneComponentInitialization: (scene: Scene) => void;
  116025. /**
  116026. * Instantiates a new effect Layer and references it in the scene.
  116027. * @param name The name of the layer
  116028. * @param scene The scene to use the layer in
  116029. */
  116030. constructor(
  116031. /** The Friendly of the effect in the scene */
  116032. name: string, scene: Scene);
  116033. /**
  116034. * Get the effect name of the layer.
  116035. * @return The effect name
  116036. */
  116037. abstract getEffectName(): string;
  116038. /**
  116039. * Checks for the readiness of the element composing the layer.
  116040. * @param subMesh the mesh to check for
  116041. * @param useInstances specify wether or not to use instances to render the mesh
  116042. * @return true if ready otherwise, false
  116043. */
  116044. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116045. /**
  116046. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116047. * @returns true if the effect requires stencil during the main canvas render pass.
  116048. */
  116049. abstract needStencil(): boolean;
  116050. /**
  116051. * Create the merge effect. This is the shader use to blit the information back
  116052. * to the main canvas at the end of the scene rendering.
  116053. * @returns The effect containing the shader used to merge the effect on the main canvas
  116054. */
  116055. protected abstract _createMergeEffect(): Effect;
  116056. /**
  116057. * Creates the render target textures and post processes used in the effect layer.
  116058. */
  116059. protected abstract _createTextureAndPostProcesses(): void;
  116060. /**
  116061. * Implementation specific of rendering the generating effect on the main canvas.
  116062. * @param effect The effect used to render through
  116063. */
  116064. protected abstract _internalRender(effect: Effect): void;
  116065. /**
  116066. * Sets the required values for both the emissive texture and and the main color.
  116067. */
  116068. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116069. /**
  116070. * Free any resources and references associated to a mesh.
  116071. * Internal use
  116072. * @param mesh The mesh to free.
  116073. */
  116074. abstract _disposeMesh(mesh: Mesh): void;
  116075. /**
  116076. * Serializes this layer (Glow or Highlight for example)
  116077. * @returns a serialized layer object
  116078. */
  116079. abstract serialize?(): any;
  116080. /**
  116081. * Initializes the effect layer with the required options.
  116082. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116083. */
  116084. protected _init(options: Partial<IEffectLayerOptions>): void;
  116085. /**
  116086. * Generates the index buffer of the full screen quad blending to the main canvas.
  116087. */
  116088. private _generateIndexBuffer;
  116089. /**
  116090. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116091. */
  116092. private _generateVertexBuffer;
  116093. /**
  116094. * Sets the main texture desired size which is the closest power of two
  116095. * of the engine canvas size.
  116096. */
  116097. private _setMainTextureSize;
  116098. /**
  116099. * Creates the main texture for the effect layer.
  116100. */
  116101. protected _createMainTexture(): void;
  116102. /**
  116103. * Adds specific effects defines.
  116104. * @param defines The defines to add specifics to.
  116105. */
  116106. protected _addCustomEffectDefines(defines: string[]): void;
  116107. /**
  116108. * Checks for the readiness of the element composing the layer.
  116109. * @param subMesh the mesh to check for
  116110. * @param useInstances specify wether or not to use instances to render the mesh
  116111. * @param emissiveTexture the associated emissive texture used to generate the glow
  116112. * @return true if ready otherwise, false
  116113. */
  116114. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116115. /**
  116116. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116117. */
  116118. render(): void;
  116119. /**
  116120. * Determine if a given mesh will be used in the current effect.
  116121. * @param mesh mesh to test
  116122. * @returns true if the mesh will be used
  116123. */
  116124. hasMesh(mesh: AbstractMesh): boolean;
  116125. /**
  116126. * Returns true if the layer contains information to display, otherwise false.
  116127. * @returns true if the glow layer should be rendered
  116128. */
  116129. shouldRender(): boolean;
  116130. /**
  116131. * Returns true if the mesh should render, otherwise false.
  116132. * @param mesh The mesh to render
  116133. * @returns true if it should render otherwise false
  116134. */
  116135. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116136. /**
  116137. * Returns true if the mesh can be rendered, otherwise false.
  116138. * @param mesh The mesh to render
  116139. * @param material The material used on the mesh
  116140. * @returns true if it can be rendered otherwise false
  116141. */
  116142. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116143. /**
  116144. * Returns true if the mesh should render, otherwise false.
  116145. * @param mesh The mesh to render
  116146. * @returns true if it should render otherwise false
  116147. */
  116148. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116149. /**
  116150. * Renders the submesh passed in parameter to the generation map.
  116151. */
  116152. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116153. /**
  116154. * Rebuild the required buffers.
  116155. * @hidden Internal use only.
  116156. */
  116157. _rebuild(): void;
  116158. /**
  116159. * Dispose only the render target textures and post process.
  116160. */
  116161. private _disposeTextureAndPostProcesses;
  116162. /**
  116163. * Dispose the highlight layer and free resources.
  116164. */
  116165. dispose(): void;
  116166. /**
  116167. * Gets the class name of the effect layer
  116168. * @returns the string with the class name of the effect layer
  116169. */
  116170. getClassName(): string;
  116171. /**
  116172. * Creates an effect layer from parsed effect layer data
  116173. * @param parsedEffectLayer defines effect layer data
  116174. * @param scene defines the current scene
  116175. * @param rootUrl defines the root URL containing the effect layer information
  116176. * @returns a parsed effect Layer
  116177. */
  116178. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116179. }
  116180. }
  116181. declare module BABYLON {
  116182. interface AbstractScene {
  116183. /**
  116184. * The list of effect layers (highlights/glow) added to the scene
  116185. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116186. * @see http://doc.babylonjs.com/how_to/glow_layer
  116187. */
  116188. effectLayers: Array<EffectLayer>;
  116189. /**
  116190. * Removes the given effect layer from this scene.
  116191. * @param toRemove defines the effect layer to remove
  116192. * @returns the index of the removed effect layer
  116193. */
  116194. removeEffectLayer(toRemove: EffectLayer): number;
  116195. /**
  116196. * Adds the given effect layer to this scene
  116197. * @param newEffectLayer defines the effect layer to add
  116198. */
  116199. addEffectLayer(newEffectLayer: EffectLayer): void;
  116200. }
  116201. /**
  116202. * Defines the layer scene component responsible to manage any effect layers
  116203. * in a given scene.
  116204. */
  116205. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116206. /**
  116207. * The component name helpfull to identify the component in the list of scene components.
  116208. */
  116209. readonly name: string;
  116210. /**
  116211. * The scene the component belongs to.
  116212. */
  116213. scene: Scene;
  116214. private _engine;
  116215. private _renderEffects;
  116216. private _needStencil;
  116217. private _previousStencilState;
  116218. /**
  116219. * Creates a new instance of the component for the given scene
  116220. * @param scene Defines the scene to register the component in
  116221. */
  116222. constructor(scene: Scene);
  116223. /**
  116224. * Registers the component in a given scene
  116225. */
  116226. register(): void;
  116227. /**
  116228. * Rebuilds the elements related to this component in case of
  116229. * context lost for instance.
  116230. */
  116231. rebuild(): void;
  116232. /**
  116233. * Serializes the component data to the specified json object
  116234. * @param serializationObject The object to serialize to
  116235. */
  116236. serialize(serializationObject: any): void;
  116237. /**
  116238. * Adds all the elements from the container to the scene
  116239. * @param container the container holding the elements
  116240. */
  116241. addFromContainer(container: AbstractScene): void;
  116242. /**
  116243. * Removes all the elements in the container from the scene
  116244. * @param container contains the elements to remove
  116245. * @param dispose if the removed element should be disposed (default: false)
  116246. */
  116247. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116248. /**
  116249. * Disposes the component and the associated ressources.
  116250. */
  116251. dispose(): void;
  116252. private _isReadyForMesh;
  116253. private _renderMainTexture;
  116254. private _setStencil;
  116255. private _setStencilBack;
  116256. private _draw;
  116257. private _drawCamera;
  116258. private _drawRenderingGroup;
  116259. }
  116260. }
  116261. declare module BABYLON {
  116262. /** @hidden */
  116263. export var glowMapMergePixelShader: {
  116264. name: string;
  116265. shader: string;
  116266. };
  116267. }
  116268. declare module BABYLON {
  116269. /** @hidden */
  116270. export var glowMapMergeVertexShader: {
  116271. name: string;
  116272. shader: string;
  116273. };
  116274. }
  116275. declare module BABYLON {
  116276. interface AbstractScene {
  116277. /**
  116278. * Return a the first highlight layer of the scene with a given name.
  116279. * @param name The name of the highlight layer to look for.
  116280. * @return The highlight layer if found otherwise null.
  116281. */
  116282. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116283. }
  116284. /**
  116285. * Glow layer options. This helps customizing the behaviour
  116286. * of the glow layer.
  116287. */
  116288. export interface IGlowLayerOptions {
  116289. /**
  116290. * Multiplication factor apply to the canvas size to compute the render target size
  116291. * used to generated the glowing objects (the smaller the faster).
  116292. */
  116293. mainTextureRatio: number;
  116294. /**
  116295. * Enforces a fixed size texture to ensure resize independant blur.
  116296. */
  116297. mainTextureFixedSize?: number;
  116298. /**
  116299. * How big is the kernel of the blur texture.
  116300. */
  116301. blurKernelSize: number;
  116302. /**
  116303. * The camera attached to the layer.
  116304. */
  116305. camera: Nullable<Camera>;
  116306. /**
  116307. * Enable MSAA by chosing the number of samples.
  116308. */
  116309. mainTextureSamples?: number;
  116310. /**
  116311. * The rendering group to draw the layer in.
  116312. */
  116313. renderingGroupId: number;
  116314. }
  116315. /**
  116316. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116317. *
  116318. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116319. * glowy meshes to your scene.
  116320. *
  116321. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116322. */
  116323. export class GlowLayer extends EffectLayer {
  116324. /**
  116325. * Effect Name of the layer.
  116326. */
  116327. static readonly EffectName: string;
  116328. /**
  116329. * The default blur kernel size used for the glow.
  116330. */
  116331. static DefaultBlurKernelSize: number;
  116332. /**
  116333. * The default texture size ratio used for the glow.
  116334. */
  116335. static DefaultTextureRatio: number;
  116336. /**
  116337. * Sets the kernel size of the blur.
  116338. */
  116339. /**
  116340. * Gets the kernel size of the blur.
  116341. */
  116342. blurKernelSize: number;
  116343. /**
  116344. * Sets the glow intensity.
  116345. */
  116346. /**
  116347. * Gets the glow intensity.
  116348. */
  116349. intensity: number;
  116350. private _options;
  116351. private _intensity;
  116352. private _horizontalBlurPostprocess1;
  116353. private _verticalBlurPostprocess1;
  116354. private _horizontalBlurPostprocess2;
  116355. private _verticalBlurPostprocess2;
  116356. private _blurTexture1;
  116357. private _blurTexture2;
  116358. private _postProcesses1;
  116359. private _postProcesses2;
  116360. private _includedOnlyMeshes;
  116361. private _excludedMeshes;
  116362. /**
  116363. * Callback used to let the user override the color selection on a per mesh basis
  116364. */
  116365. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116366. /**
  116367. * Callback used to let the user override the texture selection on a per mesh basis
  116368. */
  116369. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116370. /**
  116371. * Instantiates a new glow Layer and references it to the scene.
  116372. * @param name The name of the layer
  116373. * @param scene The scene to use the layer in
  116374. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116375. */
  116376. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116377. /**
  116378. * Get the effect name of the layer.
  116379. * @return The effect name
  116380. */
  116381. getEffectName(): string;
  116382. /**
  116383. * Create the merge effect. This is the shader use to blit the information back
  116384. * to the main canvas at the end of the scene rendering.
  116385. */
  116386. protected _createMergeEffect(): Effect;
  116387. /**
  116388. * Creates the render target textures and post processes used in the glow layer.
  116389. */
  116390. protected _createTextureAndPostProcesses(): void;
  116391. /**
  116392. * Checks for the readiness of the element composing the layer.
  116393. * @param subMesh the mesh to check for
  116394. * @param useInstances specify wether or not to use instances to render the mesh
  116395. * @param emissiveTexture the associated emissive texture used to generate the glow
  116396. * @return true if ready otherwise, false
  116397. */
  116398. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116399. /**
  116400. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116401. */
  116402. needStencil(): boolean;
  116403. /**
  116404. * Returns true if the mesh can be rendered, otherwise false.
  116405. * @param mesh The mesh to render
  116406. * @param material The material used on the mesh
  116407. * @returns true if it can be rendered otherwise false
  116408. */
  116409. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116410. /**
  116411. * Implementation specific of rendering the generating effect on the main canvas.
  116412. * @param effect The effect used to render through
  116413. */
  116414. protected _internalRender(effect: Effect): void;
  116415. /**
  116416. * Sets the required values for both the emissive texture and and the main color.
  116417. */
  116418. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116419. /**
  116420. * Returns true if the mesh should render, otherwise false.
  116421. * @param mesh The mesh to render
  116422. * @returns true if it should render otherwise false
  116423. */
  116424. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116425. /**
  116426. * Adds specific effects defines.
  116427. * @param defines The defines to add specifics to.
  116428. */
  116429. protected _addCustomEffectDefines(defines: string[]): void;
  116430. /**
  116431. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116432. * @param mesh The mesh to exclude from the glow layer
  116433. */
  116434. addExcludedMesh(mesh: Mesh): void;
  116435. /**
  116436. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116437. * @param mesh The mesh to remove
  116438. */
  116439. removeExcludedMesh(mesh: Mesh): void;
  116440. /**
  116441. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116442. * @param mesh The mesh to include in the glow layer
  116443. */
  116444. addIncludedOnlyMesh(mesh: Mesh): void;
  116445. /**
  116446. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116447. * @param mesh The mesh to remove
  116448. */
  116449. removeIncludedOnlyMesh(mesh: Mesh): void;
  116450. /**
  116451. * Determine if a given mesh will be used in the glow layer
  116452. * @param mesh The mesh to test
  116453. * @returns true if the mesh will be highlighted by the current glow layer
  116454. */
  116455. hasMesh(mesh: AbstractMesh): boolean;
  116456. /**
  116457. * Free any resources and references associated to a mesh.
  116458. * Internal use
  116459. * @param mesh The mesh to free.
  116460. * @hidden
  116461. */
  116462. _disposeMesh(mesh: Mesh): void;
  116463. /**
  116464. * Gets the class name of the effect layer
  116465. * @returns the string with the class name of the effect layer
  116466. */
  116467. getClassName(): string;
  116468. /**
  116469. * Serializes this glow layer
  116470. * @returns a serialized glow layer object
  116471. */
  116472. serialize(): any;
  116473. /**
  116474. * Creates a Glow Layer from parsed glow layer data
  116475. * @param parsedGlowLayer defines glow layer data
  116476. * @param scene defines the current scene
  116477. * @param rootUrl defines the root URL containing the glow layer information
  116478. * @returns a parsed Glow Layer
  116479. */
  116480. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116481. }
  116482. }
  116483. declare module BABYLON {
  116484. /** @hidden */
  116485. export var glowBlurPostProcessPixelShader: {
  116486. name: string;
  116487. shader: string;
  116488. };
  116489. }
  116490. declare module BABYLON {
  116491. interface AbstractScene {
  116492. /**
  116493. * Return a the first highlight layer of the scene with a given name.
  116494. * @param name The name of the highlight layer to look for.
  116495. * @return The highlight layer if found otherwise null.
  116496. */
  116497. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116498. }
  116499. /**
  116500. * Highlight layer options. This helps customizing the behaviour
  116501. * of the highlight layer.
  116502. */
  116503. export interface IHighlightLayerOptions {
  116504. /**
  116505. * Multiplication factor apply to the canvas size to compute the render target size
  116506. * used to generated the glowing objects (the smaller the faster).
  116507. */
  116508. mainTextureRatio: number;
  116509. /**
  116510. * Enforces a fixed size texture to ensure resize independant blur.
  116511. */
  116512. mainTextureFixedSize?: number;
  116513. /**
  116514. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116515. * of the picture to blur (the smaller the faster).
  116516. */
  116517. blurTextureSizeRatio: number;
  116518. /**
  116519. * How big in texel of the blur texture is the vertical blur.
  116520. */
  116521. blurVerticalSize: number;
  116522. /**
  116523. * How big in texel of the blur texture is the horizontal blur.
  116524. */
  116525. blurHorizontalSize: number;
  116526. /**
  116527. * Alpha blending mode used to apply the blur. Default is combine.
  116528. */
  116529. alphaBlendingMode: number;
  116530. /**
  116531. * The camera attached to the layer.
  116532. */
  116533. camera: Nullable<Camera>;
  116534. /**
  116535. * Should we display highlight as a solid stroke?
  116536. */
  116537. isStroke?: boolean;
  116538. /**
  116539. * The rendering group to draw the layer in.
  116540. */
  116541. renderingGroupId: number;
  116542. }
  116543. /**
  116544. * The highlight layer Helps adding a glow effect around a mesh.
  116545. *
  116546. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116547. * glowy meshes to your scene.
  116548. *
  116549. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116550. */
  116551. export class HighlightLayer extends EffectLayer {
  116552. name: string;
  116553. /**
  116554. * Effect Name of the highlight layer.
  116555. */
  116556. static readonly EffectName: string;
  116557. /**
  116558. * The neutral color used during the preparation of the glow effect.
  116559. * This is black by default as the blend operation is a blend operation.
  116560. */
  116561. static NeutralColor: Color4;
  116562. /**
  116563. * Stencil value used for glowing meshes.
  116564. */
  116565. static GlowingMeshStencilReference: number;
  116566. /**
  116567. * Stencil value used for the other meshes in the scene.
  116568. */
  116569. static NormalMeshStencilReference: number;
  116570. /**
  116571. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116572. */
  116573. innerGlow: boolean;
  116574. /**
  116575. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116576. */
  116577. outerGlow: boolean;
  116578. /**
  116579. * Specifies the horizontal size of the blur.
  116580. */
  116581. /**
  116582. * Gets the horizontal size of the blur.
  116583. */
  116584. blurHorizontalSize: number;
  116585. /**
  116586. * Specifies the vertical size of the blur.
  116587. */
  116588. /**
  116589. * Gets the vertical size of the blur.
  116590. */
  116591. blurVerticalSize: number;
  116592. /**
  116593. * An event triggered when the highlight layer is being blurred.
  116594. */
  116595. onBeforeBlurObservable: Observable<HighlightLayer>;
  116596. /**
  116597. * An event triggered when the highlight layer has been blurred.
  116598. */
  116599. onAfterBlurObservable: Observable<HighlightLayer>;
  116600. private _instanceGlowingMeshStencilReference;
  116601. private _options;
  116602. private _downSamplePostprocess;
  116603. private _horizontalBlurPostprocess;
  116604. private _verticalBlurPostprocess;
  116605. private _blurTexture;
  116606. private _meshes;
  116607. private _excludedMeshes;
  116608. /**
  116609. * Instantiates a new highlight Layer and references it to the scene..
  116610. * @param name The name of the layer
  116611. * @param scene The scene to use the layer in
  116612. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116613. */
  116614. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116615. /**
  116616. * Get the effect name of the layer.
  116617. * @return The effect name
  116618. */
  116619. getEffectName(): string;
  116620. /**
  116621. * Create the merge effect. This is the shader use to blit the information back
  116622. * to the main canvas at the end of the scene rendering.
  116623. */
  116624. protected _createMergeEffect(): Effect;
  116625. /**
  116626. * Creates the render target textures and post processes used in the highlight layer.
  116627. */
  116628. protected _createTextureAndPostProcesses(): void;
  116629. /**
  116630. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116631. */
  116632. needStencil(): boolean;
  116633. /**
  116634. * Checks for the readiness of the element composing the layer.
  116635. * @param subMesh the mesh to check for
  116636. * @param useInstances specify wether or not to use instances to render the mesh
  116637. * @param emissiveTexture the associated emissive texture used to generate the glow
  116638. * @return true if ready otherwise, false
  116639. */
  116640. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116641. /**
  116642. * Implementation specific of rendering the generating effect on the main canvas.
  116643. * @param effect The effect used to render through
  116644. */
  116645. protected _internalRender(effect: Effect): void;
  116646. /**
  116647. * Returns true if the layer contains information to display, otherwise false.
  116648. */
  116649. shouldRender(): boolean;
  116650. /**
  116651. * Returns true if the mesh should render, otherwise false.
  116652. * @param mesh The mesh to render
  116653. * @returns true if it should render otherwise false
  116654. */
  116655. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116656. /**
  116657. * Sets the required values for both the emissive texture and and the main color.
  116658. */
  116659. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116660. /**
  116661. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116662. * @param mesh The mesh to exclude from the highlight layer
  116663. */
  116664. addExcludedMesh(mesh: Mesh): void;
  116665. /**
  116666. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116667. * @param mesh The mesh to highlight
  116668. */
  116669. removeExcludedMesh(mesh: Mesh): void;
  116670. /**
  116671. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116672. * @param mesh mesh to test
  116673. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116674. */
  116675. hasMesh(mesh: AbstractMesh): boolean;
  116676. /**
  116677. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116678. * @param mesh The mesh to highlight
  116679. * @param color The color of the highlight
  116680. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116681. */
  116682. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116683. /**
  116684. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116685. * @param mesh The mesh to highlight
  116686. */
  116687. removeMesh(mesh: Mesh): void;
  116688. /**
  116689. * Force the stencil to the normal expected value for none glowing parts
  116690. */
  116691. private _defaultStencilReference;
  116692. /**
  116693. * Free any resources and references associated to a mesh.
  116694. * Internal use
  116695. * @param mesh The mesh to free.
  116696. * @hidden
  116697. */
  116698. _disposeMesh(mesh: Mesh): void;
  116699. /**
  116700. * Dispose the highlight layer and free resources.
  116701. */
  116702. dispose(): void;
  116703. /**
  116704. * Gets the class name of the effect layer
  116705. * @returns the string with the class name of the effect layer
  116706. */
  116707. getClassName(): string;
  116708. /**
  116709. * Serializes this Highlight layer
  116710. * @returns a serialized Highlight layer object
  116711. */
  116712. serialize(): any;
  116713. /**
  116714. * Creates a Highlight layer from parsed Highlight layer data
  116715. * @param parsedHightlightLayer defines the Highlight layer data
  116716. * @param scene defines the current scene
  116717. * @param rootUrl defines the root URL containing the Highlight layer information
  116718. * @returns a parsed Highlight layer
  116719. */
  116720. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116721. }
  116722. }
  116723. declare module BABYLON {
  116724. interface AbstractScene {
  116725. /**
  116726. * The list of layers (background and foreground) of the scene
  116727. */
  116728. layers: Array<Layer>;
  116729. }
  116730. /**
  116731. * Defines the layer scene component responsible to manage any layers
  116732. * in a given scene.
  116733. */
  116734. export class LayerSceneComponent implements ISceneComponent {
  116735. /**
  116736. * The component name helpfull to identify the component in the list of scene components.
  116737. */
  116738. readonly name: string;
  116739. /**
  116740. * The scene the component belongs to.
  116741. */
  116742. scene: Scene;
  116743. private _engine;
  116744. /**
  116745. * Creates a new instance of the component for the given scene
  116746. * @param scene Defines the scene to register the component in
  116747. */
  116748. constructor(scene: Scene);
  116749. /**
  116750. * Registers the component in a given scene
  116751. */
  116752. register(): void;
  116753. /**
  116754. * Rebuilds the elements related to this component in case of
  116755. * context lost for instance.
  116756. */
  116757. rebuild(): void;
  116758. /**
  116759. * Disposes the component and the associated ressources.
  116760. */
  116761. dispose(): void;
  116762. private _draw;
  116763. private _drawCameraPredicate;
  116764. private _drawCameraBackground;
  116765. private _drawCameraForeground;
  116766. private _drawRenderTargetPredicate;
  116767. private _drawRenderTargetBackground;
  116768. private _drawRenderTargetForeground;
  116769. /**
  116770. * Adds all the elements from the container to the scene
  116771. * @param container the container holding the elements
  116772. */
  116773. addFromContainer(container: AbstractScene): void;
  116774. /**
  116775. * Removes all the elements in the container from the scene
  116776. * @param container contains the elements to remove
  116777. * @param dispose if the removed element should be disposed (default: false)
  116778. */
  116779. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116780. }
  116781. }
  116782. declare module BABYLON {
  116783. /** @hidden */
  116784. export var layerPixelShader: {
  116785. name: string;
  116786. shader: string;
  116787. };
  116788. }
  116789. declare module BABYLON {
  116790. /** @hidden */
  116791. export var layerVertexShader: {
  116792. name: string;
  116793. shader: string;
  116794. };
  116795. }
  116796. declare module BABYLON {
  116797. /**
  116798. * This represents a full screen 2d layer.
  116799. * This can be useful to display a picture in the background of your scene for instance.
  116800. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116801. */
  116802. export class Layer {
  116803. /**
  116804. * Define the name of the layer.
  116805. */
  116806. name: string;
  116807. /**
  116808. * Define the texture the layer should display.
  116809. */
  116810. texture: Nullable<Texture>;
  116811. /**
  116812. * Is the layer in background or foreground.
  116813. */
  116814. isBackground: boolean;
  116815. /**
  116816. * Define the color of the layer (instead of texture).
  116817. */
  116818. color: Color4;
  116819. /**
  116820. * Define the scale of the layer in order to zoom in out of the texture.
  116821. */
  116822. scale: Vector2;
  116823. /**
  116824. * Define an offset for the layer in order to shift the texture.
  116825. */
  116826. offset: Vector2;
  116827. /**
  116828. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116829. */
  116830. alphaBlendingMode: number;
  116831. /**
  116832. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116833. * Alpha test will not mix with the background color in case of transparency.
  116834. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116835. */
  116836. alphaTest: boolean;
  116837. /**
  116838. * Define a mask to restrict the layer to only some of the scene cameras.
  116839. */
  116840. layerMask: number;
  116841. /**
  116842. * Define the list of render target the layer is visible into.
  116843. */
  116844. renderTargetTextures: RenderTargetTexture[];
  116845. /**
  116846. * Define if the layer is only used in renderTarget or if it also
  116847. * renders in the main frame buffer of the canvas.
  116848. */
  116849. renderOnlyInRenderTargetTextures: boolean;
  116850. private _scene;
  116851. private _vertexBuffers;
  116852. private _indexBuffer;
  116853. private _effect;
  116854. private _alphaTestEffect;
  116855. /**
  116856. * An event triggered when the layer is disposed.
  116857. */
  116858. onDisposeObservable: Observable<Layer>;
  116859. private _onDisposeObserver;
  116860. /**
  116861. * Back compatibility with callback before the onDisposeObservable existed.
  116862. * The set callback will be triggered when the layer has been disposed.
  116863. */
  116864. onDispose: () => void;
  116865. /**
  116866. * An event triggered before rendering the scene
  116867. */
  116868. onBeforeRenderObservable: Observable<Layer>;
  116869. private _onBeforeRenderObserver;
  116870. /**
  116871. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116872. * The set callback will be triggered just before rendering the layer.
  116873. */
  116874. onBeforeRender: () => void;
  116875. /**
  116876. * An event triggered after rendering the scene
  116877. */
  116878. onAfterRenderObservable: Observable<Layer>;
  116879. private _onAfterRenderObserver;
  116880. /**
  116881. * Back compatibility with callback before the onAfterRenderObservable existed.
  116882. * The set callback will be triggered just after rendering the layer.
  116883. */
  116884. onAfterRender: () => void;
  116885. /**
  116886. * Instantiates a new layer.
  116887. * This represents a full screen 2d layer.
  116888. * This can be useful to display a picture in the background of your scene for instance.
  116889. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116890. * @param name Define the name of the layer in the scene
  116891. * @param imgUrl Define the url of the texture to display in the layer
  116892. * @param scene Define the scene the layer belongs to
  116893. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116894. * @param color Defines a color for the layer
  116895. */
  116896. constructor(
  116897. /**
  116898. * Define the name of the layer.
  116899. */
  116900. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  116901. private _createIndexBuffer;
  116902. /** @hidden */
  116903. _rebuild(): void;
  116904. /**
  116905. * Renders the layer in the scene.
  116906. */
  116907. render(): void;
  116908. /**
  116909. * Disposes and releases the associated ressources.
  116910. */
  116911. dispose(): void;
  116912. }
  116913. }
  116914. declare module BABYLON {
  116915. /** @hidden */
  116916. export var lensFlarePixelShader: {
  116917. name: string;
  116918. shader: string;
  116919. };
  116920. }
  116921. declare module BABYLON {
  116922. /** @hidden */
  116923. export var lensFlareVertexShader: {
  116924. name: string;
  116925. shader: string;
  116926. };
  116927. }
  116928. declare module BABYLON {
  116929. /**
  116930. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116931. * It is usually composed of several `lensFlare`.
  116932. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116933. */
  116934. export class LensFlareSystem {
  116935. /**
  116936. * Define the name of the lens flare system
  116937. */
  116938. name: string;
  116939. /**
  116940. * List of lens flares used in this system.
  116941. */
  116942. lensFlares: LensFlare[];
  116943. /**
  116944. * Define a limit from the border the lens flare can be visible.
  116945. */
  116946. borderLimit: number;
  116947. /**
  116948. * Define a viewport border we do not want to see the lens flare in.
  116949. */
  116950. viewportBorder: number;
  116951. /**
  116952. * Define a predicate which could limit the list of meshes able to occlude the effect.
  116953. */
  116954. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  116955. /**
  116956. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  116957. */
  116958. layerMask: number;
  116959. /**
  116960. * Define the id of the lens flare system in the scene.
  116961. * (equal to name by default)
  116962. */
  116963. id: string;
  116964. private _scene;
  116965. private _emitter;
  116966. private _vertexBuffers;
  116967. private _indexBuffer;
  116968. private _effect;
  116969. private _positionX;
  116970. private _positionY;
  116971. private _isEnabled;
  116972. /** @hidden */
  116973. static _SceneComponentInitialization: (scene: Scene) => void;
  116974. /**
  116975. * Instantiates a lens flare system.
  116976. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116977. * It is usually composed of several `lensFlare`.
  116978. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116979. * @param name Define the name of the lens flare system in the scene
  116980. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  116981. * @param scene Define the scene the lens flare system belongs to
  116982. */
  116983. constructor(
  116984. /**
  116985. * Define the name of the lens flare system
  116986. */
  116987. name: string, emitter: any, scene: Scene);
  116988. /**
  116989. * Define if the lens flare system is enabled.
  116990. */
  116991. isEnabled: boolean;
  116992. /**
  116993. * Get the scene the effects belongs to.
  116994. * @returns the scene holding the lens flare system
  116995. */
  116996. getScene(): Scene;
  116997. /**
  116998. * Get the emitter of the lens flare system.
  116999. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117000. * @returns the emitter of the lens flare system
  117001. */
  117002. getEmitter(): any;
  117003. /**
  117004. * Set the emitter of the lens flare system.
  117005. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117006. * @param newEmitter Define the new emitter of the system
  117007. */
  117008. setEmitter(newEmitter: any): void;
  117009. /**
  117010. * Get the lens flare system emitter position.
  117011. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117012. * @returns the position
  117013. */
  117014. getEmitterPosition(): Vector3;
  117015. /**
  117016. * @hidden
  117017. */
  117018. computeEffectivePosition(globalViewport: Viewport): boolean;
  117019. /** @hidden */
  117020. _isVisible(): boolean;
  117021. /**
  117022. * @hidden
  117023. */
  117024. render(): boolean;
  117025. /**
  117026. * Dispose and release the lens flare with its associated resources.
  117027. */
  117028. dispose(): void;
  117029. /**
  117030. * Parse a lens flare system from a JSON repressentation
  117031. * @param parsedLensFlareSystem Define the JSON to parse
  117032. * @param scene Define the scene the parsed system should be instantiated in
  117033. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117034. * @returns the parsed system
  117035. */
  117036. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117037. /**
  117038. * Serialize the current Lens Flare System into a JSON representation.
  117039. * @returns the serialized JSON
  117040. */
  117041. serialize(): any;
  117042. }
  117043. }
  117044. declare module BABYLON {
  117045. /**
  117046. * This represents one of the lens effect in a `lensFlareSystem`.
  117047. * It controls one of the indiviual texture used in the effect.
  117048. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117049. */
  117050. export class LensFlare {
  117051. /**
  117052. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117053. */
  117054. size: number;
  117055. /**
  117056. * 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.
  117057. */
  117058. position: number;
  117059. /**
  117060. * Define the lens color.
  117061. */
  117062. color: Color3;
  117063. /**
  117064. * Define the lens texture.
  117065. */
  117066. texture: Nullable<Texture>;
  117067. /**
  117068. * Define the alpha mode to render this particular lens.
  117069. */
  117070. alphaMode: number;
  117071. private _system;
  117072. /**
  117073. * Creates a new Lens Flare.
  117074. * This represents one of the lens effect in a `lensFlareSystem`.
  117075. * It controls one of the indiviual texture used in the effect.
  117076. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117077. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117078. * @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.
  117079. * @param color Define the lens color
  117080. * @param imgUrl Define the lens texture url
  117081. * @param system Define the `lensFlareSystem` this flare is part of
  117082. * @returns The newly created Lens Flare
  117083. */
  117084. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117085. /**
  117086. * Instantiates a new Lens Flare.
  117087. * This represents one of the lens effect in a `lensFlareSystem`.
  117088. * It controls one of the indiviual texture used in the effect.
  117089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117090. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117091. * @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.
  117092. * @param color Define the lens color
  117093. * @param imgUrl Define the lens texture url
  117094. * @param system Define the `lensFlareSystem` this flare is part of
  117095. */
  117096. constructor(
  117097. /**
  117098. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117099. */
  117100. size: number,
  117101. /**
  117102. * 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.
  117103. */
  117104. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117105. /**
  117106. * Dispose and release the lens flare with its associated resources.
  117107. */
  117108. dispose(): void;
  117109. }
  117110. }
  117111. declare module BABYLON {
  117112. interface AbstractScene {
  117113. /**
  117114. * The list of lens flare system added to the scene
  117115. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117116. */
  117117. lensFlareSystems: Array<LensFlareSystem>;
  117118. /**
  117119. * Removes the given lens flare system from this scene.
  117120. * @param toRemove The lens flare system to remove
  117121. * @returns The index of the removed lens flare system
  117122. */
  117123. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117124. /**
  117125. * Adds the given lens flare system to this scene
  117126. * @param newLensFlareSystem The lens flare system to add
  117127. */
  117128. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117129. /**
  117130. * Gets a lens flare system using its name
  117131. * @param name defines the name to look for
  117132. * @returns the lens flare system or null if not found
  117133. */
  117134. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117135. /**
  117136. * Gets a lens flare system using its id
  117137. * @param id defines the id to look for
  117138. * @returns the lens flare system or null if not found
  117139. */
  117140. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117141. }
  117142. /**
  117143. * Defines the lens flare scene component responsible to manage any lens flares
  117144. * in a given scene.
  117145. */
  117146. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117147. /**
  117148. * The component name helpfull to identify the component in the list of scene components.
  117149. */
  117150. readonly name: string;
  117151. /**
  117152. * The scene the component belongs to.
  117153. */
  117154. scene: Scene;
  117155. /**
  117156. * Creates a new instance of the component for the given scene
  117157. * @param scene Defines the scene to register the component in
  117158. */
  117159. constructor(scene: Scene);
  117160. /**
  117161. * Registers the component in a given scene
  117162. */
  117163. register(): void;
  117164. /**
  117165. * Rebuilds the elements related to this component in case of
  117166. * context lost for instance.
  117167. */
  117168. rebuild(): void;
  117169. /**
  117170. * Adds all the elements from the container to the scene
  117171. * @param container the container holding the elements
  117172. */
  117173. addFromContainer(container: AbstractScene): void;
  117174. /**
  117175. * Removes all the elements in the container from the scene
  117176. * @param container contains the elements to remove
  117177. * @param dispose if the removed element should be disposed (default: false)
  117178. */
  117179. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117180. /**
  117181. * Serializes the component data to the specified json object
  117182. * @param serializationObject The object to serialize to
  117183. */
  117184. serialize(serializationObject: any): void;
  117185. /**
  117186. * Disposes the component and the associated ressources.
  117187. */
  117188. dispose(): void;
  117189. private _draw;
  117190. }
  117191. }
  117192. declare module BABYLON {
  117193. /**
  117194. * Defines the shadow generator component responsible to manage any shadow generators
  117195. * in a given scene.
  117196. */
  117197. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117198. /**
  117199. * The component name helpfull to identify the component in the list of scene components.
  117200. */
  117201. readonly name: string;
  117202. /**
  117203. * The scene the component belongs to.
  117204. */
  117205. scene: Scene;
  117206. /**
  117207. * Creates a new instance of the component for the given scene
  117208. * @param scene Defines the scene to register the component in
  117209. */
  117210. constructor(scene: Scene);
  117211. /**
  117212. * Registers the component in a given scene
  117213. */
  117214. register(): void;
  117215. /**
  117216. * Rebuilds the elements related to this component in case of
  117217. * context lost for instance.
  117218. */
  117219. rebuild(): void;
  117220. /**
  117221. * Serializes the component data to the specified json object
  117222. * @param serializationObject The object to serialize to
  117223. */
  117224. serialize(serializationObject: any): void;
  117225. /**
  117226. * Adds all the elements from the container to the scene
  117227. * @param container the container holding the elements
  117228. */
  117229. addFromContainer(container: AbstractScene): void;
  117230. /**
  117231. * Removes all the elements in the container from the scene
  117232. * @param container contains the elements to remove
  117233. * @param dispose if the removed element should be disposed (default: false)
  117234. */
  117235. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117236. /**
  117237. * Rebuilds the elements related to this component in case of
  117238. * context lost for instance.
  117239. */
  117240. dispose(): void;
  117241. private _gatherRenderTargets;
  117242. }
  117243. }
  117244. declare module BABYLON {
  117245. /**
  117246. * A point light is a light defined by an unique point in world space.
  117247. * The light is emitted in every direction from this point.
  117248. * A good example of a point light is a standard light bulb.
  117249. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117250. */
  117251. export class PointLight extends ShadowLight {
  117252. private _shadowAngle;
  117253. /**
  117254. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117255. * This specifies what angle the shadow will use to be created.
  117256. *
  117257. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117258. */
  117259. /**
  117260. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117261. * This specifies what angle the shadow will use to be created.
  117262. *
  117263. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117264. */
  117265. shadowAngle: number;
  117266. /**
  117267. * Gets the direction if it has been set.
  117268. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117269. */
  117270. /**
  117271. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117272. */
  117273. direction: Vector3;
  117274. /**
  117275. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117276. * A PointLight emits the light in every direction.
  117277. * It can cast shadows.
  117278. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117279. * ```javascript
  117280. * var pointLight = new PointLight("pl", camera.position, scene);
  117281. * ```
  117282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117283. * @param name The light friendly name
  117284. * @param position The position of the point light in the scene
  117285. * @param scene The scene the lights belongs to
  117286. */
  117287. constructor(name: string, position: Vector3, scene: Scene);
  117288. /**
  117289. * Returns the string "PointLight"
  117290. * @returns the class name
  117291. */
  117292. getClassName(): string;
  117293. /**
  117294. * Returns the integer 0.
  117295. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117296. */
  117297. getTypeID(): number;
  117298. /**
  117299. * Specifies wether or not the shadowmap should be a cube texture.
  117300. * @returns true if the shadowmap needs to be a cube texture.
  117301. */
  117302. needCube(): boolean;
  117303. /**
  117304. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117305. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117306. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117307. */
  117308. getShadowDirection(faceIndex?: number): Vector3;
  117309. /**
  117310. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117311. * - fov = PI / 2
  117312. * - aspect ratio : 1.0
  117313. * - z-near and far equal to the active camera minZ and maxZ.
  117314. * Returns the PointLight.
  117315. */
  117316. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117317. protected _buildUniformLayout(): void;
  117318. /**
  117319. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117320. * @param effect The effect to update
  117321. * @param lightIndex The index of the light in the effect to update
  117322. * @returns The point light
  117323. */
  117324. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117325. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117326. /**
  117327. * Prepares the list of defines specific to the light type.
  117328. * @param defines the list of defines
  117329. * @param lightIndex defines the index of the light for the effect
  117330. */
  117331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117332. }
  117333. }
  117334. declare module BABYLON {
  117335. /**
  117336. * Header information of HDR texture files.
  117337. */
  117338. export interface HDRInfo {
  117339. /**
  117340. * The height of the texture in pixels.
  117341. */
  117342. height: number;
  117343. /**
  117344. * The width of the texture in pixels.
  117345. */
  117346. width: number;
  117347. /**
  117348. * The index of the beginning of the data in the binary file.
  117349. */
  117350. dataPosition: number;
  117351. }
  117352. /**
  117353. * This groups tools to convert HDR texture to native colors array.
  117354. */
  117355. export class HDRTools {
  117356. private static Ldexp;
  117357. private static Rgbe2float;
  117358. private static readStringLine;
  117359. /**
  117360. * Reads header information from an RGBE texture stored in a native array.
  117361. * More information on this format are available here:
  117362. * https://en.wikipedia.org/wiki/RGBE_image_format
  117363. *
  117364. * @param uint8array The binary file stored in native array.
  117365. * @return The header information.
  117366. */
  117367. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117368. /**
  117369. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117370. * This RGBE texture needs to store the information as a panorama.
  117371. *
  117372. * More information on this format are available here:
  117373. * https://en.wikipedia.org/wiki/RGBE_image_format
  117374. *
  117375. * @param buffer The binary file stored in an array buffer.
  117376. * @param size The expected size of the extracted cubemap.
  117377. * @return The Cube Map information.
  117378. */
  117379. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117380. /**
  117381. * Returns the pixels data extracted from an RGBE texture.
  117382. * This pixels will be stored left to right up to down in the R G B order in one array.
  117383. *
  117384. * More information on this format are available here:
  117385. * https://en.wikipedia.org/wiki/RGBE_image_format
  117386. *
  117387. * @param uint8array The binary file stored in an array buffer.
  117388. * @param hdrInfo The header information of the file.
  117389. * @return The pixels data in RGB right to left up to down order.
  117390. */
  117391. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117392. private static RGBE_ReadPixels_RLE;
  117393. }
  117394. }
  117395. declare module BABYLON {
  117396. /**
  117397. * This represents a texture coming from an HDR input.
  117398. *
  117399. * The only supported format is currently panorama picture stored in RGBE format.
  117400. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117401. */
  117402. export class HDRCubeTexture extends BaseTexture {
  117403. private static _facesMapping;
  117404. private _generateHarmonics;
  117405. private _noMipmap;
  117406. private _textureMatrix;
  117407. private _size;
  117408. private _onLoad;
  117409. private _onError;
  117410. /**
  117411. * The texture URL.
  117412. */
  117413. url: string;
  117414. /**
  117415. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117416. */
  117417. coordinatesMode: number;
  117418. protected _isBlocking: boolean;
  117419. /**
  117420. * Sets wether or not the texture is blocking during loading.
  117421. */
  117422. /**
  117423. * Gets wether or not the texture is blocking during loading.
  117424. */
  117425. isBlocking: boolean;
  117426. protected _rotationY: number;
  117427. /**
  117428. * Sets texture matrix rotation angle around Y axis in radians.
  117429. */
  117430. /**
  117431. * Gets texture matrix rotation angle around Y axis radians.
  117432. */
  117433. rotationY: number;
  117434. /**
  117435. * Gets or sets the center of the bounding box associated with the cube texture
  117436. * It must define where the camera used to render the texture was set
  117437. */
  117438. boundingBoxPosition: Vector3;
  117439. private _boundingBoxSize;
  117440. /**
  117441. * Gets or sets the size of the bounding box associated with the cube texture
  117442. * When defined, the cubemap will switch to local mode
  117443. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117444. * @example https://www.babylonjs-playground.com/#RNASML
  117445. */
  117446. boundingBoxSize: Vector3;
  117447. /**
  117448. * Instantiates an HDRTexture from the following parameters.
  117449. *
  117450. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117451. * @param scene The scene the texture will be used in
  117452. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117453. * @param noMipmap Forces to not generate the mipmap if true
  117454. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117455. * @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)
  117456. * @param reserved Reserved flag for internal use.
  117457. */
  117458. 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>);
  117459. /**
  117460. * Get the current class name of the texture useful for serialization or dynamic coding.
  117461. * @returns "HDRCubeTexture"
  117462. */
  117463. getClassName(): string;
  117464. /**
  117465. * Occurs when the file is raw .hdr file.
  117466. */
  117467. private loadTexture;
  117468. clone(): HDRCubeTexture;
  117469. delayLoad(): void;
  117470. /**
  117471. * Get the texture reflection matrix used to rotate/transform the reflection.
  117472. * @returns the reflection matrix
  117473. */
  117474. getReflectionTextureMatrix(): Matrix;
  117475. /**
  117476. * Set the texture reflection matrix used to rotate/transform the reflection.
  117477. * @param value Define the reflection matrix to set
  117478. */
  117479. setReflectionTextureMatrix(value: Matrix): void;
  117480. /**
  117481. * Parses a JSON representation of an HDR Texture in order to create the texture
  117482. * @param parsedTexture Define the JSON representation
  117483. * @param scene Define the scene the texture should be created in
  117484. * @param rootUrl Define the root url in case we need to load relative dependencies
  117485. * @returns the newly created texture after parsing
  117486. */
  117487. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117488. serialize(): any;
  117489. }
  117490. }
  117491. declare module BABYLON {
  117492. /**
  117493. * Class used to control physics engine
  117494. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117495. */
  117496. export class PhysicsEngine implements IPhysicsEngine {
  117497. private _physicsPlugin;
  117498. /**
  117499. * Global value used to control the smallest number supported by the simulation
  117500. */
  117501. static Epsilon: number;
  117502. private _impostors;
  117503. private _joints;
  117504. /**
  117505. * Gets the gravity vector used by the simulation
  117506. */
  117507. gravity: Vector3;
  117508. /**
  117509. * Factory used to create the default physics plugin.
  117510. * @returns The default physics plugin
  117511. */
  117512. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117513. /**
  117514. * Creates a new Physics Engine
  117515. * @param gravity defines the gravity vector used by the simulation
  117516. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117517. */
  117518. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117519. /**
  117520. * Sets the gravity vector used by the simulation
  117521. * @param gravity defines the gravity vector to use
  117522. */
  117523. setGravity(gravity: Vector3): void;
  117524. /**
  117525. * Set the time step of the physics engine.
  117526. * Default is 1/60.
  117527. * To slow it down, enter 1/600 for example.
  117528. * To speed it up, 1/30
  117529. * @param newTimeStep defines the new timestep to apply to this world.
  117530. */
  117531. setTimeStep(newTimeStep?: number): void;
  117532. /**
  117533. * Get the time step of the physics engine.
  117534. * @returns the current time step
  117535. */
  117536. getTimeStep(): number;
  117537. /**
  117538. * Release all resources
  117539. */
  117540. dispose(): void;
  117541. /**
  117542. * Gets the name of the current physics plugin
  117543. * @returns the name of the plugin
  117544. */
  117545. getPhysicsPluginName(): string;
  117546. /**
  117547. * Adding a new impostor for the impostor tracking.
  117548. * This will be done by the impostor itself.
  117549. * @param impostor the impostor to add
  117550. */
  117551. addImpostor(impostor: PhysicsImpostor): void;
  117552. /**
  117553. * Remove an impostor from the engine.
  117554. * This impostor and its mesh will not longer be updated by the physics engine.
  117555. * @param impostor the impostor to remove
  117556. */
  117557. removeImpostor(impostor: PhysicsImpostor): void;
  117558. /**
  117559. * Add a joint to the physics engine
  117560. * @param mainImpostor defines the main impostor to which the joint is added.
  117561. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117562. * @param joint defines the joint that will connect both impostors.
  117563. */
  117564. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117565. /**
  117566. * Removes a joint from the simulation
  117567. * @param mainImpostor defines the impostor used with the joint
  117568. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117569. * @param joint defines the joint to remove
  117570. */
  117571. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117572. /**
  117573. * Called by the scene. No need to call it.
  117574. * @param delta defines the timespam between frames
  117575. */
  117576. _step(delta: number): void;
  117577. /**
  117578. * Gets the current plugin used to run the simulation
  117579. * @returns current plugin
  117580. */
  117581. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117582. /**
  117583. * Gets the list of physic impostors
  117584. * @returns an array of PhysicsImpostor
  117585. */
  117586. getImpostors(): Array<PhysicsImpostor>;
  117587. /**
  117588. * Gets the impostor for a physics enabled object
  117589. * @param object defines the object impersonated by the impostor
  117590. * @returns the PhysicsImpostor or null if not found
  117591. */
  117592. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117593. /**
  117594. * Gets the impostor for a physics body object
  117595. * @param body defines physics body used by the impostor
  117596. * @returns the PhysicsImpostor or null if not found
  117597. */
  117598. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117599. /**
  117600. * Does a raycast in the physics world
  117601. * @param from when should the ray start?
  117602. * @param to when should the ray end?
  117603. * @returns PhysicsRaycastResult
  117604. */
  117605. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117606. }
  117607. }
  117608. declare module BABYLON {
  117609. /** @hidden */
  117610. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117611. private _useDeltaForWorldStep;
  117612. world: any;
  117613. name: string;
  117614. private _physicsMaterials;
  117615. private _fixedTimeStep;
  117616. private _cannonRaycastResult;
  117617. private _raycastResult;
  117618. private _physicsBodysToRemoveAfterStep;
  117619. BJSCANNON: any;
  117620. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117621. setGravity(gravity: Vector3): void;
  117622. setTimeStep(timeStep: number): void;
  117623. getTimeStep(): number;
  117624. executeStep(delta: number): void;
  117625. private _removeMarkedPhysicsBodiesFromWorld;
  117626. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117627. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117628. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117629. private _processChildMeshes;
  117630. removePhysicsBody(impostor: PhysicsImpostor): void;
  117631. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117632. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117633. private _addMaterial;
  117634. private _checkWithEpsilon;
  117635. private _createShape;
  117636. private _createHeightmap;
  117637. private _minus90X;
  117638. private _plus90X;
  117639. private _tmpPosition;
  117640. private _tmpDeltaPosition;
  117641. private _tmpUnityRotation;
  117642. private _updatePhysicsBodyTransformation;
  117643. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117645. isSupported(): boolean;
  117646. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117647. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117648. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117649. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117650. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117651. getBodyMass(impostor: PhysicsImpostor): number;
  117652. getBodyFriction(impostor: PhysicsImpostor): number;
  117653. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117654. getBodyRestitution(impostor: PhysicsImpostor): number;
  117655. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117656. sleepBody(impostor: PhysicsImpostor): void;
  117657. wakeUpBody(impostor: PhysicsImpostor): void;
  117658. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117659. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117660. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117661. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117662. getRadius(impostor: PhysicsImpostor): number;
  117663. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117664. dispose(): void;
  117665. private _extendNamespace;
  117666. /**
  117667. * Does a raycast in the physics world
  117668. * @param from when should the ray start?
  117669. * @param to when should the ray end?
  117670. * @returns PhysicsRaycastResult
  117671. */
  117672. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117673. }
  117674. }
  117675. declare module BABYLON {
  117676. /** @hidden */
  117677. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117678. world: any;
  117679. name: string;
  117680. BJSOIMO: any;
  117681. private _raycastResult;
  117682. constructor(iterations?: number, oimoInjection?: any);
  117683. setGravity(gravity: Vector3): void;
  117684. setTimeStep(timeStep: number): void;
  117685. getTimeStep(): number;
  117686. private _tmpImpostorsArray;
  117687. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117688. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117689. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117690. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117691. private _tmpPositionVector;
  117692. removePhysicsBody(impostor: PhysicsImpostor): void;
  117693. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117694. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117695. isSupported(): boolean;
  117696. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117697. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117698. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117699. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117700. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117701. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117702. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117703. getBodyMass(impostor: PhysicsImpostor): number;
  117704. getBodyFriction(impostor: PhysicsImpostor): number;
  117705. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117706. getBodyRestitution(impostor: PhysicsImpostor): number;
  117707. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117708. sleepBody(impostor: PhysicsImpostor): void;
  117709. wakeUpBody(impostor: PhysicsImpostor): void;
  117710. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117711. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117712. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117713. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117714. getRadius(impostor: PhysicsImpostor): number;
  117715. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117716. dispose(): void;
  117717. /**
  117718. * Does a raycast in the physics world
  117719. * @param from when should the ray start?
  117720. * @param to when should the ray end?
  117721. * @returns PhysicsRaycastResult
  117722. */
  117723. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117724. }
  117725. }
  117726. declare module BABYLON {
  117727. /**
  117728. * Class containing static functions to help procedurally build meshes
  117729. */
  117730. export class RibbonBuilder {
  117731. /**
  117732. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117733. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117734. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117735. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117736. * * 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
  117737. * * 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
  117738. * * 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
  117739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117742. * * 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
  117743. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117744. * * 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
  117745. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117747. * @param name defines the name of the mesh
  117748. * @param options defines the options used to create the mesh
  117749. * @param scene defines the hosting scene
  117750. * @returns the ribbon mesh
  117751. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117753. */
  117754. static CreateRibbon(name: string, options: {
  117755. pathArray: Vector3[][];
  117756. closeArray?: boolean;
  117757. closePath?: boolean;
  117758. offset?: number;
  117759. updatable?: boolean;
  117760. sideOrientation?: number;
  117761. frontUVs?: Vector4;
  117762. backUVs?: Vector4;
  117763. instance?: Mesh;
  117764. invertUV?: boolean;
  117765. uvs?: Vector2[];
  117766. colors?: Color4[];
  117767. }, scene?: Nullable<Scene>): Mesh;
  117768. }
  117769. }
  117770. declare module BABYLON {
  117771. /**
  117772. * Class containing static functions to help procedurally build meshes
  117773. */
  117774. export class ShapeBuilder {
  117775. /**
  117776. * 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.
  117777. * * 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.
  117778. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117779. * * 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.
  117780. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117781. * * 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
  117782. * * 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
  117783. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117786. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117788. * @param name defines the name of the mesh
  117789. * @param options defines the options used to create the mesh
  117790. * @param scene defines the hosting scene
  117791. * @returns the extruded shape mesh
  117792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117794. */
  117795. static ExtrudeShape(name: string, options: {
  117796. shape: Vector3[];
  117797. path: Vector3[];
  117798. scale?: number;
  117799. rotation?: number;
  117800. cap?: number;
  117801. updatable?: boolean;
  117802. sideOrientation?: number;
  117803. frontUVs?: Vector4;
  117804. backUVs?: Vector4;
  117805. instance?: Mesh;
  117806. invertUV?: boolean;
  117807. }, scene?: Nullable<Scene>): Mesh;
  117808. /**
  117809. * Creates an custom extruded shape mesh.
  117810. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117811. * * 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.
  117812. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117813. * * 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
  117814. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117815. * * 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
  117816. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117817. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117818. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117819. * * 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
  117820. * * 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
  117821. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117824. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117826. * @param name defines the name of the mesh
  117827. * @param options defines the options used to create the mesh
  117828. * @param scene defines the hosting scene
  117829. * @returns the custom extruded shape mesh
  117830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117833. */
  117834. static ExtrudeShapeCustom(name: string, options: {
  117835. shape: Vector3[];
  117836. path: Vector3[];
  117837. scaleFunction?: any;
  117838. rotationFunction?: any;
  117839. ribbonCloseArray?: boolean;
  117840. ribbonClosePath?: boolean;
  117841. cap?: number;
  117842. updatable?: boolean;
  117843. sideOrientation?: number;
  117844. frontUVs?: Vector4;
  117845. backUVs?: Vector4;
  117846. instance?: Mesh;
  117847. invertUV?: boolean;
  117848. }, scene?: Nullable<Scene>): Mesh;
  117849. private static _ExtrudeShapeGeneric;
  117850. }
  117851. }
  117852. declare module BABYLON {
  117853. /**
  117854. * AmmoJS Physics plugin
  117855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117856. * @see https://github.com/kripken/ammo.js/
  117857. */
  117858. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117859. private _useDeltaForWorldStep;
  117860. /**
  117861. * Reference to the Ammo library
  117862. */
  117863. bjsAMMO: any;
  117864. /**
  117865. * Created ammoJS world which physics bodies are added to
  117866. */
  117867. world: any;
  117868. /**
  117869. * Name of the plugin
  117870. */
  117871. name: string;
  117872. private _timeStep;
  117873. private _fixedTimeStep;
  117874. private _maxSteps;
  117875. private _tmpQuaternion;
  117876. private _tmpAmmoTransform;
  117877. private _tmpAmmoQuaternion;
  117878. private _tmpAmmoConcreteContactResultCallback;
  117879. private _collisionConfiguration;
  117880. private _dispatcher;
  117881. private _overlappingPairCache;
  117882. private _solver;
  117883. private _softBodySolver;
  117884. private _tmpAmmoVectorA;
  117885. private _tmpAmmoVectorB;
  117886. private _tmpAmmoVectorC;
  117887. private _tmpAmmoVectorD;
  117888. private _tmpContactCallbackResult;
  117889. private _tmpAmmoVectorRCA;
  117890. private _tmpAmmoVectorRCB;
  117891. private _raycastResult;
  117892. private static readonly DISABLE_COLLISION_FLAG;
  117893. private static readonly KINEMATIC_FLAG;
  117894. private static readonly DISABLE_DEACTIVATION_FLAG;
  117895. /**
  117896. * Initializes the ammoJS plugin
  117897. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  117898. * @param ammoInjection can be used to inject your own ammo reference
  117899. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  117900. */
  117901. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  117902. /**
  117903. * Sets the gravity of the physics world (m/(s^2))
  117904. * @param gravity Gravity to set
  117905. */
  117906. setGravity(gravity: Vector3): void;
  117907. /**
  117908. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  117909. * @param timeStep timestep to use in seconds
  117910. */
  117911. setTimeStep(timeStep: number): void;
  117912. /**
  117913. * 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)
  117914. * @param fixedTimeStep fixedTimeStep to use in seconds
  117915. */
  117916. setFixedTimeStep(fixedTimeStep: number): void;
  117917. /**
  117918. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  117919. * @param maxSteps the maximum number of steps by the physics engine per frame
  117920. */
  117921. setMaxSteps(maxSteps: number): void;
  117922. /**
  117923. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  117924. * @returns the current timestep in seconds
  117925. */
  117926. getTimeStep(): number;
  117927. private _isImpostorInContact;
  117928. private _isImpostorPairInContact;
  117929. private _stepSimulation;
  117930. /**
  117931. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  117932. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  117933. * After the step the babylon meshes are set to the position of the physics imposters
  117934. * @param delta amount of time to step forward
  117935. * @param impostors array of imposters to update before/after the step
  117936. */
  117937. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117938. /**
  117939. * Update babylon mesh to match physics world object
  117940. * @param impostor imposter to match
  117941. */
  117942. private _afterSoftStep;
  117943. /**
  117944. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117945. * @param impostor imposter to match
  117946. */
  117947. private _ropeStep;
  117948. /**
  117949. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117950. * @param impostor imposter to match
  117951. */
  117952. private _softbodyOrClothStep;
  117953. private _tmpVector;
  117954. private _tmpMatrix;
  117955. /**
  117956. * Applies an impulse on the imposter
  117957. * @param impostor imposter to apply impulse to
  117958. * @param force amount of force to be applied to the imposter
  117959. * @param contactPoint the location to apply the impulse on the imposter
  117960. */
  117961. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117962. /**
  117963. * Applies a force on the imposter
  117964. * @param impostor imposter to apply force
  117965. * @param force amount of force to be applied to the imposter
  117966. * @param contactPoint the location to apply the force on the imposter
  117967. */
  117968. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117969. /**
  117970. * Creates a physics body using the plugin
  117971. * @param impostor the imposter to create the physics body on
  117972. */
  117973. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117974. /**
  117975. * Removes the physics body from the imposter and disposes of the body's memory
  117976. * @param impostor imposter to remove the physics body from
  117977. */
  117978. removePhysicsBody(impostor: PhysicsImpostor): void;
  117979. /**
  117980. * Generates a joint
  117981. * @param impostorJoint the imposter joint to create the joint with
  117982. */
  117983. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117984. /**
  117985. * Removes a joint
  117986. * @param impostorJoint the imposter joint to remove the joint from
  117987. */
  117988. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117989. private _addMeshVerts;
  117990. /**
  117991. * Initialise the soft body vertices to match its object's (mesh) vertices
  117992. * Softbody vertices (nodes) are in world space and to match this
  117993. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  117994. * @param impostor to create the softbody for
  117995. */
  117996. private _softVertexData;
  117997. /**
  117998. * Create an impostor's soft body
  117999. * @param impostor to create the softbody for
  118000. */
  118001. private _createSoftbody;
  118002. /**
  118003. * Create cloth for an impostor
  118004. * @param impostor to create the softbody for
  118005. */
  118006. private _createCloth;
  118007. /**
  118008. * Create rope for an impostor
  118009. * @param impostor to create the softbody for
  118010. */
  118011. private _createRope;
  118012. private _addHullVerts;
  118013. private _createShape;
  118014. /**
  118015. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118016. * @param impostor imposter containing the physics body and babylon object
  118017. */
  118018. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118019. /**
  118020. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118021. * @param impostor imposter containing the physics body and babylon object
  118022. * @param newPosition new position
  118023. * @param newRotation new rotation
  118024. */
  118025. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118026. /**
  118027. * If this plugin is supported
  118028. * @returns true if its supported
  118029. */
  118030. isSupported(): boolean;
  118031. /**
  118032. * Sets the linear velocity of the physics body
  118033. * @param impostor imposter to set the velocity on
  118034. * @param velocity velocity to set
  118035. */
  118036. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118037. /**
  118038. * Sets the angular velocity of the physics body
  118039. * @param impostor imposter to set the velocity on
  118040. * @param velocity velocity to set
  118041. */
  118042. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118043. /**
  118044. * gets the linear velocity
  118045. * @param impostor imposter to get linear velocity from
  118046. * @returns linear velocity
  118047. */
  118048. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118049. /**
  118050. * gets the angular velocity
  118051. * @param impostor imposter to get angular velocity from
  118052. * @returns angular velocity
  118053. */
  118054. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118055. /**
  118056. * Sets the mass of physics body
  118057. * @param impostor imposter to set the mass on
  118058. * @param mass mass to set
  118059. */
  118060. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118061. /**
  118062. * Gets the mass of the physics body
  118063. * @param impostor imposter to get the mass from
  118064. * @returns mass
  118065. */
  118066. getBodyMass(impostor: PhysicsImpostor): number;
  118067. /**
  118068. * Gets friction of the impostor
  118069. * @param impostor impostor to get friction from
  118070. * @returns friction value
  118071. */
  118072. getBodyFriction(impostor: PhysicsImpostor): number;
  118073. /**
  118074. * Sets friction of the impostor
  118075. * @param impostor impostor to set friction on
  118076. * @param friction friction value
  118077. */
  118078. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118079. /**
  118080. * Gets restitution of the impostor
  118081. * @param impostor impostor to get restitution from
  118082. * @returns restitution value
  118083. */
  118084. getBodyRestitution(impostor: PhysicsImpostor): number;
  118085. /**
  118086. * Sets resitution of the impostor
  118087. * @param impostor impostor to set resitution on
  118088. * @param restitution resitution value
  118089. */
  118090. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118091. /**
  118092. * Gets pressure inside the impostor
  118093. * @param impostor impostor to get pressure from
  118094. * @returns pressure value
  118095. */
  118096. getBodyPressure(impostor: PhysicsImpostor): number;
  118097. /**
  118098. * Sets pressure inside a soft body impostor
  118099. * Cloth and rope must remain 0 pressure
  118100. * @param impostor impostor to set pressure on
  118101. * @param pressure pressure value
  118102. */
  118103. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118104. /**
  118105. * Gets stiffness of the impostor
  118106. * @param impostor impostor to get stiffness from
  118107. * @returns pressure value
  118108. */
  118109. getBodyStiffness(impostor: PhysicsImpostor): number;
  118110. /**
  118111. * Sets stiffness of the impostor
  118112. * @param impostor impostor to set stiffness on
  118113. * @param stiffness stiffness value from 0 to 1
  118114. */
  118115. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118116. /**
  118117. * Gets velocityIterations of the impostor
  118118. * @param impostor impostor to get velocity iterations from
  118119. * @returns velocityIterations value
  118120. */
  118121. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118122. /**
  118123. * Sets velocityIterations of the impostor
  118124. * @param impostor impostor to set velocity iterations on
  118125. * @param velocityIterations velocityIterations value
  118126. */
  118127. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118128. /**
  118129. * Gets positionIterations of the impostor
  118130. * @param impostor impostor to get position iterations from
  118131. * @returns positionIterations value
  118132. */
  118133. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118134. /**
  118135. * Sets positionIterations of the impostor
  118136. * @param impostor impostor to set position on
  118137. * @param positionIterations positionIterations value
  118138. */
  118139. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118140. /**
  118141. * Append an anchor to a cloth object
  118142. * @param impostor is the cloth impostor to add anchor to
  118143. * @param otherImpostor is the rigid impostor to anchor to
  118144. * @param width ratio across width from 0 to 1
  118145. * @param height ratio up height from 0 to 1
  118146. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118147. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118148. */
  118149. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118150. /**
  118151. * Append an hook to a rope object
  118152. * @param impostor is the rope impostor to add hook to
  118153. * @param otherImpostor is the rigid impostor to hook to
  118154. * @param length ratio along the rope from 0 to 1
  118155. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118156. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118157. */
  118158. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118159. /**
  118160. * Sleeps the physics body and stops it from being active
  118161. * @param impostor impostor to sleep
  118162. */
  118163. sleepBody(impostor: PhysicsImpostor): void;
  118164. /**
  118165. * Activates the physics body
  118166. * @param impostor impostor to activate
  118167. */
  118168. wakeUpBody(impostor: PhysicsImpostor): void;
  118169. /**
  118170. * Updates the distance parameters of the joint
  118171. * @param joint joint to update
  118172. * @param maxDistance maximum distance of the joint
  118173. * @param minDistance minimum distance of the joint
  118174. */
  118175. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118176. /**
  118177. * Sets a motor on the joint
  118178. * @param joint joint to set motor on
  118179. * @param speed speed of the motor
  118180. * @param maxForce maximum force of the motor
  118181. * @param motorIndex index of the motor
  118182. */
  118183. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118184. /**
  118185. * Sets the motors limit
  118186. * @param joint joint to set limit on
  118187. * @param upperLimit upper limit
  118188. * @param lowerLimit lower limit
  118189. */
  118190. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118191. /**
  118192. * Syncs the position and rotation of a mesh with the impostor
  118193. * @param mesh mesh to sync
  118194. * @param impostor impostor to update the mesh with
  118195. */
  118196. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118197. /**
  118198. * Gets the radius of the impostor
  118199. * @param impostor impostor to get radius from
  118200. * @returns the radius
  118201. */
  118202. getRadius(impostor: PhysicsImpostor): number;
  118203. /**
  118204. * Gets the box size of the impostor
  118205. * @param impostor impostor to get box size from
  118206. * @param result the resulting box size
  118207. */
  118208. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118209. /**
  118210. * Disposes of the impostor
  118211. */
  118212. dispose(): void;
  118213. /**
  118214. * Does a raycast in the physics world
  118215. * @param from when should the ray start?
  118216. * @param to when should the ray end?
  118217. * @returns PhysicsRaycastResult
  118218. */
  118219. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118220. }
  118221. }
  118222. declare module BABYLON {
  118223. interface AbstractScene {
  118224. /**
  118225. * The list of reflection probes added to the scene
  118226. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118227. */
  118228. reflectionProbes: Array<ReflectionProbe>;
  118229. /**
  118230. * Removes the given reflection probe from this scene.
  118231. * @param toRemove The reflection probe to remove
  118232. * @returns The index of the removed reflection probe
  118233. */
  118234. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118235. /**
  118236. * Adds the given reflection probe to this scene.
  118237. * @param newReflectionProbe The reflection probe to add
  118238. */
  118239. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118240. }
  118241. /**
  118242. * Class used to generate realtime reflection / refraction cube textures
  118243. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118244. */
  118245. export class ReflectionProbe {
  118246. /** defines the name of the probe */
  118247. name: string;
  118248. private _scene;
  118249. private _renderTargetTexture;
  118250. private _projectionMatrix;
  118251. private _viewMatrix;
  118252. private _target;
  118253. private _add;
  118254. private _attachedMesh;
  118255. private _invertYAxis;
  118256. /** Gets or sets probe position (center of the cube map) */
  118257. position: Vector3;
  118258. /**
  118259. * Creates a new reflection probe
  118260. * @param name defines the name of the probe
  118261. * @param size defines the texture resolution (for each face)
  118262. * @param scene defines the hosting scene
  118263. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118264. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118265. */
  118266. constructor(
  118267. /** defines the name of the probe */
  118268. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118269. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118270. samples: number;
  118271. /** Gets or sets the refresh rate to use (on every frame by default) */
  118272. refreshRate: number;
  118273. /**
  118274. * Gets the hosting scene
  118275. * @returns a Scene
  118276. */
  118277. getScene(): Scene;
  118278. /** Gets the internal CubeTexture used to render to */
  118279. readonly cubeTexture: RenderTargetTexture;
  118280. /** Gets the list of meshes to render */
  118281. readonly renderList: Nullable<AbstractMesh[]>;
  118282. /**
  118283. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118284. * @param mesh defines the mesh to attach to
  118285. */
  118286. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118287. /**
  118288. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118289. * @param renderingGroupId The rendering group id corresponding to its index
  118290. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118291. */
  118292. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118293. /**
  118294. * Clean all associated resources
  118295. */
  118296. dispose(): void;
  118297. /**
  118298. * Converts the reflection probe information to a readable string for debug purpose.
  118299. * @param fullDetails Supports for multiple levels of logging within scene loading
  118300. * @returns the human readable reflection probe info
  118301. */
  118302. toString(fullDetails?: boolean): string;
  118303. /**
  118304. * Get the class name of the relfection probe.
  118305. * @returns "ReflectionProbe"
  118306. */
  118307. getClassName(): string;
  118308. /**
  118309. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118310. * @returns The JSON representation of the texture
  118311. */
  118312. serialize(): any;
  118313. /**
  118314. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118315. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118316. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118317. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118318. * @returns The parsed reflection probe if successful
  118319. */
  118320. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118321. }
  118322. }
  118323. declare module BABYLON {
  118324. /** @hidden */
  118325. export var _BabylonLoaderRegistered: boolean;
  118326. }
  118327. declare module BABYLON {
  118328. /**
  118329. * The Physically based simple base material of BJS.
  118330. *
  118331. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118332. * It is used as the base class for both the specGloss and metalRough conventions.
  118333. */
  118334. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118335. /**
  118336. * Number of Simultaneous lights allowed on the material.
  118337. */
  118338. maxSimultaneousLights: number;
  118339. /**
  118340. * If sets to true, disables all the lights affecting the material.
  118341. */
  118342. disableLighting: boolean;
  118343. /**
  118344. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118345. */
  118346. environmentTexture: BaseTexture;
  118347. /**
  118348. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118349. */
  118350. invertNormalMapX: boolean;
  118351. /**
  118352. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118353. */
  118354. invertNormalMapY: boolean;
  118355. /**
  118356. * Normal map used in the model.
  118357. */
  118358. normalTexture: BaseTexture;
  118359. /**
  118360. * Emissivie color used to self-illuminate the model.
  118361. */
  118362. emissiveColor: Color3;
  118363. /**
  118364. * Emissivie texture used to self-illuminate the model.
  118365. */
  118366. emissiveTexture: BaseTexture;
  118367. /**
  118368. * Occlusion Channel Strenght.
  118369. */
  118370. occlusionStrength: number;
  118371. /**
  118372. * Occlusion Texture of the material (adding extra occlusion effects).
  118373. */
  118374. occlusionTexture: BaseTexture;
  118375. /**
  118376. * Defines the alpha limits in alpha test mode.
  118377. */
  118378. alphaCutOff: number;
  118379. /**
  118380. * Gets the current double sided mode.
  118381. */
  118382. /**
  118383. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118384. */
  118385. doubleSided: boolean;
  118386. /**
  118387. * Stores the pre-calculated light information of a mesh in a texture.
  118388. */
  118389. lightmapTexture: BaseTexture;
  118390. /**
  118391. * If true, the light map contains occlusion information instead of lighting info.
  118392. */
  118393. useLightmapAsShadowmap: boolean;
  118394. /**
  118395. * Instantiates a new PBRMaterial instance.
  118396. *
  118397. * @param name The material name
  118398. * @param scene The scene the material will be use in.
  118399. */
  118400. constructor(name: string, scene: Scene);
  118401. getClassName(): string;
  118402. }
  118403. }
  118404. declare module BABYLON {
  118405. /**
  118406. * The PBR material of BJS following the metal roughness convention.
  118407. *
  118408. * This fits to the PBR convention in the GLTF definition:
  118409. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118410. */
  118411. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118412. /**
  118413. * The base color has two different interpretations depending on the value of metalness.
  118414. * When the material is a metal, the base color is the specific measured reflectance value
  118415. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118416. * of the material.
  118417. */
  118418. baseColor: Color3;
  118419. /**
  118420. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118421. * well as opacity information in the alpha channel.
  118422. */
  118423. baseTexture: BaseTexture;
  118424. /**
  118425. * Specifies the metallic scalar value of the material.
  118426. * Can also be used to scale the metalness values of the metallic texture.
  118427. */
  118428. metallic: number;
  118429. /**
  118430. * Specifies the roughness scalar value of the material.
  118431. * Can also be used to scale the roughness values of the metallic texture.
  118432. */
  118433. roughness: number;
  118434. /**
  118435. * Texture containing both the metallic value in the B channel and the
  118436. * roughness value in the G channel to keep better precision.
  118437. */
  118438. metallicRoughnessTexture: BaseTexture;
  118439. /**
  118440. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118441. *
  118442. * @param name The material name
  118443. * @param scene The scene the material will be use in.
  118444. */
  118445. constructor(name: string, scene: Scene);
  118446. /**
  118447. * Return the currrent class name of the material.
  118448. */
  118449. getClassName(): string;
  118450. /**
  118451. * Makes a duplicate of the current material.
  118452. * @param name - name to use for the new material.
  118453. */
  118454. clone(name: string): PBRMetallicRoughnessMaterial;
  118455. /**
  118456. * Serialize the material to a parsable JSON object.
  118457. */
  118458. serialize(): any;
  118459. /**
  118460. * Parses a JSON object correponding to the serialize function.
  118461. */
  118462. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118463. }
  118464. }
  118465. declare module BABYLON {
  118466. /**
  118467. * The PBR material of BJS following the specular glossiness convention.
  118468. *
  118469. * This fits to the PBR convention in the GLTF definition:
  118470. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118471. */
  118472. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118473. /**
  118474. * Specifies the diffuse color of the material.
  118475. */
  118476. diffuseColor: Color3;
  118477. /**
  118478. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118479. * channel.
  118480. */
  118481. diffuseTexture: BaseTexture;
  118482. /**
  118483. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118484. */
  118485. specularColor: Color3;
  118486. /**
  118487. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118488. */
  118489. glossiness: number;
  118490. /**
  118491. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118492. */
  118493. specularGlossinessTexture: BaseTexture;
  118494. /**
  118495. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118496. *
  118497. * @param name The material name
  118498. * @param scene The scene the material will be use in.
  118499. */
  118500. constructor(name: string, scene: Scene);
  118501. /**
  118502. * Return the currrent class name of the material.
  118503. */
  118504. getClassName(): string;
  118505. /**
  118506. * Makes a duplicate of the current material.
  118507. * @param name - name to use for the new material.
  118508. */
  118509. clone(name: string): PBRSpecularGlossinessMaterial;
  118510. /**
  118511. * Serialize the material to a parsable JSON object.
  118512. */
  118513. serialize(): any;
  118514. /**
  118515. * Parses a JSON object correponding to the serialize function.
  118516. */
  118517. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118518. }
  118519. }
  118520. declare module BABYLON {
  118521. /**
  118522. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118523. * It can help converting any input color in a desired output one. This can then be used to create effects
  118524. * from sepia, black and white to sixties or futuristic rendering...
  118525. *
  118526. * The only supported format is currently 3dl.
  118527. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118528. */
  118529. export class ColorGradingTexture extends BaseTexture {
  118530. /**
  118531. * The current texture matrix. (will always be identity in color grading texture)
  118532. */
  118533. private _textureMatrix;
  118534. /**
  118535. * The texture URL.
  118536. */
  118537. url: string;
  118538. /**
  118539. * Empty line regex stored for GC.
  118540. */
  118541. private static _noneEmptyLineRegex;
  118542. private _engine;
  118543. /**
  118544. * Instantiates a ColorGradingTexture from the following parameters.
  118545. *
  118546. * @param url The location of the color gradind data (currently only supporting 3dl)
  118547. * @param scene The scene the texture will be used in
  118548. */
  118549. constructor(url: string, scene: Scene);
  118550. /**
  118551. * Returns the texture matrix used in most of the material.
  118552. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118553. */
  118554. getTextureMatrix(): Matrix;
  118555. /**
  118556. * Occurs when the file being loaded is a .3dl LUT file.
  118557. */
  118558. private load3dlTexture;
  118559. /**
  118560. * Starts the loading process of the texture.
  118561. */
  118562. private loadTexture;
  118563. /**
  118564. * Clones the color gradind texture.
  118565. */
  118566. clone(): ColorGradingTexture;
  118567. /**
  118568. * Called during delayed load for textures.
  118569. */
  118570. delayLoad(): void;
  118571. /**
  118572. * Parses a color grading texture serialized by Babylon.
  118573. * @param parsedTexture The texture information being parsedTexture
  118574. * @param scene The scene to load the texture in
  118575. * @param rootUrl The root url of the data assets to load
  118576. * @return A color gradind texture
  118577. */
  118578. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118579. /**
  118580. * Serializes the LUT texture to json format.
  118581. */
  118582. serialize(): any;
  118583. }
  118584. }
  118585. declare module BABYLON {
  118586. /**
  118587. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118588. */
  118589. export class EquiRectangularCubeTexture extends BaseTexture {
  118590. /** The six faces of the cube. */
  118591. private static _FacesMapping;
  118592. private _noMipmap;
  118593. private _onLoad;
  118594. private _onError;
  118595. /** The size of the cubemap. */
  118596. private _size;
  118597. /** The buffer of the image. */
  118598. private _buffer;
  118599. /** The width of the input image. */
  118600. private _width;
  118601. /** The height of the input image. */
  118602. private _height;
  118603. /** The URL to the image. */
  118604. url: string;
  118605. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118606. coordinatesMode: number;
  118607. /**
  118608. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118609. * @param url The location of the image
  118610. * @param scene The scene the texture will be used in
  118611. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118612. * @param noMipmap Forces to not generate the mipmap if true
  118613. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118614. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118615. * @param onLoad — defines a callback called when texture is loaded
  118616. * @param onError — defines a callback called if there is an error
  118617. */
  118618. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118619. /**
  118620. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118621. */
  118622. private loadImage;
  118623. /**
  118624. * Convert the image buffer into a cubemap and create a CubeTexture.
  118625. */
  118626. private loadTexture;
  118627. /**
  118628. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118629. * @param buffer The ArrayBuffer that should be converted.
  118630. * @returns The buffer as Float32Array.
  118631. */
  118632. private getFloat32ArrayFromArrayBuffer;
  118633. /**
  118634. * Get the current class name of the texture useful for serialization or dynamic coding.
  118635. * @returns "EquiRectangularCubeTexture"
  118636. */
  118637. getClassName(): string;
  118638. /**
  118639. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118640. * @returns A clone of the current EquiRectangularCubeTexture.
  118641. */
  118642. clone(): EquiRectangularCubeTexture;
  118643. }
  118644. }
  118645. declare module BABYLON {
  118646. /**
  118647. * Based on jsTGALoader - Javascript loader for TGA file
  118648. * By Vincent Thibault
  118649. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118650. */
  118651. export class TGATools {
  118652. private static _TYPE_INDEXED;
  118653. private static _TYPE_RGB;
  118654. private static _TYPE_GREY;
  118655. private static _TYPE_RLE_INDEXED;
  118656. private static _TYPE_RLE_RGB;
  118657. private static _TYPE_RLE_GREY;
  118658. private static _ORIGIN_MASK;
  118659. private static _ORIGIN_SHIFT;
  118660. private static _ORIGIN_BL;
  118661. private static _ORIGIN_BR;
  118662. private static _ORIGIN_UL;
  118663. private static _ORIGIN_UR;
  118664. /**
  118665. * Gets the header of a TGA file
  118666. * @param data defines the TGA data
  118667. * @returns the header
  118668. */
  118669. static GetTGAHeader(data: Uint8Array): any;
  118670. /**
  118671. * Uploads TGA content to a Babylon Texture
  118672. * @hidden
  118673. */
  118674. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118675. /** @hidden */
  118676. 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;
  118677. /** @hidden */
  118678. 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;
  118679. /** @hidden */
  118680. 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;
  118681. /** @hidden */
  118682. 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;
  118683. /** @hidden */
  118684. 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;
  118685. /** @hidden */
  118686. 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;
  118687. }
  118688. }
  118689. declare module BABYLON {
  118690. /**
  118691. * Implementation of the TGA Texture Loader.
  118692. * @hidden
  118693. */
  118694. export class _TGATextureLoader implements IInternalTextureLoader {
  118695. /**
  118696. * Defines wether the loader supports cascade loading the different faces.
  118697. */
  118698. readonly supportCascades: boolean;
  118699. /**
  118700. * This returns if the loader support the current file information.
  118701. * @param extension defines the file extension of the file being loaded
  118702. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118703. * @param fallback defines the fallback internal texture if any
  118704. * @param isBase64 defines whether the texture is encoded as a base64
  118705. * @param isBuffer defines whether the texture data are stored as a buffer
  118706. * @returns true if the loader can load the specified file
  118707. */
  118708. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118709. /**
  118710. * Transform the url before loading if required.
  118711. * @param rootUrl the url of the texture
  118712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118713. * @returns the transformed texture
  118714. */
  118715. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118716. /**
  118717. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118718. * @param rootUrl the url of the texture
  118719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118720. * @returns the fallback texture
  118721. */
  118722. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118723. /**
  118724. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118725. * @param data contains the texture data
  118726. * @param texture defines the BabylonJS internal texture
  118727. * @param createPolynomials will be true if polynomials have been requested
  118728. * @param onLoad defines the callback to trigger once the texture is ready
  118729. * @param onError defines the callback to trigger in case of error
  118730. */
  118731. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118732. /**
  118733. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118734. * @param data contains the texture data
  118735. * @param texture defines the BabylonJS internal texture
  118736. * @param callback defines the method to call once ready to upload
  118737. */
  118738. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118739. }
  118740. }
  118741. declare module BABYLON {
  118742. /**
  118743. * Info about the .basis files
  118744. */
  118745. class BasisFileInfo {
  118746. /**
  118747. * If the file has alpha
  118748. */
  118749. hasAlpha: boolean;
  118750. /**
  118751. * Info about each image of the basis file
  118752. */
  118753. images: Array<{
  118754. levels: Array<{
  118755. width: number;
  118756. height: number;
  118757. transcodedPixels: ArrayBufferView;
  118758. }>;
  118759. }>;
  118760. }
  118761. /**
  118762. * Result of transcoding a basis file
  118763. */
  118764. class TranscodeResult {
  118765. /**
  118766. * Info about the .basis file
  118767. */
  118768. fileInfo: BasisFileInfo;
  118769. /**
  118770. * Format to use when loading the file
  118771. */
  118772. format: number;
  118773. }
  118774. /**
  118775. * Configuration options for the Basis transcoder
  118776. */
  118777. export class BasisTranscodeConfiguration {
  118778. /**
  118779. * Supported compression formats used to determine the supported output format of the transcoder
  118780. */
  118781. supportedCompressionFormats?: {
  118782. /**
  118783. * etc1 compression format
  118784. */
  118785. etc1?: boolean;
  118786. /**
  118787. * s3tc compression format
  118788. */
  118789. s3tc?: boolean;
  118790. /**
  118791. * pvrtc compression format
  118792. */
  118793. pvrtc?: boolean;
  118794. /**
  118795. * etc2 compression format
  118796. */
  118797. etc2?: boolean;
  118798. };
  118799. /**
  118800. * If mipmap levels should be loaded for transcoded images (Default: true)
  118801. */
  118802. loadMipmapLevels?: boolean;
  118803. /**
  118804. * Index of a single image to load (Default: all images)
  118805. */
  118806. loadSingleImage?: number;
  118807. }
  118808. /**
  118809. * Used to load .Basis files
  118810. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118811. */
  118812. export class BasisTools {
  118813. private static _IgnoreSupportedFormats;
  118814. /**
  118815. * URL to use when loading the basis transcoder
  118816. */
  118817. static JSModuleURL: string;
  118818. /**
  118819. * URL to use when loading the wasm module for the transcoder
  118820. */
  118821. static WasmModuleURL: string;
  118822. /**
  118823. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118824. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118825. * @returns internal format corresponding to the Basis format
  118826. */
  118827. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118828. private static _WorkerPromise;
  118829. private static _Worker;
  118830. private static _actionId;
  118831. private static _CreateWorkerAsync;
  118832. /**
  118833. * Transcodes a loaded image file to compressed pixel data
  118834. * @param imageData image data to transcode
  118835. * @param config configuration options for the transcoding
  118836. * @returns a promise resulting in the transcoded image
  118837. */
  118838. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118839. /**
  118840. * Loads a texture from the transcode result
  118841. * @param texture texture load to
  118842. * @param transcodeResult the result of transcoding the basis file to load from
  118843. */
  118844. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118845. }
  118846. }
  118847. declare module BABYLON {
  118848. /**
  118849. * Loader for .basis file format
  118850. */
  118851. export class _BasisTextureLoader implements IInternalTextureLoader {
  118852. /**
  118853. * Defines whether the loader supports cascade loading the different faces.
  118854. */
  118855. readonly supportCascades: boolean;
  118856. /**
  118857. * This returns if the loader support the current file information.
  118858. * @param extension defines the file extension of the file being loaded
  118859. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118860. * @param fallback defines the fallback internal texture if any
  118861. * @param isBase64 defines whether the texture is encoded as a base64
  118862. * @param isBuffer defines whether the texture data are stored as a buffer
  118863. * @returns true if the loader can load the specified file
  118864. */
  118865. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118866. /**
  118867. * Transform the url before loading if required.
  118868. * @param rootUrl the url of the texture
  118869. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118870. * @returns the transformed texture
  118871. */
  118872. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118873. /**
  118874. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118875. * @param rootUrl the url of the texture
  118876. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118877. * @returns the fallback texture
  118878. */
  118879. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118880. /**
  118881. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118882. * @param data contains the texture data
  118883. * @param texture defines the BabylonJS internal texture
  118884. * @param createPolynomials will be true if polynomials have been requested
  118885. * @param onLoad defines the callback to trigger once the texture is ready
  118886. * @param onError defines the callback to trigger in case of error
  118887. */
  118888. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118889. /**
  118890. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118891. * @param data contains the texture data
  118892. * @param texture defines the BabylonJS internal texture
  118893. * @param callback defines the method to call once ready to upload
  118894. */
  118895. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118896. }
  118897. }
  118898. declare module BABYLON {
  118899. /**
  118900. * 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.
  118901. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118902. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118903. */
  118904. export class CustomProceduralTexture extends ProceduralTexture {
  118905. private _animate;
  118906. private _time;
  118907. private _config;
  118908. private _texturePath;
  118909. /**
  118910. * Instantiates a new Custom Procedural Texture.
  118911. * 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.
  118912. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118913. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118914. * @param name Define the name of the texture
  118915. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  118916. * @param size Define the size of the texture to create
  118917. * @param scene Define the scene the texture belongs to
  118918. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  118919. * @param generateMipMaps Define if the texture should creates mip maps or not
  118920. */
  118921. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118922. private _loadJson;
  118923. /**
  118924. * Is the texture ready to be used ? (rendered at least once)
  118925. * @returns true if ready, otherwise, false.
  118926. */
  118927. isReady(): boolean;
  118928. /**
  118929. * Render the texture to its associated render target.
  118930. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  118931. */
  118932. render(useCameraPostProcess?: boolean): void;
  118933. /**
  118934. * Update the list of dependant textures samplers in the shader.
  118935. */
  118936. updateTextures(): void;
  118937. /**
  118938. * Update the uniform values of the procedural texture in the shader.
  118939. */
  118940. updateShaderUniforms(): void;
  118941. /**
  118942. * Define if the texture animates or not.
  118943. */
  118944. animate: boolean;
  118945. }
  118946. }
  118947. declare module BABYLON {
  118948. /** @hidden */
  118949. export var noisePixelShader: {
  118950. name: string;
  118951. shader: string;
  118952. };
  118953. }
  118954. declare module BABYLON {
  118955. /**
  118956. * Class used to generate noise procedural textures
  118957. */
  118958. export class NoiseProceduralTexture extends ProceduralTexture {
  118959. private _time;
  118960. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  118961. brightness: number;
  118962. /** Defines the number of octaves to process */
  118963. octaves: number;
  118964. /** Defines the level of persistence (0.8 by default) */
  118965. persistence: number;
  118966. /** Gets or sets animation speed factor (default is 1) */
  118967. animationSpeedFactor: number;
  118968. /**
  118969. * Creates a new NoiseProceduralTexture
  118970. * @param name defines the name fo the texture
  118971. * @param size defines the size of the texture (default is 256)
  118972. * @param scene defines the hosting scene
  118973. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  118974. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  118975. */
  118976. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118977. private _updateShaderUniforms;
  118978. protected _getDefines(): string;
  118979. /** Generate the current state of the procedural texture */
  118980. render(useCameraPostProcess?: boolean): void;
  118981. /**
  118982. * Serializes this noise procedural texture
  118983. * @returns a serialized noise procedural texture object
  118984. */
  118985. serialize(): any;
  118986. /**
  118987. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  118988. * @param parsedTexture defines parsed texture data
  118989. * @param scene defines the current scene
  118990. * @param rootUrl defines the root URL containing noise procedural texture information
  118991. * @returns a parsed NoiseProceduralTexture
  118992. */
  118993. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  118994. }
  118995. }
  118996. declare module BABYLON {
  118997. /**
  118998. * Raw cube texture where the raw buffers are passed in
  118999. */
  119000. export class RawCubeTexture extends CubeTexture {
  119001. /**
  119002. * Creates a cube texture where the raw buffers are passed in.
  119003. * @param scene defines the scene the texture is attached to
  119004. * @param data defines the array of data to use to create each face
  119005. * @param size defines the size of the textures
  119006. * @param format defines the format of the data
  119007. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119008. * @param generateMipMaps defines if the engine should generate the mip levels
  119009. * @param invertY defines if data must be stored with Y axis inverted
  119010. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119011. * @param compression defines the compression used (null by default)
  119012. */
  119013. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119014. /**
  119015. * Updates the raw cube texture.
  119016. * @param data defines the data to store
  119017. * @param format defines the data format
  119018. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119019. * @param invertY defines if data must be stored with Y axis inverted
  119020. * @param compression defines the compression used (null by default)
  119021. * @param level defines which level of the texture to update
  119022. */
  119023. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119024. /**
  119025. * Updates a raw cube texture with RGBD encoded data.
  119026. * @param data defines the array of data [mipmap][face] to use to create each face
  119027. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119028. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119029. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119030. * @returns a promsie that resolves when the operation is complete
  119031. */
  119032. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119033. /**
  119034. * Clones the raw cube texture.
  119035. * @return a new cube texture
  119036. */
  119037. clone(): CubeTexture;
  119038. /** @hidden */
  119039. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119040. }
  119041. }
  119042. declare module BABYLON {
  119043. /**
  119044. * Class used to store 3D textures containing user data
  119045. */
  119046. export class RawTexture3D extends Texture {
  119047. /** Gets or sets the texture format to use */
  119048. format: number;
  119049. private _engine;
  119050. /**
  119051. * Create a new RawTexture3D
  119052. * @param data defines the data of the texture
  119053. * @param width defines the width of the texture
  119054. * @param height defines the height of the texture
  119055. * @param depth defines the depth of the texture
  119056. * @param format defines the texture format to use
  119057. * @param scene defines the hosting scene
  119058. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119059. * @param invertY defines if texture must be stored with Y axis inverted
  119060. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119061. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119062. */
  119063. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119064. /** Gets or sets the texture format to use */
  119065. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119066. /**
  119067. * Update the texture with new data
  119068. * @param data defines the data to store in the texture
  119069. */
  119070. update(data: ArrayBufferView): void;
  119071. }
  119072. }
  119073. declare module BABYLON {
  119074. /**
  119075. * Creates a refraction texture used by refraction channel of the standard material.
  119076. * It is like a mirror but to see through a material.
  119077. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119078. */
  119079. export class RefractionTexture extends RenderTargetTexture {
  119080. /**
  119081. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119082. * 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.
  119083. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119084. */
  119085. refractionPlane: Plane;
  119086. /**
  119087. * Define how deep under the surface we should see.
  119088. */
  119089. depth: number;
  119090. /**
  119091. * Creates a refraction texture used by refraction channel of the standard material.
  119092. * It is like a mirror but to see through a material.
  119093. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119094. * @param name Define the texture name
  119095. * @param size Define the size of the underlying texture
  119096. * @param scene Define the scene the refraction belongs to
  119097. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119098. */
  119099. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119100. /**
  119101. * Clone the refraction texture.
  119102. * @returns the cloned texture
  119103. */
  119104. clone(): RefractionTexture;
  119105. /**
  119106. * Serialize the texture to a JSON representation you could use in Parse later on
  119107. * @returns the serialized JSON representation
  119108. */
  119109. serialize(): any;
  119110. }
  119111. }
  119112. declare module BABYLON {
  119113. /**
  119114. * Defines the options related to the creation of an HtmlElementTexture
  119115. */
  119116. export interface IHtmlElementTextureOptions {
  119117. /**
  119118. * Defines wether mip maps should be created or not.
  119119. */
  119120. generateMipMaps?: boolean;
  119121. /**
  119122. * Defines the sampling mode of the texture.
  119123. */
  119124. samplingMode?: number;
  119125. /**
  119126. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119127. */
  119128. engine: Nullable<Engine>;
  119129. /**
  119130. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119131. */
  119132. scene: Nullable<Scene>;
  119133. }
  119134. /**
  119135. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119136. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119137. * is automatically managed.
  119138. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119139. * in your application.
  119140. *
  119141. * As the update is not automatic, you need to call them manually.
  119142. */
  119143. export class HtmlElementTexture extends BaseTexture {
  119144. /**
  119145. * The texture URL.
  119146. */
  119147. element: HTMLVideoElement | HTMLCanvasElement;
  119148. private static readonly DefaultOptions;
  119149. private _textureMatrix;
  119150. private _engine;
  119151. private _isVideo;
  119152. private _generateMipMaps;
  119153. private _samplingMode;
  119154. /**
  119155. * Instantiates a HtmlElementTexture from the following parameters.
  119156. *
  119157. * @param name Defines the name of the texture
  119158. * @param element Defines the video or canvas the texture is filled with
  119159. * @param options Defines the other none mandatory texture creation options
  119160. */
  119161. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119162. private _createInternalTexture;
  119163. /**
  119164. * Returns the texture matrix used in most of the material.
  119165. */
  119166. getTextureMatrix(): Matrix;
  119167. /**
  119168. * Updates the content of the texture.
  119169. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119170. */
  119171. update(invertY?: Nullable<boolean>): void;
  119172. }
  119173. }
  119174. declare module BABYLON {
  119175. /**
  119176. * Enum used to define the target of a block
  119177. */
  119178. export enum NodeMaterialBlockTargets {
  119179. /** Vertex shader */
  119180. Vertex = 1,
  119181. /** Fragment shader */
  119182. Fragment = 2,
  119183. /** Neutral */
  119184. Neutral = 4,
  119185. /** Vertex and Fragment */
  119186. VertexAndFragment = 3
  119187. }
  119188. }
  119189. declare module BABYLON {
  119190. /**
  119191. * Defines the kind of connection point for node based material
  119192. */
  119193. export enum NodeMaterialBlockConnectionPointTypes {
  119194. /** Float */
  119195. Float = 1,
  119196. /** Int */
  119197. Int = 2,
  119198. /** Vector2 */
  119199. Vector2 = 4,
  119200. /** Vector3 */
  119201. Vector3 = 8,
  119202. /** Vector4 */
  119203. Vector4 = 16,
  119204. /** Color3 */
  119205. Color3 = 32,
  119206. /** Color4 */
  119207. Color4 = 64,
  119208. /** Matrix */
  119209. Matrix = 128,
  119210. /** Detect type based on connection */
  119211. AutoDetect = 1024,
  119212. /** Output type that will be defined by input type */
  119213. BasedOnInput = 2048
  119214. }
  119215. }
  119216. declare module BABYLON {
  119217. /**
  119218. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119219. */
  119220. export enum NodeMaterialBlockConnectionPointMode {
  119221. /** Value is an uniform */
  119222. Uniform = 0,
  119223. /** Value is a mesh attribute */
  119224. Attribute = 1,
  119225. /** Value is a varying between vertex and fragment shaders */
  119226. Varying = 2,
  119227. /** Mode is undefined */
  119228. Undefined = 3
  119229. }
  119230. }
  119231. declare module BABYLON {
  119232. /**
  119233. * Enum used to define system values e.g. values automatically provided by the system
  119234. */
  119235. export enum NodeMaterialSystemValues {
  119236. /** World */
  119237. World = 1,
  119238. /** View */
  119239. View = 2,
  119240. /** Projection */
  119241. Projection = 3,
  119242. /** ViewProjection */
  119243. ViewProjection = 4,
  119244. /** WorldView */
  119245. WorldView = 5,
  119246. /** WorldViewProjection */
  119247. WorldViewProjection = 6,
  119248. /** CameraPosition */
  119249. CameraPosition = 7,
  119250. /** Fog Color */
  119251. FogColor = 8,
  119252. /** Delta time */
  119253. DeltaTime = 9
  119254. }
  119255. }
  119256. declare module BABYLON {
  119257. /**
  119258. * Root class for all node material optimizers
  119259. */
  119260. export class NodeMaterialOptimizer {
  119261. /**
  119262. * Function used to optimize a NodeMaterial graph
  119263. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119264. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119265. */
  119266. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119267. }
  119268. }
  119269. declare module BABYLON {
  119270. /**
  119271. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119272. */
  119273. export class TransformBlock extends NodeMaterialBlock {
  119274. /**
  119275. * Defines the value to use to complement W value to transform it to a Vector4
  119276. */
  119277. complementW: number;
  119278. /**
  119279. * Defines the value to use to complement z value to transform it to a Vector4
  119280. */
  119281. complementZ: number;
  119282. /**
  119283. * Creates a new TransformBlock
  119284. * @param name defines the block name
  119285. */
  119286. constructor(name: string);
  119287. /**
  119288. * Gets the current class name
  119289. * @returns the class name
  119290. */
  119291. getClassName(): string;
  119292. /**
  119293. * Gets the vector input
  119294. */
  119295. readonly vector: NodeMaterialConnectionPoint;
  119296. /**
  119297. * Gets the output component
  119298. */
  119299. readonly output: NodeMaterialConnectionPoint;
  119300. /**
  119301. * Gets the matrix transform input
  119302. */
  119303. readonly transform: NodeMaterialConnectionPoint;
  119304. protected _buildBlock(state: NodeMaterialBuildState): this;
  119305. serialize(): any;
  119306. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119307. protected _dumpPropertiesCode(): string;
  119308. }
  119309. }
  119310. declare module BABYLON {
  119311. /**
  119312. * Block used to output the vertex position
  119313. */
  119314. export class VertexOutputBlock extends NodeMaterialBlock {
  119315. /**
  119316. * Creates a new VertexOutputBlock
  119317. * @param name defines the block name
  119318. */
  119319. constructor(name: string);
  119320. /**
  119321. * Gets the current class name
  119322. * @returns the class name
  119323. */
  119324. getClassName(): string;
  119325. /**
  119326. * Gets the vector input component
  119327. */
  119328. readonly vector: NodeMaterialConnectionPoint;
  119329. protected _buildBlock(state: NodeMaterialBuildState): this;
  119330. }
  119331. }
  119332. declare module BABYLON {
  119333. /**
  119334. * Block used to output the final color
  119335. */
  119336. export class FragmentOutputBlock extends NodeMaterialBlock {
  119337. /**
  119338. * Create a new FragmentOutputBlock
  119339. * @param name defines the block name
  119340. */
  119341. constructor(name: string);
  119342. /**
  119343. * Gets the current class name
  119344. * @returns the class name
  119345. */
  119346. getClassName(): string;
  119347. /**
  119348. * Gets the rgba input component
  119349. */
  119350. readonly rgba: NodeMaterialConnectionPoint;
  119351. /**
  119352. * Gets the rgb input component
  119353. */
  119354. readonly rgb: NodeMaterialConnectionPoint;
  119355. /**
  119356. * Gets the a input component
  119357. */
  119358. readonly a: NodeMaterialConnectionPoint;
  119359. protected _buildBlock(state: NodeMaterialBuildState): this;
  119360. }
  119361. }
  119362. declare module BABYLON {
  119363. /**
  119364. * Block used to read a reflection texture from a sampler
  119365. */
  119366. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119367. private _define3DName;
  119368. private _defineCubicName;
  119369. private _defineExplicitName;
  119370. private _defineProjectionName;
  119371. private _defineLocalCubicName;
  119372. private _defineSphericalName;
  119373. private _definePlanarName;
  119374. private _defineEquirectangularName;
  119375. private _defineMirroredEquirectangularFixedName;
  119376. private _defineEquirectangularFixedName;
  119377. private _defineSkyboxName;
  119378. private _cubeSamplerName;
  119379. private _2DSamplerName;
  119380. private _positionUVWName;
  119381. private _directionWName;
  119382. private _reflectionCoordsName;
  119383. private _reflection2DCoordsName;
  119384. private _reflectionColorName;
  119385. private _reflectionMatrixName;
  119386. /**
  119387. * Gets or sets the texture associated with the node
  119388. */
  119389. texture: Nullable<BaseTexture>;
  119390. /**
  119391. * Create a new TextureBlock
  119392. * @param name defines the block name
  119393. */
  119394. constructor(name: string);
  119395. /**
  119396. * Gets the current class name
  119397. * @returns the class name
  119398. */
  119399. getClassName(): string;
  119400. /**
  119401. * Gets the world position input component
  119402. */
  119403. readonly position: NodeMaterialConnectionPoint;
  119404. /**
  119405. * Gets the world position input component
  119406. */
  119407. readonly worldPosition: NodeMaterialConnectionPoint;
  119408. /**
  119409. * Gets the world normal input component
  119410. */
  119411. readonly worldNormal: NodeMaterialConnectionPoint;
  119412. /**
  119413. * Gets the world input component
  119414. */
  119415. readonly world: NodeMaterialConnectionPoint;
  119416. /**
  119417. * Gets the camera (or eye) position component
  119418. */
  119419. readonly cameraPosition: NodeMaterialConnectionPoint;
  119420. /**
  119421. * Gets the view input component
  119422. */
  119423. readonly view: NodeMaterialConnectionPoint;
  119424. /**
  119425. * Gets the rgb output component
  119426. */
  119427. readonly rgb: NodeMaterialConnectionPoint;
  119428. /**
  119429. * Gets the r output component
  119430. */
  119431. readonly r: NodeMaterialConnectionPoint;
  119432. /**
  119433. * Gets the g output component
  119434. */
  119435. readonly g: NodeMaterialConnectionPoint;
  119436. /**
  119437. * Gets the b output component
  119438. */
  119439. readonly b: NodeMaterialConnectionPoint;
  119440. autoConfigure(material: NodeMaterial): void;
  119441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119442. isReady(): boolean;
  119443. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119444. private _injectVertexCode;
  119445. private _writeOutput;
  119446. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119447. serialize(): any;
  119448. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119449. }
  119450. }
  119451. declare module BABYLON {
  119452. /**
  119453. * Interface used to configure the node material editor
  119454. */
  119455. export interface INodeMaterialEditorOptions {
  119456. /** Define the URl to load node editor script */
  119457. editorURL?: string;
  119458. }
  119459. /** @hidden */
  119460. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119461. /** BONES */
  119462. NUM_BONE_INFLUENCERS: number;
  119463. BonesPerMesh: number;
  119464. BONETEXTURE: boolean;
  119465. /** MORPH TARGETS */
  119466. MORPHTARGETS: boolean;
  119467. MORPHTARGETS_NORMAL: boolean;
  119468. MORPHTARGETS_TANGENT: boolean;
  119469. MORPHTARGETS_UV: boolean;
  119470. NUM_MORPH_INFLUENCERS: number;
  119471. /** IMAGE PROCESSING */
  119472. IMAGEPROCESSING: boolean;
  119473. VIGNETTE: boolean;
  119474. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119475. VIGNETTEBLENDMODEOPAQUE: boolean;
  119476. TONEMAPPING: boolean;
  119477. TONEMAPPING_ACES: boolean;
  119478. CONTRAST: boolean;
  119479. EXPOSURE: boolean;
  119480. COLORCURVES: boolean;
  119481. COLORGRADING: boolean;
  119482. COLORGRADING3D: boolean;
  119483. SAMPLER3DGREENDEPTH: boolean;
  119484. SAMPLER3DBGRMAP: boolean;
  119485. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119486. /** MISC. */
  119487. BUMPDIRECTUV: number;
  119488. constructor();
  119489. setValue(name: string, value: boolean): void;
  119490. }
  119491. /**
  119492. * Class used to configure NodeMaterial
  119493. */
  119494. export interface INodeMaterialOptions {
  119495. /**
  119496. * Defines if blocks should emit comments
  119497. */
  119498. emitComments: boolean;
  119499. }
  119500. /**
  119501. * Class used to create a node based material built by assembling shader blocks
  119502. */
  119503. export class NodeMaterial extends PushMaterial {
  119504. private static _BuildIdGenerator;
  119505. private _options;
  119506. private _vertexCompilationState;
  119507. private _fragmentCompilationState;
  119508. private _sharedData;
  119509. private _buildId;
  119510. private _buildWasSuccessful;
  119511. private _cachedWorldViewMatrix;
  119512. private _cachedWorldViewProjectionMatrix;
  119513. private _optimizers;
  119514. private _animationFrame;
  119515. /** Define the URl to load node editor script */
  119516. static EditorURL: string;
  119517. private BJSNODEMATERIALEDITOR;
  119518. /** Get the inspector from bundle or global */
  119519. private _getGlobalNodeMaterialEditor;
  119520. /**
  119521. * 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)
  119522. */
  119523. ignoreAlpha: boolean;
  119524. /**
  119525. * Defines the maximum number of lights that can be used in the material
  119526. */
  119527. maxSimultaneousLights: number;
  119528. /**
  119529. * Observable raised when the material is built
  119530. */
  119531. onBuildObservable: Observable<NodeMaterial>;
  119532. /**
  119533. * Gets or sets the root nodes of the material vertex shader
  119534. */
  119535. _vertexOutputNodes: NodeMaterialBlock[];
  119536. /**
  119537. * Gets or sets the root nodes of the material fragment (pixel) shader
  119538. */
  119539. _fragmentOutputNodes: NodeMaterialBlock[];
  119540. /** Gets or sets options to control the node material overall behavior */
  119541. options: INodeMaterialOptions;
  119542. /**
  119543. * Default configuration related to image processing available in the standard Material.
  119544. */
  119545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119546. /**
  119547. * Gets the image processing configuration used either in this material.
  119548. */
  119549. /**
  119550. * Sets the Default image processing configuration used either in the this material.
  119551. *
  119552. * If sets to null, the scene one is in use.
  119553. */
  119554. imageProcessingConfiguration: ImageProcessingConfiguration;
  119555. /**
  119556. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119557. */
  119558. attachedBlocks: NodeMaterialBlock[];
  119559. /**
  119560. * Create a new node based material
  119561. * @param name defines the material name
  119562. * @param scene defines the hosting scene
  119563. * @param options defines creation option
  119564. */
  119565. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119566. /**
  119567. * Gets the current class name of the material e.g. "NodeMaterial"
  119568. * @returns the class name
  119569. */
  119570. getClassName(): string;
  119571. /**
  119572. * Keep track of the image processing observer to allow dispose and replace.
  119573. */
  119574. private _imageProcessingObserver;
  119575. /**
  119576. * Attaches a new image processing configuration to the Standard Material.
  119577. * @param configuration
  119578. */
  119579. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119580. /**
  119581. * Get a block by its name
  119582. * @param name defines the name of the block to retrieve
  119583. * @returns the required block or null if not found
  119584. */
  119585. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119586. /**
  119587. * Get a block by its name
  119588. * @param predicate defines the predicate used to find the good candidate
  119589. * @returns the required block or null if not found
  119590. */
  119591. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119592. /**
  119593. * Get an input block by its name
  119594. * @param predicate defines the predicate used to find the good candidate
  119595. * @returns the required input block or null if not found
  119596. */
  119597. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119598. /**
  119599. * Gets the list of input blocks attached to this material
  119600. * @returns an array of InputBlocks
  119601. */
  119602. getInputBlocks(): InputBlock[];
  119603. /**
  119604. * Adds a new optimizer to the list of optimizers
  119605. * @param optimizer defines the optimizers to add
  119606. * @returns the current material
  119607. */
  119608. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119609. /**
  119610. * Remove an optimizer from the list of optimizers
  119611. * @param optimizer defines the optimizers to remove
  119612. * @returns the current material
  119613. */
  119614. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119615. /**
  119616. * Add a new block to the list of output nodes
  119617. * @param node defines the node to add
  119618. * @returns the current material
  119619. */
  119620. addOutputNode(node: NodeMaterialBlock): this;
  119621. /**
  119622. * Remove a block from the list of root nodes
  119623. * @param node defines the node to remove
  119624. * @returns the current material
  119625. */
  119626. removeOutputNode(node: NodeMaterialBlock): this;
  119627. private _addVertexOutputNode;
  119628. private _removeVertexOutputNode;
  119629. private _addFragmentOutputNode;
  119630. private _removeFragmentOutputNode;
  119631. /**
  119632. * Specifies if the material will require alpha blending
  119633. * @returns a boolean specifying if alpha blending is needed
  119634. */
  119635. needAlphaBlending(): boolean;
  119636. /**
  119637. * Specifies if this material should be rendered in alpha test mode
  119638. * @returns a boolean specifying if an alpha test is needed.
  119639. */
  119640. needAlphaTesting(): boolean;
  119641. private _initializeBlock;
  119642. private _resetDualBlocks;
  119643. /**
  119644. * Build the material and generates the inner effect
  119645. * @param verbose defines if the build should log activity
  119646. */
  119647. build(verbose?: boolean): void;
  119648. /**
  119649. * Runs an otpimization phase to try to improve the shader code
  119650. */
  119651. optimize(): void;
  119652. private _prepareDefinesForAttributes;
  119653. /**
  119654. * Get if the submesh is ready to be used and all its information available.
  119655. * Child classes can use it to update shaders
  119656. * @param mesh defines the mesh to check
  119657. * @param subMesh defines which submesh to check
  119658. * @param useInstances specifies that instances should be used
  119659. * @returns a boolean indicating that the submesh is ready or not
  119660. */
  119661. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119662. /**
  119663. * Get a string representing the shaders built by the current node graph
  119664. */
  119665. readonly compiledShaders: string;
  119666. /**
  119667. * Binds the world matrix to the material
  119668. * @param world defines the world transformation matrix
  119669. */
  119670. bindOnlyWorldMatrix(world: Matrix): void;
  119671. /**
  119672. * Binds the submesh to this material by preparing the effect and shader to draw
  119673. * @param world defines the world transformation matrix
  119674. * @param mesh defines the mesh containing the submesh
  119675. * @param subMesh defines the submesh to bind the material to
  119676. */
  119677. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119678. /**
  119679. * Gets the active textures from the material
  119680. * @returns an array of textures
  119681. */
  119682. getActiveTextures(): BaseTexture[];
  119683. /**
  119684. * Gets the list of texture blocks
  119685. * @returns an array of texture blocks
  119686. */
  119687. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119688. /**
  119689. * Specifies if the material uses a texture
  119690. * @param texture defines the texture to check against the material
  119691. * @returns a boolean specifying if the material uses the texture
  119692. */
  119693. hasTexture(texture: BaseTexture): boolean;
  119694. /**
  119695. * Disposes the material
  119696. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119697. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119698. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119699. */
  119700. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119701. /** Creates the node editor window. */
  119702. private _createNodeEditor;
  119703. /**
  119704. * Launch the node material editor
  119705. * @param config Define the configuration of the editor
  119706. * @return a promise fulfilled when the node editor is visible
  119707. */
  119708. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119709. /**
  119710. * Clear the current material
  119711. */
  119712. clear(): void;
  119713. /**
  119714. * Clear the current material and set it to a default state
  119715. */
  119716. setToDefault(): void;
  119717. /**
  119718. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119719. * @param url defines the url to load from
  119720. * @returns a promise that will fullfil when the material is fully loaded
  119721. */
  119722. loadAsync(url: string): Promise<unknown>;
  119723. private _gatherBlocks;
  119724. /**
  119725. * Generate a string containing the code declaration required to create an equivalent of this material
  119726. * @returns a string
  119727. */
  119728. generateCode(): string;
  119729. /**
  119730. * Serializes this material in a JSON representation
  119731. * @returns the serialized material object
  119732. */
  119733. serialize(): any;
  119734. private _restoreConnections;
  119735. /**
  119736. * Clear the current graph and load a new one from a serialization object
  119737. * @param source defines the JSON representation of the material
  119738. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119739. */
  119740. loadFromSerialization(source: any, rootUrl?: string): void;
  119741. /**
  119742. * Creates a node material from parsed material data
  119743. * @param source defines the JSON representation of the material
  119744. * @param scene defines the hosting scene
  119745. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119746. * @returns a new node material
  119747. */
  119748. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119749. /**
  119750. * Creates a new node material set to default basic configuration
  119751. * @param name defines the name of the material
  119752. * @param scene defines the hosting scene
  119753. * @returns a new NodeMaterial
  119754. */
  119755. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119756. }
  119757. }
  119758. declare module BABYLON {
  119759. /**
  119760. * Block used to read a texture from a sampler
  119761. */
  119762. export class TextureBlock extends NodeMaterialBlock {
  119763. private _defineName;
  119764. private _linearDefineName;
  119765. private _samplerName;
  119766. private _transformedUVName;
  119767. private _textureTransformName;
  119768. private _textureInfoName;
  119769. private _mainUVName;
  119770. private _mainUVDefineName;
  119771. /**
  119772. * Gets or sets the texture associated with the node
  119773. */
  119774. texture: Nullable<Texture>;
  119775. /**
  119776. * Create a new TextureBlock
  119777. * @param name defines the block name
  119778. */
  119779. constructor(name: string);
  119780. /**
  119781. * Gets the current class name
  119782. * @returns the class name
  119783. */
  119784. getClassName(): string;
  119785. /**
  119786. * Gets the uv input component
  119787. */
  119788. readonly uv: NodeMaterialConnectionPoint;
  119789. /**
  119790. * Gets the rgba output component
  119791. */
  119792. readonly rgba: NodeMaterialConnectionPoint;
  119793. /**
  119794. * Gets the rgb output component
  119795. */
  119796. readonly rgb: NodeMaterialConnectionPoint;
  119797. /**
  119798. * Gets the r output component
  119799. */
  119800. readonly r: NodeMaterialConnectionPoint;
  119801. /**
  119802. * Gets the g output component
  119803. */
  119804. readonly g: NodeMaterialConnectionPoint;
  119805. /**
  119806. * Gets the b output component
  119807. */
  119808. readonly b: NodeMaterialConnectionPoint;
  119809. /**
  119810. * Gets the a output component
  119811. */
  119812. readonly a: NodeMaterialConnectionPoint;
  119813. readonly target: NodeMaterialBlockTargets;
  119814. autoConfigure(material: NodeMaterial): void;
  119815. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119817. isReady(): boolean;
  119818. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119819. private readonly _isMixed;
  119820. private _injectVertexCode;
  119821. private _writeOutput;
  119822. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119823. protected _dumpPropertiesCode(): string;
  119824. serialize(): any;
  119825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119826. }
  119827. }
  119828. declare module BABYLON {
  119829. /**
  119830. * Class used to store shared data between 2 NodeMaterialBuildState
  119831. */
  119832. export class NodeMaterialBuildStateSharedData {
  119833. /**
  119834. * Gets the list of emitted varyings
  119835. */
  119836. temps: string[];
  119837. /**
  119838. * Gets the list of emitted varyings
  119839. */
  119840. varyings: string[];
  119841. /**
  119842. * Gets the varying declaration string
  119843. */
  119844. varyingDeclaration: string;
  119845. /**
  119846. * Input blocks
  119847. */
  119848. inputBlocks: InputBlock[];
  119849. /**
  119850. * Input blocks
  119851. */
  119852. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119853. /**
  119854. * Bindable blocks (Blocks that need to set data to the effect)
  119855. */
  119856. bindableBlocks: NodeMaterialBlock[];
  119857. /**
  119858. * List of blocks that can provide a compilation fallback
  119859. */
  119860. blocksWithFallbacks: NodeMaterialBlock[];
  119861. /**
  119862. * List of blocks that can provide a define update
  119863. */
  119864. blocksWithDefines: NodeMaterialBlock[];
  119865. /**
  119866. * List of blocks that can provide a repeatable content
  119867. */
  119868. repeatableContentBlocks: NodeMaterialBlock[];
  119869. /**
  119870. * List of blocks that can provide a dynamic list of uniforms
  119871. */
  119872. dynamicUniformBlocks: NodeMaterialBlock[];
  119873. /**
  119874. * List of blocks that can block the isReady function for the material
  119875. */
  119876. blockingBlocks: NodeMaterialBlock[];
  119877. /**
  119878. * Gets the list of animated inputs
  119879. */
  119880. animatedInputs: InputBlock[];
  119881. /**
  119882. * Build Id used to avoid multiple recompilations
  119883. */
  119884. buildId: number;
  119885. /** List of emitted variables */
  119886. variableNames: {
  119887. [key: string]: number;
  119888. };
  119889. /** List of emitted defines */
  119890. defineNames: {
  119891. [key: string]: number;
  119892. };
  119893. /** Should emit comments? */
  119894. emitComments: boolean;
  119895. /** Emit build activity */
  119896. verbose: boolean;
  119897. /** Gets or sets the hosting scene */
  119898. scene: Scene;
  119899. /**
  119900. * Gets the compilation hints emitted at compilation time
  119901. */
  119902. hints: {
  119903. needWorldViewMatrix: boolean;
  119904. needWorldViewProjectionMatrix: boolean;
  119905. needAlphaBlending: boolean;
  119906. needAlphaTesting: boolean;
  119907. };
  119908. /**
  119909. * List of compilation checks
  119910. */
  119911. checks: {
  119912. emitVertex: boolean;
  119913. emitFragment: boolean;
  119914. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  119915. };
  119916. /** Creates a new shared data */
  119917. constructor();
  119918. /**
  119919. * Emits console errors and exceptions if there is a failing check
  119920. */
  119921. emitErrors(): void;
  119922. }
  119923. }
  119924. declare module BABYLON {
  119925. /**
  119926. * Class used to store node based material build state
  119927. */
  119928. export class NodeMaterialBuildState {
  119929. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  119930. supportUniformBuffers: boolean;
  119931. /**
  119932. * Gets the list of emitted attributes
  119933. */
  119934. attributes: string[];
  119935. /**
  119936. * Gets the list of emitted uniforms
  119937. */
  119938. uniforms: string[];
  119939. /**
  119940. * Gets the list of emitted constants
  119941. */
  119942. constants: string[];
  119943. /**
  119944. * Gets the list of emitted uniform buffers
  119945. */
  119946. uniformBuffers: string[];
  119947. /**
  119948. * Gets the list of emitted samplers
  119949. */
  119950. samplers: string[];
  119951. /**
  119952. * Gets the list of emitted functions
  119953. */
  119954. functions: {
  119955. [key: string]: string;
  119956. };
  119957. /**
  119958. * Gets the list of emitted extensions
  119959. */
  119960. extensions: {
  119961. [key: string]: string;
  119962. };
  119963. /**
  119964. * Gets the target of the compilation state
  119965. */
  119966. target: NodeMaterialBlockTargets;
  119967. /**
  119968. * Gets the list of emitted counters
  119969. */
  119970. counters: {
  119971. [key: string]: number;
  119972. };
  119973. /**
  119974. * Shared data between multiple NodeMaterialBuildState instances
  119975. */
  119976. sharedData: NodeMaterialBuildStateSharedData;
  119977. /** @hidden */
  119978. _vertexState: NodeMaterialBuildState;
  119979. /** @hidden */
  119980. _attributeDeclaration: string;
  119981. /** @hidden */
  119982. _uniformDeclaration: string;
  119983. /** @hidden */
  119984. _constantDeclaration: string;
  119985. /** @hidden */
  119986. _samplerDeclaration: string;
  119987. /** @hidden */
  119988. _varyingTransfer: string;
  119989. private _repeatableContentAnchorIndex;
  119990. /** @hidden */
  119991. _builtCompilationString: string;
  119992. /**
  119993. * Gets the emitted compilation strings
  119994. */
  119995. compilationString: string;
  119996. /**
  119997. * Finalize the compilation strings
  119998. * @param state defines the current compilation state
  119999. */
  120000. finalize(state: NodeMaterialBuildState): void;
  120001. /** @hidden */
  120002. readonly _repeatableContentAnchor: string;
  120003. /** @hidden */
  120004. _getFreeVariableName(prefix: string): string;
  120005. /** @hidden */
  120006. _getFreeDefineName(prefix: string): string;
  120007. /** @hidden */
  120008. _excludeVariableName(name: string): void;
  120009. /** @hidden */
  120010. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120011. /** @hidden */
  120012. _emitExtension(name: string, extension: string): void;
  120013. /** @hidden */
  120014. _emitFunction(name: string, code: string, comments: string): void;
  120015. /** @hidden */
  120016. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120017. replaceStrings?: {
  120018. search: RegExp;
  120019. replace: string;
  120020. }[];
  120021. repeatKey?: string;
  120022. }): string;
  120023. /** @hidden */
  120024. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120025. repeatKey?: string;
  120026. removeAttributes?: boolean;
  120027. removeUniforms?: boolean;
  120028. removeVaryings?: boolean;
  120029. removeIfDef?: boolean;
  120030. replaceStrings?: {
  120031. search: RegExp;
  120032. replace: string;
  120033. }[];
  120034. }, storeKey?: string): void;
  120035. /** @hidden */
  120036. _registerTempVariable(name: string): boolean;
  120037. /** @hidden */
  120038. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120039. /** @hidden */
  120040. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120041. /** @hidden */
  120042. _emitFloat(value: number): string;
  120043. }
  120044. }
  120045. declare module BABYLON {
  120046. /**
  120047. * Defines a block that can be used inside a node based material
  120048. */
  120049. export class NodeMaterialBlock {
  120050. private _buildId;
  120051. private _buildTarget;
  120052. private _target;
  120053. private _isFinalMerger;
  120054. private _isInput;
  120055. /** @hidden */
  120056. _codeVariableName: string;
  120057. /** @hidden */
  120058. _inputs: NodeMaterialConnectionPoint[];
  120059. /** @hidden */
  120060. _outputs: NodeMaterialConnectionPoint[];
  120061. /** @hidden */
  120062. _preparationId: number;
  120063. /**
  120064. * Gets or sets the name of the block
  120065. */
  120066. name: string;
  120067. /**
  120068. * Gets or sets the unique id of the node
  120069. */
  120070. uniqueId: number;
  120071. /**
  120072. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120073. */
  120074. readonly isFinalMerger: boolean;
  120075. /**
  120076. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120077. */
  120078. readonly isInput: boolean;
  120079. /**
  120080. * Gets or sets the build Id
  120081. */
  120082. buildId: number;
  120083. /**
  120084. * Gets or sets the target of the block
  120085. */
  120086. target: NodeMaterialBlockTargets;
  120087. /**
  120088. * Gets the list of input points
  120089. */
  120090. readonly inputs: NodeMaterialConnectionPoint[];
  120091. /** Gets the list of output points */
  120092. readonly outputs: NodeMaterialConnectionPoint[];
  120093. /**
  120094. * Find an input by its name
  120095. * @param name defines the name of the input to look for
  120096. * @returns the input or null if not found
  120097. */
  120098. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120099. /**
  120100. * Find an output by its name
  120101. * @param name defines the name of the outputto look for
  120102. * @returns the output or null if not found
  120103. */
  120104. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120105. /**
  120106. * Creates a new NodeMaterialBlock
  120107. * @param name defines the block name
  120108. * @param target defines the target of that block (Vertex by default)
  120109. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120110. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120111. */
  120112. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120113. /**
  120114. * Initialize the block and prepare the context for build
  120115. * @param state defines the state that will be used for the build
  120116. */
  120117. initialize(state: NodeMaterialBuildState): void;
  120118. /**
  120119. * Bind data to effect. Will only be called for blocks with isBindable === true
  120120. * @param effect defines the effect to bind data to
  120121. * @param nodeMaterial defines the hosting NodeMaterial
  120122. * @param mesh defines the mesh that will be rendered
  120123. */
  120124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120125. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120126. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120127. protected _writeFloat(value: number): string;
  120128. /**
  120129. * Gets the current class name e.g. "NodeMaterialBlock"
  120130. * @returns the class name
  120131. */
  120132. getClassName(): string;
  120133. /**
  120134. * Register a new input. Must be called inside a block constructor
  120135. * @param name defines the connection point name
  120136. * @param type defines the connection point type
  120137. * @param isOptional defines a boolean indicating that this input can be omitted
  120138. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120139. * @returns the current block
  120140. */
  120141. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120142. /**
  120143. * Register a new output. Must be called inside a block constructor
  120144. * @param name defines the connection point name
  120145. * @param type defines the connection point type
  120146. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120147. * @returns the current block
  120148. */
  120149. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120150. /**
  120151. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120152. * @param forOutput defines an optional connection point to check compatibility with
  120153. * @returns the first available input or null
  120154. */
  120155. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120156. /**
  120157. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120158. * @param forBlock defines an optional block to check compatibility with
  120159. * @returns the first available input or null
  120160. */
  120161. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120162. /**
  120163. * Gets the sibling of the given output
  120164. * @param current defines the current output
  120165. * @returns the next output in the list or null
  120166. */
  120167. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120168. /**
  120169. * Connect current block with another block
  120170. * @param other defines the block to connect with
  120171. * @param options define the various options to help pick the right connections
  120172. * @returns the current block
  120173. */
  120174. connectTo(other: NodeMaterialBlock, options?: {
  120175. input?: string;
  120176. output?: string;
  120177. outputSwizzle?: string;
  120178. }): this | undefined;
  120179. protected _buildBlock(state: NodeMaterialBuildState): void;
  120180. /**
  120181. * Add uniforms, samplers and uniform buffers at compilation time
  120182. * @param state defines the state to update
  120183. * @param nodeMaterial defines the node material requesting the update
  120184. * @param defines defines the material defines to update
  120185. */
  120186. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120187. /**
  120188. * Add potential fallbacks if shader compilation fails
  120189. * @param mesh defines the mesh to be rendered
  120190. * @param fallbacks defines the current prioritized list of fallbacks
  120191. */
  120192. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120193. /**
  120194. * Initialize defines for shader compilation
  120195. * @param mesh defines the mesh to be rendered
  120196. * @param nodeMaterial defines the node material requesting the update
  120197. * @param defines defines the material defines to update
  120198. * @param useInstances specifies that instances should be used
  120199. */
  120200. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120201. /**
  120202. * Update defines for shader compilation
  120203. * @param mesh defines the mesh to be rendered
  120204. * @param nodeMaterial defines the node material requesting the update
  120205. * @param defines defines the material defines to update
  120206. * @param useInstances specifies that instances should be used
  120207. */
  120208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120209. /**
  120210. * Lets the block try to connect some inputs automatically
  120211. * @param material defines the hosting NodeMaterial
  120212. */
  120213. autoConfigure(material: NodeMaterial): void;
  120214. /**
  120215. * Function called when a block is declared as repeatable content generator
  120216. * @param vertexShaderState defines the current compilation state for the vertex shader
  120217. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120218. * @param mesh defines the mesh to be rendered
  120219. * @param defines defines the material defines to update
  120220. */
  120221. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120222. /**
  120223. * Checks if the block is ready
  120224. * @param mesh defines the mesh to be rendered
  120225. * @param nodeMaterial defines the node material requesting the update
  120226. * @param defines defines the material defines to update
  120227. * @param useInstances specifies that instances should be used
  120228. * @returns true if the block is ready
  120229. */
  120230. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120231. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120232. private _processBuild;
  120233. /**
  120234. * Compile the current node and generate the shader code
  120235. * @param state defines the current compilation state (uniforms, samplers, current string)
  120236. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120237. * @returns true if already built
  120238. */
  120239. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120240. protected _inputRename(name: string): string;
  120241. protected _outputRename(name: string): string;
  120242. protected _dumpPropertiesCode(): string;
  120243. /** @hidden */
  120244. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120245. /**
  120246. * Clone the current block to a new identical block
  120247. * @param scene defines the hosting scene
  120248. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120249. * @returns a copy of the current block
  120250. */
  120251. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120252. /**
  120253. * Serializes this block in a JSON representation
  120254. * @returns the serialized block object
  120255. */
  120256. serialize(): any;
  120257. /** @hidden */
  120258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120259. }
  120260. }
  120261. declare module BABYLON {
  120262. /**
  120263. * Enum defining the type of animations supported by InputBlock
  120264. */
  120265. export enum AnimatedInputBlockTypes {
  120266. /** No animation */
  120267. None = 0,
  120268. /** Time based animation. Will only work for floats */
  120269. Time = 1
  120270. }
  120271. }
  120272. declare module BABYLON {
  120273. /**
  120274. * Block used to expose an input value
  120275. */
  120276. export class InputBlock extends NodeMaterialBlock {
  120277. private _mode;
  120278. private _associatedVariableName;
  120279. private _storedValue;
  120280. private _valueCallback;
  120281. private _type;
  120282. private _animationType;
  120283. /** Gets or set a value used to limit the range of float values */
  120284. min: number;
  120285. /** Gets or set a value used to limit the range of float values */
  120286. max: number;
  120287. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120288. matrixMode: number;
  120289. /** @hidden */
  120290. _systemValue: Nullable<NodeMaterialSystemValues>;
  120291. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120292. visibleInInspector: boolean;
  120293. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120294. isConstant: boolean;
  120295. /**
  120296. * Gets or sets the connection point type (default is float)
  120297. */
  120298. readonly type: NodeMaterialBlockConnectionPointTypes;
  120299. /**
  120300. * Creates a new InputBlock
  120301. * @param name defines the block name
  120302. * @param target defines the target of that block (Vertex by default)
  120303. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120304. */
  120305. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120306. /**
  120307. * Gets the output component
  120308. */
  120309. readonly output: NodeMaterialConnectionPoint;
  120310. /**
  120311. * Set the source of this connection point to a vertex attribute
  120312. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120313. * @returns the current connection point
  120314. */
  120315. setAsAttribute(attributeName?: string): InputBlock;
  120316. /**
  120317. * Set the source of this connection point to a system value
  120318. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120319. * @returns the current connection point
  120320. */
  120321. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120322. /**
  120323. * Gets or sets the value of that point.
  120324. * Please note that this value will be ignored if valueCallback is defined
  120325. */
  120326. value: any;
  120327. /**
  120328. * Gets or sets a callback used to get the value of that point.
  120329. * Please note that setting this value will force the connection point to ignore the value property
  120330. */
  120331. valueCallback: () => any;
  120332. /**
  120333. * Gets or sets the associated variable name in the shader
  120334. */
  120335. associatedVariableName: string;
  120336. /** Gets or sets the type of animation applied to the input */
  120337. animationType: AnimatedInputBlockTypes;
  120338. /**
  120339. * Gets a boolean indicating that this connection point not defined yet
  120340. */
  120341. readonly isUndefined: boolean;
  120342. /**
  120343. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120344. * In this case the connection point name must be the name of the uniform to use.
  120345. * Can only be set on inputs
  120346. */
  120347. isUniform: boolean;
  120348. /**
  120349. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120350. * In this case the connection point name must be the name of the attribute to use
  120351. * Can only be set on inputs
  120352. */
  120353. isAttribute: boolean;
  120354. /**
  120355. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120356. * Can only be set on exit points
  120357. */
  120358. isVarying: boolean;
  120359. /**
  120360. * Gets a boolean indicating that the current connection point is a system value
  120361. */
  120362. readonly isSystemValue: boolean;
  120363. /**
  120364. * Gets or sets the current well known value or null if not defined as a system value
  120365. */
  120366. systemValue: Nullable<NodeMaterialSystemValues>;
  120367. /**
  120368. * Gets the current class name
  120369. * @returns the class name
  120370. */
  120371. getClassName(): string;
  120372. /**
  120373. * Animate the input if animationType !== None
  120374. * @param scene defines the rendering scene
  120375. */
  120376. animate(scene: Scene): void;
  120377. private _emitDefine;
  120378. initialize(state: NodeMaterialBuildState): void;
  120379. /**
  120380. * Set the input block to its default value (based on its type)
  120381. */
  120382. setDefaultValue(): void;
  120383. private _emitConstant;
  120384. private _emit;
  120385. /** @hidden */
  120386. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120387. /** @hidden */
  120388. _transmit(effect: Effect, scene: Scene): void;
  120389. protected _buildBlock(state: NodeMaterialBuildState): void;
  120390. protected _dumpPropertiesCode(): string;
  120391. serialize(): any;
  120392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120393. }
  120394. }
  120395. declare module BABYLON {
  120396. /**
  120397. * Defines a connection point for a block
  120398. */
  120399. export class NodeMaterialConnectionPoint {
  120400. /** @hidden */
  120401. _ownerBlock: NodeMaterialBlock;
  120402. /** @hidden */
  120403. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120404. private _endpoints;
  120405. private _associatedVariableName;
  120406. /** @hidden */
  120407. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120408. /** @hidden */
  120409. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120410. private _type;
  120411. /** @hidden */
  120412. _enforceAssociatedVariableName: boolean;
  120413. /**
  120414. * Gets or sets the additional types supported by this connection point
  120415. */
  120416. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120417. /**
  120418. * Gets or sets the additional types excluded by this connection point
  120419. */
  120420. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120421. /**
  120422. * Gets or sets the associated variable name in the shader
  120423. */
  120424. associatedVariableName: string;
  120425. /**
  120426. * Gets or sets the connection point type (default is float)
  120427. */
  120428. type: NodeMaterialBlockConnectionPointTypes;
  120429. /**
  120430. * Gets or sets the connection point name
  120431. */
  120432. name: string;
  120433. /**
  120434. * Gets or sets a boolean indicating that this connection point can be omitted
  120435. */
  120436. isOptional: boolean;
  120437. /**
  120438. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120439. */
  120440. define: string;
  120441. /** Gets or sets the target of that connection point */
  120442. target: NodeMaterialBlockTargets;
  120443. /**
  120444. * Gets a boolean indicating that the current point is connected
  120445. */
  120446. readonly isConnected: boolean;
  120447. /**
  120448. * Gets a boolean indicating that the current point is connected to an input block
  120449. */
  120450. readonly isConnectedToInputBlock: boolean;
  120451. /**
  120452. * Gets a the connected input block (if any)
  120453. */
  120454. readonly connectInputBlock: Nullable<InputBlock>;
  120455. /** Get the other side of the connection (if any) */
  120456. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120457. /** Get the block that owns this connection point */
  120458. readonly ownerBlock: NodeMaterialBlock;
  120459. /** Get the block connected on the other side of this connection (if any) */
  120460. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120461. /** Get the block connected on the endpoints of this connection (if any) */
  120462. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120463. /** Gets the list of connected endpoints */
  120464. readonly endpoints: NodeMaterialConnectionPoint[];
  120465. /** Gets a boolean indicating if that output point is connected to at least one input */
  120466. readonly hasEndpoints: boolean;
  120467. /**
  120468. * Creates a new connection point
  120469. * @param name defines the connection point name
  120470. * @param ownerBlock defines the block hosting this connection point
  120471. */
  120472. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120473. /**
  120474. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120475. * @returns the class name
  120476. */
  120477. getClassName(): string;
  120478. /**
  120479. * Gets an boolean indicating if the current point can be connected to another point
  120480. * @param connectionPoint defines the other connection point
  120481. * @returns true if the connection is possible
  120482. */
  120483. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120484. /**
  120485. * Connect this point to another connection point
  120486. * @param connectionPoint defines the other connection point
  120487. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120488. * @returns the current connection point
  120489. */
  120490. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120491. /**
  120492. * Disconnect this point from one of his endpoint
  120493. * @param endpoint defines the other connection point
  120494. * @returns the current connection point
  120495. */
  120496. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120497. /**
  120498. * Serializes this point in a JSON representation
  120499. * @returns the serialized point object
  120500. */
  120501. serialize(): any;
  120502. }
  120503. }
  120504. declare module BABYLON {
  120505. /**
  120506. * Block used to add support for vertex skinning (bones)
  120507. */
  120508. export class BonesBlock extends NodeMaterialBlock {
  120509. /**
  120510. * Creates a new BonesBlock
  120511. * @param name defines the block name
  120512. */
  120513. constructor(name: string);
  120514. /**
  120515. * Initialize the block and prepare the context for build
  120516. * @param state defines the state that will be used for the build
  120517. */
  120518. initialize(state: NodeMaterialBuildState): void;
  120519. /**
  120520. * Gets the current class name
  120521. * @returns the class name
  120522. */
  120523. getClassName(): string;
  120524. /**
  120525. * Gets the matrix indices input component
  120526. */
  120527. readonly matricesIndices: NodeMaterialConnectionPoint;
  120528. /**
  120529. * Gets the matrix weights input component
  120530. */
  120531. readonly matricesWeights: NodeMaterialConnectionPoint;
  120532. /**
  120533. * Gets the extra matrix indices input component
  120534. */
  120535. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120536. /**
  120537. * Gets the extra matrix weights input component
  120538. */
  120539. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120540. /**
  120541. * Gets the world input component
  120542. */
  120543. readonly world: NodeMaterialConnectionPoint;
  120544. /**
  120545. * Gets the output component
  120546. */
  120547. readonly output: NodeMaterialConnectionPoint;
  120548. autoConfigure(material: NodeMaterial): void;
  120549. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120551. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120552. protected _buildBlock(state: NodeMaterialBuildState): this;
  120553. }
  120554. }
  120555. declare module BABYLON {
  120556. /**
  120557. * Block used to add support for instances
  120558. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120559. */
  120560. export class InstancesBlock extends NodeMaterialBlock {
  120561. /**
  120562. * Creates a new InstancesBlock
  120563. * @param name defines the block name
  120564. */
  120565. constructor(name: string);
  120566. /**
  120567. * Gets the current class name
  120568. * @returns the class name
  120569. */
  120570. getClassName(): string;
  120571. /**
  120572. * Gets the first world row input component
  120573. */
  120574. readonly world0: NodeMaterialConnectionPoint;
  120575. /**
  120576. * Gets the second world row input component
  120577. */
  120578. readonly world1: NodeMaterialConnectionPoint;
  120579. /**
  120580. * Gets the third world row input component
  120581. */
  120582. readonly world2: NodeMaterialConnectionPoint;
  120583. /**
  120584. * Gets the forth world row input component
  120585. */
  120586. readonly world3: NodeMaterialConnectionPoint;
  120587. /**
  120588. * Gets the world input component
  120589. */
  120590. readonly world: NodeMaterialConnectionPoint;
  120591. /**
  120592. * Gets the output component
  120593. */
  120594. readonly output: NodeMaterialConnectionPoint;
  120595. autoConfigure(material: NodeMaterial): void;
  120596. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120597. protected _buildBlock(state: NodeMaterialBuildState): this;
  120598. }
  120599. }
  120600. declare module BABYLON {
  120601. /**
  120602. * Block used to add morph targets support to vertex shader
  120603. */
  120604. export class MorphTargetsBlock extends NodeMaterialBlock {
  120605. private _repeatableContentAnchor;
  120606. private _repeatebleContentGenerated;
  120607. /**
  120608. * Create a new MorphTargetsBlock
  120609. * @param name defines the block name
  120610. */
  120611. constructor(name: string);
  120612. /**
  120613. * Gets the current class name
  120614. * @returns the class name
  120615. */
  120616. getClassName(): string;
  120617. /**
  120618. * Gets the position input component
  120619. */
  120620. readonly position: NodeMaterialConnectionPoint;
  120621. /**
  120622. * Gets the normal input component
  120623. */
  120624. readonly normal: NodeMaterialConnectionPoint;
  120625. /**
  120626. * Gets the tangent input component
  120627. */
  120628. readonly tangent: NodeMaterialConnectionPoint;
  120629. /**
  120630. * Gets the tangent input component
  120631. */
  120632. readonly uv: NodeMaterialConnectionPoint;
  120633. /**
  120634. * Gets the position output component
  120635. */
  120636. readonly positionOutput: NodeMaterialConnectionPoint;
  120637. /**
  120638. * Gets the normal output component
  120639. */
  120640. readonly normalOutput: NodeMaterialConnectionPoint;
  120641. /**
  120642. * Gets the tangent output component
  120643. */
  120644. readonly tangentOutput: NodeMaterialConnectionPoint;
  120645. /**
  120646. * Gets the tangent output component
  120647. */
  120648. readonly uvOutput: NodeMaterialConnectionPoint;
  120649. initialize(state: NodeMaterialBuildState): void;
  120650. autoConfigure(material: NodeMaterial): void;
  120651. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120653. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120654. protected _buildBlock(state: NodeMaterialBuildState): this;
  120655. }
  120656. }
  120657. declare module BABYLON {
  120658. /**
  120659. * Block used to get data information from a light
  120660. */
  120661. export class LightInformationBlock extends NodeMaterialBlock {
  120662. private _lightDataUniformName;
  120663. private _lightColorUniformName;
  120664. private _lightTypeDefineName;
  120665. /**
  120666. * Gets or sets the light associated with this block
  120667. */
  120668. light: Nullable<Light>;
  120669. /**
  120670. * Creates a new LightInformationBlock
  120671. * @param name defines the block name
  120672. */
  120673. constructor(name: string);
  120674. /**
  120675. * Gets the current class name
  120676. * @returns the class name
  120677. */
  120678. getClassName(): string;
  120679. /**
  120680. * Gets the world position input component
  120681. */
  120682. readonly worldPosition: NodeMaterialConnectionPoint;
  120683. /**
  120684. * Gets the direction output component
  120685. */
  120686. readonly direction: NodeMaterialConnectionPoint;
  120687. /**
  120688. * Gets the direction output component
  120689. */
  120690. readonly color: NodeMaterialConnectionPoint;
  120691. /**
  120692. * Gets the direction output component
  120693. */
  120694. readonly intensity: NodeMaterialConnectionPoint;
  120695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120696. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120697. protected _buildBlock(state: NodeMaterialBuildState): this;
  120698. serialize(): any;
  120699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120700. }
  120701. }
  120702. declare module BABYLON {
  120703. /**
  120704. * Block used to add image processing support to fragment shader
  120705. */
  120706. export class ImageProcessingBlock extends NodeMaterialBlock {
  120707. /**
  120708. * Create a new ImageProcessingBlock
  120709. * @param name defines the block name
  120710. */
  120711. constructor(name: string);
  120712. /**
  120713. * Gets the current class name
  120714. * @returns the class name
  120715. */
  120716. getClassName(): string;
  120717. /**
  120718. * Gets the color input component
  120719. */
  120720. readonly color: NodeMaterialConnectionPoint;
  120721. /**
  120722. * Gets the output component
  120723. */
  120724. readonly output: NodeMaterialConnectionPoint;
  120725. /**
  120726. * Initialize the block and prepare the context for build
  120727. * @param state defines the state that will be used for the build
  120728. */
  120729. initialize(state: NodeMaterialBuildState): void;
  120730. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120733. protected _buildBlock(state: NodeMaterialBuildState): this;
  120734. }
  120735. }
  120736. declare module BABYLON {
  120737. /**
  120738. * Block used to pertub normals based on a normal map
  120739. */
  120740. export class PerturbNormalBlock extends NodeMaterialBlock {
  120741. private _tangentSpaceParameterName;
  120742. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120743. invertX: boolean;
  120744. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120745. invertY: boolean;
  120746. /**
  120747. * Create a new PerturbNormalBlock
  120748. * @param name defines the block name
  120749. */
  120750. constructor(name: string);
  120751. /**
  120752. * Gets the current class name
  120753. * @returns the class name
  120754. */
  120755. getClassName(): string;
  120756. /**
  120757. * Gets the world position input component
  120758. */
  120759. readonly worldPosition: NodeMaterialConnectionPoint;
  120760. /**
  120761. * Gets the world normal input component
  120762. */
  120763. readonly worldNormal: NodeMaterialConnectionPoint;
  120764. /**
  120765. * Gets the uv input component
  120766. */
  120767. readonly uv: NodeMaterialConnectionPoint;
  120768. /**
  120769. * Gets the normal map color input component
  120770. */
  120771. readonly normalMapColor: NodeMaterialConnectionPoint;
  120772. /**
  120773. * Gets the strength input component
  120774. */
  120775. readonly strength: NodeMaterialConnectionPoint;
  120776. /**
  120777. * Gets the output component
  120778. */
  120779. readonly output: NodeMaterialConnectionPoint;
  120780. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120781. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120782. autoConfigure(material: NodeMaterial): void;
  120783. protected _buildBlock(state: NodeMaterialBuildState): this;
  120784. protected _dumpPropertiesCode(): string;
  120785. serialize(): any;
  120786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120787. }
  120788. }
  120789. declare module BABYLON {
  120790. /**
  120791. * Block used to discard a pixel if a value is smaller than a cutoff
  120792. */
  120793. export class DiscardBlock extends NodeMaterialBlock {
  120794. /**
  120795. * Create a new DiscardBlock
  120796. * @param name defines the block name
  120797. */
  120798. constructor(name: string);
  120799. /**
  120800. * Gets the current class name
  120801. * @returns the class name
  120802. */
  120803. getClassName(): string;
  120804. /**
  120805. * Gets the color input component
  120806. */
  120807. readonly value: NodeMaterialConnectionPoint;
  120808. /**
  120809. * Gets the cutoff input component
  120810. */
  120811. readonly cutoff: NodeMaterialConnectionPoint;
  120812. protected _buildBlock(state: NodeMaterialBuildState): this;
  120813. }
  120814. }
  120815. declare module BABYLON {
  120816. /**
  120817. * Block used to add support for scene fog
  120818. */
  120819. export class FogBlock extends NodeMaterialBlock {
  120820. private _fogDistanceName;
  120821. private _fogParameters;
  120822. /**
  120823. * Create a new FogBlock
  120824. * @param name defines the block name
  120825. */
  120826. constructor(name: string);
  120827. /**
  120828. * Gets the current class name
  120829. * @returns the class name
  120830. */
  120831. getClassName(): string;
  120832. /**
  120833. * Gets the world position input component
  120834. */
  120835. readonly worldPosition: NodeMaterialConnectionPoint;
  120836. /**
  120837. * Gets the view input component
  120838. */
  120839. readonly view: NodeMaterialConnectionPoint;
  120840. /**
  120841. * Gets the color input component
  120842. */
  120843. readonly input: NodeMaterialConnectionPoint;
  120844. /**
  120845. * Gets the fog color input component
  120846. */
  120847. readonly fogColor: NodeMaterialConnectionPoint;
  120848. /**
  120849. * Gets the output component
  120850. */
  120851. readonly output: NodeMaterialConnectionPoint;
  120852. autoConfigure(material: NodeMaterial): void;
  120853. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120854. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120855. protected _buildBlock(state: NodeMaterialBuildState): this;
  120856. }
  120857. }
  120858. declare module BABYLON {
  120859. /**
  120860. * Block used to add light in the fragment shader
  120861. */
  120862. export class LightBlock extends NodeMaterialBlock {
  120863. private _lightId;
  120864. /**
  120865. * Gets or sets the light associated with this block
  120866. */
  120867. light: Nullable<Light>;
  120868. /**
  120869. * Create a new LightBlock
  120870. * @param name defines the block name
  120871. */
  120872. constructor(name: string);
  120873. /**
  120874. * Gets the current class name
  120875. * @returns the class name
  120876. */
  120877. getClassName(): string;
  120878. /**
  120879. * Gets the world position input component
  120880. */
  120881. readonly worldPosition: NodeMaterialConnectionPoint;
  120882. /**
  120883. * Gets the world normal input component
  120884. */
  120885. readonly worldNormal: NodeMaterialConnectionPoint;
  120886. /**
  120887. * Gets the camera (or eye) position component
  120888. */
  120889. readonly cameraPosition: NodeMaterialConnectionPoint;
  120890. /**
  120891. * Gets the glossiness component
  120892. */
  120893. readonly glossiness: NodeMaterialConnectionPoint;
  120894. /**
  120895. * Gets the glossinness power component
  120896. */
  120897. readonly glossPower: NodeMaterialConnectionPoint;
  120898. /**
  120899. * Gets the diffuse color component
  120900. */
  120901. readonly diffuseColor: NodeMaterialConnectionPoint;
  120902. /**
  120903. * Gets the specular color component
  120904. */
  120905. readonly specularColor: NodeMaterialConnectionPoint;
  120906. /**
  120907. * Gets the diffuse output component
  120908. */
  120909. readonly diffuseOutput: NodeMaterialConnectionPoint;
  120910. /**
  120911. * Gets the specular output component
  120912. */
  120913. readonly specularOutput: NodeMaterialConnectionPoint;
  120914. autoConfigure(material: NodeMaterial): void;
  120915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120916. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120917. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120918. private _injectVertexCode;
  120919. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120920. serialize(): any;
  120921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120922. }
  120923. }
  120924. declare module BABYLON {
  120925. /**
  120926. * Block used to multiply 2 values
  120927. */
  120928. export class MultiplyBlock extends NodeMaterialBlock {
  120929. /**
  120930. * Creates a new MultiplyBlock
  120931. * @param name defines the block name
  120932. */
  120933. constructor(name: string);
  120934. /**
  120935. * Gets the current class name
  120936. * @returns the class name
  120937. */
  120938. getClassName(): string;
  120939. /**
  120940. * Gets the left operand input component
  120941. */
  120942. readonly left: NodeMaterialConnectionPoint;
  120943. /**
  120944. * Gets the right operand input component
  120945. */
  120946. readonly right: NodeMaterialConnectionPoint;
  120947. /**
  120948. * Gets the output component
  120949. */
  120950. readonly output: NodeMaterialConnectionPoint;
  120951. protected _buildBlock(state: NodeMaterialBuildState): this;
  120952. }
  120953. }
  120954. declare module BABYLON {
  120955. /**
  120956. * Block used to add 2 vectors
  120957. */
  120958. export class AddBlock extends NodeMaterialBlock {
  120959. /**
  120960. * Creates a new AddBlock
  120961. * @param name defines the block name
  120962. */
  120963. constructor(name: string);
  120964. /**
  120965. * Gets the current class name
  120966. * @returns the class name
  120967. */
  120968. getClassName(): string;
  120969. /**
  120970. * Gets the left operand input component
  120971. */
  120972. readonly left: NodeMaterialConnectionPoint;
  120973. /**
  120974. * Gets the right operand input component
  120975. */
  120976. readonly right: NodeMaterialConnectionPoint;
  120977. /**
  120978. * Gets the output component
  120979. */
  120980. readonly output: NodeMaterialConnectionPoint;
  120981. protected _buildBlock(state: NodeMaterialBuildState): this;
  120982. }
  120983. }
  120984. declare module BABYLON {
  120985. /**
  120986. * Block used to scale a vector by a float
  120987. */
  120988. export class ScaleBlock extends NodeMaterialBlock {
  120989. /**
  120990. * Creates a new ScaleBlock
  120991. * @param name defines the block name
  120992. */
  120993. constructor(name: string);
  120994. /**
  120995. * Gets the current class name
  120996. * @returns the class name
  120997. */
  120998. getClassName(): string;
  120999. /**
  121000. * Gets the input component
  121001. */
  121002. readonly input: NodeMaterialConnectionPoint;
  121003. /**
  121004. * Gets the factor input component
  121005. */
  121006. readonly factor: NodeMaterialConnectionPoint;
  121007. /**
  121008. * Gets the output component
  121009. */
  121010. readonly output: NodeMaterialConnectionPoint;
  121011. protected _buildBlock(state: NodeMaterialBuildState): this;
  121012. }
  121013. }
  121014. declare module BABYLON {
  121015. /**
  121016. * Block used to clamp a float
  121017. */
  121018. export class ClampBlock extends NodeMaterialBlock {
  121019. /** Gets or sets the minimum range */
  121020. minimum: number;
  121021. /** Gets or sets the maximum range */
  121022. maximum: number;
  121023. /**
  121024. * Creates a new ClampBlock
  121025. * @param name defines the block name
  121026. */
  121027. constructor(name: string);
  121028. /**
  121029. * Gets the current class name
  121030. * @returns the class name
  121031. */
  121032. getClassName(): string;
  121033. /**
  121034. * Gets the value input component
  121035. */
  121036. readonly value: NodeMaterialConnectionPoint;
  121037. /**
  121038. * Gets the output component
  121039. */
  121040. readonly output: NodeMaterialConnectionPoint;
  121041. protected _buildBlock(state: NodeMaterialBuildState): this;
  121042. protected _dumpPropertiesCode(): string;
  121043. serialize(): any;
  121044. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121045. }
  121046. }
  121047. declare module BABYLON {
  121048. /**
  121049. * Block used to apply a cross product between 2 vectors
  121050. */
  121051. export class CrossBlock extends NodeMaterialBlock {
  121052. /**
  121053. * Creates a new CrossBlock
  121054. * @param name defines the block name
  121055. */
  121056. constructor(name: string);
  121057. /**
  121058. * Gets the current class name
  121059. * @returns the class name
  121060. */
  121061. getClassName(): string;
  121062. /**
  121063. * Gets the left operand input component
  121064. */
  121065. readonly left: NodeMaterialConnectionPoint;
  121066. /**
  121067. * Gets the right operand input component
  121068. */
  121069. readonly right: NodeMaterialConnectionPoint;
  121070. /**
  121071. * Gets the output component
  121072. */
  121073. readonly output: NodeMaterialConnectionPoint;
  121074. protected _buildBlock(state: NodeMaterialBuildState): this;
  121075. }
  121076. }
  121077. declare module BABYLON {
  121078. /**
  121079. * Block used to apply a dot product between 2 vectors
  121080. */
  121081. export class DotBlock extends NodeMaterialBlock {
  121082. /**
  121083. * Creates a new DotBlock
  121084. * @param name defines the block name
  121085. */
  121086. constructor(name: string);
  121087. /**
  121088. * Gets the current class name
  121089. * @returns the class name
  121090. */
  121091. getClassName(): string;
  121092. /**
  121093. * Gets the left operand input component
  121094. */
  121095. readonly left: NodeMaterialConnectionPoint;
  121096. /**
  121097. * Gets the right operand input component
  121098. */
  121099. readonly right: NodeMaterialConnectionPoint;
  121100. /**
  121101. * Gets the output component
  121102. */
  121103. readonly output: NodeMaterialConnectionPoint;
  121104. protected _buildBlock(state: NodeMaterialBuildState): this;
  121105. }
  121106. }
  121107. declare module BABYLON {
  121108. /**
  121109. * Block used to remap a float from a range to a new one
  121110. */
  121111. export class RemapBlock extends NodeMaterialBlock {
  121112. /**
  121113. * Gets or sets the source range
  121114. */
  121115. sourceRange: Vector2;
  121116. /**
  121117. * Gets or sets the target range
  121118. */
  121119. targetRange: Vector2;
  121120. /**
  121121. * Creates a new RemapBlock
  121122. * @param name defines the block name
  121123. */
  121124. constructor(name: string);
  121125. /**
  121126. * Gets the current class name
  121127. * @returns the class name
  121128. */
  121129. getClassName(): string;
  121130. /**
  121131. * Gets the input component
  121132. */
  121133. readonly input: NodeMaterialConnectionPoint;
  121134. /**
  121135. * Gets the source min input component
  121136. */
  121137. readonly sourceMin: NodeMaterialConnectionPoint;
  121138. /**
  121139. * Gets the source max input component
  121140. */
  121141. readonly sourceMax: NodeMaterialConnectionPoint;
  121142. /**
  121143. * Gets the target min input component
  121144. */
  121145. readonly targetMin: NodeMaterialConnectionPoint;
  121146. /**
  121147. * Gets the target max input component
  121148. */
  121149. readonly targetMax: NodeMaterialConnectionPoint;
  121150. /**
  121151. * Gets the output component
  121152. */
  121153. readonly output: NodeMaterialConnectionPoint;
  121154. protected _buildBlock(state: NodeMaterialBuildState): this;
  121155. protected _dumpPropertiesCode(): string;
  121156. serialize(): any;
  121157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121158. }
  121159. }
  121160. declare module BABYLON {
  121161. /**
  121162. * Block used to normalize a vector
  121163. */
  121164. export class NormalizeBlock extends NodeMaterialBlock {
  121165. /**
  121166. * Creates a new NormalizeBlock
  121167. * @param name defines the block name
  121168. */
  121169. constructor(name: string);
  121170. /**
  121171. * Gets the current class name
  121172. * @returns the class name
  121173. */
  121174. getClassName(): string;
  121175. /**
  121176. * Gets the input component
  121177. */
  121178. readonly input: NodeMaterialConnectionPoint;
  121179. /**
  121180. * Gets the output component
  121181. */
  121182. readonly output: NodeMaterialConnectionPoint;
  121183. protected _buildBlock(state: NodeMaterialBuildState): this;
  121184. }
  121185. }
  121186. declare module BABYLON {
  121187. /**
  121188. * Operations supported by the Trigonometry block
  121189. */
  121190. export enum TrigonometryBlockOperations {
  121191. /** Cos */
  121192. Cos = 0,
  121193. /** Sin */
  121194. Sin = 1,
  121195. /** Abs */
  121196. Abs = 2,
  121197. /** Exp */
  121198. Exp = 3,
  121199. /** Exp2 */
  121200. Exp2 = 4,
  121201. /** Round */
  121202. Round = 5,
  121203. /** Floor */
  121204. Floor = 6,
  121205. /** Ceiling */
  121206. Ceiling = 7,
  121207. /** Square root */
  121208. Sqrt = 8,
  121209. /** Log */
  121210. Log = 9,
  121211. /** Tangent */
  121212. Tan = 10,
  121213. /** Arc tangent */
  121214. ArcTan = 11,
  121215. /** Arc cosinus */
  121216. ArcCos = 12,
  121217. /** Arc sinus */
  121218. ArcSin = 13,
  121219. /** Fraction */
  121220. Fract = 14,
  121221. /** Sign */
  121222. Sign = 15,
  121223. /** To radians (from degrees) */
  121224. Radians = 16,
  121225. /** To degrees (from radians) */
  121226. Degrees = 17
  121227. }
  121228. /**
  121229. * Block used to apply trigonometry operation to floats
  121230. */
  121231. export class TrigonometryBlock extends NodeMaterialBlock {
  121232. /**
  121233. * Gets or sets the operation applied by the block
  121234. */
  121235. operation: TrigonometryBlockOperations;
  121236. /**
  121237. * Creates a new TrigonometryBlock
  121238. * @param name defines the block name
  121239. */
  121240. constructor(name: string);
  121241. /**
  121242. * Gets the current class name
  121243. * @returns the class name
  121244. */
  121245. getClassName(): string;
  121246. /**
  121247. * Gets the input component
  121248. */
  121249. readonly input: NodeMaterialConnectionPoint;
  121250. /**
  121251. * Gets the output component
  121252. */
  121253. readonly output: NodeMaterialConnectionPoint;
  121254. protected _buildBlock(state: NodeMaterialBuildState): this;
  121255. serialize(): any;
  121256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121257. }
  121258. }
  121259. declare module BABYLON {
  121260. /**
  121261. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121262. */
  121263. export class ColorMergerBlock extends NodeMaterialBlock {
  121264. /**
  121265. * Create a new ColorMergerBlock
  121266. * @param name defines the block name
  121267. */
  121268. constructor(name: string);
  121269. /**
  121270. * Gets the current class name
  121271. * @returns the class name
  121272. */
  121273. getClassName(): string;
  121274. /**
  121275. * Gets the r component (input)
  121276. */
  121277. readonly r: NodeMaterialConnectionPoint;
  121278. /**
  121279. * Gets the g component (input)
  121280. */
  121281. readonly g: NodeMaterialConnectionPoint;
  121282. /**
  121283. * Gets the b component (input)
  121284. */
  121285. readonly b: NodeMaterialConnectionPoint;
  121286. /**
  121287. * Gets the a component (input)
  121288. */
  121289. readonly a: NodeMaterialConnectionPoint;
  121290. /**
  121291. * Gets the rgba component (output)
  121292. */
  121293. readonly rgba: NodeMaterialConnectionPoint;
  121294. /**
  121295. * Gets the rgb component (output)
  121296. */
  121297. readonly rgb: NodeMaterialConnectionPoint;
  121298. protected _buildBlock(state: NodeMaterialBuildState): this;
  121299. }
  121300. }
  121301. declare module BABYLON {
  121302. /**
  121303. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121304. */
  121305. export class VectorMergerBlock extends NodeMaterialBlock {
  121306. /**
  121307. * Create a new VectorMergerBlock
  121308. * @param name defines the block name
  121309. */
  121310. constructor(name: string);
  121311. /**
  121312. * Gets the current class name
  121313. * @returns the class name
  121314. */
  121315. getClassName(): string;
  121316. /**
  121317. * Gets the x component (input)
  121318. */
  121319. readonly x: NodeMaterialConnectionPoint;
  121320. /**
  121321. * Gets the y component (input)
  121322. */
  121323. readonly y: NodeMaterialConnectionPoint;
  121324. /**
  121325. * Gets the z component (input)
  121326. */
  121327. readonly z: NodeMaterialConnectionPoint;
  121328. /**
  121329. * Gets the w component (input)
  121330. */
  121331. readonly w: NodeMaterialConnectionPoint;
  121332. /**
  121333. * Gets the xyzw component (output)
  121334. */
  121335. readonly xyzw: NodeMaterialConnectionPoint;
  121336. /**
  121337. * Gets the xyz component (output)
  121338. */
  121339. readonly xyz: NodeMaterialConnectionPoint;
  121340. /**
  121341. * Gets the xy component (output)
  121342. */
  121343. readonly xy: NodeMaterialConnectionPoint;
  121344. protected _buildBlock(state: NodeMaterialBuildState): this;
  121345. }
  121346. }
  121347. declare module BABYLON {
  121348. /**
  121349. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121350. */
  121351. export class ColorSplitterBlock extends NodeMaterialBlock {
  121352. /**
  121353. * Create a new ColorSplitterBlock
  121354. * @param name defines the block name
  121355. */
  121356. constructor(name: string);
  121357. /**
  121358. * Gets the current class name
  121359. * @returns the class name
  121360. */
  121361. getClassName(): string;
  121362. /**
  121363. * Gets the rgba component (input)
  121364. */
  121365. readonly rgba: NodeMaterialConnectionPoint;
  121366. /**
  121367. * Gets the rgb component (input)
  121368. */
  121369. readonly rgbIn: NodeMaterialConnectionPoint;
  121370. /**
  121371. * Gets the rgb component (output)
  121372. */
  121373. readonly rgbOut: NodeMaterialConnectionPoint;
  121374. /**
  121375. * Gets the r component (output)
  121376. */
  121377. readonly r: NodeMaterialConnectionPoint;
  121378. /**
  121379. * Gets the g component (output)
  121380. */
  121381. readonly g: NodeMaterialConnectionPoint;
  121382. /**
  121383. * Gets the b component (output)
  121384. */
  121385. readonly b: NodeMaterialConnectionPoint;
  121386. /**
  121387. * Gets the a component (output)
  121388. */
  121389. readonly a: NodeMaterialConnectionPoint;
  121390. protected _inputRename(name: string): string;
  121391. protected _outputRename(name: string): string;
  121392. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121393. }
  121394. }
  121395. declare module BABYLON {
  121396. /**
  121397. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121398. */
  121399. export class VectorSplitterBlock extends NodeMaterialBlock {
  121400. /**
  121401. * Create a new VectorSplitterBlock
  121402. * @param name defines the block name
  121403. */
  121404. constructor(name: string);
  121405. /**
  121406. * Gets the current class name
  121407. * @returns the class name
  121408. */
  121409. getClassName(): string;
  121410. /**
  121411. * Gets the xyzw component (input)
  121412. */
  121413. readonly xyzw: NodeMaterialConnectionPoint;
  121414. /**
  121415. * Gets the xyz component (input)
  121416. */
  121417. readonly xyzIn: NodeMaterialConnectionPoint;
  121418. /**
  121419. * Gets the xy component (input)
  121420. */
  121421. readonly xyIn: NodeMaterialConnectionPoint;
  121422. /**
  121423. * Gets the xyz component (output)
  121424. */
  121425. readonly xyzOut: NodeMaterialConnectionPoint;
  121426. /**
  121427. * Gets the xy component (output)
  121428. */
  121429. readonly xyOut: NodeMaterialConnectionPoint;
  121430. /**
  121431. * Gets the x component (output)
  121432. */
  121433. readonly x: NodeMaterialConnectionPoint;
  121434. /**
  121435. * Gets the y component (output)
  121436. */
  121437. readonly y: NodeMaterialConnectionPoint;
  121438. /**
  121439. * Gets the z component (output)
  121440. */
  121441. readonly z: NodeMaterialConnectionPoint;
  121442. /**
  121443. * Gets the w component (output)
  121444. */
  121445. readonly w: NodeMaterialConnectionPoint;
  121446. protected _inputRename(name: string): string;
  121447. protected _outputRename(name: string): string;
  121448. protected _buildBlock(state: NodeMaterialBuildState): this;
  121449. }
  121450. }
  121451. declare module BABYLON {
  121452. /**
  121453. * Block used to lerp 2 values
  121454. */
  121455. export class LerpBlock extends NodeMaterialBlock {
  121456. /**
  121457. * Creates a new LerpBlock
  121458. * @param name defines the block name
  121459. */
  121460. constructor(name: string);
  121461. /**
  121462. * Gets the current class name
  121463. * @returns the class name
  121464. */
  121465. getClassName(): string;
  121466. /**
  121467. * Gets the left operand input component
  121468. */
  121469. readonly left: NodeMaterialConnectionPoint;
  121470. /**
  121471. * Gets the right operand input component
  121472. */
  121473. readonly right: NodeMaterialConnectionPoint;
  121474. /**
  121475. * Gets the gradient operand input component
  121476. */
  121477. readonly gradient: NodeMaterialConnectionPoint;
  121478. /**
  121479. * Gets the output component
  121480. */
  121481. readonly output: NodeMaterialConnectionPoint;
  121482. protected _buildBlock(state: NodeMaterialBuildState): this;
  121483. }
  121484. }
  121485. declare module BABYLON {
  121486. /**
  121487. * Block used to divide 2 vectors
  121488. */
  121489. export class DivideBlock extends NodeMaterialBlock {
  121490. /**
  121491. * Creates a new DivideBlock
  121492. * @param name defines the block name
  121493. */
  121494. constructor(name: string);
  121495. /**
  121496. * Gets the current class name
  121497. * @returns the class name
  121498. */
  121499. getClassName(): string;
  121500. /**
  121501. * Gets the left operand input component
  121502. */
  121503. readonly left: NodeMaterialConnectionPoint;
  121504. /**
  121505. * Gets the right operand input component
  121506. */
  121507. readonly right: NodeMaterialConnectionPoint;
  121508. /**
  121509. * Gets the output component
  121510. */
  121511. readonly output: NodeMaterialConnectionPoint;
  121512. protected _buildBlock(state: NodeMaterialBuildState): this;
  121513. }
  121514. }
  121515. declare module BABYLON {
  121516. /**
  121517. * Block used to subtract 2 vectors
  121518. */
  121519. export class SubtractBlock extends NodeMaterialBlock {
  121520. /**
  121521. * Creates a new SubtractBlock
  121522. * @param name defines the block name
  121523. */
  121524. constructor(name: string);
  121525. /**
  121526. * Gets the current class name
  121527. * @returns the class name
  121528. */
  121529. getClassName(): string;
  121530. /**
  121531. * Gets the left operand input component
  121532. */
  121533. readonly left: NodeMaterialConnectionPoint;
  121534. /**
  121535. * Gets the right operand input component
  121536. */
  121537. readonly right: NodeMaterialConnectionPoint;
  121538. /**
  121539. * Gets the output component
  121540. */
  121541. readonly output: NodeMaterialConnectionPoint;
  121542. protected _buildBlock(state: NodeMaterialBuildState): this;
  121543. }
  121544. }
  121545. declare module BABYLON {
  121546. /**
  121547. * Block used to step a value
  121548. */
  121549. export class StepBlock extends NodeMaterialBlock {
  121550. /**
  121551. * Creates a new StepBlock
  121552. * @param name defines the block name
  121553. */
  121554. constructor(name: string);
  121555. /**
  121556. * Gets the current class name
  121557. * @returns the class name
  121558. */
  121559. getClassName(): string;
  121560. /**
  121561. * Gets the value operand input component
  121562. */
  121563. readonly value: NodeMaterialConnectionPoint;
  121564. /**
  121565. * Gets the edge operand input component
  121566. */
  121567. readonly edge: NodeMaterialConnectionPoint;
  121568. /**
  121569. * Gets the output component
  121570. */
  121571. readonly output: NodeMaterialConnectionPoint;
  121572. protected _buildBlock(state: NodeMaterialBuildState): this;
  121573. }
  121574. }
  121575. declare module BABYLON {
  121576. /**
  121577. * Block used to get the opposite (1 - x) of a value
  121578. */
  121579. export class OneMinusBlock extends NodeMaterialBlock {
  121580. /**
  121581. * Creates a new OneMinusBlock
  121582. * @param name defines the block name
  121583. */
  121584. constructor(name: string);
  121585. /**
  121586. * Gets the current class name
  121587. * @returns the class name
  121588. */
  121589. getClassName(): string;
  121590. /**
  121591. * Gets the input component
  121592. */
  121593. readonly input: NodeMaterialConnectionPoint;
  121594. /**
  121595. * Gets the output component
  121596. */
  121597. readonly output: NodeMaterialConnectionPoint;
  121598. protected _buildBlock(state: NodeMaterialBuildState): this;
  121599. }
  121600. }
  121601. declare module BABYLON {
  121602. /**
  121603. * Block used to get the view direction
  121604. */
  121605. export class ViewDirectionBlock extends NodeMaterialBlock {
  121606. /**
  121607. * Creates a new ViewDirectionBlock
  121608. * @param name defines the block name
  121609. */
  121610. constructor(name: string);
  121611. /**
  121612. * Gets the current class name
  121613. * @returns the class name
  121614. */
  121615. getClassName(): string;
  121616. /**
  121617. * Gets the world position component
  121618. */
  121619. readonly worldPosition: NodeMaterialConnectionPoint;
  121620. /**
  121621. * Gets the camera position component
  121622. */
  121623. readonly cameraPosition: NodeMaterialConnectionPoint;
  121624. /**
  121625. * Gets the output component
  121626. */
  121627. readonly output: NodeMaterialConnectionPoint;
  121628. autoConfigure(material: NodeMaterial): void;
  121629. protected _buildBlock(state: NodeMaterialBuildState): this;
  121630. }
  121631. }
  121632. declare module BABYLON {
  121633. /**
  121634. * Block used to compute fresnel value
  121635. */
  121636. export class FresnelBlock extends NodeMaterialBlock {
  121637. /**
  121638. * Create a new FresnelBlock
  121639. * @param name defines the block name
  121640. */
  121641. constructor(name: string);
  121642. /**
  121643. * Gets the current class name
  121644. * @returns the class name
  121645. */
  121646. getClassName(): string;
  121647. /**
  121648. * Gets the world normal input component
  121649. */
  121650. readonly worldNormal: NodeMaterialConnectionPoint;
  121651. /**
  121652. * Gets the view direction input component
  121653. */
  121654. readonly viewDirection: NodeMaterialConnectionPoint;
  121655. /**
  121656. * Gets the bias input component
  121657. */
  121658. readonly bias: NodeMaterialConnectionPoint;
  121659. /**
  121660. * Gets the camera (or eye) position component
  121661. */
  121662. readonly power: NodeMaterialConnectionPoint;
  121663. /**
  121664. * Gets the fresnel output component
  121665. */
  121666. readonly fresnel: NodeMaterialConnectionPoint;
  121667. autoConfigure(material: NodeMaterial): void;
  121668. protected _buildBlock(state: NodeMaterialBuildState): this;
  121669. }
  121670. }
  121671. declare module BABYLON {
  121672. /**
  121673. * Block used to get the max of 2 values
  121674. */
  121675. export class MaxBlock extends NodeMaterialBlock {
  121676. /**
  121677. * Creates a new MaxBlock
  121678. * @param name defines the block name
  121679. */
  121680. constructor(name: string);
  121681. /**
  121682. * Gets the current class name
  121683. * @returns the class name
  121684. */
  121685. getClassName(): string;
  121686. /**
  121687. * Gets the left operand input component
  121688. */
  121689. readonly left: NodeMaterialConnectionPoint;
  121690. /**
  121691. * Gets the right operand input component
  121692. */
  121693. readonly right: NodeMaterialConnectionPoint;
  121694. /**
  121695. * Gets the output component
  121696. */
  121697. readonly output: NodeMaterialConnectionPoint;
  121698. protected _buildBlock(state: NodeMaterialBuildState): this;
  121699. }
  121700. }
  121701. declare module BABYLON {
  121702. /**
  121703. * Block used to get the min of 2 values
  121704. */
  121705. export class MinBlock extends NodeMaterialBlock {
  121706. /**
  121707. * Creates a new MinBlock
  121708. * @param name defines the block name
  121709. */
  121710. constructor(name: string);
  121711. /**
  121712. * Gets the current class name
  121713. * @returns the class name
  121714. */
  121715. getClassName(): string;
  121716. /**
  121717. * Gets the left operand input component
  121718. */
  121719. readonly left: NodeMaterialConnectionPoint;
  121720. /**
  121721. * Gets the right operand input component
  121722. */
  121723. readonly right: NodeMaterialConnectionPoint;
  121724. /**
  121725. * Gets the output component
  121726. */
  121727. readonly output: NodeMaterialConnectionPoint;
  121728. protected _buildBlock(state: NodeMaterialBuildState): this;
  121729. }
  121730. }
  121731. declare module BABYLON {
  121732. /**
  121733. * Block used to get the distance between 2 values
  121734. */
  121735. export class DistanceBlock extends NodeMaterialBlock {
  121736. /**
  121737. * Creates a new DistanceBlock
  121738. * @param name defines the block name
  121739. */
  121740. constructor(name: string);
  121741. /**
  121742. * Gets the current class name
  121743. * @returns the class name
  121744. */
  121745. getClassName(): string;
  121746. /**
  121747. * Gets the left operand input component
  121748. */
  121749. readonly left: NodeMaterialConnectionPoint;
  121750. /**
  121751. * Gets the right operand input component
  121752. */
  121753. readonly right: NodeMaterialConnectionPoint;
  121754. /**
  121755. * Gets the output component
  121756. */
  121757. readonly output: NodeMaterialConnectionPoint;
  121758. protected _buildBlock(state: NodeMaterialBuildState): this;
  121759. }
  121760. }
  121761. declare module BABYLON {
  121762. /**
  121763. * Block used to get the length of a vector
  121764. */
  121765. export class LengthBlock extends NodeMaterialBlock {
  121766. /**
  121767. * Creates a new LengthBlock
  121768. * @param name defines the block name
  121769. */
  121770. constructor(name: string);
  121771. /**
  121772. * Gets the current class name
  121773. * @returns the class name
  121774. */
  121775. getClassName(): string;
  121776. /**
  121777. * Gets the value input component
  121778. */
  121779. readonly value: NodeMaterialConnectionPoint;
  121780. /**
  121781. * Gets the output component
  121782. */
  121783. readonly output: NodeMaterialConnectionPoint;
  121784. protected _buildBlock(state: NodeMaterialBuildState): this;
  121785. }
  121786. }
  121787. declare module BABYLON {
  121788. /**
  121789. * Block used to get negative version of a value (i.e. x * -1)
  121790. */
  121791. export class NegateBlock extends NodeMaterialBlock {
  121792. /**
  121793. * Creates a new NegateBlock
  121794. * @param name defines the block name
  121795. */
  121796. constructor(name: string);
  121797. /**
  121798. * Gets the current class name
  121799. * @returns the class name
  121800. */
  121801. getClassName(): string;
  121802. /**
  121803. * Gets the value input component
  121804. */
  121805. readonly value: NodeMaterialConnectionPoint;
  121806. /**
  121807. * Gets the output component
  121808. */
  121809. readonly output: NodeMaterialConnectionPoint;
  121810. protected _buildBlock(state: NodeMaterialBuildState): this;
  121811. }
  121812. }
  121813. declare module BABYLON {
  121814. /**
  121815. * Block used to get the value of the first parameter raised to the power of the second
  121816. */
  121817. export class PowBlock extends NodeMaterialBlock {
  121818. /**
  121819. * Creates a new PowBlock
  121820. * @param name defines the block name
  121821. */
  121822. constructor(name: string);
  121823. /**
  121824. * Gets the current class name
  121825. * @returns the class name
  121826. */
  121827. getClassName(): string;
  121828. /**
  121829. * Gets the value operand input component
  121830. */
  121831. readonly value: NodeMaterialConnectionPoint;
  121832. /**
  121833. * Gets the power operand input component
  121834. */
  121835. readonly power: NodeMaterialConnectionPoint;
  121836. /**
  121837. * Gets the output component
  121838. */
  121839. readonly output: NodeMaterialConnectionPoint;
  121840. protected _buildBlock(state: NodeMaterialBuildState): this;
  121841. }
  121842. }
  121843. declare module BABYLON {
  121844. /**
  121845. * Block used to get a random number
  121846. */
  121847. export class RandomNumberBlock extends NodeMaterialBlock {
  121848. /**
  121849. * Creates a new RandomNumberBlock
  121850. * @param name defines the block name
  121851. */
  121852. constructor(name: string);
  121853. /**
  121854. * Gets the current class name
  121855. * @returns the class name
  121856. */
  121857. getClassName(): string;
  121858. /**
  121859. * Gets the seed input component
  121860. */
  121861. readonly seed: NodeMaterialConnectionPoint;
  121862. /**
  121863. * Gets the output component
  121864. */
  121865. readonly output: NodeMaterialConnectionPoint;
  121866. protected _buildBlock(state: NodeMaterialBuildState): this;
  121867. }
  121868. }
  121869. declare module BABYLON {
  121870. /**
  121871. * Block used to compute arc tangent of 2 values
  121872. */
  121873. export class ArcTan2Block extends NodeMaterialBlock {
  121874. /**
  121875. * Creates a new ArcTan2Block
  121876. * @param name defines the block name
  121877. */
  121878. constructor(name: string);
  121879. /**
  121880. * Gets the current class name
  121881. * @returns the class name
  121882. */
  121883. getClassName(): string;
  121884. /**
  121885. * Gets the x operand input component
  121886. */
  121887. readonly x: NodeMaterialConnectionPoint;
  121888. /**
  121889. * Gets the y operand input component
  121890. */
  121891. readonly y: NodeMaterialConnectionPoint;
  121892. /**
  121893. * Gets the output component
  121894. */
  121895. readonly output: NodeMaterialConnectionPoint;
  121896. protected _buildBlock(state: NodeMaterialBuildState): this;
  121897. }
  121898. }
  121899. declare module BABYLON {
  121900. /**
  121901. * Block used to smooth step a value
  121902. */
  121903. export class SmoothStepBlock extends NodeMaterialBlock {
  121904. /**
  121905. * Creates a new SmoothStepBlock
  121906. * @param name defines the block name
  121907. */
  121908. constructor(name: string);
  121909. /**
  121910. * Gets the current class name
  121911. * @returns the class name
  121912. */
  121913. getClassName(): string;
  121914. /**
  121915. * Gets the value operand input component
  121916. */
  121917. readonly value: NodeMaterialConnectionPoint;
  121918. /**
  121919. * Gets the first edge operand input component
  121920. */
  121921. readonly edge0: NodeMaterialConnectionPoint;
  121922. /**
  121923. * Gets the second edge operand input component
  121924. */
  121925. readonly edge1: NodeMaterialConnectionPoint;
  121926. /**
  121927. * Gets the output component
  121928. */
  121929. readonly output: NodeMaterialConnectionPoint;
  121930. protected _buildBlock(state: NodeMaterialBuildState): this;
  121931. }
  121932. }
  121933. declare module BABYLON {
  121934. /**
  121935. * Block used to get the reciprocal (1 / x) of a value
  121936. */
  121937. export class ReciprocalBlock extends NodeMaterialBlock {
  121938. /**
  121939. * Creates a new ReciprocalBlock
  121940. * @param name defines the block name
  121941. */
  121942. constructor(name: string);
  121943. /**
  121944. * Gets the current class name
  121945. * @returns the class name
  121946. */
  121947. getClassName(): string;
  121948. /**
  121949. * Gets the input component
  121950. */
  121951. readonly input: NodeMaterialConnectionPoint;
  121952. /**
  121953. * Gets the output component
  121954. */
  121955. readonly output: NodeMaterialConnectionPoint;
  121956. protected _buildBlock(state: NodeMaterialBuildState): this;
  121957. }
  121958. }
  121959. declare module BABYLON {
  121960. /**
  121961. * Block used to replace a color by another one
  121962. */
  121963. export class ReplaceColorBlock extends NodeMaterialBlock {
  121964. /**
  121965. * Creates a new ReplaceColorBlock
  121966. * @param name defines the block name
  121967. */
  121968. constructor(name: string);
  121969. /**
  121970. * Gets the current class name
  121971. * @returns the class name
  121972. */
  121973. getClassName(): string;
  121974. /**
  121975. * Gets the value input component
  121976. */
  121977. readonly value: NodeMaterialConnectionPoint;
  121978. /**
  121979. * Gets the reference input component
  121980. */
  121981. readonly reference: NodeMaterialConnectionPoint;
  121982. /**
  121983. * Gets the distance input component
  121984. */
  121985. readonly distance: NodeMaterialConnectionPoint;
  121986. /**
  121987. * Gets the replacement input component
  121988. */
  121989. readonly replacement: NodeMaterialConnectionPoint;
  121990. /**
  121991. * Gets the output component
  121992. */
  121993. readonly output: NodeMaterialConnectionPoint;
  121994. protected _buildBlock(state: NodeMaterialBuildState): this;
  121995. }
  121996. }
  121997. declare module BABYLON {
  121998. /**
  121999. * Block used to posterize a value
  122000. * @see https://en.wikipedia.org/wiki/Posterization
  122001. */
  122002. export class PosterizeBlock extends NodeMaterialBlock {
  122003. /**
  122004. * Creates a new PosterizeBlock
  122005. * @param name defines the block name
  122006. */
  122007. constructor(name: string);
  122008. /**
  122009. * Gets the current class name
  122010. * @returns the class name
  122011. */
  122012. getClassName(): string;
  122013. /**
  122014. * Gets the value input component
  122015. */
  122016. readonly value: NodeMaterialConnectionPoint;
  122017. /**
  122018. * Gets the steps input component
  122019. */
  122020. readonly steps: NodeMaterialConnectionPoint;
  122021. /**
  122022. * Gets the output component
  122023. */
  122024. readonly output: NodeMaterialConnectionPoint;
  122025. protected _buildBlock(state: NodeMaterialBuildState): this;
  122026. }
  122027. }
  122028. declare module BABYLON {
  122029. /**
  122030. * Operations supported by the Wave block
  122031. */
  122032. export enum WaveBlockKind {
  122033. /** SawTooth */
  122034. SawTooth = 0,
  122035. /** Square */
  122036. Square = 1,
  122037. /** Triangle */
  122038. Triangle = 2
  122039. }
  122040. /**
  122041. * Block used to apply wave operation to floats
  122042. */
  122043. export class WaveBlock extends NodeMaterialBlock {
  122044. /**
  122045. * Gets or sets the kibnd of wave to be applied by the block
  122046. */
  122047. kind: WaveBlockKind;
  122048. /**
  122049. * Creates a new WaveBlock
  122050. * @param name defines the block name
  122051. */
  122052. constructor(name: string);
  122053. /**
  122054. * Gets the current class name
  122055. * @returns the class name
  122056. */
  122057. getClassName(): string;
  122058. /**
  122059. * Gets the input component
  122060. */
  122061. readonly input: NodeMaterialConnectionPoint;
  122062. /**
  122063. * Gets the output component
  122064. */
  122065. readonly output: NodeMaterialConnectionPoint;
  122066. protected _buildBlock(state: NodeMaterialBuildState): this;
  122067. serialize(): any;
  122068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122069. }
  122070. }
  122071. declare module BABYLON {
  122072. /**
  122073. * Class used to store a color step for the GradientBlock
  122074. */
  122075. export class GradientBlockColorStep {
  122076. /**
  122077. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122078. */
  122079. step: number;
  122080. /**
  122081. * Gets or sets the color associated with this step
  122082. */
  122083. color: Color3;
  122084. /**
  122085. * Creates a new GradientBlockColorStep
  122086. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122087. * @param color defines the color associated with this step
  122088. */
  122089. constructor(
  122090. /**
  122091. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122092. */
  122093. step: number,
  122094. /**
  122095. * Gets or sets the color associated with this step
  122096. */
  122097. color: Color3);
  122098. }
  122099. /**
  122100. * Block used to return a color from a gradient based on an input value between 0 and 1
  122101. */
  122102. export class GradientBlock extends NodeMaterialBlock {
  122103. colorSteps: GradientBlockColorStep[];
  122104. /**
  122105. * Creates a new GradientBlock
  122106. * @param name defines the block name
  122107. */
  122108. constructor(name: string);
  122109. /**
  122110. * Gets the current class name
  122111. * @returns the class name
  122112. */
  122113. getClassName(): string;
  122114. /**
  122115. * Gets the gradient input component
  122116. */
  122117. readonly gradient: NodeMaterialConnectionPoint;
  122118. /**
  122119. * Gets the output component
  122120. */
  122121. readonly output: NodeMaterialConnectionPoint;
  122122. private _writeColorConstant;
  122123. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122124. serialize(): any;
  122125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122126. protected _dumpPropertiesCode(): string;
  122127. }
  122128. }
  122129. declare module BABYLON {
  122130. /**
  122131. * Effect Render Options
  122132. */
  122133. export interface IEffectRendererOptions {
  122134. /**
  122135. * Defines the vertices positions.
  122136. */
  122137. positions?: number[];
  122138. /**
  122139. * Defines the indices.
  122140. */
  122141. indices?: number[];
  122142. }
  122143. /**
  122144. * Helper class to render one or more effects
  122145. */
  122146. export class EffectRenderer {
  122147. private engine;
  122148. private static _DefaultOptions;
  122149. private _vertexBuffers;
  122150. private _indexBuffer;
  122151. private _ringBufferIndex;
  122152. private _ringScreenBuffer;
  122153. private _fullscreenViewport;
  122154. private _getNextFrameBuffer;
  122155. /**
  122156. * Creates an effect renderer
  122157. * @param engine the engine to use for rendering
  122158. * @param options defines the options of the effect renderer
  122159. */
  122160. constructor(engine: Engine, options?: IEffectRendererOptions);
  122161. /**
  122162. * Sets the current viewport in normalized coordinates 0-1
  122163. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122164. */
  122165. setViewport(viewport?: Viewport): void;
  122166. /**
  122167. * Binds the embedded attributes buffer to the effect.
  122168. * @param effect Defines the effect to bind the attributes for
  122169. */
  122170. bindBuffers(effect: Effect): void;
  122171. /**
  122172. * Sets the current effect wrapper to use during draw.
  122173. * The effect needs to be ready before calling this api.
  122174. * This also sets the default full screen position attribute.
  122175. * @param effectWrapper Defines the effect to draw with
  122176. */
  122177. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122178. /**
  122179. * Draws a full screen quad.
  122180. */
  122181. draw(): void;
  122182. /**
  122183. * renders one or more effects to a specified texture
  122184. * @param effectWrappers list of effects to renderer
  122185. * @param outputTexture texture to draw to, if null it will render to the screen
  122186. */
  122187. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122188. /**
  122189. * Disposes of the effect renderer
  122190. */
  122191. dispose(): void;
  122192. }
  122193. /**
  122194. * Options to create an EffectWrapper
  122195. */
  122196. interface EffectWrapperCreationOptions {
  122197. /**
  122198. * Engine to use to create the effect
  122199. */
  122200. engine: Engine;
  122201. /**
  122202. * Fragment shader for the effect
  122203. */
  122204. fragmentShader: string;
  122205. /**
  122206. * Vertex shader for the effect
  122207. */
  122208. vertexShader?: string;
  122209. /**
  122210. * Attributes to use in the shader
  122211. */
  122212. attributeNames?: Array<string>;
  122213. /**
  122214. * Uniforms to use in the shader
  122215. */
  122216. uniformNames?: Array<string>;
  122217. /**
  122218. * Texture sampler names to use in the shader
  122219. */
  122220. samplerNames?: Array<string>;
  122221. /**
  122222. * The friendly name of the effect displayed in Spector.
  122223. */
  122224. name?: string;
  122225. }
  122226. /**
  122227. * Wraps an effect to be used for rendering
  122228. */
  122229. export class EffectWrapper {
  122230. /**
  122231. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122232. */
  122233. onApplyObservable: Observable<{}>;
  122234. /**
  122235. * The underlying effect
  122236. */
  122237. effect: Effect;
  122238. /**
  122239. * Creates an effect to be renderer
  122240. * @param creationOptions options to create the effect
  122241. */
  122242. constructor(creationOptions: EffectWrapperCreationOptions);
  122243. /**
  122244. * Disposes of the effect wrapper
  122245. */
  122246. dispose(): void;
  122247. }
  122248. }
  122249. declare module BABYLON {
  122250. /**
  122251. * Helper class to push actions to a pool of workers.
  122252. */
  122253. export class WorkerPool implements IDisposable {
  122254. private _workerInfos;
  122255. private _pendingActions;
  122256. /**
  122257. * Constructor
  122258. * @param workers Array of workers to use for actions
  122259. */
  122260. constructor(workers: Array<Worker>);
  122261. /**
  122262. * Terminates all workers and clears any pending actions.
  122263. */
  122264. dispose(): void;
  122265. /**
  122266. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122267. * pended until a worker has completed its action.
  122268. * @param action The action to perform. Call onComplete when the action is complete.
  122269. */
  122270. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122271. private _execute;
  122272. }
  122273. }
  122274. declare module BABYLON {
  122275. /**
  122276. * Configuration for Draco compression
  122277. */
  122278. export interface IDracoCompressionConfiguration {
  122279. /**
  122280. * Configuration for the decoder.
  122281. */
  122282. decoder: {
  122283. /**
  122284. * The url to the WebAssembly module.
  122285. */
  122286. wasmUrl?: string;
  122287. /**
  122288. * The url to the WebAssembly binary.
  122289. */
  122290. wasmBinaryUrl?: string;
  122291. /**
  122292. * The url to the fallback JavaScript module.
  122293. */
  122294. fallbackUrl?: string;
  122295. };
  122296. }
  122297. /**
  122298. * Draco compression (https://google.github.io/draco/)
  122299. *
  122300. * This class wraps the Draco module.
  122301. *
  122302. * **Encoder**
  122303. *
  122304. * The encoder is not currently implemented.
  122305. *
  122306. * **Decoder**
  122307. *
  122308. * 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.
  122309. *
  122310. * To update the configuration, use the following code:
  122311. * ```javascript
  122312. * DracoCompression.Configuration = {
  122313. * decoder: {
  122314. * wasmUrl: "<url to the WebAssembly library>",
  122315. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122316. * fallbackUrl: "<url to the fallback JavaScript library>",
  122317. * }
  122318. * };
  122319. * ```
  122320. *
  122321. * 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.
  122322. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122323. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122324. *
  122325. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122326. * ```javascript
  122327. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122328. * ```
  122329. *
  122330. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122331. */
  122332. export class DracoCompression implements IDisposable {
  122333. private _workerPoolPromise?;
  122334. private _decoderModulePromise?;
  122335. /**
  122336. * The configuration. Defaults to the following urls:
  122337. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122338. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122339. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122340. */
  122341. static Configuration: IDracoCompressionConfiguration;
  122342. /**
  122343. * Returns true if the decoder configuration is available.
  122344. */
  122345. static readonly DecoderAvailable: boolean;
  122346. /**
  122347. * Default number of workers to create when creating the draco compression object.
  122348. */
  122349. static DefaultNumWorkers: number;
  122350. private static GetDefaultNumWorkers;
  122351. private static _Default;
  122352. /**
  122353. * Default instance for the draco compression object.
  122354. */
  122355. static readonly Default: DracoCompression;
  122356. /**
  122357. * Constructor
  122358. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122359. */
  122360. constructor(numWorkers?: number);
  122361. /**
  122362. * Stop all async operations and release resources.
  122363. */
  122364. dispose(): void;
  122365. /**
  122366. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122367. * @returns a promise that resolves when ready
  122368. */
  122369. whenReadyAsync(): Promise<void>;
  122370. /**
  122371. * Decode Draco compressed mesh data to vertex data.
  122372. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122373. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122374. * @returns A promise that resolves with the decoded vertex data
  122375. */
  122376. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122377. [kind: string]: number;
  122378. }): Promise<VertexData>;
  122379. }
  122380. }
  122381. declare module BABYLON {
  122382. /**
  122383. * Class for building Constructive Solid Geometry
  122384. */
  122385. export class CSG {
  122386. private polygons;
  122387. /**
  122388. * The world matrix
  122389. */
  122390. matrix: Matrix;
  122391. /**
  122392. * Stores the position
  122393. */
  122394. position: Vector3;
  122395. /**
  122396. * Stores the rotation
  122397. */
  122398. rotation: Vector3;
  122399. /**
  122400. * Stores the rotation quaternion
  122401. */
  122402. rotationQuaternion: Nullable<Quaternion>;
  122403. /**
  122404. * Stores the scaling vector
  122405. */
  122406. scaling: Vector3;
  122407. /**
  122408. * Convert the Mesh to CSG
  122409. * @param mesh The Mesh to convert to CSG
  122410. * @returns A new CSG from the Mesh
  122411. */
  122412. static FromMesh(mesh: Mesh): CSG;
  122413. /**
  122414. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122415. * @param polygons Polygons used to construct a CSG solid
  122416. */
  122417. private static FromPolygons;
  122418. /**
  122419. * Clones, or makes a deep copy, of the CSG
  122420. * @returns A new CSG
  122421. */
  122422. clone(): CSG;
  122423. /**
  122424. * Unions this CSG with another CSG
  122425. * @param csg The CSG to union against this CSG
  122426. * @returns The unioned CSG
  122427. */
  122428. union(csg: CSG): CSG;
  122429. /**
  122430. * Unions this CSG with another CSG in place
  122431. * @param csg The CSG to union against this CSG
  122432. */
  122433. unionInPlace(csg: CSG): void;
  122434. /**
  122435. * Subtracts this CSG with another CSG
  122436. * @param csg The CSG to subtract against this CSG
  122437. * @returns A new CSG
  122438. */
  122439. subtract(csg: CSG): CSG;
  122440. /**
  122441. * Subtracts this CSG with another CSG in place
  122442. * @param csg The CSG to subtact against this CSG
  122443. */
  122444. subtractInPlace(csg: CSG): void;
  122445. /**
  122446. * Intersect this CSG with another CSG
  122447. * @param csg The CSG to intersect against this CSG
  122448. * @returns A new CSG
  122449. */
  122450. intersect(csg: CSG): CSG;
  122451. /**
  122452. * Intersects this CSG with another CSG in place
  122453. * @param csg The CSG to intersect against this CSG
  122454. */
  122455. intersectInPlace(csg: CSG): void;
  122456. /**
  122457. * Return a new CSG solid with solid and empty space switched. This solid is
  122458. * not modified.
  122459. * @returns A new CSG solid with solid and empty space switched
  122460. */
  122461. inverse(): CSG;
  122462. /**
  122463. * Inverses the CSG in place
  122464. */
  122465. inverseInPlace(): void;
  122466. /**
  122467. * This is used to keep meshes transformations so they can be restored
  122468. * when we build back a Babylon Mesh
  122469. * NB : All CSG operations are performed in world coordinates
  122470. * @param csg The CSG to copy the transform attributes from
  122471. * @returns This CSG
  122472. */
  122473. copyTransformAttributes(csg: CSG): CSG;
  122474. /**
  122475. * Build Raw mesh from CSG
  122476. * Coordinates here are in world space
  122477. * @param name The name of the mesh geometry
  122478. * @param scene The Scene
  122479. * @param keepSubMeshes Specifies if the submeshes should be kept
  122480. * @returns A new Mesh
  122481. */
  122482. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122483. /**
  122484. * Build Mesh from CSG taking material and transforms into account
  122485. * @param name The name of the Mesh
  122486. * @param material The material of the Mesh
  122487. * @param scene The Scene
  122488. * @param keepSubMeshes Specifies if submeshes should be kept
  122489. * @returns The new Mesh
  122490. */
  122491. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122492. }
  122493. }
  122494. declare module BABYLON {
  122495. /**
  122496. * Class used to create a trail following a mesh
  122497. */
  122498. export class TrailMesh extends Mesh {
  122499. private _generator;
  122500. private _autoStart;
  122501. private _running;
  122502. private _diameter;
  122503. private _length;
  122504. private _sectionPolygonPointsCount;
  122505. private _sectionVectors;
  122506. private _sectionNormalVectors;
  122507. private _beforeRenderObserver;
  122508. /**
  122509. * @constructor
  122510. * @param name The value used by scene.getMeshByName() to do a lookup.
  122511. * @param generator The mesh to generate a trail.
  122512. * @param scene The scene to add this mesh to.
  122513. * @param diameter Diameter of trailing mesh. Default is 1.
  122514. * @param length Length of trailing mesh. Default is 60.
  122515. * @param autoStart Automatically start trailing mesh. Default true.
  122516. */
  122517. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122518. /**
  122519. * "TrailMesh"
  122520. * @returns "TrailMesh"
  122521. */
  122522. getClassName(): string;
  122523. private _createMesh;
  122524. /**
  122525. * Start trailing mesh.
  122526. */
  122527. start(): void;
  122528. /**
  122529. * Stop trailing mesh.
  122530. */
  122531. stop(): void;
  122532. /**
  122533. * Update trailing mesh geometry.
  122534. */
  122535. update(): void;
  122536. /**
  122537. * Returns a new TrailMesh object.
  122538. * @param name is a string, the name given to the new mesh
  122539. * @param newGenerator use new generator object for cloned trail mesh
  122540. * @returns a new mesh
  122541. */
  122542. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122543. /**
  122544. * Serializes this trail mesh
  122545. * @param serializationObject object to write serialization to
  122546. */
  122547. serialize(serializationObject: any): void;
  122548. /**
  122549. * Parses a serialized trail mesh
  122550. * @param parsedMesh the serialized mesh
  122551. * @param scene the scene to create the trail mesh in
  122552. * @returns the created trail mesh
  122553. */
  122554. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122555. }
  122556. }
  122557. declare module BABYLON {
  122558. /**
  122559. * Class containing static functions to help procedurally build meshes
  122560. */
  122561. export class TiledBoxBuilder {
  122562. /**
  122563. * Creates a box mesh
  122564. * 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)
  122565. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122569. * @param name defines the name of the mesh
  122570. * @param options defines the options used to create the mesh
  122571. * @param scene defines the hosting scene
  122572. * @returns the box mesh
  122573. */
  122574. static CreateTiledBox(name: string, options: {
  122575. pattern?: number;
  122576. width?: number;
  122577. height?: number;
  122578. depth?: number;
  122579. tileSize?: number;
  122580. tileWidth?: number;
  122581. tileHeight?: number;
  122582. alignHorizontal?: number;
  122583. alignVertical?: number;
  122584. faceUV?: Vector4[];
  122585. faceColors?: Color4[];
  122586. sideOrientation?: number;
  122587. updatable?: boolean;
  122588. }, scene?: Nullable<Scene>): Mesh;
  122589. }
  122590. }
  122591. declare module BABYLON {
  122592. /**
  122593. * Class containing static functions to help procedurally build meshes
  122594. */
  122595. export class TorusKnotBuilder {
  122596. /**
  122597. * Creates a torus knot mesh
  122598. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122599. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122600. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122601. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122605. * @param name defines the name of the mesh
  122606. * @param options defines the options used to create the mesh
  122607. * @param scene defines the hosting scene
  122608. * @returns the torus knot mesh
  122609. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122610. */
  122611. static CreateTorusKnot(name: string, options: {
  122612. radius?: number;
  122613. tube?: number;
  122614. radialSegments?: number;
  122615. tubularSegments?: number;
  122616. p?: number;
  122617. q?: number;
  122618. updatable?: boolean;
  122619. sideOrientation?: number;
  122620. frontUVs?: Vector4;
  122621. backUVs?: Vector4;
  122622. }, scene: any): Mesh;
  122623. }
  122624. }
  122625. declare module BABYLON {
  122626. /**
  122627. * Polygon
  122628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122629. */
  122630. export class Polygon {
  122631. /**
  122632. * Creates a rectangle
  122633. * @param xmin bottom X coord
  122634. * @param ymin bottom Y coord
  122635. * @param xmax top X coord
  122636. * @param ymax top Y coord
  122637. * @returns points that make the resulting rectation
  122638. */
  122639. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122640. /**
  122641. * Creates a circle
  122642. * @param radius radius of circle
  122643. * @param cx scale in x
  122644. * @param cy scale in y
  122645. * @param numberOfSides number of sides that make up the circle
  122646. * @returns points that make the resulting circle
  122647. */
  122648. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122649. /**
  122650. * Creates a polygon from input string
  122651. * @param input Input polygon data
  122652. * @returns the parsed points
  122653. */
  122654. static Parse(input: string): Vector2[];
  122655. /**
  122656. * Starts building a polygon from x and y coordinates
  122657. * @param x x coordinate
  122658. * @param y y coordinate
  122659. * @returns the started path2
  122660. */
  122661. static StartingAt(x: number, y: number): Path2;
  122662. }
  122663. /**
  122664. * Builds a polygon
  122665. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122666. */
  122667. export class PolygonMeshBuilder {
  122668. private _points;
  122669. private _outlinepoints;
  122670. private _holes;
  122671. private _name;
  122672. private _scene;
  122673. private _epoints;
  122674. private _eholes;
  122675. private _addToepoint;
  122676. /**
  122677. * Babylon reference to the earcut plugin.
  122678. */
  122679. bjsEarcut: any;
  122680. /**
  122681. * Creates a PolygonMeshBuilder
  122682. * @param name name of the builder
  122683. * @param contours Path of the polygon
  122684. * @param scene scene to add to when creating the mesh
  122685. * @param earcutInjection can be used to inject your own earcut reference
  122686. */
  122687. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122688. /**
  122689. * Adds a whole within the polygon
  122690. * @param hole Array of points defining the hole
  122691. * @returns this
  122692. */
  122693. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122694. /**
  122695. * Creates the polygon
  122696. * @param updatable If the mesh should be updatable
  122697. * @param depth The depth of the mesh created
  122698. * @returns the created mesh
  122699. */
  122700. build(updatable?: boolean, depth?: number): Mesh;
  122701. /**
  122702. * Creates the polygon
  122703. * @param depth The depth of the mesh created
  122704. * @returns the created VertexData
  122705. */
  122706. buildVertexData(depth?: number): VertexData;
  122707. /**
  122708. * Adds a side to the polygon
  122709. * @param positions points that make the polygon
  122710. * @param normals normals of the polygon
  122711. * @param uvs uvs of the polygon
  122712. * @param indices indices of the polygon
  122713. * @param bounds bounds of the polygon
  122714. * @param points points of the polygon
  122715. * @param depth depth of the polygon
  122716. * @param flip flip of the polygon
  122717. */
  122718. private addSide;
  122719. }
  122720. }
  122721. declare module BABYLON {
  122722. /**
  122723. * Class containing static functions to help procedurally build meshes
  122724. */
  122725. export class PolygonBuilder {
  122726. /**
  122727. * Creates a polygon mesh
  122728. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122729. * * 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
  122730. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122733. * * Remember you can only change the shape positions, not their number when updating a polygon
  122734. * @param name defines the name of the mesh
  122735. * @param options defines the options used to create the mesh
  122736. * @param scene defines the hosting scene
  122737. * @param earcutInjection can be used to inject your own earcut reference
  122738. * @returns the polygon mesh
  122739. */
  122740. static CreatePolygon(name: string, options: {
  122741. shape: Vector3[];
  122742. holes?: Vector3[][];
  122743. depth?: number;
  122744. faceUV?: Vector4[];
  122745. faceColors?: Color4[];
  122746. updatable?: boolean;
  122747. sideOrientation?: number;
  122748. frontUVs?: Vector4;
  122749. backUVs?: Vector4;
  122750. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122751. /**
  122752. * Creates an extruded polygon mesh, with depth in the Y direction.
  122753. * * 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)
  122754. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122755. * @param name defines the name of the mesh
  122756. * @param options defines the options used to create the mesh
  122757. * @param scene defines the hosting scene
  122758. * @param earcutInjection can be used to inject your own earcut reference
  122759. * @returns the polygon mesh
  122760. */
  122761. static ExtrudePolygon(name: string, options: {
  122762. shape: Vector3[];
  122763. holes?: Vector3[][];
  122764. depth?: number;
  122765. faceUV?: Vector4[];
  122766. faceColors?: Color4[];
  122767. updatable?: boolean;
  122768. sideOrientation?: number;
  122769. frontUVs?: Vector4;
  122770. backUVs?: Vector4;
  122771. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122772. }
  122773. }
  122774. declare module BABYLON {
  122775. /**
  122776. * Class containing static functions to help procedurally build meshes
  122777. */
  122778. export class LatheBuilder {
  122779. /**
  122780. * Creates lathe mesh.
  122781. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122782. * * 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
  122783. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122784. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122785. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122786. * * 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
  122787. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122788. * * 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
  122789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122791. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122793. * @param name defines the name of the mesh
  122794. * @param options defines the options used to create the mesh
  122795. * @param scene defines the hosting scene
  122796. * @returns the lathe mesh
  122797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122798. */
  122799. static CreateLathe(name: string, options: {
  122800. shape: Vector3[];
  122801. radius?: number;
  122802. tessellation?: number;
  122803. clip?: number;
  122804. arc?: number;
  122805. closed?: boolean;
  122806. updatable?: boolean;
  122807. sideOrientation?: number;
  122808. frontUVs?: Vector4;
  122809. backUVs?: Vector4;
  122810. cap?: number;
  122811. invertUV?: boolean;
  122812. }, scene?: Nullable<Scene>): Mesh;
  122813. }
  122814. }
  122815. declare module BABYLON {
  122816. /**
  122817. * Class containing static functions to help procedurally build meshes
  122818. */
  122819. export class TiledPlaneBuilder {
  122820. /**
  122821. * Creates a tiled plane mesh
  122822. * * The parameter `pattern` will, depending on value, do nothing or
  122823. * * * flip (reflect about central vertical) alternate tiles across and up
  122824. * * * flip every tile on alternate rows
  122825. * * * rotate (180 degs) alternate tiles across and up
  122826. * * * rotate every tile on alternate rows
  122827. * * * flip and rotate alternate tiles across and up
  122828. * * * flip and rotate every tile on alternate rows
  122829. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122830. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122833. * * 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)
  122834. * * 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)
  122835. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122836. * @param name defines the name of the mesh
  122837. * @param options defines the options used to create the mesh
  122838. * @param scene defines the hosting scene
  122839. * @returns the box mesh
  122840. */
  122841. static CreateTiledPlane(name: string, options: {
  122842. pattern?: number;
  122843. tileSize?: number;
  122844. tileWidth?: number;
  122845. tileHeight?: number;
  122846. size?: number;
  122847. width?: number;
  122848. height?: number;
  122849. alignHorizontal?: number;
  122850. alignVertical?: number;
  122851. sideOrientation?: number;
  122852. frontUVs?: Vector4;
  122853. backUVs?: Vector4;
  122854. updatable?: boolean;
  122855. }, scene?: Nullable<Scene>): Mesh;
  122856. }
  122857. }
  122858. declare module BABYLON {
  122859. /**
  122860. * Class containing static functions to help procedurally build meshes
  122861. */
  122862. export class TubeBuilder {
  122863. /**
  122864. * Creates a tube mesh.
  122865. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122866. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122867. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122868. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122869. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122870. * * 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)
  122871. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122872. * * 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
  122873. * * 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
  122874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122876. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122878. * @param name defines the name of the mesh
  122879. * @param options defines the options used to create the mesh
  122880. * @param scene defines the hosting scene
  122881. * @returns the tube mesh
  122882. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122883. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122884. */
  122885. static CreateTube(name: string, options: {
  122886. path: Vector3[];
  122887. radius?: number;
  122888. tessellation?: number;
  122889. radiusFunction?: {
  122890. (i: number, distance: number): number;
  122891. };
  122892. cap?: number;
  122893. arc?: number;
  122894. updatable?: boolean;
  122895. sideOrientation?: number;
  122896. frontUVs?: Vector4;
  122897. backUVs?: Vector4;
  122898. instance?: Mesh;
  122899. invertUV?: boolean;
  122900. }, scene?: Nullable<Scene>): Mesh;
  122901. }
  122902. }
  122903. declare module BABYLON {
  122904. /**
  122905. * Class containing static functions to help procedurally build meshes
  122906. */
  122907. export class IcoSphereBuilder {
  122908. /**
  122909. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122910. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122911. * * 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`)
  122912. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122913. * * 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
  122914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122917. * @param name defines the name of the mesh
  122918. * @param options defines the options used to create the mesh
  122919. * @param scene defines the hosting scene
  122920. * @returns the icosahedron mesh
  122921. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122922. */
  122923. static CreateIcoSphere(name: string, options: {
  122924. radius?: number;
  122925. radiusX?: number;
  122926. radiusY?: number;
  122927. radiusZ?: number;
  122928. flat?: boolean;
  122929. subdivisions?: number;
  122930. sideOrientation?: number;
  122931. frontUVs?: Vector4;
  122932. backUVs?: Vector4;
  122933. updatable?: boolean;
  122934. }, scene?: Nullable<Scene>): Mesh;
  122935. }
  122936. }
  122937. declare module BABYLON {
  122938. /**
  122939. * Class containing static functions to help procedurally build meshes
  122940. */
  122941. export class DecalBuilder {
  122942. /**
  122943. * Creates a decal mesh.
  122944. * 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
  122945. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122946. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122947. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122948. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122949. * @param name defines the name of the mesh
  122950. * @param sourceMesh defines the mesh where the decal must be applied
  122951. * @param options defines the options used to create the mesh
  122952. * @param scene defines the hosting scene
  122953. * @returns the decal mesh
  122954. * @see https://doc.babylonjs.com/how_to/decals
  122955. */
  122956. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122957. position?: Vector3;
  122958. normal?: Vector3;
  122959. size?: Vector3;
  122960. angle?: number;
  122961. }): Mesh;
  122962. }
  122963. }
  122964. declare module BABYLON {
  122965. /**
  122966. * Class containing static functions to help procedurally build meshes
  122967. */
  122968. export class MeshBuilder {
  122969. /**
  122970. * Creates a box mesh
  122971. * * The parameter `size` sets the size (float) of each box side (default 1)
  122972. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122973. * * 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)
  122974. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122978. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122979. * @param name defines the name of the mesh
  122980. * @param options defines the options used to create the mesh
  122981. * @param scene defines the hosting scene
  122982. * @returns the box mesh
  122983. */
  122984. static CreateBox(name: string, options: {
  122985. size?: number;
  122986. width?: number;
  122987. height?: number;
  122988. depth?: number;
  122989. faceUV?: Vector4[];
  122990. faceColors?: Color4[];
  122991. sideOrientation?: number;
  122992. frontUVs?: Vector4;
  122993. backUVs?: Vector4;
  122994. updatable?: boolean;
  122995. }, scene?: Nullable<Scene>): Mesh;
  122996. /**
  122997. * Creates a tiled box mesh
  122998. * * faceTiles sets the pattern, tile size and number of tiles for a face
  122999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123000. * @param name defines the name of the mesh
  123001. * @param options defines the options used to create the mesh
  123002. * @param scene defines the hosting scene
  123003. * @returns the tiled box mesh
  123004. */
  123005. static CreateTiledBox(name: string, options: {
  123006. pattern?: number;
  123007. size?: number;
  123008. width?: number;
  123009. height?: number;
  123010. depth: number;
  123011. tileSize?: number;
  123012. tileWidth?: number;
  123013. tileHeight?: number;
  123014. faceUV?: Vector4[];
  123015. faceColors?: Color4[];
  123016. alignHorizontal?: number;
  123017. alignVertical?: number;
  123018. sideOrientation?: number;
  123019. updatable?: boolean;
  123020. }, scene?: Nullable<Scene>): Mesh;
  123021. /**
  123022. * Creates a sphere mesh
  123023. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123024. * * 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`)
  123025. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123026. * * 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
  123027. * * 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)
  123028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123031. * @param name defines the name of the mesh
  123032. * @param options defines the options used to create the mesh
  123033. * @param scene defines the hosting scene
  123034. * @returns the sphere mesh
  123035. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123036. */
  123037. static CreateSphere(name: string, options: {
  123038. segments?: number;
  123039. diameter?: number;
  123040. diameterX?: number;
  123041. diameterY?: number;
  123042. diameterZ?: number;
  123043. arc?: number;
  123044. slice?: number;
  123045. sideOrientation?: number;
  123046. frontUVs?: Vector4;
  123047. backUVs?: Vector4;
  123048. updatable?: boolean;
  123049. }, scene?: Nullable<Scene>): Mesh;
  123050. /**
  123051. * Creates a plane polygonal mesh. By default, this is a disc
  123052. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123053. * * 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
  123054. * * 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
  123055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123058. * @param name defines the name of the mesh
  123059. * @param options defines the options used to create the mesh
  123060. * @param scene defines the hosting scene
  123061. * @returns the plane polygonal mesh
  123062. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123063. */
  123064. static CreateDisc(name: string, options: {
  123065. radius?: number;
  123066. tessellation?: number;
  123067. arc?: number;
  123068. updatable?: boolean;
  123069. sideOrientation?: number;
  123070. frontUVs?: Vector4;
  123071. backUVs?: Vector4;
  123072. }, scene?: Nullable<Scene>): Mesh;
  123073. /**
  123074. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123075. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123076. * * 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`)
  123077. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123078. * * 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
  123079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123082. * @param name defines the name of the mesh
  123083. * @param options defines the options used to create the mesh
  123084. * @param scene defines the hosting scene
  123085. * @returns the icosahedron mesh
  123086. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123087. */
  123088. static CreateIcoSphere(name: string, options: {
  123089. radius?: number;
  123090. radiusX?: number;
  123091. radiusY?: number;
  123092. radiusZ?: number;
  123093. flat?: boolean;
  123094. subdivisions?: number;
  123095. sideOrientation?: number;
  123096. frontUVs?: Vector4;
  123097. backUVs?: Vector4;
  123098. updatable?: boolean;
  123099. }, scene?: Nullable<Scene>): Mesh;
  123100. /**
  123101. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123102. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123103. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123104. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123105. * * 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
  123106. * * 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
  123107. * * 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
  123108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123110. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123111. * * 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
  123112. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123113. * * 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
  123114. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123116. * @param name defines the name of the mesh
  123117. * @param options defines the options used to create the mesh
  123118. * @param scene defines the hosting scene
  123119. * @returns the ribbon mesh
  123120. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123122. */
  123123. static CreateRibbon(name: string, options: {
  123124. pathArray: Vector3[][];
  123125. closeArray?: boolean;
  123126. closePath?: boolean;
  123127. offset?: number;
  123128. updatable?: boolean;
  123129. sideOrientation?: number;
  123130. frontUVs?: Vector4;
  123131. backUVs?: Vector4;
  123132. instance?: Mesh;
  123133. invertUV?: boolean;
  123134. uvs?: Vector2[];
  123135. colors?: Color4[];
  123136. }, scene?: Nullable<Scene>): Mesh;
  123137. /**
  123138. * Creates a cylinder or a cone mesh
  123139. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123140. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123141. * * 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.
  123142. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123143. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123144. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123145. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123146. * * 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).
  123147. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123148. * * 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).
  123149. * * 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
  123150. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123151. * * 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
  123152. * * 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.
  123153. * * If `enclose` is false, a ring surface is one element.
  123154. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123155. * * 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
  123156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123159. * @param name defines the name of the mesh
  123160. * @param options defines the options used to create the mesh
  123161. * @param scene defines the hosting scene
  123162. * @returns the cylinder mesh
  123163. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123164. */
  123165. static CreateCylinder(name: string, options: {
  123166. height?: number;
  123167. diameterTop?: number;
  123168. diameterBottom?: number;
  123169. diameter?: number;
  123170. tessellation?: number;
  123171. subdivisions?: number;
  123172. arc?: number;
  123173. faceColors?: Color4[];
  123174. faceUV?: Vector4[];
  123175. updatable?: boolean;
  123176. hasRings?: boolean;
  123177. enclose?: boolean;
  123178. cap?: number;
  123179. sideOrientation?: number;
  123180. frontUVs?: Vector4;
  123181. backUVs?: Vector4;
  123182. }, scene?: Nullable<Scene>): Mesh;
  123183. /**
  123184. * Creates a torus mesh
  123185. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123186. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123187. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123191. * @param name defines the name of the mesh
  123192. * @param options defines the options used to create the mesh
  123193. * @param scene defines the hosting scene
  123194. * @returns the torus mesh
  123195. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123196. */
  123197. static CreateTorus(name: string, options: {
  123198. diameter?: number;
  123199. thickness?: number;
  123200. tessellation?: number;
  123201. updatable?: boolean;
  123202. sideOrientation?: number;
  123203. frontUVs?: Vector4;
  123204. backUVs?: Vector4;
  123205. }, scene?: Nullable<Scene>): Mesh;
  123206. /**
  123207. * Creates a torus knot mesh
  123208. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123209. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123210. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123211. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123215. * @param name defines the name of the mesh
  123216. * @param options defines the options used to create the mesh
  123217. * @param scene defines the hosting scene
  123218. * @returns the torus knot mesh
  123219. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123220. */
  123221. static CreateTorusKnot(name: string, options: {
  123222. radius?: number;
  123223. tube?: number;
  123224. radialSegments?: number;
  123225. tubularSegments?: number;
  123226. p?: number;
  123227. q?: number;
  123228. updatable?: boolean;
  123229. sideOrientation?: number;
  123230. frontUVs?: Vector4;
  123231. backUVs?: Vector4;
  123232. }, scene?: Nullable<Scene>): Mesh;
  123233. /**
  123234. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123235. * * 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
  123236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123237. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123238. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123239. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123241. * * 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
  123242. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123245. * @param name defines the name of the new line system
  123246. * @param options defines the options used to create the line system
  123247. * @param scene defines the hosting scene
  123248. * @returns a new line system mesh
  123249. */
  123250. static CreateLineSystem(name: string, options: {
  123251. lines: Vector3[][];
  123252. updatable?: boolean;
  123253. instance?: Nullable<LinesMesh>;
  123254. colors?: Nullable<Color4[][]>;
  123255. useVertexAlpha?: boolean;
  123256. }, scene: Nullable<Scene>): LinesMesh;
  123257. /**
  123258. * Creates a line mesh
  123259. * 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
  123260. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123261. * * The parameter `points` is an array successive Vector3
  123262. * * 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
  123263. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123264. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123265. * * When updating an instance, remember that only point positions can change, not the number of points
  123266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123268. * @param name defines the name of the new line system
  123269. * @param options defines the options used to create the line system
  123270. * @param scene defines the hosting scene
  123271. * @returns a new line mesh
  123272. */
  123273. static CreateLines(name: string, options: {
  123274. points: Vector3[];
  123275. updatable?: boolean;
  123276. instance?: Nullable<LinesMesh>;
  123277. colors?: Color4[];
  123278. useVertexAlpha?: boolean;
  123279. }, scene?: Nullable<Scene>): LinesMesh;
  123280. /**
  123281. * Creates a dashed line mesh
  123282. * * 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
  123283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123284. * * The parameter `points` is an array successive Vector3
  123285. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123286. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123287. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123288. * * 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
  123289. * * When updating an instance, remember that only point positions can change, not the number of points
  123290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123291. * @param name defines the name of the mesh
  123292. * @param options defines the options used to create the mesh
  123293. * @param scene defines the hosting scene
  123294. * @returns the dashed line mesh
  123295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123296. */
  123297. static CreateDashedLines(name: string, options: {
  123298. points: Vector3[];
  123299. dashSize?: number;
  123300. gapSize?: number;
  123301. dashNb?: number;
  123302. updatable?: boolean;
  123303. instance?: LinesMesh;
  123304. }, scene?: Nullable<Scene>): LinesMesh;
  123305. /**
  123306. * 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.
  123307. * * 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.
  123308. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123309. * * 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.
  123310. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123311. * * 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
  123312. * * 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
  123313. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123316. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123318. * @param name defines the name of the mesh
  123319. * @param options defines the options used to create the mesh
  123320. * @param scene defines the hosting scene
  123321. * @returns the extruded shape mesh
  123322. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123324. */
  123325. static ExtrudeShape(name: string, options: {
  123326. shape: Vector3[];
  123327. path: Vector3[];
  123328. scale?: number;
  123329. rotation?: number;
  123330. cap?: number;
  123331. updatable?: boolean;
  123332. sideOrientation?: number;
  123333. frontUVs?: Vector4;
  123334. backUVs?: Vector4;
  123335. instance?: Mesh;
  123336. invertUV?: boolean;
  123337. }, scene?: Nullable<Scene>): Mesh;
  123338. /**
  123339. * Creates an custom extruded shape mesh.
  123340. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123341. * * 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.
  123342. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123343. * * 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
  123344. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123345. * * 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
  123346. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123347. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123348. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123349. * * 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
  123350. * * 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
  123351. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123356. * @param name defines the name of the mesh
  123357. * @param options defines the options used to create the mesh
  123358. * @param scene defines the hosting scene
  123359. * @returns the custom extruded shape mesh
  123360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123363. */
  123364. static ExtrudeShapeCustom(name: string, options: {
  123365. shape: Vector3[];
  123366. path: Vector3[];
  123367. scaleFunction?: any;
  123368. rotationFunction?: any;
  123369. ribbonCloseArray?: boolean;
  123370. ribbonClosePath?: boolean;
  123371. cap?: number;
  123372. updatable?: boolean;
  123373. sideOrientation?: number;
  123374. frontUVs?: Vector4;
  123375. backUVs?: Vector4;
  123376. instance?: Mesh;
  123377. invertUV?: boolean;
  123378. }, scene?: Nullable<Scene>): Mesh;
  123379. /**
  123380. * Creates lathe mesh.
  123381. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123382. * * 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
  123383. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123384. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123385. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123386. * * 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
  123387. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123388. * * 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
  123389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123391. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123393. * @param name defines the name of the mesh
  123394. * @param options defines the options used to create the mesh
  123395. * @param scene defines the hosting scene
  123396. * @returns the lathe mesh
  123397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123398. */
  123399. static CreateLathe(name: string, options: {
  123400. shape: Vector3[];
  123401. radius?: number;
  123402. tessellation?: number;
  123403. clip?: number;
  123404. arc?: number;
  123405. closed?: boolean;
  123406. updatable?: boolean;
  123407. sideOrientation?: number;
  123408. frontUVs?: Vector4;
  123409. backUVs?: Vector4;
  123410. cap?: number;
  123411. invertUV?: boolean;
  123412. }, scene?: Nullable<Scene>): Mesh;
  123413. /**
  123414. * Creates a tiled plane mesh
  123415. * * You can set a limited pattern arrangement with the tiles
  123416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123419. * @param name defines the name of the mesh
  123420. * @param options defines the options used to create the mesh
  123421. * @param scene defines the hosting scene
  123422. * @returns the plane mesh
  123423. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123424. */
  123425. static CreateTiledPlane(name: string, options: {
  123426. pattern?: number;
  123427. tileSize?: number;
  123428. tileWidth?: number;
  123429. tileHeight?: number;
  123430. size?: number;
  123431. width?: number;
  123432. height?: number;
  123433. alignHorizontal?: number;
  123434. alignVertical?: number;
  123435. sideOrientation?: number;
  123436. frontUVs?: Vector4;
  123437. backUVs?: Vector4;
  123438. updatable?: boolean;
  123439. }, scene?: Nullable<Scene>): Mesh;
  123440. /**
  123441. * Creates a plane mesh
  123442. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123443. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123444. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123448. * @param name defines the name of the mesh
  123449. * @param options defines the options used to create the mesh
  123450. * @param scene defines the hosting scene
  123451. * @returns the plane mesh
  123452. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123453. */
  123454. static CreatePlane(name: string, options: {
  123455. size?: number;
  123456. width?: number;
  123457. height?: number;
  123458. sideOrientation?: number;
  123459. frontUVs?: Vector4;
  123460. backUVs?: Vector4;
  123461. updatable?: boolean;
  123462. sourcePlane?: Plane;
  123463. }, scene?: Nullable<Scene>): Mesh;
  123464. /**
  123465. * Creates a ground mesh
  123466. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123467. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123469. * @param name defines the name of the mesh
  123470. * @param options defines the options used to create the mesh
  123471. * @param scene defines the hosting scene
  123472. * @returns the ground mesh
  123473. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123474. */
  123475. static CreateGround(name: string, options: {
  123476. width?: number;
  123477. height?: number;
  123478. subdivisions?: number;
  123479. subdivisionsX?: number;
  123480. subdivisionsY?: number;
  123481. updatable?: boolean;
  123482. }, scene?: Nullable<Scene>): Mesh;
  123483. /**
  123484. * Creates a tiled ground mesh
  123485. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123486. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123487. * * 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
  123488. * * 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
  123489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123490. * @param name defines the name of the mesh
  123491. * @param options defines the options used to create the mesh
  123492. * @param scene defines the hosting scene
  123493. * @returns the tiled ground mesh
  123494. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123495. */
  123496. static CreateTiledGround(name: string, options: {
  123497. xmin: number;
  123498. zmin: number;
  123499. xmax: number;
  123500. zmax: number;
  123501. subdivisions?: {
  123502. w: number;
  123503. h: number;
  123504. };
  123505. precision?: {
  123506. w: number;
  123507. h: number;
  123508. };
  123509. updatable?: boolean;
  123510. }, scene?: Nullable<Scene>): Mesh;
  123511. /**
  123512. * Creates a ground mesh from a height map
  123513. * * The parameter `url` sets the URL of the height map image resource.
  123514. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123515. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123516. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123517. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123518. * * 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.
  123519. * * 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).
  123520. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123522. * @param name defines the name of the mesh
  123523. * @param url defines the url to the height map
  123524. * @param options defines the options used to create the mesh
  123525. * @param scene defines the hosting scene
  123526. * @returns the ground mesh
  123527. * @see https://doc.babylonjs.com/babylon101/height_map
  123528. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123529. */
  123530. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123531. width?: number;
  123532. height?: number;
  123533. subdivisions?: number;
  123534. minHeight?: number;
  123535. maxHeight?: number;
  123536. colorFilter?: Color3;
  123537. alphaFilter?: number;
  123538. updatable?: boolean;
  123539. onReady?: (mesh: GroundMesh) => void;
  123540. }, scene?: Nullable<Scene>): GroundMesh;
  123541. /**
  123542. * Creates a polygon mesh
  123543. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123544. * * 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
  123545. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123548. * * Remember you can only change the shape positions, not their number when updating a polygon
  123549. * @param name defines the name of the mesh
  123550. * @param options defines the options used to create the mesh
  123551. * @param scene defines the hosting scene
  123552. * @param earcutInjection can be used to inject your own earcut reference
  123553. * @returns the polygon mesh
  123554. */
  123555. static CreatePolygon(name: string, options: {
  123556. shape: Vector3[];
  123557. holes?: Vector3[][];
  123558. depth?: number;
  123559. faceUV?: Vector4[];
  123560. faceColors?: Color4[];
  123561. updatable?: boolean;
  123562. sideOrientation?: number;
  123563. frontUVs?: Vector4;
  123564. backUVs?: Vector4;
  123565. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123566. /**
  123567. * Creates an extruded polygon mesh, with depth in the Y direction.
  123568. * * 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)
  123569. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123570. * @param name defines the name of the mesh
  123571. * @param options defines the options used to create the mesh
  123572. * @param scene defines the hosting scene
  123573. * @param earcutInjection can be used to inject your own earcut reference
  123574. * @returns the polygon mesh
  123575. */
  123576. static ExtrudePolygon(name: string, options: {
  123577. shape: Vector3[];
  123578. holes?: Vector3[][];
  123579. depth?: number;
  123580. faceUV?: Vector4[];
  123581. faceColors?: Color4[];
  123582. updatable?: boolean;
  123583. sideOrientation?: number;
  123584. frontUVs?: Vector4;
  123585. backUVs?: Vector4;
  123586. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123587. /**
  123588. * Creates a tube mesh.
  123589. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123590. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123591. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123592. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123593. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123594. * * 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)
  123595. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123596. * * 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
  123597. * * 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
  123598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123602. * @param name defines the name of the mesh
  123603. * @param options defines the options used to create the mesh
  123604. * @param scene defines the hosting scene
  123605. * @returns the tube mesh
  123606. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123607. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123608. */
  123609. static CreateTube(name: string, options: {
  123610. path: Vector3[];
  123611. radius?: number;
  123612. tessellation?: number;
  123613. radiusFunction?: {
  123614. (i: number, distance: number): number;
  123615. };
  123616. cap?: number;
  123617. arc?: number;
  123618. updatable?: boolean;
  123619. sideOrientation?: number;
  123620. frontUVs?: Vector4;
  123621. backUVs?: Vector4;
  123622. instance?: Mesh;
  123623. invertUV?: boolean;
  123624. }, scene?: Nullable<Scene>): Mesh;
  123625. /**
  123626. * Creates a polyhedron mesh
  123627. * * 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
  123628. * * The parameter `size` (positive float, default 1) sets the polygon size
  123629. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123630. * * 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`
  123631. * * 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
  123632. * * 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)`)
  123633. * * 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
  123634. * * 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
  123635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123638. * @param name defines the name of the mesh
  123639. * @param options defines the options used to create the mesh
  123640. * @param scene defines the hosting scene
  123641. * @returns the polyhedron mesh
  123642. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123643. */
  123644. static CreatePolyhedron(name: string, options: {
  123645. type?: number;
  123646. size?: number;
  123647. sizeX?: number;
  123648. sizeY?: number;
  123649. sizeZ?: number;
  123650. custom?: any;
  123651. faceUV?: Vector4[];
  123652. faceColors?: Color4[];
  123653. flat?: boolean;
  123654. updatable?: boolean;
  123655. sideOrientation?: number;
  123656. frontUVs?: Vector4;
  123657. backUVs?: Vector4;
  123658. }, scene?: Nullable<Scene>): Mesh;
  123659. /**
  123660. * Creates a decal mesh.
  123661. * 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
  123662. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123663. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123664. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123665. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123666. * @param name defines the name of the mesh
  123667. * @param sourceMesh defines the mesh where the decal must be applied
  123668. * @param options defines the options used to create the mesh
  123669. * @param scene defines the hosting scene
  123670. * @returns the decal mesh
  123671. * @see https://doc.babylonjs.com/how_to/decals
  123672. */
  123673. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123674. position?: Vector3;
  123675. normal?: Vector3;
  123676. size?: Vector3;
  123677. angle?: number;
  123678. }): Mesh;
  123679. }
  123680. }
  123681. declare module BABYLON {
  123682. /**
  123683. * A simplifier interface for future simplification implementations
  123684. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123685. */
  123686. export interface ISimplifier {
  123687. /**
  123688. * Simplification of a given mesh according to the given settings.
  123689. * Since this requires computation, it is assumed that the function runs async.
  123690. * @param settings The settings of the simplification, including quality and distance
  123691. * @param successCallback A callback that will be called after the mesh was simplified.
  123692. * @param errorCallback in case of an error, this callback will be called. optional.
  123693. */
  123694. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123695. }
  123696. /**
  123697. * Expected simplification settings.
  123698. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123700. */
  123701. export interface ISimplificationSettings {
  123702. /**
  123703. * Gets or sets the expected quality
  123704. */
  123705. quality: number;
  123706. /**
  123707. * Gets or sets the distance when this optimized version should be used
  123708. */
  123709. distance: number;
  123710. /**
  123711. * Gets an already optimized mesh
  123712. */
  123713. optimizeMesh?: boolean;
  123714. }
  123715. /**
  123716. * Class used to specify simplification options
  123717. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123718. */
  123719. export class SimplificationSettings implements ISimplificationSettings {
  123720. /** expected quality */
  123721. quality: number;
  123722. /** distance when this optimized version should be used */
  123723. distance: number;
  123724. /** already optimized mesh */
  123725. optimizeMesh?: boolean | undefined;
  123726. /**
  123727. * Creates a SimplificationSettings
  123728. * @param quality expected quality
  123729. * @param distance distance when this optimized version should be used
  123730. * @param optimizeMesh already optimized mesh
  123731. */
  123732. constructor(
  123733. /** expected quality */
  123734. quality: number,
  123735. /** distance when this optimized version should be used */
  123736. distance: number,
  123737. /** already optimized mesh */
  123738. optimizeMesh?: boolean | undefined);
  123739. }
  123740. /**
  123741. * Interface used to define a simplification task
  123742. */
  123743. export interface ISimplificationTask {
  123744. /**
  123745. * Array of settings
  123746. */
  123747. settings: Array<ISimplificationSettings>;
  123748. /**
  123749. * Simplification type
  123750. */
  123751. simplificationType: SimplificationType;
  123752. /**
  123753. * Mesh to simplify
  123754. */
  123755. mesh: Mesh;
  123756. /**
  123757. * Callback called on success
  123758. */
  123759. successCallback?: () => void;
  123760. /**
  123761. * Defines if parallel processing can be used
  123762. */
  123763. parallelProcessing: boolean;
  123764. }
  123765. /**
  123766. * Queue used to order the simplification tasks
  123767. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123768. */
  123769. export class SimplificationQueue {
  123770. private _simplificationArray;
  123771. /**
  123772. * Gets a boolean indicating that the process is still running
  123773. */
  123774. running: boolean;
  123775. /**
  123776. * Creates a new queue
  123777. */
  123778. constructor();
  123779. /**
  123780. * Adds a new simplification task
  123781. * @param task defines a task to add
  123782. */
  123783. addTask(task: ISimplificationTask): void;
  123784. /**
  123785. * Execute next task
  123786. */
  123787. executeNext(): void;
  123788. /**
  123789. * Execute a simplification task
  123790. * @param task defines the task to run
  123791. */
  123792. runSimplification(task: ISimplificationTask): void;
  123793. private getSimplifier;
  123794. }
  123795. /**
  123796. * The implemented types of simplification
  123797. * At the moment only Quadratic Error Decimation is implemented
  123798. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123799. */
  123800. export enum SimplificationType {
  123801. /** Quadratic error decimation */
  123802. QUADRATIC = 0
  123803. }
  123804. }
  123805. declare module BABYLON {
  123806. interface Scene {
  123807. /** @hidden (Backing field) */
  123808. _simplificationQueue: SimplificationQueue;
  123809. /**
  123810. * Gets or sets the simplification queue attached to the scene
  123811. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123812. */
  123813. simplificationQueue: SimplificationQueue;
  123814. }
  123815. interface Mesh {
  123816. /**
  123817. * Simplify the mesh according to the given array of settings.
  123818. * Function will return immediately and will simplify async
  123819. * @param settings a collection of simplification settings
  123820. * @param parallelProcessing should all levels calculate parallel or one after the other
  123821. * @param simplificationType the type of simplification to run
  123822. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123823. * @returns the current mesh
  123824. */
  123825. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123826. }
  123827. /**
  123828. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123829. * created in a scene
  123830. */
  123831. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123832. /**
  123833. * The component name helpfull to identify the component in the list of scene components.
  123834. */
  123835. readonly name: string;
  123836. /**
  123837. * The scene the component belongs to.
  123838. */
  123839. scene: Scene;
  123840. /**
  123841. * Creates a new instance of the component for the given scene
  123842. * @param scene Defines the scene to register the component in
  123843. */
  123844. constructor(scene: Scene);
  123845. /**
  123846. * Registers the component in a given scene
  123847. */
  123848. register(): void;
  123849. /**
  123850. * Rebuilds the elements related to this component in case of
  123851. * context lost for instance.
  123852. */
  123853. rebuild(): void;
  123854. /**
  123855. * Disposes the component and the associated ressources
  123856. */
  123857. dispose(): void;
  123858. private _beforeCameraUpdate;
  123859. }
  123860. }
  123861. declare module BABYLON {
  123862. /**
  123863. * Navigation plugin interface to add navigation constrained by a navigation mesh
  123864. */
  123865. export interface INavigationEnginePlugin {
  123866. /**
  123867. * plugin name
  123868. */
  123869. name: string;
  123870. /**
  123871. * Creates a navigation mesh
  123872. * @param meshes array of all the geometry used to compute the navigatio mesh
  123873. * @param parameters bunch of parameters used to filter geometry
  123874. */
  123875. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123876. /**
  123877. * Create a navigation mesh debug mesh
  123878. * @param scene is where the mesh will be added
  123879. * @returns debug display mesh
  123880. */
  123881. createDebugNavMesh(scene: Scene): Mesh;
  123882. /**
  123883. * Get a navigation mesh constrained position, closest to the parameter position
  123884. * @param position world position
  123885. * @returns the closest point to position constrained by the navigation mesh
  123886. */
  123887. getClosestPoint(position: Vector3): Vector3;
  123888. /**
  123889. * Get a navigation mesh constrained position, within a particular radius
  123890. * @param position world position
  123891. * @param maxRadius the maximum distance to the constrained world position
  123892. * @returns the closest point to position constrained by the navigation mesh
  123893. */
  123894. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123895. /**
  123896. * Compute the final position from a segment made of destination-position
  123897. * @param position world position
  123898. * @param destination world position
  123899. * @returns the resulting point along the navmesh
  123900. */
  123901. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123902. /**
  123903. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123904. * @param start world position
  123905. * @param end world position
  123906. * @returns array containing world position composing the path
  123907. */
  123908. computePath(start: Vector3, end: Vector3): Vector3[];
  123909. /**
  123910. * If this plugin is supported
  123911. * @returns true if plugin is supported
  123912. */
  123913. isSupported(): boolean;
  123914. /**
  123915. * Create a new Crowd so you can add agents
  123916. * @param maxAgents the maximum agent count in the crowd
  123917. * @param maxAgentRadius the maximum radius an agent can have
  123918. * @param scene to attach the crowd to
  123919. * @returns the crowd you can add agents to
  123920. */
  123921. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123922. /**
  123923. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123924. * The queries will try to find a solution within those bounds
  123925. * default is (1,1,1)
  123926. * @param extent x,y,z value that define the extent around the queries point of reference
  123927. */
  123928. setDefaultQueryExtent(extent: Vector3): void;
  123929. /**
  123930. * Get the Bounding box extent specified by setDefaultQueryExtent
  123931. * @returns the box extent values
  123932. */
  123933. getDefaultQueryExtent(): Vector3;
  123934. /**
  123935. * Release all resources
  123936. */
  123937. dispose(): void;
  123938. }
  123939. /**
  123940. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  123941. */
  123942. export interface ICrowd {
  123943. /**
  123944. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123945. * You can attach anything to that node. The node position is updated in the scene update tick.
  123946. * @param pos world position that will be constrained by the navigation mesh
  123947. * @param parameters agent parameters
  123948. * @param transform hooked to the agent that will be update by the scene
  123949. * @returns agent index
  123950. */
  123951. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123952. /**
  123953. * Returns the agent position in world space
  123954. * @param index agent index returned by addAgent
  123955. * @returns world space position
  123956. */
  123957. getAgentPosition(index: number): Vector3;
  123958. /**
  123959. * Gets the agent velocity in world space
  123960. * @param index agent index returned by addAgent
  123961. * @returns world space velocity
  123962. */
  123963. getAgentVelocity(index: number): Vector3;
  123964. /**
  123965. * remove a particular agent previously created
  123966. * @param index agent index returned by addAgent
  123967. */
  123968. removeAgent(index: number): void;
  123969. /**
  123970. * get the list of all agents attached to this crowd
  123971. * @returns list of agent indices
  123972. */
  123973. getAgents(): number[];
  123974. /**
  123975. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123976. * @param deltaTime in seconds
  123977. */
  123978. update(deltaTime: number): void;
  123979. /**
  123980. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123981. * @param index agent index returned by addAgent
  123982. * @param destination targeted world position
  123983. */
  123984. agentGoto(index: number, destination: Vector3): void;
  123985. /**
  123986. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123987. * The queries will try to find a solution within those bounds
  123988. * default is (1,1,1)
  123989. * @param extent x,y,z value that define the extent around the queries point of reference
  123990. */
  123991. setDefaultQueryExtent(extent: Vector3): void;
  123992. /**
  123993. * Get the Bounding box extent specified by setDefaultQueryExtent
  123994. * @returns the box extent values
  123995. */
  123996. getDefaultQueryExtent(): Vector3;
  123997. /**
  123998. * Release all resources
  123999. */
  124000. dispose(): void;
  124001. }
  124002. /**
  124003. * Configures an agent
  124004. */
  124005. export interface IAgentParameters {
  124006. /**
  124007. * Agent radius. [Limit: >= 0]
  124008. */
  124009. radius: number;
  124010. /**
  124011. * Agent height. [Limit: > 0]
  124012. */
  124013. height: number;
  124014. /**
  124015. * Maximum allowed acceleration. [Limit: >= 0]
  124016. */
  124017. maxAcceleration: number;
  124018. /**
  124019. * Maximum allowed speed. [Limit: >= 0]
  124020. */
  124021. maxSpeed: number;
  124022. /**
  124023. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124024. */
  124025. collisionQueryRange: number;
  124026. /**
  124027. * The path visibility optimization range. [Limit: > 0]
  124028. */
  124029. pathOptimizationRange: number;
  124030. /**
  124031. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124032. */
  124033. separationWeight: number;
  124034. }
  124035. /**
  124036. * Configures the navigation mesh creation
  124037. */
  124038. export interface INavMeshParameters {
  124039. /**
  124040. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124041. */
  124042. cs: number;
  124043. /**
  124044. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124045. */
  124046. ch: number;
  124047. /**
  124048. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124049. */
  124050. walkableSlopeAngle: number;
  124051. /**
  124052. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124053. * be considered walkable. [Limit: >= 3] [Units: vx]
  124054. */
  124055. walkableHeight: number;
  124056. /**
  124057. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124058. */
  124059. walkableClimb: number;
  124060. /**
  124061. * The distance to erode/shrink the walkable area of the heightfield away from
  124062. * obstructions. [Limit: >=0] [Units: vx]
  124063. */
  124064. walkableRadius: number;
  124065. /**
  124066. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124067. */
  124068. maxEdgeLen: number;
  124069. /**
  124070. * The maximum distance a simplfied contour's border edges should deviate
  124071. * the original raw contour. [Limit: >=0] [Units: vx]
  124072. */
  124073. maxSimplificationError: number;
  124074. /**
  124075. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124076. */
  124077. minRegionArea: number;
  124078. /**
  124079. * Any regions with a span count smaller than this value will, if possible,
  124080. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124081. */
  124082. mergeRegionArea: number;
  124083. /**
  124084. * The maximum number of vertices allowed for polygons generated during the
  124085. * contour to polygon conversion process. [Limit: >= 3]
  124086. */
  124087. maxVertsPerPoly: number;
  124088. /**
  124089. * Sets the sampling distance to use when generating the detail mesh.
  124090. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124091. */
  124092. detailSampleDist: number;
  124093. /**
  124094. * The maximum distance the detail mesh surface should deviate from heightfield
  124095. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124096. */
  124097. detailSampleMaxError: number;
  124098. }
  124099. }
  124100. declare module BABYLON {
  124101. /**
  124102. * RecastJS navigation plugin
  124103. */
  124104. export class RecastJSPlugin implements INavigationEnginePlugin {
  124105. /**
  124106. * Reference to the Recast library
  124107. */
  124108. bjsRECAST: any;
  124109. /**
  124110. * plugin name
  124111. */
  124112. name: string;
  124113. /**
  124114. * the first navmesh created. We might extend this to support multiple navmeshes
  124115. */
  124116. navMesh: any;
  124117. /**
  124118. * Initializes the recastJS plugin
  124119. * @param recastInjection can be used to inject your own recast reference
  124120. */
  124121. constructor(recastInjection?: any);
  124122. /**
  124123. * Creates a navigation mesh
  124124. * @param meshes array of all the geometry used to compute the navigatio mesh
  124125. * @param parameters bunch of parameters used to filter geometry
  124126. */
  124127. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124128. /**
  124129. * Create a navigation mesh debug mesh
  124130. * @param scene is where the mesh will be added
  124131. * @returns debug display mesh
  124132. */
  124133. createDebugNavMesh(scene: Scene): Mesh;
  124134. /**
  124135. * Get a navigation mesh constrained position, closest to the parameter position
  124136. * @param position world position
  124137. * @returns the closest point to position constrained by the navigation mesh
  124138. */
  124139. getClosestPoint(position: Vector3): Vector3;
  124140. /**
  124141. * Get a navigation mesh constrained position, within a particular radius
  124142. * @param position world position
  124143. * @param maxRadius the maximum distance to the constrained world position
  124144. * @returns the closest point to position constrained by the navigation mesh
  124145. */
  124146. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124147. /**
  124148. * Compute the final position from a segment made of destination-position
  124149. * @param position world position
  124150. * @param destination world position
  124151. * @returns the resulting point along the navmesh
  124152. */
  124153. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124154. /**
  124155. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124156. * @param start world position
  124157. * @param end world position
  124158. * @returns array containing world position composing the path
  124159. */
  124160. computePath(start: Vector3, end: Vector3): Vector3[];
  124161. /**
  124162. * Create a new Crowd so you can add agents
  124163. * @param maxAgents the maximum agent count in the crowd
  124164. * @param maxAgentRadius the maximum radius an agent can have
  124165. * @param scene to attach the crowd to
  124166. * @returns the crowd you can add agents to
  124167. */
  124168. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124169. /**
  124170. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124171. * The queries will try to find a solution within those bounds
  124172. * default is (1,1,1)
  124173. * @param extent x,y,z value that define the extent around the queries point of reference
  124174. */
  124175. setDefaultQueryExtent(extent: Vector3): void;
  124176. /**
  124177. * Get the Bounding box extent specified by setDefaultQueryExtent
  124178. * @returns the box extent values
  124179. */
  124180. getDefaultQueryExtent(): Vector3;
  124181. /**
  124182. * Disposes
  124183. */
  124184. dispose(): void;
  124185. /**
  124186. * If this plugin is supported
  124187. * @returns true if plugin is supported
  124188. */
  124189. isSupported(): boolean;
  124190. }
  124191. /**
  124192. * Recast detour crowd implementation
  124193. */
  124194. export class RecastJSCrowd implements ICrowd {
  124195. /**
  124196. * Recast/detour plugin
  124197. */
  124198. bjsRECASTPlugin: RecastJSPlugin;
  124199. /**
  124200. * Link to the detour crowd
  124201. */
  124202. recastCrowd: any;
  124203. /**
  124204. * One transform per agent
  124205. */
  124206. transforms: TransformNode[];
  124207. /**
  124208. * All agents created
  124209. */
  124210. agents: number[];
  124211. /**
  124212. * Link to the scene is kept to unregister the crowd from the scene
  124213. */
  124214. private _scene;
  124215. /**
  124216. * Observer for crowd updates
  124217. */
  124218. private _onBeforeAnimationsObserver;
  124219. /**
  124220. * Constructor
  124221. * @param plugin recastJS plugin
  124222. * @param maxAgents the maximum agent count in the crowd
  124223. * @param maxAgentRadius the maximum radius an agent can have
  124224. * @param scene to attach the crowd to
  124225. * @returns the crowd you can add agents to
  124226. */
  124227. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124228. /**
  124229. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124230. * You can attach anything to that node. The node position is updated in the scene update tick.
  124231. * @param pos world position that will be constrained by the navigation mesh
  124232. * @param parameters agent parameters
  124233. * @param transform hooked to the agent that will be update by the scene
  124234. * @returns agent index
  124235. */
  124236. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124237. /**
  124238. * Returns the agent position in world space
  124239. * @param index agent index returned by addAgent
  124240. * @returns world space position
  124241. */
  124242. getAgentPosition(index: number): Vector3;
  124243. /**
  124244. * Returns the agent velocity in world space
  124245. * @param index agent index returned by addAgent
  124246. * @returns world space velocity
  124247. */
  124248. getAgentVelocity(index: number): Vector3;
  124249. /**
  124250. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124251. * @param index agent index returned by addAgent
  124252. * @param destination targeted world position
  124253. */
  124254. agentGoto(index: number, destination: Vector3): void;
  124255. /**
  124256. * remove a particular agent previously created
  124257. * @param index agent index returned by addAgent
  124258. */
  124259. removeAgent(index: number): void;
  124260. /**
  124261. * get the list of all agents attached to this crowd
  124262. * @returns list of agent indices
  124263. */
  124264. getAgents(): number[];
  124265. /**
  124266. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124267. * @param deltaTime in seconds
  124268. */
  124269. update(deltaTime: number): void;
  124270. /**
  124271. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124272. * The queries will try to find a solution within those bounds
  124273. * default is (1,1,1)
  124274. * @param extent x,y,z value that define the extent around the queries point of reference
  124275. */
  124276. setDefaultQueryExtent(extent: Vector3): void;
  124277. /**
  124278. * Get the Bounding box extent specified by setDefaultQueryExtent
  124279. * @returns the box extent values
  124280. */
  124281. getDefaultQueryExtent(): Vector3;
  124282. /**
  124283. * Release all resources
  124284. */
  124285. dispose(): void;
  124286. }
  124287. }
  124288. declare module BABYLON {
  124289. /**
  124290. * Class used to enable access to IndexedDB
  124291. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124292. */
  124293. export class Database implements IOfflineProvider {
  124294. private _callbackManifestChecked;
  124295. private _currentSceneUrl;
  124296. private _db;
  124297. private _enableSceneOffline;
  124298. private _enableTexturesOffline;
  124299. private _manifestVersionFound;
  124300. private _mustUpdateRessources;
  124301. private _hasReachedQuota;
  124302. private _isSupported;
  124303. private _idbFactory;
  124304. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124305. private static IsUASupportingBlobStorage;
  124306. /**
  124307. * Gets a boolean indicating if Database storate is enabled (off by default)
  124308. */
  124309. static IDBStorageEnabled: boolean;
  124310. /**
  124311. * Gets a boolean indicating if scene must be saved in the database
  124312. */
  124313. readonly enableSceneOffline: boolean;
  124314. /**
  124315. * Gets a boolean indicating if textures must be saved in the database
  124316. */
  124317. readonly enableTexturesOffline: boolean;
  124318. /**
  124319. * Creates a new Database
  124320. * @param urlToScene defines the url to load the scene
  124321. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124322. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124323. */
  124324. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124325. private static _ParseURL;
  124326. private static _ReturnFullUrlLocation;
  124327. private _checkManifestFile;
  124328. /**
  124329. * Open the database and make it available
  124330. * @param successCallback defines the callback to call on success
  124331. * @param errorCallback defines the callback to call on error
  124332. */
  124333. open(successCallback: () => void, errorCallback: () => void): void;
  124334. /**
  124335. * Loads an image from the database
  124336. * @param url defines the url to load from
  124337. * @param image defines the target DOM image
  124338. */
  124339. loadImage(url: string, image: HTMLImageElement): void;
  124340. private _loadImageFromDBAsync;
  124341. private _saveImageIntoDBAsync;
  124342. private _checkVersionFromDB;
  124343. private _loadVersionFromDBAsync;
  124344. private _saveVersionIntoDBAsync;
  124345. /**
  124346. * Loads a file from database
  124347. * @param url defines the URL to load from
  124348. * @param sceneLoaded defines a callback to call on success
  124349. * @param progressCallBack defines a callback to call when progress changed
  124350. * @param errorCallback defines a callback to call on error
  124351. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124352. */
  124353. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124354. private _loadFileAsync;
  124355. private _saveFileAsync;
  124356. /**
  124357. * Validates if xhr data is correct
  124358. * @param xhr defines the request to validate
  124359. * @param dataType defines the expected data type
  124360. * @returns true if data is correct
  124361. */
  124362. private static _ValidateXHRData;
  124363. }
  124364. }
  124365. declare module BABYLON {
  124366. /** @hidden */
  124367. export var gpuUpdateParticlesPixelShader: {
  124368. name: string;
  124369. shader: string;
  124370. };
  124371. }
  124372. declare module BABYLON {
  124373. /** @hidden */
  124374. export var gpuUpdateParticlesVertexShader: {
  124375. name: string;
  124376. shader: string;
  124377. };
  124378. }
  124379. declare module BABYLON {
  124380. /** @hidden */
  124381. export var clipPlaneFragmentDeclaration2: {
  124382. name: string;
  124383. shader: string;
  124384. };
  124385. }
  124386. declare module BABYLON {
  124387. /** @hidden */
  124388. export var gpuRenderParticlesPixelShader: {
  124389. name: string;
  124390. shader: string;
  124391. };
  124392. }
  124393. declare module BABYLON {
  124394. /** @hidden */
  124395. export var clipPlaneVertexDeclaration2: {
  124396. name: string;
  124397. shader: string;
  124398. };
  124399. }
  124400. declare module BABYLON {
  124401. /** @hidden */
  124402. export var gpuRenderParticlesVertexShader: {
  124403. name: string;
  124404. shader: string;
  124405. };
  124406. }
  124407. declare module BABYLON {
  124408. /**
  124409. * This represents a GPU particle system in Babylon
  124410. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124411. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124412. */
  124413. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124414. /**
  124415. * The layer mask we are rendering the particles through.
  124416. */
  124417. layerMask: number;
  124418. private _capacity;
  124419. private _activeCount;
  124420. private _currentActiveCount;
  124421. private _accumulatedCount;
  124422. private _renderEffect;
  124423. private _updateEffect;
  124424. private _buffer0;
  124425. private _buffer1;
  124426. private _spriteBuffer;
  124427. private _updateVAO;
  124428. private _renderVAO;
  124429. private _targetIndex;
  124430. private _sourceBuffer;
  124431. private _targetBuffer;
  124432. private _engine;
  124433. private _currentRenderId;
  124434. private _started;
  124435. private _stopped;
  124436. private _timeDelta;
  124437. private _randomTexture;
  124438. private _randomTexture2;
  124439. private _attributesStrideSize;
  124440. private _updateEffectOptions;
  124441. private _randomTextureSize;
  124442. private _actualFrame;
  124443. private readonly _rawTextureWidth;
  124444. /**
  124445. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124446. */
  124447. static readonly IsSupported: boolean;
  124448. /**
  124449. * An event triggered when the system is disposed.
  124450. */
  124451. onDisposeObservable: Observable<GPUParticleSystem>;
  124452. /**
  124453. * Gets the maximum number of particles active at the same time.
  124454. * @returns The max number of active particles.
  124455. */
  124456. getCapacity(): number;
  124457. /**
  124458. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124459. * to override the particles.
  124460. */
  124461. forceDepthWrite: boolean;
  124462. /**
  124463. * Gets or set the number of active particles
  124464. */
  124465. activeParticleCount: number;
  124466. private _preWarmDone;
  124467. /**
  124468. * Is this system ready to be used/rendered
  124469. * @return true if the system is ready
  124470. */
  124471. isReady(): boolean;
  124472. /**
  124473. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124474. * @returns True if it has been started, otherwise false.
  124475. */
  124476. isStarted(): boolean;
  124477. /**
  124478. * Starts the particle system and begins to emit
  124479. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124480. */
  124481. start(delay?: number): void;
  124482. /**
  124483. * Stops the particle system.
  124484. */
  124485. stop(): void;
  124486. /**
  124487. * Remove all active particles
  124488. */
  124489. reset(): void;
  124490. /**
  124491. * Returns the string "GPUParticleSystem"
  124492. * @returns a string containing the class name
  124493. */
  124494. getClassName(): string;
  124495. private _colorGradientsTexture;
  124496. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124497. /**
  124498. * Adds a new color gradient
  124499. * @param gradient defines the gradient to use (between 0 and 1)
  124500. * @param color1 defines the color to affect to the specified gradient
  124501. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124502. * @returns the current particle system
  124503. */
  124504. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124505. /**
  124506. * Remove a specific color gradient
  124507. * @param gradient defines the gradient to remove
  124508. * @returns the current particle system
  124509. */
  124510. removeColorGradient(gradient: number): GPUParticleSystem;
  124511. private _angularSpeedGradientsTexture;
  124512. private _sizeGradientsTexture;
  124513. private _velocityGradientsTexture;
  124514. private _limitVelocityGradientsTexture;
  124515. private _dragGradientsTexture;
  124516. private _addFactorGradient;
  124517. /**
  124518. * Adds a new size gradient
  124519. * @param gradient defines the gradient to use (between 0 and 1)
  124520. * @param factor defines the size factor to affect to the specified gradient
  124521. * @returns the current particle system
  124522. */
  124523. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124524. /**
  124525. * Remove a specific size gradient
  124526. * @param gradient defines the gradient to remove
  124527. * @returns the current particle system
  124528. */
  124529. removeSizeGradient(gradient: number): GPUParticleSystem;
  124530. /**
  124531. * Adds a new angular speed gradient
  124532. * @param gradient defines the gradient to use (between 0 and 1)
  124533. * @param factor defines the angular speed to affect to the specified gradient
  124534. * @returns the current particle system
  124535. */
  124536. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124537. /**
  124538. * Remove a specific angular speed gradient
  124539. * @param gradient defines the gradient to remove
  124540. * @returns the current particle system
  124541. */
  124542. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124543. /**
  124544. * Adds a new velocity gradient
  124545. * @param gradient defines the gradient to use (between 0 and 1)
  124546. * @param factor defines the velocity to affect to the specified gradient
  124547. * @returns the current particle system
  124548. */
  124549. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124550. /**
  124551. * Remove a specific velocity gradient
  124552. * @param gradient defines the gradient to remove
  124553. * @returns the current particle system
  124554. */
  124555. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124556. /**
  124557. * Adds a new limit velocity gradient
  124558. * @param gradient defines the gradient to use (between 0 and 1)
  124559. * @param factor defines the limit velocity value to affect to the specified gradient
  124560. * @returns the current particle system
  124561. */
  124562. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124563. /**
  124564. * Remove a specific limit velocity gradient
  124565. * @param gradient defines the gradient to remove
  124566. * @returns the current particle system
  124567. */
  124568. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124569. /**
  124570. * Adds a new drag gradient
  124571. * @param gradient defines the gradient to use (between 0 and 1)
  124572. * @param factor defines the drag value to affect to the specified gradient
  124573. * @returns the current particle system
  124574. */
  124575. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124576. /**
  124577. * Remove a specific drag gradient
  124578. * @param gradient defines the gradient to remove
  124579. * @returns the current particle system
  124580. */
  124581. removeDragGradient(gradient: number): GPUParticleSystem;
  124582. /**
  124583. * Not supported by GPUParticleSystem
  124584. * @param gradient defines the gradient to use (between 0 and 1)
  124585. * @param factor defines the emit rate value to affect to the specified gradient
  124586. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124587. * @returns the current particle system
  124588. */
  124589. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124590. /**
  124591. * Not supported by GPUParticleSystem
  124592. * @param gradient defines the gradient to remove
  124593. * @returns the current particle system
  124594. */
  124595. removeEmitRateGradient(gradient: number): IParticleSystem;
  124596. /**
  124597. * Not supported by GPUParticleSystem
  124598. * @param gradient defines the gradient to use (between 0 and 1)
  124599. * @param factor defines the start size value to affect to the specified gradient
  124600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124601. * @returns the current particle system
  124602. */
  124603. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124604. /**
  124605. * Not supported by GPUParticleSystem
  124606. * @param gradient defines the gradient to remove
  124607. * @returns the current particle system
  124608. */
  124609. removeStartSizeGradient(gradient: number): IParticleSystem;
  124610. /**
  124611. * Not supported by GPUParticleSystem
  124612. * @param gradient defines the gradient to use (between 0 and 1)
  124613. * @param min defines the color remap minimal range
  124614. * @param max defines the color remap maximal range
  124615. * @returns the current particle system
  124616. */
  124617. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124618. /**
  124619. * Not supported by GPUParticleSystem
  124620. * @param gradient defines the gradient to remove
  124621. * @returns the current particle system
  124622. */
  124623. removeColorRemapGradient(): IParticleSystem;
  124624. /**
  124625. * Not supported by GPUParticleSystem
  124626. * @param gradient defines the gradient to use (between 0 and 1)
  124627. * @param min defines the alpha remap minimal range
  124628. * @param max defines the alpha remap maximal range
  124629. * @returns the current particle system
  124630. */
  124631. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124632. /**
  124633. * Not supported by GPUParticleSystem
  124634. * @param gradient defines the gradient to remove
  124635. * @returns the current particle system
  124636. */
  124637. removeAlphaRemapGradient(): IParticleSystem;
  124638. /**
  124639. * Not supported by GPUParticleSystem
  124640. * @param gradient defines the gradient to use (between 0 and 1)
  124641. * @param color defines the color to affect to the specified gradient
  124642. * @returns the current particle system
  124643. */
  124644. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124645. /**
  124646. * Not supported by GPUParticleSystem
  124647. * @param gradient defines the gradient to remove
  124648. * @returns the current particle system
  124649. */
  124650. removeRampGradient(): IParticleSystem;
  124651. /**
  124652. * Not supported by GPUParticleSystem
  124653. * @returns the list of ramp gradients
  124654. */
  124655. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124656. /**
  124657. * Not supported by GPUParticleSystem
  124658. * Gets or sets a boolean indicating that ramp gradients must be used
  124659. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124660. */
  124661. useRampGradients: boolean;
  124662. /**
  124663. * Not supported by GPUParticleSystem
  124664. * @param gradient defines the gradient to use (between 0 and 1)
  124665. * @param factor defines the life time factor to affect to the specified gradient
  124666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124667. * @returns the current particle system
  124668. */
  124669. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124670. /**
  124671. * Not supported by GPUParticleSystem
  124672. * @param gradient defines the gradient to remove
  124673. * @returns the current particle system
  124674. */
  124675. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124676. /**
  124677. * Instantiates a GPU particle system.
  124678. * 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.
  124679. * @param name The name of the particle system
  124680. * @param options The options used to create the system
  124681. * @param scene The scene the particle system belongs to
  124682. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124683. */
  124684. constructor(name: string, options: Partial<{
  124685. capacity: number;
  124686. randomTextureSize: number;
  124687. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124688. protected _reset(): void;
  124689. private _createUpdateVAO;
  124690. private _createRenderVAO;
  124691. private _initialize;
  124692. /** @hidden */
  124693. _recreateUpdateEffect(): void;
  124694. /** @hidden */
  124695. _recreateRenderEffect(): void;
  124696. /**
  124697. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124698. * @param preWarm defines if we are in the pre-warmimg phase
  124699. */
  124700. animate(preWarm?: boolean): void;
  124701. private _createFactorGradientTexture;
  124702. private _createSizeGradientTexture;
  124703. private _createAngularSpeedGradientTexture;
  124704. private _createVelocityGradientTexture;
  124705. private _createLimitVelocityGradientTexture;
  124706. private _createDragGradientTexture;
  124707. private _createColorGradientTexture;
  124708. /**
  124709. * Renders the particle system in its current state
  124710. * @param preWarm defines if the system should only update the particles but not render them
  124711. * @returns the current number of particles
  124712. */
  124713. render(preWarm?: boolean): number;
  124714. /**
  124715. * Rebuilds the particle system
  124716. */
  124717. rebuild(): void;
  124718. private _releaseBuffers;
  124719. private _releaseVAOs;
  124720. /**
  124721. * Disposes the particle system and free the associated resources
  124722. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124723. */
  124724. dispose(disposeTexture?: boolean): void;
  124725. /**
  124726. * Clones the particle system.
  124727. * @param name The name of the cloned object
  124728. * @param newEmitter The new emitter to use
  124729. * @returns the cloned particle system
  124730. */
  124731. clone(name: string, newEmitter: any): GPUParticleSystem;
  124732. /**
  124733. * Serializes the particle system to a JSON object.
  124734. * @returns the JSON object
  124735. */
  124736. serialize(): any;
  124737. /**
  124738. * Parses a JSON object to create a GPU particle system.
  124739. * @param parsedParticleSystem The JSON object to parse
  124740. * @param scene The scene to create the particle system in
  124741. * @param rootUrl The root url to use to load external dependencies like texture
  124742. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124743. * @returns the parsed GPU particle system
  124744. */
  124745. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124746. }
  124747. }
  124748. declare module BABYLON {
  124749. /**
  124750. * Represents a set of particle systems working together to create a specific effect
  124751. */
  124752. export class ParticleSystemSet implements IDisposable {
  124753. private _emitterCreationOptions;
  124754. private _emitterNode;
  124755. /**
  124756. * Gets the particle system list
  124757. */
  124758. systems: IParticleSystem[];
  124759. /**
  124760. * Gets the emitter node used with this set
  124761. */
  124762. readonly emitterNode: Nullable<TransformNode>;
  124763. /**
  124764. * Creates a new emitter mesh as a sphere
  124765. * @param options defines the options used to create the sphere
  124766. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124767. * @param scene defines the hosting scene
  124768. */
  124769. setEmitterAsSphere(options: {
  124770. diameter: number;
  124771. segments: number;
  124772. color: Color3;
  124773. }, renderingGroupId: number, scene: Scene): void;
  124774. /**
  124775. * Starts all particle systems of the set
  124776. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124777. */
  124778. start(emitter?: AbstractMesh): void;
  124779. /**
  124780. * Release all associated resources
  124781. */
  124782. dispose(): void;
  124783. /**
  124784. * Serialize the set into a JSON compatible object
  124785. * @returns a JSON compatible representation of the set
  124786. */
  124787. serialize(): any;
  124788. /**
  124789. * Parse a new ParticleSystemSet from a serialized source
  124790. * @param data defines a JSON compatible representation of the set
  124791. * @param scene defines the hosting scene
  124792. * @param gpu defines if we want GPU particles or CPU particles
  124793. * @returns a new ParticleSystemSet
  124794. */
  124795. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124796. }
  124797. }
  124798. declare module BABYLON {
  124799. /**
  124800. * This class is made for on one-liner static method to help creating particle system set.
  124801. */
  124802. export class ParticleHelper {
  124803. /**
  124804. * Gets or sets base Assets URL
  124805. */
  124806. static BaseAssetsUrl: string;
  124807. /**
  124808. * Create a default particle system that you can tweak
  124809. * @param emitter defines the emitter to use
  124810. * @param capacity defines the system capacity (default is 500 particles)
  124811. * @param scene defines the hosting scene
  124812. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124813. * @returns the new Particle system
  124814. */
  124815. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124816. /**
  124817. * This is the main static method (one-liner) of this helper to create different particle systems
  124818. * @param type This string represents the type to the particle system to create
  124819. * @param scene The scene where the particle system should live
  124820. * @param gpu If the system will use gpu
  124821. * @returns the ParticleSystemSet created
  124822. */
  124823. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124824. /**
  124825. * Static function used to export a particle system to a ParticleSystemSet variable.
  124826. * Please note that the emitter shape is not exported
  124827. * @param systems defines the particle systems to export
  124828. * @returns the created particle system set
  124829. */
  124830. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124831. }
  124832. }
  124833. declare module BABYLON {
  124834. interface Engine {
  124835. /**
  124836. * Create an effect to use with particle systems.
  124837. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124838. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124839. * @param uniformsNames defines a list of attribute names
  124840. * @param samplers defines an array of string used to represent textures
  124841. * @param defines defines the string containing the defines to use to compile the shaders
  124842. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124843. * @param onCompiled defines a function to call when the effect creation is successful
  124844. * @param onError defines a function to call when the effect creation has failed
  124845. * @returns the new Effect
  124846. */
  124847. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124848. }
  124849. interface Mesh {
  124850. /**
  124851. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124852. * @returns an array of IParticleSystem
  124853. */
  124854. getEmittedParticleSystems(): IParticleSystem[];
  124855. /**
  124856. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124857. * @returns an array of IParticleSystem
  124858. */
  124859. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124860. }
  124861. /**
  124862. * @hidden
  124863. */
  124864. export var _IDoNeedToBeInTheBuild: number;
  124865. }
  124866. declare module BABYLON {
  124867. interface Scene {
  124868. /** @hidden (Backing field) */
  124869. _physicsEngine: Nullable<IPhysicsEngine>;
  124870. /**
  124871. * Gets the current physics engine
  124872. * @returns a IPhysicsEngine or null if none attached
  124873. */
  124874. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  124875. /**
  124876. * Enables physics to the current scene
  124877. * @param gravity defines the scene's gravity for the physics engine
  124878. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  124879. * @return a boolean indicating if the physics engine was initialized
  124880. */
  124881. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  124882. /**
  124883. * Disables and disposes the physics engine associated with the scene
  124884. */
  124885. disablePhysicsEngine(): void;
  124886. /**
  124887. * Gets a boolean indicating if there is an active physics engine
  124888. * @returns a boolean indicating if there is an active physics engine
  124889. */
  124890. isPhysicsEnabled(): boolean;
  124891. /**
  124892. * Deletes a physics compound impostor
  124893. * @param compound defines the compound to delete
  124894. */
  124895. deleteCompoundImpostor(compound: any): void;
  124896. /**
  124897. * An event triggered when physic simulation is about to be run
  124898. */
  124899. onBeforePhysicsObservable: Observable<Scene>;
  124900. /**
  124901. * An event triggered when physic simulation has been done
  124902. */
  124903. onAfterPhysicsObservable: Observable<Scene>;
  124904. }
  124905. interface AbstractMesh {
  124906. /** @hidden */
  124907. _physicsImpostor: Nullable<PhysicsImpostor>;
  124908. /**
  124909. * Gets or sets impostor used for physic simulation
  124910. * @see http://doc.babylonjs.com/features/physics_engine
  124911. */
  124912. physicsImpostor: Nullable<PhysicsImpostor>;
  124913. /**
  124914. * Gets the current physics impostor
  124915. * @see http://doc.babylonjs.com/features/physics_engine
  124916. * @returns a physics impostor or null
  124917. */
  124918. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  124919. /** Apply a physic impulse to the mesh
  124920. * @param force defines the force to apply
  124921. * @param contactPoint defines where to apply the force
  124922. * @returns the current mesh
  124923. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  124924. */
  124925. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  124926. /**
  124927. * Creates a physic joint between two meshes
  124928. * @param otherMesh defines the other mesh to use
  124929. * @param pivot1 defines the pivot to use on this mesh
  124930. * @param pivot2 defines the pivot to use on the other mesh
  124931. * @param options defines additional options (can be plugin dependent)
  124932. * @returns the current mesh
  124933. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  124934. */
  124935. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  124936. /** @hidden */
  124937. _disposePhysicsObserver: Nullable<Observer<Node>>;
  124938. }
  124939. /**
  124940. * Defines the physics engine scene component responsible to manage a physics engine
  124941. */
  124942. export class PhysicsEngineSceneComponent implements ISceneComponent {
  124943. /**
  124944. * The component name helpful to identify the component in the list of scene components.
  124945. */
  124946. readonly name: string;
  124947. /**
  124948. * The scene the component belongs to.
  124949. */
  124950. scene: Scene;
  124951. /**
  124952. * Creates a new instance of the component for the given scene
  124953. * @param scene Defines the scene to register the component in
  124954. */
  124955. constructor(scene: Scene);
  124956. /**
  124957. * Registers the component in a given scene
  124958. */
  124959. register(): void;
  124960. /**
  124961. * Rebuilds the elements related to this component in case of
  124962. * context lost for instance.
  124963. */
  124964. rebuild(): void;
  124965. /**
  124966. * Disposes the component and the associated ressources
  124967. */
  124968. dispose(): void;
  124969. }
  124970. }
  124971. declare module BABYLON {
  124972. /**
  124973. * A helper for physics simulations
  124974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124975. */
  124976. export class PhysicsHelper {
  124977. private _scene;
  124978. private _physicsEngine;
  124979. /**
  124980. * Initializes the Physics helper
  124981. * @param scene Babylon.js scene
  124982. */
  124983. constructor(scene: Scene);
  124984. /**
  124985. * Applies a radial explosion impulse
  124986. * @param origin the origin of the explosion
  124987. * @param radiusOrEventOptions the radius or the options of radial explosion
  124988. * @param strength the explosion strength
  124989. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124990. * @returns A physics radial explosion event, or null
  124991. */
  124992. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124993. /**
  124994. * Applies a radial explosion force
  124995. * @param origin the origin of the explosion
  124996. * @param radiusOrEventOptions the radius or the options of radial explosion
  124997. * @param strength the explosion strength
  124998. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124999. * @returns A physics radial explosion event, or null
  125000. */
  125001. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125002. /**
  125003. * Creates a gravitational field
  125004. * @param origin the origin of the explosion
  125005. * @param radiusOrEventOptions the radius or the options of radial explosion
  125006. * @param strength the explosion strength
  125007. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125008. * @returns A physics gravitational field event, or null
  125009. */
  125010. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125011. /**
  125012. * Creates a physics updraft event
  125013. * @param origin the origin of the updraft
  125014. * @param radiusOrEventOptions the radius or the options of the updraft
  125015. * @param strength the strength of the updraft
  125016. * @param height the height of the updraft
  125017. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125018. * @returns A physics updraft event, or null
  125019. */
  125020. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125021. /**
  125022. * Creates a physics vortex event
  125023. * @param origin the of the vortex
  125024. * @param radiusOrEventOptions the radius or the options of the vortex
  125025. * @param strength the strength of the vortex
  125026. * @param height the height of the vortex
  125027. * @returns a Physics vortex event, or null
  125028. * A physics vortex event or null
  125029. */
  125030. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125031. }
  125032. /**
  125033. * Represents a physics radial explosion event
  125034. */
  125035. class PhysicsRadialExplosionEvent {
  125036. private _scene;
  125037. private _options;
  125038. private _sphere;
  125039. private _dataFetched;
  125040. /**
  125041. * Initializes a radial explosioin event
  125042. * @param _scene BabylonJS scene
  125043. * @param _options The options for the vortex event
  125044. */
  125045. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125046. /**
  125047. * Returns the data related to the radial explosion event (sphere).
  125048. * @returns The radial explosion event data
  125049. */
  125050. getData(): PhysicsRadialExplosionEventData;
  125051. /**
  125052. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125053. * @param impostor A physics imposter
  125054. * @param origin the origin of the explosion
  125055. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125056. */
  125057. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125058. /**
  125059. * Triggers affecterd impostors callbacks
  125060. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125061. */
  125062. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125063. /**
  125064. * Disposes the sphere.
  125065. * @param force Specifies if the sphere should be disposed by force
  125066. */
  125067. dispose(force?: boolean): void;
  125068. /*** Helpers ***/
  125069. private _prepareSphere;
  125070. private _intersectsWithSphere;
  125071. }
  125072. /**
  125073. * Represents a gravitational field event
  125074. */
  125075. class PhysicsGravitationalFieldEvent {
  125076. private _physicsHelper;
  125077. private _scene;
  125078. private _origin;
  125079. private _options;
  125080. private _tickCallback;
  125081. private _sphere;
  125082. private _dataFetched;
  125083. /**
  125084. * Initializes the physics gravitational field event
  125085. * @param _physicsHelper A physics helper
  125086. * @param _scene BabylonJS scene
  125087. * @param _origin The origin position of the gravitational field event
  125088. * @param _options The options for the vortex event
  125089. */
  125090. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125091. /**
  125092. * Returns the data related to the gravitational field event (sphere).
  125093. * @returns A gravitational field event
  125094. */
  125095. getData(): PhysicsGravitationalFieldEventData;
  125096. /**
  125097. * Enables the gravitational field.
  125098. */
  125099. enable(): void;
  125100. /**
  125101. * Disables the gravitational field.
  125102. */
  125103. disable(): void;
  125104. /**
  125105. * Disposes the sphere.
  125106. * @param force The force to dispose from the gravitational field event
  125107. */
  125108. dispose(force?: boolean): void;
  125109. private _tick;
  125110. }
  125111. /**
  125112. * Represents a physics updraft event
  125113. */
  125114. class PhysicsUpdraftEvent {
  125115. private _scene;
  125116. private _origin;
  125117. private _options;
  125118. private _physicsEngine;
  125119. private _originTop;
  125120. private _originDirection;
  125121. private _tickCallback;
  125122. private _cylinder;
  125123. private _cylinderPosition;
  125124. private _dataFetched;
  125125. /**
  125126. * Initializes the physics updraft event
  125127. * @param _scene BabylonJS scene
  125128. * @param _origin The origin position of the updraft
  125129. * @param _options The options for the updraft event
  125130. */
  125131. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125132. /**
  125133. * Returns the data related to the updraft event (cylinder).
  125134. * @returns A physics updraft event
  125135. */
  125136. getData(): PhysicsUpdraftEventData;
  125137. /**
  125138. * Enables the updraft.
  125139. */
  125140. enable(): void;
  125141. /**
  125142. * Disables the updraft.
  125143. */
  125144. disable(): void;
  125145. /**
  125146. * Disposes the cylinder.
  125147. * @param force Specifies if the updraft should be disposed by force
  125148. */
  125149. dispose(force?: boolean): void;
  125150. private getImpostorHitData;
  125151. private _tick;
  125152. /*** Helpers ***/
  125153. private _prepareCylinder;
  125154. private _intersectsWithCylinder;
  125155. }
  125156. /**
  125157. * Represents a physics vortex event
  125158. */
  125159. class PhysicsVortexEvent {
  125160. private _scene;
  125161. private _origin;
  125162. private _options;
  125163. private _physicsEngine;
  125164. private _originTop;
  125165. private _tickCallback;
  125166. private _cylinder;
  125167. private _cylinderPosition;
  125168. private _dataFetched;
  125169. /**
  125170. * Initializes the physics vortex event
  125171. * @param _scene The BabylonJS scene
  125172. * @param _origin The origin position of the vortex
  125173. * @param _options The options for the vortex event
  125174. */
  125175. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125176. /**
  125177. * Returns the data related to the vortex event (cylinder).
  125178. * @returns The physics vortex event data
  125179. */
  125180. getData(): PhysicsVortexEventData;
  125181. /**
  125182. * Enables the vortex.
  125183. */
  125184. enable(): void;
  125185. /**
  125186. * Disables the cortex.
  125187. */
  125188. disable(): void;
  125189. /**
  125190. * Disposes the sphere.
  125191. * @param force
  125192. */
  125193. dispose(force?: boolean): void;
  125194. private getImpostorHitData;
  125195. private _tick;
  125196. /*** Helpers ***/
  125197. private _prepareCylinder;
  125198. private _intersectsWithCylinder;
  125199. }
  125200. /**
  125201. * Options fot the radial explosion event
  125202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125203. */
  125204. export class PhysicsRadialExplosionEventOptions {
  125205. /**
  125206. * The radius of the sphere for the radial explosion.
  125207. */
  125208. radius: number;
  125209. /**
  125210. * The strenth of the explosion.
  125211. */
  125212. strength: number;
  125213. /**
  125214. * The strenght of the force in correspondence to the distance of the affected object
  125215. */
  125216. falloff: PhysicsRadialImpulseFalloff;
  125217. /**
  125218. * Sphere options for the radial explosion.
  125219. */
  125220. sphere: {
  125221. segments: number;
  125222. diameter: number;
  125223. };
  125224. /**
  125225. * Sphere options for the radial explosion.
  125226. */
  125227. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125228. }
  125229. /**
  125230. * Options fot the updraft event
  125231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125232. */
  125233. export class PhysicsUpdraftEventOptions {
  125234. /**
  125235. * The radius of the cylinder for the vortex
  125236. */
  125237. radius: number;
  125238. /**
  125239. * The strenth of the updraft.
  125240. */
  125241. strength: number;
  125242. /**
  125243. * The height of the cylinder for the updraft.
  125244. */
  125245. height: number;
  125246. /**
  125247. * The mode for the the updraft.
  125248. */
  125249. updraftMode: PhysicsUpdraftMode;
  125250. }
  125251. /**
  125252. * Options fot the vortex event
  125253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125254. */
  125255. export class PhysicsVortexEventOptions {
  125256. /**
  125257. * The radius of the cylinder for the vortex
  125258. */
  125259. radius: number;
  125260. /**
  125261. * The strenth of the vortex.
  125262. */
  125263. strength: number;
  125264. /**
  125265. * The height of the cylinder for the vortex.
  125266. */
  125267. height: number;
  125268. /**
  125269. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125270. */
  125271. centripetalForceThreshold: number;
  125272. /**
  125273. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125274. */
  125275. centripetalForceMultiplier: number;
  125276. /**
  125277. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125278. */
  125279. centrifugalForceMultiplier: number;
  125280. /**
  125281. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125282. */
  125283. updraftForceMultiplier: number;
  125284. }
  125285. /**
  125286. * The strenght of the force in correspondence to the distance of the affected object
  125287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125288. */
  125289. export enum PhysicsRadialImpulseFalloff {
  125290. /** Defines that impulse is constant in strength across it's whole radius */
  125291. Constant = 0,
  125292. /** Defines that impulse gets weaker if it's further from the origin */
  125293. Linear = 1
  125294. }
  125295. /**
  125296. * The strength of the force in correspondence to the distance of the affected object
  125297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125298. */
  125299. export enum PhysicsUpdraftMode {
  125300. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125301. Center = 0,
  125302. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125303. Perpendicular = 1
  125304. }
  125305. /**
  125306. * Interface for a physics hit data
  125307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125308. */
  125309. export interface PhysicsHitData {
  125310. /**
  125311. * The force applied at the contact point
  125312. */
  125313. force: Vector3;
  125314. /**
  125315. * The contact point
  125316. */
  125317. contactPoint: Vector3;
  125318. /**
  125319. * The distance from the origin to the contact point
  125320. */
  125321. distanceFromOrigin: number;
  125322. }
  125323. /**
  125324. * Interface for radial explosion event data
  125325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125326. */
  125327. export interface PhysicsRadialExplosionEventData {
  125328. /**
  125329. * A sphere used for the radial explosion event
  125330. */
  125331. sphere: Mesh;
  125332. }
  125333. /**
  125334. * Interface for gravitational field event data
  125335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125336. */
  125337. export interface PhysicsGravitationalFieldEventData {
  125338. /**
  125339. * A sphere mesh used for the gravitational field event
  125340. */
  125341. sphere: Mesh;
  125342. }
  125343. /**
  125344. * Interface for updraft event data
  125345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125346. */
  125347. export interface PhysicsUpdraftEventData {
  125348. /**
  125349. * A cylinder used for the updraft event
  125350. */
  125351. cylinder: Mesh;
  125352. }
  125353. /**
  125354. * Interface for vortex event data
  125355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125356. */
  125357. export interface PhysicsVortexEventData {
  125358. /**
  125359. * A cylinder used for the vortex event
  125360. */
  125361. cylinder: Mesh;
  125362. }
  125363. /**
  125364. * Interface for an affected physics impostor
  125365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125366. */
  125367. export interface PhysicsAffectedImpostorWithData {
  125368. /**
  125369. * The impostor affected by the effect
  125370. */
  125371. impostor: PhysicsImpostor;
  125372. /**
  125373. * The data about the hit/horce from the explosion
  125374. */
  125375. hitData: PhysicsHitData;
  125376. }
  125377. }
  125378. declare module BABYLON {
  125379. /** @hidden */
  125380. export var blackAndWhitePixelShader: {
  125381. name: string;
  125382. shader: string;
  125383. };
  125384. }
  125385. declare module BABYLON {
  125386. /**
  125387. * Post process used to render in black and white
  125388. */
  125389. export class BlackAndWhitePostProcess extends PostProcess {
  125390. /**
  125391. * Linear about to convert he result to black and white (default: 1)
  125392. */
  125393. degree: number;
  125394. /**
  125395. * Creates a black and white post process
  125396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125397. * @param name The name of the effect.
  125398. * @param options The required width/height ratio to downsize to before computing the render pass.
  125399. * @param camera The camera to apply the render pass to.
  125400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125401. * @param engine The engine which the post process will be applied. (default: current engine)
  125402. * @param reusable If the post process can be reused on the same frame. (default: false)
  125403. */
  125404. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125405. }
  125406. }
  125407. declare module BABYLON {
  125408. /**
  125409. * This represents a set of one or more post processes in Babylon.
  125410. * A post process can be used to apply a shader to a texture after it is rendered.
  125411. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125412. */
  125413. export class PostProcessRenderEffect {
  125414. private _postProcesses;
  125415. private _getPostProcesses;
  125416. private _singleInstance;
  125417. private _cameras;
  125418. private _indicesForCamera;
  125419. /**
  125420. * Name of the effect
  125421. * @hidden
  125422. */
  125423. _name: string;
  125424. /**
  125425. * Instantiates a post process render effect.
  125426. * A post process can be used to apply a shader to a texture after it is rendered.
  125427. * @param engine The engine the effect is tied to
  125428. * @param name The name of the effect
  125429. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125430. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125431. */
  125432. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125433. /**
  125434. * Checks if all the post processes in the effect are supported.
  125435. */
  125436. readonly isSupported: boolean;
  125437. /**
  125438. * Updates the current state of the effect
  125439. * @hidden
  125440. */
  125441. _update(): void;
  125442. /**
  125443. * Attaches the effect on cameras
  125444. * @param cameras The camera to attach to.
  125445. * @hidden
  125446. */
  125447. _attachCameras(cameras: Camera): void;
  125448. /**
  125449. * Attaches the effect on cameras
  125450. * @param cameras The camera to attach to.
  125451. * @hidden
  125452. */
  125453. _attachCameras(cameras: Camera[]): void;
  125454. /**
  125455. * Detaches the effect on cameras
  125456. * @param cameras The camera to detatch from.
  125457. * @hidden
  125458. */
  125459. _detachCameras(cameras: Camera): void;
  125460. /**
  125461. * Detatches the effect on cameras
  125462. * @param cameras The camera to detatch from.
  125463. * @hidden
  125464. */
  125465. _detachCameras(cameras: Camera[]): void;
  125466. /**
  125467. * Enables the effect on given cameras
  125468. * @param cameras The camera to enable.
  125469. * @hidden
  125470. */
  125471. _enable(cameras: Camera): void;
  125472. /**
  125473. * Enables the effect on given cameras
  125474. * @param cameras The camera to enable.
  125475. * @hidden
  125476. */
  125477. _enable(cameras: Nullable<Camera[]>): void;
  125478. /**
  125479. * Disables the effect on the given cameras
  125480. * @param cameras The camera to disable.
  125481. * @hidden
  125482. */
  125483. _disable(cameras: Camera): void;
  125484. /**
  125485. * Disables the effect on the given cameras
  125486. * @param cameras The camera to disable.
  125487. * @hidden
  125488. */
  125489. _disable(cameras: Nullable<Camera[]>): void;
  125490. /**
  125491. * Gets a list of the post processes contained in the effect.
  125492. * @param camera The camera to get the post processes on.
  125493. * @returns The list of the post processes in the effect.
  125494. */
  125495. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125496. }
  125497. }
  125498. declare module BABYLON {
  125499. /** @hidden */
  125500. export var extractHighlightsPixelShader: {
  125501. name: string;
  125502. shader: string;
  125503. };
  125504. }
  125505. declare module BABYLON {
  125506. /**
  125507. * 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.
  125508. */
  125509. export class ExtractHighlightsPostProcess extends PostProcess {
  125510. /**
  125511. * The luminance threshold, pixels below this value will be set to black.
  125512. */
  125513. threshold: number;
  125514. /** @hidden */
  125515. _exposure: number;
  125516. /**
  125517. * Post process which has the input texture to be used when performing highlight extraction
  125518. * @hidden
  125519. */
  125520. _inputPostProcess: Nullable<PostProcess>;
  125521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125522. }
  125523. }
  125524. declare module BABYLON {
  125525. /** @hidden */
  125526. export var bloomMergePixelShader: {
  125527. name: string;
  125528. shader: string;
  125529. };
  125530. }
  125531. declare module BABYLON {
  125532. /**
  125533. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125534. */
  125535. export class BloomMergePostProcess extends PostProcess {
  125536. /** Weight of the bloom to be added to the original input. */
  125537. weight: number;
  125538. /**
  125539. * Creates a new instance of @see BloomMergePostProcess
  125540. * @param name The name of the effect.
  125541. * @param originalFromInput Post process which's input will be used for the merge.
  125542. * @param blurred Blurred highlights post process which's output will be used.
  125543. * @param weight Weight of the bloom to be added to the original input.
  125544. * @param options The required width/height ratio to downsize to before computing the render pass.
  125545. * @param camera The camera to apply the render pass to.
  125546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125547. * @param engine The engine which the post process will be applied. (default: current engine)
  125548. * @param reusable If the post process can be reused on the same frame. (default: false)
  125549. * @param textureType Type of textures used when performing the post process. (default: 0)
  125550. * @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)
  125551. */
  125552. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125553. /** Weight of the bloom to be added to the original input. */
  125554. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125555. }
  125556. }
  125557. declare module BABYLON {
  125558. /**
  125559. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125560. */
  125561. export class BloomEffect extends PostProcessRenderEffect {
  125562. private bloomScale;
  125563. /**
  125564. * @hidden Internal
  125565. */
  125566. _effects: Array<PostProcess>;
  125567. /**
  125568. * @hidden Internal
  125569. */
  125570. _downscale: ExtractHighlightsPostProcess;
  125571. private _blurX;
  125572. private _blurY;
  125573. private _merge;
  125574. /**
  125575. * The luminance threshold to find bright areas of the image to bloom.
  125576. */
  125577. threshold: number;
  125578. /**
  125579. * The strength of the bloom.
  125580. */
  125581. weight: number;
  125582. /**
  125583. * Specifies the size of the bloom blur kernel, relative to the final output size
  125584. */
  125585. kernel: number;
  125586. /**
  125587. * Creates a new instance of @see BloomEffect
  125588. * @param scene The scene the effect belongs to.
  125589. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125590. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125591. * @param bloomWeight The the strength of bloom.
  125592. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125593. * @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)
  125594. */
  125595. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125596. /**
  125597. * Disposes each of the internal effects for a given camera.
  125598. * @param camera The camera to dispose the effect on.
  125599. */
  125600. disposeEffects(camera: Camera): void;
  125601. /**
  125602. * @hidden Internal
  125603. */
  125604. _updateEffects(): void;
  125605. /**
  125606. * Internal
  125607. * @returns if all the contained post processes are ready.
  125608. * @hidden
  125609. */
  125610. _isReady(): boolean;
  125611. }
  125612. }
  125613. declare module BABYLON {
  125614. /** @hidden */
  125615. export var chromaticAberrationPixelShader: {
  125616. name: string;
  125617. shader: string;
  125618. };
  125619. }
  125620. declare module BABYLON {
  125621. /**
  125622. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125623. */
  125624. export class ChromaticAberrationPostProcess extends PostProcess {
  125625. /**
  125626. * The amount of seperation of rgb channels (default: 30)
  125627. */
  125628. aberrationAmount: number;
  125629. /**
  125630. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125631. */
  125632. radialIntensity: number;
  125633. /**
  125634. * 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))
  125635. */
  125636. direction: Vector2;
  125637. /**
  125638. * 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))
  125639. */
  125640. centerPosition: Vector2;
  125641. /**
  125642. * Creates a new instance ChromaticAberrationPostProcess
  125643. * @param name The name of the effect.
  125644. * @param screenWidth The width of the screen to apply the effect on.
  125645. * @param screenHeight The height of the screen to apply the effect on.
  125646. * @param options The required width/height ratio to downsize to before computing the render pass.
  125647. * @param camera The camera to apply the render pass to.
  125648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125649. * @param engine The engine which the post process will be applied. (default: current engine)
  125650. * @param reusable If the post process can be reused on the same frame. (default: false)
  125651. * @param textureType Type of textures used when performing the post process. (default: 0)
  125652. * @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)
  125653. */
  125654. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125655. }
  125656. }
  125657. declare module BABYLON {
  125658. /** @hidden */
  125659. export var circleOfConfusionPixelShader: {
  125660. name: string;
  125661. shader: string;
  125662. };
  125663. }
  125664. declare module BABYLON {
  125665. /**
  125666. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125667. */
  125668. export class CircleOfConfusionPostProcess extends PostProcess {
  125669. /**
  125670. * 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.
  125671. */
  125672. lensSize: number;
  125673. /**
  125674. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125675. */
  125676. fStop: number;
  125677. /**
  125678. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125679. */
  125680. focusDistance: number;
  125681. /**
  125682. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125683. */
  125684. focalLength: number;
  125685. private _depthTexture;
  125686. /**
  125687. * Creates a new instance CircleOfConfusionPostProcess
  125688. * @param name The name of the effect.
  125689. * @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.
  125690. * @param options The required width/height ratio to downsize to before computing the render pass.
  125691. * @param camera The camera to apply the render pass to.
  125692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125693. * @param engine The engine which the post process will be applied. (default: current engine)
  125694. * @param reusable If the post process can be reused on the same frame. (default: false)
  125695. * @param textureType Type of textures used when performing the post process. (default: 0)
  125696. * @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)
  125697. */
  125698. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125699. /**
  125700. * 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.
  125701. */
  125702. depthTexture: RenderTargetTexture;
  125703. }
  125704. }
  125705. declare module BABYLON {
  125706. /** @hidden */
  125707. export var colorCorrectionPixelShader: {
  125708. name: string;
  125709. shader: string;
  125710. };
  125711. }
  125712. declare module BABYLON {
  125713. /**
  125714. *
  125715. * This post-process allows the modification of rendered colors by using
  125716. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125717. *
  125718. * The object needs to be provided an url to a texture containing the color
  125719. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125720. * Use an image editing software to tweak the LUT to match your needs.
  125721. *
  125722. * For an example of a color LUT, see here:
  125723. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125724. * For explanations on color grading, see here:
  125725. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125726. *
  125727. */
  125728. export class ColorCorrectionPostProcess extends PostProcess {
  125729. private _colorTableTexture;
  125730. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125731. }
  125732. }
  125733. declare module BABYLON {
  125734. /** @hidden */
  125735. export var convolutionPixelShader: {
  125736. name: string;
  125737. shader: string;
  125738. };
  125739. }
  125740. declare module BABYLON {
  125741. /**
  125742. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125743. * input texture to perform effects such as edge detection or sharpening
  125744. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125745. */
  125746. export class ConvolutionPostProcess extends PostProcess {
  125747. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125748. kernel: number[];
  125749. /**
  125750. * Creates a new instance ConvolutionPostProcess
  125751. * @param name The name of the effect.
  125752. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125753. * @param options The required width/height ratio to downsize to before computing the render pass.
  125754. * @param camera The camera to apply the render pass to.
  125755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125756. * @param engine The engine which the post process will be applied. (default: current engine)
  125757. * @param reusable If the post process can be reused on the same frame. (default: false)
  125758. * @param textureType Type of textures used when performing the post process. (default: 0)
  125759. */
  125760. constructor(name: string,
  125761. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125762. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125763. /**
  125764. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125765. */
  125766. static EdgeDetect0Kernel: number[];
  125767. /**
  125768. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125769. */
  125770. static EdgeDetect1Kernel: number[];
  125771. /**
  125772. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125773. */
  125774. static EdgeDetect2Kernel: number[];
  125775. /**
  125776. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125777. */
  125778. static SharpenKernel: number[];
  125779. /**
  125780. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125781. */
  125782. static EmbossKernel: number[];
  125783. /**
  125784. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125785. */
  125786. static GaussianKernel: number[];
  125787. }
  125788. }
  125789. declare module BABYLON {
  125790. /**
  125791. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125792. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125793. * based on samples that have a large difference in distance than the center pixel.
  125794. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125795. */
  125796. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125797. direction: Vector2;
  125798. /**
  125799. * Creates a new instance CircleOfConfusionPostProcess
  125800. * @param name The name of the effect.
  125801. * @param scene The scene the effect belongs to.
  125802. * @param direction The direction the blur should be applied.
  125803. * @param kernel The size of the kernel used to blur.
  125804. * @param options The required width/height ratio to downsize to before computing the render pass.
  125805. * @param camera The camera to apply the render pass to.
  125806. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125807. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125809. * @param engine The engine which the post process will be applied. (default: current engine)
  125810. * @param reusable If the post process can be reused on the same frame. (default: false)
  125811. * @param textureType Type of textures used when performing the post process. (default: 0)
  125812. * @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)
  125813. */
  125814. 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);
  125815. }
  125816. }
  125817. declare module BABYLON {
  125818. /** @hidden */
  125819. export var depthOfFieldMergePixelShader: {
  125820. name: string;
  125821. shader: string;
  125822. };
  125823. }
  125824. declare module BABYLON {
  125825. /**
  125826. * Options to be set when merging outputs from the default pipeline.
  125827. */
  125828. export class DepthOfFieldMergePostProcessOptions {
  125829. /**
  125830. * The original image to merge on top of
  125831. */
  125832. originalFromInput: PostProcess;
  125833. /**
  125834. * Parameters to perform the merge of the depth of field effect
  125835. */
  125836. depthOfField?: {
  125837. circleOfConfusion: PostProcess;
  125838. blurSteps: Array<PostProcess>;
  125839. };
  125840. /**
  125841. * Parameters to perform the merge of bloom effect
  125842. */
  125843. bloom?: {
  125844. blurred: PostProcess;
  125845. weight: number;
  125846. };
  125847. }
  125848. /**
  125849. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125850. */
  125851. export class DepthOfFieldMergePostProcess extends PostProcess {
  125852. private blurSteps;
  125853. /**
  125854. * Creates a new instance of DepthOfFieldMergePostProcess
  125855. * @param name The name of the effect.
  125856. * @param originalFromInput Post process which's input will be used for the merge.
  125857. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125858. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125859. * @param options The required width/height ratio to downsize to before computing the render pass.
  125860. * @param camera The camera to apply the render pass to.
  125861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125862. * @param engine The engine which the post process will be applied. (default: current engine)
  125863. * @param reusable If the post process can be reused on the same frame. (default: false)
  125864. * @param textureType Type of textures used when performing the post process. (default: 0)
  125865. * @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)
  125866. */
  125867. 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);
  125868. /**
  125869. * Updates the effect with the current post process compile time values and recompiles the shader.
  125870. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125871. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125872. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125873. * @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
  125874. * @param onCompiled Called when the shader has been compiled.
  125875. * @param onError Called if there is an error when compiling a shader.
  125876. */
  125877. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  125878. }
  125879. }
  125880. declare module BABYLON {
  125881. /**
  125882. * Specifies the level of max blur that should be applied when using the depth of field effect
  125883. */
  125884. export enum DepthOfFieldEffectBlurLevel {
  125885. /**
  125886. * Subtle blur
  125887. */
  125888. Low = 0,
  125889. /**
  125890. * Medium blur
  125891. */
  125892. Medium = 1,
  125893. /**
  125894. * Large blur
  125895. */
  125896. High = 2
  125897. }
  125898. /**
  125899. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125900. */
  125901. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  125902. private _circleOfConfusion;
  125903. /**
  125904. * @hidden Internal, blurs from high to low
  125905. */
  125906. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  125907. private _depthOfFieldBlurY;
  125908. private _dofMerge;
  125909. /**
  125910. * @hidden Internal post processes in depth of field effect
  125911. */
  125912. _effects: Array<PostProcess>;
  125913. /**
  125914. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  125915. */
  125916. focalLength: number;
  125917. /**
  125918. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125919. */
  125920. fStop: number;
  125921. /**
  125922. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125923. */
  125924. focusDistance: number;
  125925. /**
  125926. * 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.
  125927. */
  125928. lensSize: number;
  125929. /**
  125930. * Creates a new instance DepthOfFieldEffect
  125931. * @param scene The scene the effect belongs to.
  125932. * @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.
  125933. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125934. * @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)
  125935. */
  125936. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  125937. /**
  125938. * Get the current class name of the current effet
  125939. * @returns "DepthOfFieldEffect"
  125940. */
  125941. getClassName(): string;
  125942. /**
  125943. * 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.
  125944. */
  125945. depthTexture: RenderTargetTexture;
  125946. /**
  125947. * Disposes each of the internal effects for a given camera.
  125948. * @param camera The camera to dispose the effect on.
  125949. */
  125950. disposeEffects(camera: Camera): void;
  125951. /**
  125952. * @hidden Internal
  125953. */
  125954. _updateEffects(): void;
  125955. /**
  125956. * Internal
  125957. * @returns if all the contained post processes are ready.
  125958. * @hidden
  125959. */
  125960. _isReady(): boolean;
  125961. }
  125962. }
  125963. declare module BABYLON {
  125964. /** @hidden */
  125965. export var displayPassPixelShader: {
  125966. name: string;
  125967. shader: string;
  125968. };
  125969. }
  125970. declare module BABYLON {
  125971. /**
  125972. * DisplayPassPostProcess which produces an output the same as it's input
  125973. */
  125974. export class DisplayPassPostProcess extends PostProcess {
  125975. /**
  125976. * Creates the DisplayPassPostProcess
  125977. * @param name The name of the effect.
  125978. * @param options The required width/height ratio to downsize to before computing the render pass.
  125979. * @param camera The camera to apply the render pass to.
  125980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125981. * @param engine The engine which the post process will be applied. (default: current engine)
  125982. * @param reusable If the post process can be reused on the same frame. (default: false)
  125983. */
  125984. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125985. }
  125986. }
  125987. declare module BABYLON {
  125988. /** @hidden */
  125989. export var filterPixelShader: {
  125990. name: string;
  125991. shader: string;
  125992. };
  125993. }
  125994. declare module BABYLON {
  125995. /**
  125996. * Applies a kernel filter to the image
  125997. */
  125998. export class FilterPostProcess extends PostProcess {
  125999. /** The matrix to be applied to the image */
  126000. kernelMatrix: Matrix;
  126001. /**
  126002. *
  126003. * @param name The name of the effect.
  126004. * @param kernelMatrix The matrix to be applied to the image
  126005. * @param options The required width/height ratio to downsize to before computing the render pass.
  126006. * @param camera The camera to apply the render pass to.
  126007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126008. * @param engine The engine which the post process will be applied. (default: current engine)
  126009. * @param reusable If the post process can be reused on the same frame. (default: false)
  126010. */
  126011. constructor(name: string,
  126012. /** The matrix to be applied to the image */
  126013. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126014. }
  126015. }
  126016. declare module BABYLON {
  126017. /** @hidden */
  126018. export var fxaaPixelShader: {
  126019. name: string;
  126020. shader: string;
  126021. };
  126022. }
  126023. declare module BABYLON {
  126024. /** @hidden */
  126025. export var fxaaVertexShader: {
  126026. name: string;
  126027. shader: string;
  126028. };
  126029. }
  126030. declare module BABYLON {
  126031. /**
  126032. * Fxaa post process
  126033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126034. */
  126035. export class FxaaPostProcess extends PostProcess {
  126036. /** @hidden */
  126037. texelWidth: number;
  126038. /** @hidden */
  126039. texelHeight: number;
  126040. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126041. private _getDefines;
  126042. }
  126043. }
  126044. declare module BABYLON {
  126045. /** @hidden */
  126046. export var grainPixelShader: {
  126047. name: string;
  126048. shader: string;
  126049. };
  126050. }
  126051. declare module BABYLON {
  126052. /**
  126053. * The GrainPostProcess adds noise to the image at mid luminance levels
  126054. */
  126055. export class GrainPostProcess extends PostProcess {
  126056. /**
  126057. * The intensity of the grain added (default: 30)
  126058. */
  126059. intensity: number;
  126060. /**
  126061. * If the grain should be randomized on every frame
  126062. */
  126063. animated: boolean;
  126064. /**
  126065. * Creates a new instance of @see GrainPostProcess
  126066. * @param name The name of the effect.
  126067. * @param options The required width/height ratio to downsize to before computing the render pass.
  126068. * @param camera The camera to apply the render pass to.
  126069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126070. * @param engine The engine which the post process will be applied. (default: current engine)
  126071. * @param reusable If the post process can be reused on the same frame. (default: false)
  126072. * @param textureType Type of textures used when performing the post process. (default: 0)
  126073. * @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)
  126074. */
  126075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126076. }
  126077. }
  126078. declare module BABYLON {
  126079. /** @hidden */
  126080. export var highlightsPixelShader: {
  126081. name: string;
  126082. shader: string;
  126083. };
  126084. }
  126085. declare module BABYLON {
  126086. /**
  126087. * Extracts highlights from the image
  126088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126089. */
  126090. export class HighlightsPostProcess extends PostProcess {
  126091. /**
  126092. * Extracts highlights from the image
  126093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126094. * @param name The name of the effect.
  126095. * @param options The required width/height ratio to downsize to before computing the render pass.
  126096. * @param camera The camera to apply the render pass to.
  126097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126098. * @param engine The engine which the post process will be applied. (default: current engine)
  126099. * @param reusable If the post process can be reused on the same frame. (default: false)
  126100. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126101. */
  126102. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126103. }
  126104. }
  126105. declare module BABYLON {
  126106. /** @hidden */
  126107. export var mrtFragmentDeclaration: {
  126108. name: string;
  126109. shader: string;
  126110. };
  126111. }
  126112. declare module BABYLON {
  126113. /** @hidden */
  126114. export var geometryPixelShader: {
  126115. name: string;
  126116. shader: string;
  126117. };
  126118. }
  126119. declare module BABYLON {
  126120. /** @hidden */
  126121. export var geometryVertexShader: {
  126122. name: string;
  126123. shader: string;
  126124. };
  126125. }
  126126. declare module BABYLON {
  126127. /** @hidden */
  126128. interface ISavedTransformationMatrix {
  126129. world: Matrix;
  126130. viewProjection: Matrix;
  126131. }
  126132. /**
  126133. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126134. */
  126135. export class GeometryBufferRenderer {
  126136. /**
  126137. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126138. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126139. */
  126140. static readonly POSITION_TEXTURE_TYPE: number;
  126141. /**
  126142. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126143. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126144. */
  126145. static readonly VELOCITY_TEXTURE_TYPE: number;
  126146. /**
  126147. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126148. * in order to compute objects velocities when enableVelocity is set to "true"
  126149. * @hidden
  126150. */
  126151. _previousTransformationMatrices: {
  126152. [index: number]: ISavedTransformationMatrix;
  126153. };
  126154. /**
  126155. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126156. * in order to compute objects velocities when enableVelocity is set to "true"
  126157. * @hidden
  126158. */
  126159. _previousBonesTransformationMatrices: {
  126160. [index: number]: Float32Array;
  126161. };
  126162. /**
  126163. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126164. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126165. */
  126166. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126167. private _scene;
  126168. private _multiRenderTarget;
  126169. private _ratio;
  126170. private _enablePosition;
  126171. private _enableVelocity;
  126172. private _positionIndex;
  126173. private _velocityIndex;
  126174. protected _effect: Effect;
  126175. protected _cachedDefines: string;
  126176. /**
  126177. * Set the render list (meshes to be rendered) used in the G buffer.
  126178. */
  126179. renderList: Mesh[];
  126180. /**
  126181. * Gets wether or not G buffer are supported by the running hardware.
  126182. * This requires draw buffer supports
  126183. */
  126184. readonly isSupported: boolean;
  126185. /**
  126186. * Returns the index of the given texture type in the G-Buffer textures array
  126187. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126188. * @returns the index of the given texture type in the G-Buffer textures array
  126189. */
  126190. getTextureIndex(textureType: number): number;
  126191. /**
  126192. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126193. */
  126194. /**
  126195. * Sets whether or not objects positions are enabled for the G buffer.
  126196. */
  126197. enablePosition: boolean;
  126198. /**
  126199. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126200. */
  126201. /**
  126202. * Sets wether or not objects velocities are enabled for the G buffer.
  126203. */
  126204. enableVelocity: boolean;
  126205. /**
  126206. * Gets the scene associated with the buffer.
  126207. */
  126208. readonly scene: Scene;
  126209. /**
  126210. * Gets the ratio used by the buffer during its creation.
  126211. * How big is the buffer related to the main canvas.
  126212. */
  126213. readonly ratio: number;
  126214. /** @hidden */
  126215. static _SceneComponentInitialization: (scene: Scene) => void;
  126216. /**
  126217. * Creates a new G Buffer for the scene
  126218. * @param scene The scene the buffer belongs to
  126219. * @param ratio How big is the buffer related to the main canvas.
  126220. */
  126221. constructor(scene: Scene, ratio?: number);
  126222. /**
  126223. * Checks wether everything is ready to render a submesh to the G buffer.
  126224. * @param subMesh the submesh to check readiness for
  126225. * @param useInstances is the mesh drawn using instance or not
  126226. * @returns true if ready otherwise false
  126227. */
  126228. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126229. /**
  126230. * Gets the current underlying G Buffer.
  126231. * @returns the buffer
  126232. */
  126233. getGBuffer(): MultiRenderTarget;
  126234. /**
  126235. * Gets the number of samples used to render the buffer (anti aliasing).
  126236. */
  126237. /**
  126238. * Sets the number of samples used to render the buffer (anti aliasing).
  126239. */
  126240. samples: number;
  126241. /**
  126242. * Disposes the renderer and frees up associated resources.
  126243. */
  126244. dispose(): void;
  126245. protected _createRenderTargets(): void;
  126246. private _copyBonesTransformationMatrices;
  126247. }
  126248. }
  126249. declare module BABYLON {
  126250. interface Scene {
  126251. /** @hidden (Backing field) */
  126252. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126253. /**
  126254. * Gets or Sets the current geometry buffer associated to the scene.
  126255. */
  126256. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126257. /**
  126258. * Enables a GeometryBufferRender and associates it with the scene
  126259. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126260. * @returns the GeometryBufferRenderer
  126261. */
  126262. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126263. /**
  126264. * Disables the GeometryBufferRender associated with the scene
  126265. */
  126266. disableGeometryBufferRenderer(): void;
  126267. }
  126268. /**
  126269. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126270. * in several rendering techniques.
  126271. */
  126272. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126273. /**
  126274. * The component name helpful to identify the component in the list of scene components.
  126275. */
  126276. readonly name: string;
  126277. /**
  126278. * The scene the component belongs to.
  126279. */
  126280. scene: Scene;
  126281. /**
  126282. * Creates a new instance of the component for the given scene
  126283. * @param scene Defines the scene to register the component in
  126284. */
  126285. constructor(scene: Scene);
  126286. /**
  126287. * Registers the component in a given scene
  126288. */
  126289. register(): void;
  126290. /**
  126291. * Rebuilds the elements related to this component in case of
  126292. * context lost for instance.
  126293. */
  126294. rebuild(): void;
  126295. /**
  126296. * Disposes the component and the associated ressources
  126297. */
  126298. dispose(): void;
  126299. private _gatherRenderTargets;
  126300. }
  126301. }
  126302. declare module BABYLON {
  126303. /** @hidden */
  126304. export var motionBlurPixelShader: {
  126305. name: string;
  126306. shader: string;
  126307. };
  126308. }
  126309. declare module BABYLON {
  126310. /**
  126311. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126312. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126313. * As an example, all you have to do is to create the post-process:
  126314. * var mb = new BABYLON.MotionBlurPostProcess(
  126315. * 'mb', // The name of the effect.
  126316. * scene, // The scene containing the objects to blur according to their velocity.
  126317. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126318. * camera // The camera to apply the render pass to.
  126319. * );
  126320. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126321. */
  126322. export class MotionBlurPostProcess extends PostProcess {
  126323. /**
  126324. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126325. */
  126326. motionStrength: number;
  126327. /**
  126328. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126329. */
  126330. /**
  126331. * Sets the number of iterations to be used for motion blur quality
  126332. */
  126333. motionBlurSamples: number;
  126334. private _motionBlurSamples;
  126335. private _geometryBufferRenderer;
  126336. /**
  126337. * Creates a new instance MotionBlurPostProcess
  126338. * @param name The name of the effect.
  126339. * @param scene The scene containing the objects to blur according to their velocity.
  126340. * @param options The required width/height ratio to downsize to before computing the render pass.
  126341. * @param camera The camera to apply the render pass to.
  126342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126343. * @param engine The engine which the post process will be applied. (default: current engine)
  126344. * @param reusable If the post process can be reused on the same frame. (default: false)
  126345. * @param textureType Type of textures used when performing the post process. (default: 0)
  126346. * @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)
  126347. */
  126348. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126349. /**
  126350. * Excludes the given skinned mesh from computing bones velocities.
  126351. * 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.
  126352. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126353. */
  126354. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126355. /**
  126356. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126357. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126358. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126359. */
  126360. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126361. /**
  126362. * Disposes the post process.
  126363. * @param camera The camera to dispose the post process on.
  126364. */
  126365. dispose(camera?: Camera): void;
  126366. }
  126367. }
  126368. declare module BABYLON {
  126369. /** @hidden */
  126370. export var refractionPixelShader: {
  126371. name: string;
  126372. shader: string;
  126373. };
  126374. }
  126375. declare module BABYLON {
  126376. /**
  126377. * Post process which applies a refractin texture
  126378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126379. */
  126380. export class RefractionPostProcess extends PostProcess {
  126381. /** the base color of the refraction (used to taint the rendering) */
  126382. color: Color3;
  126383. /** simulated refraction depth */
  126384. depth: number;
  126385. /** the coefficient of the base color (0 to remove base color tainting) */
  126386. colorLevel: number;
  126387. private _refTexture;
  126388. private _ownRefractionTexture;
  126389. /**
  126390. * Gets or sets the refraction texture
  126391. * Please note that you are responsible for disposing the texture if you set it manually
  126392. */
  126393. refractionTexture: Texture;
  126394. /**
  126395. * Initializes the RefractionPostProcess
  126396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126397. * @param name The name of the effect.
  126398. * @param refractionTextureUrl Url of the refraction texture to use
  126399. * @param color the base color of the refraction (used to taint the rendering)
  126400. * @param depth simulated refraction depth
  126401. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126402. * @param camera The camera to apply the render pass to.
  126403. * @param options The required width/height ratio to downsize to before computing the render pass.
  126404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126405. * @param engine The engine which the post process will be applied. (default: current engine)
  126406. * @param reusable If the post process can be reused on the same frame. (default: false)
  126407. */
  126408. constructor(name: string, refractionTextureUrl: string,
  126409. /** the base color of the refraction (used to taint the rendering) */
  126410. color: Color3,
  126411. /** simulated refraction depth */
  126412. depth: number,
  126413. /** the coefficient of the base color (0 to remove base color tainting) */
  126414. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126415. /**
  126416. * Disposes of the post process
  126417. * @param camera Camera to dispose post process on
  126418. */
  126419. dispose(camera: Camera): void;
  126420. }
  126421. }
  126422. declare module BABYLON {
  126423. /** @hidden */
  126424. export var sharpenPixelShader: {
  126425. name: string;
  126426. shader: string;
  126427. };
  126428. }
  126429. declare module BABYLON {
  126430. /**
  126431. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126432. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126433. */
  126434. export class SharpenPostProcess extends PostProcess {
  126435. /**
  126436. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126437. */
  126438. colorAmount: number;
  126439. /**
  126440. * How much sharpness should be applied (default: 0.3)
  126441. */
  126442. edgeAmount: number;
  126443. /**
  126444. * Creates a new instance ConvolutionPostProcess
  126445. * @param name The name of the effect.
  126446. * @param options The required width/height ratio to downsize to before computing the render pass.
  126447. * @param camera The camera to apply the render pass to.
  126448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126449. * @param engine The engine which the post process will be applied. (default: current engine)
  126450. * @param reusable If the post process can be reused on the same frame. (default: false)
  126451. * @param textureType Type of textures used when performing the post process. (default: 0)
  126452. * @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)
  126453. */
  126454. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126455. }
  126456. }
  126457. declare module BABYLON {
  126458. /**
  126459. * PostProcessRenderPipeline
  126460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126461. */
  126462. export class PostProcessRenderPipeline {
  126463. private engine;
  126464. private _renderEffects;
  126465. private _renderEffectsForIsolatedPass;
  126466. /**
  126467. * List of inspectable custom properties (used by the Inspector)
  126468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126469. */
  126470. inspectableCustomProperties: IInspectable[];
  126471. /**
  126472. * @hidden
  126473. */
  126474. protected _cameras: Camera[];
  126475. /** @hidden */
  126476. _name: string;
  126477. /**
  126478. * Gets pipeline name
  126479. */
  126480. readonly name: string;
  126481. /**
  126482. * Initializes a PostProcessRenderPipeline
  126483. * @param engine engine to add the pipeline to
  126484. * @param name name of the pipeline
  126485. */
  126486. constructor(engine: Engine, name: string);
  126487. /**
  126488. * Gets the class name
  126489. * @returns "PostProcessRenderPipeline"
  126490. */
  126491. getClassName(): string;
  126492. /**
  126493. * If all the render effects in the pipeline are supported
  126494. */
  126495. readonly isSupported: boolean;
  126496. /**
  126497. * Adds an effect to the pipeline
  126498. * @param renderEffect the effect to add
  126499. */
  126500. addEffect(renderEffect: PostProcessRenderEffect): void;
  126501. /** @hidden */
  126502. _rebuild(): void;
  126503. /** @hidden */
  126504. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126505. /** @hidden */
  126506. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126507. /** @hidden */
  126508. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126509. /** @hidden */
  126510. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126511. /** @hidden */
  126512. _attachCameras(cameras: Camera, unique: boolean): void;
  126513. /** @hidden */
  126514. _attachCameras(cameras: Camera[], unique: boolean): void;
  126515. /** @hidden */
  126516. _detachCameras(cameras: Camera): void;
  126517. /** @hidden */
  126518. _detachCameras(cameras: Nullable<Camera[]>): void;
  126519. /** @hidden */
  126520. _update(): void;
  126521. /** @hidden */
  126522. _reset(): void;
  126523. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126524. /**
  126525. * Disposes of the pipeline
  126526. */
  126527. dispose(): void;
  126528. }
  126529. }
  126530. declare module BABYLON {
  126531. /**
  126532. * PostProcessRenderPipelineManager class
  126533. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126534. */
  126535. export class PostProcessRenderPipelineManager {
  126536. private _renderPipelines;
  126537. /**
  126538. * Initializes a PostProcessRenderPipelineManager
  126539. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126540. */
  126541. constructor();
  126542. /**
  126543. * Gets the list of supported render pipelines
  126544. */
  126545. readonly supportedPipelines: PostProcessRenderPipeline[];
  126546. /**
  126547. * Adds a pipeline to the manager
  126548. * @param renderPipeline The pipeline to add
  126549. */
  126550. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126551. /**
  126552. * Attaches a camera to the pipeline
  126553. * @param renderPipelineName The name of the pipeline to attach to
  126554. * @param cameras the camera to attach
  126555. * @param unique if the camera can be attached multiple times to the pipeline
  126556. */
  126557. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126558. /**
  126559. * Detaches a camera from the pipeline
  126560. * @param renderPipelineName The name of the pipeline to detach from
  126561. * @param cameras the camera to detach
  126562. */
  126563. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126564. /**
  126565. * Enables an effect by name on a pipeline
  126566. * @param renderPipelineName the name of the pipeline to enable the effect in
  126567. * @param renderEffectName the name of the effect to enable
  126568. * @param cameras the cameras that the effect should be enabled on
  126569. */
  126570. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126571. /**
  126572. * Disables an effect by name on a pipeline
  126573. * @param renderPipelineName the name of the pipeline to disable the effect in
  126574. * @param renderEffectName the name of the effect to disable
  126575. * @param cameras the cameras that the effect should be disabled on
  126576. */
  126577. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126578. /**
  126579. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126580. */
  126581. update(): void;
  126582. /** @hidden */
  126583. _rebuild(): void;
  126584. /**
  126585. * Disposes of the manager and pipelines
  126586. */
  126587. dispose(): void;
  126588. }
  126589. }
  126590. declare module BABYLON {
  126591. interface Scene {
  126592. /** @hidden (Backing field) */
  126593. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126594. /**
  126595. * Gets the postprocess render pipeline manager
  126596. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126597. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126598. */
  126599. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126600. }
  126601. /**
  126602. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126603. */
  126604. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126605. /**
  126606. * The component name helpfull to identify the component in the list of scene components.
  126607. */
  126608. readonly name: string;
  126609. /**
  126610. * The scene the component belongs to.
  126611. */
  126612. scene: Scene;
  126613. /**
  126614. * Creates a new instance of the component for the given scene
  126615. * @param scene Defines the scene to register the component in
  126616. */
  126617. constructor(scene: Scene);
  126618. /**
  126619. * Registers the component in a given scene
  126620. */
  126621. register(): void;
  126622. /**
  126623. * Rebuilds the elements related to this component in case of
  126624. * context lost for instance.
  126625. */
  126626. rebuild(): void;
  126627. /**
  126628. * Disposes the component and the associated ressources
  126629. */
  126630. dispose(): void;
  126631. private _gatherRenderTargets;
  126632. }
  126633. }
  126634. declare module BABYLON {
  126635. /**
  126636. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126637. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126638. */
  126639. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126640. private _scene;
  126641. private _camerasToBeAttached;
  126642. /**
  126643. * ID of the sharpen post process,
  126644. */
  126645. private readonly SharpenPostProcessId;
  126646. /**
  126647. * @ignore
  126648. * ID of the image processing post process;
  126649. */
  126650. readonly ImageProcessingPostProcessId: string;
  126651. /**
  126652. * @ignore
  126653. * ID of the Fast Approximate Anti-Aliasing post process;
  126654. */
  126655. readonly FxaaPostProcessId: string;
  126656. /**
  126657. * ID of the chromatic aberration post process,
  126658. */
  126659. private readonly ChromaticAberrationPostProcessId;
  126660. /**
  126661. * ID of the grain post process
  126662. */
  126663. private readonly GrainPostProcessId;
  126664. /**
  126665. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126666. */
  126667. sharpen: SharpenPostProcess;
  126668. private _sharpenEffect;
  126669. private bloom;
  126670. /**
  126671. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126672. */
  126673. depthOfField: DepthOfFieldEffect;
  126674. /**
  126675. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126676. */
  126677. fxaa: FxaaPostProcess;
  126678. /**
  126679. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126680. */
  126681. imageProcessing: ImageProcessingPostProcess;
  126682. /**
  126683. * Chromatic aberration post process which will shift rgb colors in the image
  126684. */
  126685. chromaticAberration: ChromaticAberrationPostProcess;
  126686. private _chromaticAberrationEffect;
  126687. /**
  126688. * Grain post process which add noise to the image
  126689. */
  126690. grain: GrainPostProcess;
  126691. private _grainEffect;
  126692. /**
  126693. * Glow post process which adds a glow to emissive areas of the image
  126694. */
  126695. private _glowLayer;
  126696. /**
  126697. * Animations which can be used to tweak settings over a period of time
  126698. */
  126699. animations: Animation[];
  126700. private _imageProcessingConfigurationObserver;
  126701. private _sharpenEnabled;
  126702. private _bloomEnabled;
  126703. private _depthOfFieldEnabled;
  126704. private _depthOfFieldBlurLevel;
  126705. private _fxaaEnabled;
  126706. private _imageProcessingEnabled;
  126707. private _defaultPipelineTextureType;
  126708. private _bloomScale;
  126709. private _chromaticAberrationEnabled;
  126710. private _grainEnabled;
  126711. private _buildAllowed;
  126712. /**
  126713. * Gets active scene
  126714. */
  126715. readonly scene: Scene;
  126716. /**
  126717. * Enable or disable the sharpen process from the pipeline
  126718. */
  126719. sharpenEnabled: boolean;
  126720. private _resizeObserver;
  126721. private _hardwareScaleLevel;
  126722. private _bloomKernel;
  126723. /**
  126724. * Specifies the size of the bloom blur kernel, relative to the final output size
  126725. */
  126726. bloomKernel: number;
  126727. /**
  126728. * Specifies the weight of the bloom in the final rendering
  126729. */
  126730. private _bloomWeight;
  126731. /**
  126732. * Specifies the luma threshold for the area that will be blurred by the bloom
  126733. */
  126734. private _bloomThreshold;
  126735. private _hdr;
  126736. /**
  126737. * The strength of the bloom.
  126738. */
  126739. bloomWeight: number;
  126740. /**
  126741. * The strength of the bloom.
  126742. */
  126743. bloomThreshold: number;
  126744. /**
  126745. * The scale of the bloom, lower value will provide better performance.
  126746. */
  126747. bloomScale: number;
  126748. /**
  126749. * Enable or disable the bloom from the pipeline
  126750. */
  126751. bloomEnabled: boolean;
  126752. private _rebuildBloom;
  126753. /**
  126754. * If the depth of field is enabled.
  126755. */
  126756. depthOfFieldEnabled: boolean;
  126757. /**
  126758. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126759. */
  126760. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126761. /**
  126762. * If the anti aliasing is enabled.
  126763. */
  126764. fxaaEnabled: boolean;
  126765. private _samples;
  126766. /**
  126767. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126768. */
  126769. samples: number;
  126770. /**
  126771. * If image processing is enabled.
  126772. */
  126773. imageProcessingEnabled: boolean;
  126774. /**
  126775. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126776. */
  126777. glowLayerEnabled: boolean;
  126778. /**
  126779. * Gets the glow layer (or null if not defined)
  126780. */
  126781. readonly glowLayer: Nullable<GlowLayer>;
  126782. /**
  126783. * Enable or disable the chromaticAberration process from the pipeline
  126784. */
  126785. chromaticAberrationEnabled: boolean;
  126786. /**
  126787. * Enable or disable the grain process from the pipeline
  126788. */
  126789. grainEnabled: boolean;
  126790. /**
  126791. * @constructor
  126792. * @param name - The rendering pipeline name (default: "")
  126793. * @param hdr - If high dynamic range textures should be used (default: true)
  126794. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126795. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126796. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126797. */
  126798. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126799. /**
  126800. * Get the class name
  126801. * @returns "DefaultRenderingPipeline"
  126802. */
  126803. getClassName(): string;
  126804. /**
  126805. * Force the compilation of the entire pipeline.
  126806. */
  126807. prepare(): void;
  126808. private _hasCleared;
  126809. private _prevPostProcess;
  126810. private _prevPrevPostProcess;
  126811. private _setAutoClearAndTextureSharing;
  126812. private _depthOfFieldSceneObserver;
  126813. private _buildPipeline;
  126814. private _disposePostProcesses;
  126815. /**
  126816. * Adds a camera to the pipeline
  126817. * @param camera the camera to be added
  126818. */
  126819. addCamera(camera: Camera): void;
  126820. /**
  126821. * Removes a camera from the pipeline
  126822. * @param camera the camera to remove
  126823. */
  126824. removeCamera(camera: Camera): void;
  126825. /**
  126826. * Dispose of the pipeline and stop all post processes
  126827. */
  126828. dispose(): void;
  126829. /**
  126830. * Serialize the rendering pipeline (Used when exporting)
  126831. * @returns the serialized object
  126832. */
  126833. serialize(): any;
  126834. /**
  126835. * Parse the serialized pipeline
  126836. * @param source Source pipeline.
  126837. * @param scene The scene to load the pipeline to.
  126838. * @param rootUrl The URL of the serialized pipeline.
  126839. * @returns An instantiated pipeline from the serialized object.
  126840. */
  126841. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126842. }
  126843. }
  126844. declare module BABYLON {
  126845. /** @hidden */
  126846. export var lensHighlightsPixelShader: {
  126847. name: string;
  126848. shader: string;
  126849. };
  126850. }
  126851. declare module BABYLON {
  126852. /** @hidden */
  126853. export var depthOfFieldPixelShader: {
  126854. name: string;
  126855. shader: string;
  126856. };
  126857. }
  126858. declare module BABYLON {
  126859. /**
  126860. * BABYLON.JS Chromatic Aberration GLSL Shader
  126861. * Author: Olivier Guyot
  126862. * Separates very slightly R, G and B colors on the edges of the screen
  126863. * Inspired by Francois Tarlier & Martins Upitis
  126864. */
  126865. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  126866. /**
  126867. * @ignore
  126868. * The chromatic aberration PostProcess id in the pipeline
  126869. */
  126870. LensChromaticAberrationEffect: string;
  126871. /**
  126872. * @ignore
  126873. * The highlights enhancing PostProcess id in the pipeline
  126874. */
  126875. HighlightsEnhancingEffect: string;
  126876. /**
  126877. * @ignore
  126878. * The depth-of-field PostProcess id in the pipeline
  126879. */
  126880. LensDepthOfFieldEffect: string;
  126881. private _scene;
  126882. private _depthTexture;
  126883. private _grainTexture;
  126884. private _chromaticAberrationPostProcess;
  126885. private _highlightsPostProcess;
  126886. private _depthOfFieldPostProcess;
  126887. private _edgeBlur;
  126888. private _grainAmount;
  126889. private _chromaticAberration;
  126890. private _distortion;
  126891. private _highlightsGain;
  126892. private _highlightsThreshold;
  126893. private _dofDistance;
  126894. private _dofAperture;
  126895. private _dofDarken;
  126896. private _dofPentagon;
  126897. private _blurNoise;
  126898. /**
  126899. * @constructor
  126900. *
  126901. * Effect parameters are as follow:
  126902. * {
  126903. * chromatic_aberration: number; // from 0 to x (1 for realism)
  126904. * edge_blur: number; // from 0 to x (1 for realism)
  126905. * distortion: number; // from 0 to x (1 for realism)
  126906. * grain_amount: number; // from 0 to 1
  126907. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  126908. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  126909. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  126910. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  126911. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  126912. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  126913. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  126914. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  126915. * }
  126916. * Note: if an effect parameter is unset, effect is disabled
  126917. *
  126918. * @param name The rendering pipeline name
  126919. * @param parameters - An object containing all parameters (see above)
  126920. * @param scene The scene linked to this pipeline
  126921. * @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)
  126922. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126923. */
  126924. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  126925. /**
  126926. * Get the class name
  126927. * @returns "LensRenderingPipeline"
  126928. */
  126929. getClassName(): string;
  126930. /**
  126931. * Gets associated scene
  126932. */
  126933. readonly scene: Scene;
  126934. /**
  126935. * Gets or sets the edge blur
  126936. */
  126937. edgeBlur: number;
  126938. /**
  126939. * Gets or sets the grain amount
  126940. */
  126941. grainAmount: number;
  126942. /**
  126943. * Gets or sets the chromatic aberration amount
  126944. */
  126945. chromaticAberration: number;
  126946. /**
  126947. * Gets or sets the depth of field aperture
  126948. */
  126949. dofAperture: number;
  126950. /**
  126951. * Gets or sets the edge distortion
  126952. */
  126953. edgeDistortion: number;
  126954. /**
  126955. * Gets or sets the depth of field distortion
  126956. */
  126957. dofDistortion: number;
  126958. /**
  126959. * Gets or sets the darken out of focus amount
  126960. */
  126961. darkenOutOfFocus: number;
  126962. /**
  126963. * Gets or sets a boolean indicating if blur noise is enabled
  126964. */
  126965. blurNoise: boolean;
  126966. /**
  126967. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  126968. */
  126969. pentagonBokeh: boolean;
  126970. /**
  126971. * Gets or sets the highlight grain amount
  126972. */
  126973. highlightsGain: number;
  126974. /**
  126975. * Gets or sets the highlight threshold
  126976. */
  126977. highlightsThreshold: number;
  126978. /**
  126979. * Sets the amount of blur at the edges
  126980. * @param amount blur amount
  126981. */
  126982. setEdgeBlur(amount: number): void;
  126983. /**
  126984. * Sets edge blur to 0
  126985. */
  126986. disableEdgeBlur(): void;
  126987. /**
  126988. * Sets the amout of grain
  126989. * @param amount Amount of grain
  126990. */
  126991. setGrainAmount(amount: number): void;
  126992. /**
  126993. * Set grain amount to 0
  126994. */
  126995. disableGrain(): void;
  126996. /**
  126997. * Sets the chromatic aberration amount
  126998. * @param amount amount of chromatic aberration
  126999. */
  127000. setChromaticAberration(amount: number): void;
  127001. /**
  127002. * Sets chromatic aberration amount to 0
  127003. */
  127004. disableChromaticAberration(): void;
  127005. /**
  127006. * Sets the EdgeDistortion amount
  127007. * @param amount amount of EdgeDistortion
  127008. */
  127009. setEdgeDistortion(amount: number): void;
  127010. /**
  127011. * Sets edge distortion to 0
  127012. */
  127013. disableEdgeDistortion(): void;
  127014. /**
  127015. * Sets the FocusDistance amount
  127016. * @param amount amount of FocusDistance
  127017. */
  127018. setFocusDistance(amount: number): void;
  127019. /**
  127020. * Disables depth of field
  127021. */
  127022. disableDepthOfField(): void;
  127023. /**
  127024. * Sets the Aperture amount
  127025. * @param amount amount of Aperture
  127026. */
  127027. setAperture(amount: number): void;
  127028. /**
  127029. * Sets the DarkenOutOfFocus amount
  127030. * @param amount amount of DarkenOutOfFocus
  127031. */
  127032. setDarkenOutOfFocus(amount: number): void;
  127033. private _pentagonBokehIsEnabled;
  127034. /**
  127035. * Creates a pentagon bokeh effect
  127036. */
  127037. enablePentagonBokeh(): void;
  127038. /**
  127039. * Disables the pentagon bokeh effect
  127040. */
  127041. disablePentagonBokeh(): void;
  127042. /**
  127043. * Enables noise blur
  127044. */
  127045. enableNoiseBlur(): void;
  127046. /**
  127047. * Disables noise blur
  127048. */
  127049. disableNoiseBlur(): void;
  127050. /**
  127051. * Sets the HighlightsGain amount
  127052. * @param amount amount of HighlightsGain
  127053. */
  127054. setHighlightsGain(amount: number): void;
  127055. /**
  127056. * Sets the HighlightsThreshold amount
  127057. * @param amount amount of HighlightsThreshold
  127058. */
  127059. setHighlightsThreshold(amount: number): void;
  127060. /**
  127061. * Disables highlights
  127062. */
  127063. disableHighlights(): void;
  127064. /**
  127065. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127066. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127067. */
  127068. dispose(disableDepthRender?: boolean): void;
  127069. private _createChromaticAberrationPostProcess;
  127070. private _createHighlightsPostProcess;
  127071. private _createDepthOfFieldPostProcess;
  127072. private _createGrainTexture;
  127073. }
  127074. }
  127075. declare module BABYLON {
  127076. /** @hidden */
  127077. export var ssao2PixelShader: {
  127078. name: string;
  127079. shader: string;
  127080. };
  127081. }
  127082. declare module BABYLON {
  127083. /** @hidden */
  127084. export var ssaoCombinePixelShader: {
  127085. name: string;
  127086. shader: string;
  127087. };
  127088. }
  127089. declare module BABYLON {
  127090. /**
  127091. * Render pipeline to produce ssao effect
  127092. */
  127093. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127094. /**
  127095. * @ignore
  127096. * The PassPostProcess id in the pipeline that contains the original scene color
  127097. */
  127098. SSAOOriginalSceneColorEffect: string;
  127099. /**
  127100. * @ignore
  127101. * The SSAO PostProcess id in the pipeline
  127102. */
  127103. SSAORenderEffect: string;
  127104. /**
  127105. * @ignore
  127106. * The horizontal blur PostProcess id in the pipeline
  127107. */
  127108. SSAOBlurHRenderEffect: string;
  127109. /**
  127110. * @ignore
  127111. * The vertical blur PostProcess id in the pipeline
  127112. */
  127113. SSAOBlurVRenderEffect: string;
  127114. /**
  127115. * @ignore
  127116. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127117. */
  127118. SSAOCombineRenderEffect: string;
  127119. /**
  127120. * The output strength of the SSAO post-process. Default value is 1.0.
  127121. */
  127122. totalStrength: number;
  127123. /**
  127124. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127125. */
  127126. maxZ: number;
  127127. /**
  127128. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127129. */
  127130. minZAspect: number;
  127131. private _samples;
  127132. /**
  127133. * Number of samples used for the SSAO calculations. Default value is 8
  127134. */
  127135. samples: number;
  127136. private _textureSamples;
  127137. /**
  127138. * Number of samples to use for antialiasing
  127139. */
  127140. textureSamples: number;
  127141. /**
  127142. * Ratio object used for SSAO ratio and blur ratio
  127143. */
  127144. private _ratio;
  127145. /**
  127146. * Dynamically generated sphere sampler.
  127147. */
  127148. private _sampleSphere;
  127149. /**
  127150. * Blur filter offsets
  127151. */
  127152. private _samplerOffsets;
  127153. private _expensiveBlur;
  127154. /**
  127155. * If bilateral blur should be used
  127156. */
  127157. expensiveBlur: boolean;
  127158. /**
  127159. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127160. */
  127161. radius: number;
  127162. /**
  127163. * The base color of the SSAO post-process
  127164. * The final result is "base + ssao" between [0, 1]
  127165. */
  127166. base: number;
  127167. /**
  127168. * Support test.
  127169. */
  127170. static readonly IsSupported: boolean;
  127171. private _scene;
  127172. private _depthTexture;
  127173. private _normalTexture;
  127174. private _randomTexture;
  127175. private _originalColorPostProcess;
  127176. private _ssaoPostProcess;
  127177. private _blurHPostProcess;
  127178. private _blurVPostProcess;
  127179. private _ssaoCombinePostProcess;
  127180. private _firstUpdate;
  127181. /**
  127182. * Gets active scene
  127183. */
  127184. readonly scene: Scene;
  127185. /**
  127186. * @constructor
  127187. * @param name The rendering pipeline name
  127188. * @param scene The scene linked to this pipeline
  127189. * @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 }
  127190. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127191. */
  127192. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127193. /**
  127194. * Get the class name
  127195. * @returns "SSAO2RenderingPipeline"
  127196. */
  127197. getClassName(): string;
  127198. /**
  127199. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127200. */
  127201. dispose(disableGeometryBufferRenderer?: boolean): void;
  127202. private _createBlurPostProcess;
  127203. /** @hidden */
  127204. _rebuild(): void;
  127205. private _bits;
  127206. private _radicalInverse_VdC;
  127207. private _hammersley;
  127208. private _hemisphereSample_uniform;
  127209. private _generateHemisphere;
  127210. private _createSSAOPostProcess;
  127211. private _createSSAOCombinePostProcess;
  127212. private _createRandomTexture;
  127213. /**
  127214. * Serialize the rendering pipeline (Used when exporting)
  127215. * @returns the serialized object
  127216. */
  127217. serialize(): any;
  127218. /**
  127219. * Parse the serialized pipeline
  127220. * @param source Source pipeline.
  127221. * @param scene The scene to load the pipeline to.
  127222. * @param rootUrl The URL of the serialized pipeline.
  127223. * @returns An instantiated pipeline from the serialized object.
  127224. */
  127225. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127226. }
  127227. }
  127228. declare module BABYLON {
  127229. /** @hidden */
  127230. export var ssaoPixelShader: {
  127231. name: string;
  127232. shader: string;
  127233. };
  127234. }
  127235. declare module BABYLON {
  127236. /**
  127237. * Render pipeline to produce ssao effect
  127238. */
  127239. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127240. /**
  127241. * @ignore
  127242. * The PassPostProcess id in the pipeline that contains the original scene color
  127243. */
  127244. SSAOOriginalSceneColorEffect: string;
  127245. /**
  127246. * @ignore
  127247. * The SSAO PostProcess id in the pipeline
  127248. */
  127249. SSAORenderEffect: string;
  127250. /**
  127251. * @ignore
  127252. * The horizontal blur PostProcess id in the pipeline
  127253. */
  127254. SSAOBlurHRenderEffect: string;
  127255. /**
  127256. * @ignore
  127257. * The vertical blur PostProcess id in the pipeline
  127258. */
  127259. SSAOBlurVRenderEffect: string;
  127260. /**
  127261. * @ignore
  127262. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127263. */
  127264. SSAOCombineRenderEffect: string;
  127265. /**
  127266. * The output strength of the SSAO post-process. Default value is 1.0.
  127267. */
  127268. totalStrength: number;
  127269. /**
  127270. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127271. */
  127272. radius: number;
  127273. /**
  127274. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127275. * Must not be equal to fallOff and superior to fallOff.
  127276. * Default value is 0.0075
  127277. */
  127278. area: number;
  127279. /**
  127280. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127281. * Must not be equal to area and inferior to area.
  127282. * Default value is 0.000001
  127283. */
  127284. fallOff: number;
  127285. /**
  127286. * The base color of the SSAO post-process
  127287. * The final result is "base + ssao" between [0, 1]
  127288. */
  127289. base: number;
  127290. private _scene;
  127291. private _depthTexture;
  127292. private _randomTexture;
  127293. private _originalColorPostProcess;
  127294. private _ssaoPostProcess;
  127295. private _blurHPostProcess;
  127296. private _blurVPostProcess;
  127297. private _ssaoCombinePostProcess;
  127298. private _firstUpdate;
  127299. /**
  127300. * Gets active scene
  127301. */
  127302. readonly scene: Scene;
  127303. /**
  127304. * @constructor
  127305. * @param name - The rendering pipeline name
  127306. * @param scene - The scene linked to this pipeline
  127307. * @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 }
  127308. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127309. */
  127310. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127311. /**
  127312. * Get the class name
  127313. * @returns "SSAORenderingPipeline"
  127314. */
  127315. getClassName(): string;
  127316. /**
  127317. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127318. */
  127319. dispose(disableDepthRender?: boolean): void;
  127320. private _createBlurPostProcess;
  127321. /** @hidden */
  127322. _rebuild(): void;
  127323. private _createSSAOPostProcess;
  127324. private _createSSAOCombinePostProcess;
  127325. private _createRandomTexture;
  127326. }
  127327. }
  127328. declare module BABYLON {
  127329. /** @hidden */
  127330. export var standardPixelShader: {
  127331. name: string;
  127332. shader: string;
  127333. };
  127334. }
  127335. declare module BABYLON {
  127336. /**
  127337. * Standard rendering pipeline
  127338. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127339. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127340. */
  127341. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127342. /**
  127343. * Public members
  127344. */
  127345. /**
  127346. * Post-process which contains the original scene color before the pipeline applies all the effects
  127347. */
  127348. originalPostProcess: Nullable<PostProcess>;
  127349. /**
  127350. * Post-process used to down scale an image x4
  127351. */
  127352. downSampleX4PostProcess: Nullable<PostProcess>;
  127353. /**
  127354. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127355. */
  127356. brightPassPostProcess: Nullable<PostProcess>;
  127357. /**
  127358. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127359. */
  127360. blurHPostProcesses: PostProcess[];
  127361. /**
  127362. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127363. */
  127364. blurVPostProcesses: PostProcess[];
  127365. /**
  127366. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127367. */
  127368. textureAdderPostProcess: Nullable<PostProcess>;
  127369. /**
  127370. * Post-process used to create volumetric lighting effect
  127371. */
  127372. volumetricLightPostProcess: Nullable<PostProcess>;
  127373. /**
  127374. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127375. */
  127376. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127377. /**
  127378. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127379. */
  127380. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127381. /**
  127382. * Post-process used to merge the volumetric light effect and the real scene color
  127383. */
  127384. volumetricLightMergePostProces: Nullable<PostProcess>;
  127385. /**
  127386. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127387. */
  127388. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127389. /**
  127390. * Base post-process used to calculate the average luminance of the final image for HDR
  127391. */
  127392. luminancePostProcess: Nullable<PostProcess>;
  127393. /**
  127394. * Post-processes used to create down sample post-processes in order to get
  127395. * the average luminance of the final image for HDR
  127396. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127397. */
  127398. luminanceDownSamplePostProcesses: PostProcess[];
  127399. /**
  127400. * Post-process used to create a HDR effect (light adaptation)
  127401. */
  127402. hdrPostProcess: Nullable<PostProcess>;
  127403. /**
  127404. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127405. */
  127406. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127407. /**
  127408. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127409. */
  127410. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127411. /**
  127412. * Post-process used to merge the final HDR post-process and the real scene color
  127413. */
  127414. hdrFinalPostProcess: Nullable<PostProcess>;
  127415. /**
  127416. * Post-process used to create a lens flare effect
  127417. */
  127418. lensFlarePostProcess: Nullable<PostProcess>;
  127419. /**
  127420. * Post-process that merges the result of the lens flare post-process and the real scene color
  127421. */
  127422. lensFlareComposePostProcess: Nullable<PostProcess>;
  127423. /**
  127424. * Post-process used to create a motion blur effect
  127425. */
  127426. motionBlurPostProcess: Nullable<PostProcess>;
  127427. /**
  127428. * Post-process used to create a depth of field effect
  127429. */
  127430. depthOfFieldPostProcess: Nullable<PostProcess>;
  127431. /**
  127432. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127433. */
  127434. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127435. /**
  127436. * Represents the brightness threshold in order to configure the illuminated surfaces
  127437. */
  127438. brightThreshold: number;
  127439. /**
  127440. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127441. */
  127442. blurWidth: number;
  127443. /**
  127444. * Sets if the blur for highlighted surfaces must be only horizontal
  127445. */
  127446. horizontalBlur: boolean;
  127447. /**
  127448. * Gets the overall exposure used by the pipeline
  127449. */
  127450. /**
  127451. * Sets the overall exposure used by the pipeline
  127452. */
  127453. exposure: number;
  127454. /**
  127455. * Texture used typically to simulate "dirty" on camera lens
  127456. */
  127457. lensTexture: Nullable<Texture>;
  127458. /**
  127459. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127460. */
  127461. volumetricLightCoefficient: number;
  127462. /**
  127463. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127464. */
  127465. volumetricLightPower: number;
  127466. /**
  127467. * Used the set the blur intensity to smooth the volumetric lights
  127468. */
  127469. volumetricLightBlurScale: number;
  127470. /**
  127471. * Light (spot or directional) used to generate the volumetric lights rays
  127472. * The source light must have a shadow generate so the pipeline can get its
  127473. * depth map
  127474. */
  127475. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127476. /**
  127477. * For eye adaptation, represents the minimum luminance the eye can see
  127478. */
  127479. hdrMinimumLuminance: number;
  127480. /**
  127481. * For eye adaptation, represents the decrease luminance speed
  127482. */
  127483. hdrDecreaseRate: number;
  127484. /**
  127485. * For eye adaptation, represents the increase luminance speed
  127486. */
  127487. hdrIncreaseRate: number;
  127488. /**
  127489. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127490. */
  127491. /**
  127492. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127493. */
  127494. hdrAutoExposure: boolean;
  127495. /**
  127496. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127497. */
  127498. lensColorTexture: Nullable<Texture>;
  127499. /**
  127500. * The overall strengh for the lens flare effect
  127501. */
  127502. lensFlareStrength: number;
  127503. /**
  127504. * Dispersion coefficient for lens flare ghosts
  127505. */
  127506. lensFlareGhostDispersal: number;
  127507. /**
  127508. * Main lens flare halo width
  127509. */
  127510. lensFlareHaloWidth: number;
  127511. /**
  127512. * Based on the lens distortion effect, defines how much the lens flare result
  127513. * is distorted
  127514. */
  127515. lensFlareDistortionStrength: number;
  127516. /**
  127517. * Configures the blur intensity used for for lens flare (halo)
  127518. */
  127519. lensFlareBlurWidth: number;
  127520. /**
  127521. * Lens star texture must be used to simulate rays on the flares and is available
  127522. * in the documentation
  127523. */
  127524. lensStarTexture: Nullable<Texture>;
  127525. /**
  127526. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127527. * flare effect by taking account of the dirt texture
  127528. */
  127529. lensFlareDirtTexture: Nullable<Texture>;
  127530. /**
  127531. * Represents the focal length for the depth of field effect
  127532. */
  127533. depthOfFieldDistance: number;
  127534. /**
  127535. * Represents the blur intensity for the blurred part of the depth of field effect
  127536. */
  127537. depthOfFieldBlurWidth: number;
  127538. /**
  127539. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127540. */
  127541. /**
  127542. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127543. */
  127544. motionStrength: number;
  127545. /**
  127546. * Gets wether or not the motion blur post-process is object based or screen based.
  127547. */
  127548. /**
  127549. * Sets wether or not the motion blur post-process should be object based or screen based
  127550. */
  127551. objectBasedMotionBlur: boolean;
  127552. /**
  127553. * List of animations for the pipeline (IAnimatable implementation)
  127554. */
  127555. animations: Animation[];
  127556. /**
  127557. * Private members
  127558. */
  127559. private _scene;
  127560. private _currentDepthOfFieldSource;
  127561. private _basePostProcess;
  127562. private _fixedExposure;
  127563. private _currentExposure;
  127564. private _hdrAutoExposure;
  127565. private _hdrCurrentLuminance;
  127566. private _motionStrength;
  127567. private _isObjectBasedMotionBlur;
  127568. private _floatTextureType;
  127569. private _camerasToBeAttached;
  127570. private _ratio;
  127571. private _bloomEnabled;
  127572. private _depthOfFieldEnabled;
  127573. private _vlsEnabled;
  127574. private _lensFlareEnabled;
  127575. private _hdrEnabled;
  127576. private _motionBlurEnabled;
  127577. private _fxaaEnabled;
  127578. private _motionBlurSamples;
  127579. private _volumetricLightStepsCount;
  127580. private _samples;
  127581. /**
  127582. * @ignore
  127583. * Specifies if the bloom pipeline is enabled
  127584. */
  127585. BloomEnabled: boolean;
  127586. /**
  127587. * @ignore
  127588. * Specifies if the depth of field pipeline is enabed
  127589. */
  127590. DepthOfFieldEnabled: boolean;
  127591. /**
  127592. * @ignore
  127593. * Specifies if the lens flare pipeline is enabed
  127594. */
  127595. LensFlareEnabled: boolean;
  127596. /**
  127597. * @ignore
  127598. * Specifies if the HDR pipeline is enabled
  127599. */
  127600. HDREnabled: boolean;
  127601. /**
  127602. * @ignore
  127603. * Specifies if the volumetric lights scattering effect is enabled
  127604. */
  127605. VLSEnabled: boolean;
  127606. /**
  127607. * @ignore
  127608. * Specifies if the motion blur effect is enabled
  127609. */
  127610. MotionBlurEnabled: boolean;
  127611. /**
  127612. * Specifies if anti-aliasing is enabled
  127613. */
  127614. fxaaEnabled: boolean;
  127615. /**
  127616. * Specifies the number of steps used to calculate the volumetric lights
  127617. * Typically in interval [50, 200]
  127618. */
  127619. volumetricLightStepsCount: number;
  127620. /**
  127621. * Specifies the number of samples used for the motion blur effect
  127622. * Typically in interval [16, 64]
  127623. */
  127624. motionBlurSamples: number;
  127625. /**
  127626. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127627. */
  127628. samples: number;
  127629. /**
  127630. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127631. * @constructor
  127632. * @param name The rendering pipeline name
  127633. * @param scene The scene linked to this pipeline
  127634. * @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)
  127635. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127636. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127637. */
  127638. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127639. private _buildPipeline;
  127640. private _createDownSampleX4PostProcess;
  127641. private _createBrightPassPostProcess;
  127642. private _createBlurPostProcesses;
  127643. private _createTextureAdderPostProcess;
  127644. private _createVolumetricLightPostProcess;
  127645. private _createLuminancePostProcesses;
  127646. private _createHdrPostProcess;
  127647. private _createLensFlarePostProcess;
  127648. private _createDepthOfFieldPostProcess;
  127649. private _createMotionBlurPostProcess;
  127650. private _getDepthTexture;
  127651. private _disposePostProcesses;
  127652. /**
  127653. * Dispose of the pipeline and stop all post processes
  127654. */
  127655. dispose(): void;
  127656. /**
  127657. * Serialize the rendering pipeline (Used when exporting)
  127658. * @returns the serialized object
  127659. */
  127660. serialize(): any;
  127661. /**
  127662. * Parse the serialized pipeline
  127663. * @param source Source pipeline.
  127664. * @param scene The scene to load the pipeline to.
  127665. * @param rootUrl The URL of the serialized pipeline.
  127666. * @returns An instantiated pipeline from the serialized object.
  127667. */
  127668. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127669. /**
  127670. * Luminance steps
  127671. */
  127672. static LuminanceSteps: number;
  127673. }
  127674. }
  127675. declare module BABYLON {
  127676. /** @hidden */
  127677. export var tonemapPixelShader: {
  127678. name: string;
  127679. shader: string;
  127680. };
  127681. }
  127682. declare module BABYLON {
  127683. /** Defines operator used for tonemapping */
  127684. export enum TonemappingOperator {
  127685. /** Hable */
  127686. Hable = 0,
  127687. /** Reinhard */
  127688. Reinhard = 1,
  127689. /** HejiDawson */
  127690. HejiDawson = 2,
  127691. /** Photographic */
  127692. Photographic = 3
  127693. }
  127694. /**
  127695. * Defines a post process to apply tone mapping
  127696. */
  127697. export class TonemapPostProcess extends PostProcess {
  127698. private _operator;
  127699. /** Defines the required exposure adjustement */
  127700. exposureAdjustment: number;
  127701. /**
  127702. * Creates a new TonemapPostProcess
  127703. * @param name defines the name of the postprocess
  127704. * @param _operator defines the operator to use
  127705. * @param exposureAdjustment defines the required exposure adjustement
  127706. * @param camera defines the camera to use (can be null)
  127707. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127708. * @param engine defines the hosting engine (can be ignore if camera is set)
  127709. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127710. */
  127711. constructor(name: string, _operator: TonemappingOperator,
  127712. /** Defines the required exposure adjustement */
  127713. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127714. }
  127715. }
  127716. declare module BABYLON {
  127717. /** @hidden */
  127718. export var depthVertexShader: {
  127719. name: string;
  127720. shader: string;
  127721. };
  127722. }
  127723. declare module BABYLON {
  127724. /** @hidden */
  127725. export var volumetricLightScatteringPixelShader: {
  127726. name: string;
  127727. shader: string;
  127728. };
  127729. }
  127730. declare module BABYLON {
  127731. /** @hidden */
  127732. export var volumetricLightScatteringPassVertexShader: {
  127733. name: string;
  127734. shader: string;
  127735. };
  127736. }
  127737. declare module BABYLON {
  127738. /** @hidden */
  127739. export var volumetricLightScatteringPassPixelShader: {
  127740. name: string;
  127741. shader: string;
  127742. };
  127743. }
  127744. declare module BABYLON {
  127745. /**
  127746. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127747. */
  127748. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127749. private _volumetricLightScatteringPass;
  127750. private _volumetricLightScatteringRTT;
  127751. private _viewPort;
  127752. private _screenCoordinates;
  127753. private _cachedDefines;
  127754. /**
  127755. * If not undefined, the mesh position is computed from the attached node position
  127756. */
  127757. attachedNode: {
  127758. position: Vector3;
  127759. };
  127760. /**
  127761. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127762. */
  127763. customMeshPosition: Vector3;
  127764. /**
  127765. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127766. */
  127767. useCustomMeshPosition: boolean;
  127768. /**
  127769. * If the post-process should inverse the light scattering direction
  127770. */
  127771. invert: boolean;
  127772. /**
  127773. * The internal mesh used by the post-process
  127774. */
  127775. mesh: Mesh;
  127776. /**
  127777. * @hidden
  127778. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127779. */
  127780. useDiffuseColor: boolean;
  127781. /**
  127782. * Array containing the excluded meshes not rendered in the internal pass
  127783. */
  127784. excludedMeshes: AbstractMesh[];
  127785. /**
  127786. * Controls the overall intensity of the post-process
  127787. */
  127788. exposure: number;
  127789. /**
  127790. * Dissipates each sample's contribution in range [0, 1]
  127791. */
  127792. decay: number;
  127793. /**
  127794. * Controls the overall intensity of each sample
  127795. */
  127796. weight: number;
  127797. /**
  127798. * Controls the density of each sample
  127799. */
  127800. density: number;
  127801. /**
  127802. * @constructor
  127803. * @param name The post-process name
  127804. * @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)
  127805. * @param camera The camera that the post-process will be attached to
  127806. * @param mesh The mesh used to create the light scattering
  127807. * @param samples The post-process quality, default 100
  127808. * @param samplingModeThe post-process filtering mode
  127809. * @param engine The babylon engine
  127810. * @param reusable If the post-process is reusable
  127811. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127812. */
  127813. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127814. /**
  127815. * Returns the string "VolumetricLightScatteringPostProcess"
  127816. * @returns "VolumetricLightScatteringPostProcess"
  127817. */
  127818. getClassName(): string;
  127819. private _isReady;
  127820. /**
  127821. * Sets the new light position for light scattering effect
  127822. * @param position The new custom light position
  127823. */
  127824. setCustomMeshPosition(position: Vector3): void;
  127825. /**
  127826. * Returns the light position for light scattering effect
  127827. * @return Vector3 The custom light position
  127828. */
  127829. getCustomMeshPosition(): Vector3;
  127830. /**
  127831. * Disposes the internal assets and detaches the post-process from the camera
  127832. */
  127833. dispose(camera: Camera): void;
  127834. /**
  127835. * Returns the render target texture used by the post-process
  127836. * @return the render target texture used by the post-process
  127837. */
  127838. getPass(): RenderTargetTexture;
  127839. private _meshExcluded;
  127840. private _createPass;
  127841. private _updateMeshScreenCoordinates;
  127842. /**
  127843. * Creates a default mesh for the Volumeric Light Scattering post-process
  127844. * @param name The mesh name
  127845. * @param scene The scene where to create the mesh
  127846. * @return the default mesh
  127847. */
  127848. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127849. }
  127850. }
  127851. declare module BABYLON {
  127852. interface Scene {
  127853. /** @hidden (Backing field) */
  127854. _boundingBoxRenderer: BoundingBoxRenderer;
  127855. /** @hidden (Backing field) */
  127856. _forceShowBoundingBoxes: boolean;
  127857. /**
  127858. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127859. */
  127860. forceShowBoundingBoxes: boolean;
  127861. /**
  127862. * Gets the bounding box renderer associated with the scene
  127863. * @returns a BoundingBoxRenderer
  127864. */
  127865. getBoundingBoxRenderer(): BoundingBoxRenderer;
  127866. }
  127867. interface AbstractMesh {
  127868. /** @hidden (Backing field) */
  127869. _showBoundingBox: boolean;
  127870. /**
  127871. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  127872. */
  127873. showBoundingBox: boolean;
  127874. }
  127875. /**
  127876. * Component responsible of rendering the bounding box of the meshes in a scene.
  127877. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  127878. */
  127879. export class BoundingBoxRenderer implements ISceneComponent {
  127880. /**
  127881. * The component name helpfull to identify the component in the list of scene components.
  127882. */
  127883. readonly name: string;
  127884. /**
  127885. * The scene the component belongs to.
  127886. */
  127887. scene: Scene;
  127888. /**
  127889. * Color of the bounding box lines placed in front of an object
  127890. */
  127891. frontColor: Color3;
  127892. /**
  127893. * Color of the bounding box lines placed behind an object
  127894. */
  127895. backColor: Color3;
  127896. /**
  127897. * Defines if the renderer should show the back lines or not
  127898. */
  127899. showBackLines: boolean;
  127900. /**
  127901. * @hidden
  127902. */
  127903. renderList: SmartArray<BoundingBox>;
  127904. private _colorShader;
  127905. private _vertexBuffers;
  127906. private _indexBuffer;
  127907. private _fillIndexBuffer;
  127908. private _fillIndexData;
  127909. /**
  127910. * Instantiates a new bounding box renderer in a scene.
  127911. * @param scene the scene the renderer renders in
  127912. */
  127913. constructor(scene: Scene);
  127914. /**
  127915. * Registers the component in a given scene
  127916. */
  127917. register(): void;
  127918. private _evaluateSubMesh;
  127919. private _activeMesh;
  127920. private _prepareRessources;
  127921. private _createIndexBuffer;
  127922. /**
  127923. * Rebuilds the elements related to this component in case of
  127924. * context lost for instance.
  127925. */
  127926. rebuild(): void;
  127927. /**
  127928. * @hidden
  127929. */
  127930. reset(): void;
  127931. /**
  127932. * Render the bounding boxes of a specific rendering group
  127933. * @param renderingGroupId defines the rendering group to render
  127934. */
  127935. render(renderingGroupId: number): void;
  127936. /**
  127937. * In case of occlusion queries, we can render the occlusion bounding box through this method
  127938. * @param mesh Define the mesh to render the occlusion bounding box for
  127939. */
  127940. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  127941. /**
  127942. * Dispose and release the resources attached to this renderer.
  127943. */
  127944. dispose(): void;
  127945. }
  127946. }
  127947. declare module BABYLON {
  127948. /** @hidden */
  127949. export var depthPixelShader: {
  127950. name: string;
  127951. shader: string;
  127952. };
  127953. }
  127954. declare module BABYLON {
  127955. /**
  127956. * This represents a depth renderer in Babylon.
  127957. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127958. */
  127959. export class DepthRenderer {
  127960. private _scene;
  127961. private _depthMap;
  127962. private _effect;
  127963. private readonly _storeNonLinearDepth;
  127964. private readonly _clearColor;
  127965. /** Get if the depth renderer is using packed depth or not */
  127966. readonly isPacked: boolean;
  127967. private _cachedDefines;
  127968. private _camera;
  127969. /**
  127970. * Specifiess that the depth renderer will only be used within
  127971. * the camera it is created for.
  127972. * This can help forcing its rendering during the camera processing.
  127973. */
  127974. useOnlyInActiveCamera: boolean;
  127975. /** @hidden */
  127976. static _SceneComponentInitialization: (scene: Scene) => void;
  127977. /**
  127978. * Instantiates a depth renderer
  127979. * @param scene The scene the renderer belongs to
  127980. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127981. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127982. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127983. */
  127984. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127985. /**
  127986. * Creates the depth rendering effect and checks if the effect is ready.
  127987. * @param subMesh The submesh to be used to render the depth map of
  127988. * @param useInstances If multiple world instances should be used
  127989. * @returns if the depth renderer is ready to render the depth map
  127990. */
  127991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127992. /**
  127993. * Gets the texture which the depth map will be written to.
  127994. * @returns The depth map texture
  127995. */
  127996. getDepthMap(): RenderTargetTexture;
  127997. /**
  127998. * Disposes of the depth renderer.
  127999. */
  128000. dispose(): void;
  128001. }
  128002. }
  128003. declare module BABYLON {
  128004. interface Scene {
  128005. /** @hidden (Backing field) */
  128006. _depthRenderer: {
  128007. [id: string]: DepthRenderer;
  128008. };
  128009. /**
  128010. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128011. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128012. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128013. * @returns the created depth renderer
  128014. */
  128015. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128016. /**
  128017. * Disables a depth renderer for a given camera
  128018. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128019. */
  128020. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128021. }
  128022. /**
  128023. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128024. * in several rendering techniques.
  128025. */
  128026. export class DepthRendererSceneComponent implements ISceneComponent {
  128027. /**
  128028. * The component name helpfull to identify the component in the list of scene components.
  128029. */
  128030. readonly name: string;
  128031. /**
  128032. * The scene the component belongs to.
  128033. */
  128034. scene: Scene;
  128035. /**
  128036. * Creates a new instance of the component for the given scene
  128037. * @param scene Defines the scene to register the component in
  128038. */
  128039. constructor(scene: Scene);
  128040. /**
  128041. * Registers the component in a given scene
  128042. */
  128043. register(): void;
  128044. /**
  128045. * Rebuilds the elements related to this component in case of
  128046. * context lost for instance.
  128047. */
  128048. rebuild(): void;
  128049. /**
  128050. * Disposes the component and the associated ressources
  128051. */
  128052. dispose(): void;
  128053. private _gatherRenderTargets;
  128054. private _gatherActiveCameraRenderTargets;
  128055. }
  128056. }
  128057. declare module BABYLON {
  128058. /** @hidden */
  128059. export var outlinePixelShader: {
  128060. name: string;
  128061. shader: string;
  128062. };
  128063. }
  128064. declare module BABYLON {
  128065. /** @hidden */
  128066. export var outlineVertexShader: {
  128067. name: string;
  128068. shader: string;
  128069. };
  128070. }
  128071. declare module BABYLON {
  128072. interface Scene {
  128073. /** @hidden */
  128074. _outlineRenderer: OutlineRenderer;
  128075. /**
  128076. * Gets the outline renderer associated with the scene
  128077. * @returns a OutlineRenderer
  128078. */
  128079. getOutlineRenderer(): OutlineRenderer;
  128080. }
  128081. interface AbstractMesh {
  128082. /** @hidden (Backing field) */
  128083. _renderOutline: boolean;
  128084. /**
  128085. * Gets or sets a boolean indicating if the outline must be rendered as well
  128086. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128087. */
  128088. renderOutline: boolean;
  128089. /** @hidden (Backing field) */
  128090. _renderOverlay: boolean;
  128091. /**
  128092. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128093. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128094. */
  128095. renderOverlay: boolean;
  128096. }
  128097. /**
  128098. * This class is responsible to draw bothe outline/overlay of meshes.
  128099. * It should not be used directly but through the available method on mesh.
  128100. */
  128101. export class OutlineRenderer implements ISceneComponent {
  128102. /**
  128103. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128104. */
  128105. private static _StencilReference;
  128106. /**
  128107. * The name of the component. Each component must have a unique name.
  128108. */
  128109. name: string;
  128110. /**
  128111. * The scene the component belongs to.
  128112. */
  128113. scene: Scene;
  128114. /**
  128115. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128116. */
  128117. zOffset: number;
  128118. private _engine;
  128119. private _effect;
  128120. private _cachedDefines;
  128121. private _savedDepthWrite;
  128122. /**
  128123. * Instantiates a new outline renderer. (There could be only one per scene).
  128124. * @param scene Defines the scene it belongs to
  128125. */
  128126. constructor(scene: Scene);
  128127. /**
  128128. * Register the component to one instance of a scene.
  128129. */
  128130. register(): void;
  128131. /**
  128132. * Rebuilds the elements related to this component in case of
  128133. * context lost for instance.
  128134. */
  128135. rebuild(): void;
  128136. /**
  128137. * Disposes the component and the associated ressources.
  128138. */
  128139. dispose(): void;
  128140. /**
  128141. * Renders the outline in the canvas.
  128142. * @param subMesh Defines the sumesh to render
  128143. * @param batch Defines the batch of meshes in case of instances
  128144. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128145. */
  128146. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128147. /**
  128148. * Returns whether or not the outline renderer is ready for a given submesh.
  128149. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128150. * @param subMesh Defines the submesh to check readyness for
  128151. * @param useInstances Defines wheter wee are trying to render instances or not
  128152. * @returns true if ready otherwise false
  128153. */
  128154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128155. private _beforeRenderingMesh;
  128156. private _afterRenderingMesh;
  128157. }
  128158. }
  128159. declare module BABYLON {
  128160. /**
  128161. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128162. * @see http://doc.babylonjs.com/babylon101/sprites
  128163. */
  128164. export class SpritePackedManager extends SpriteManager {
  128165. /** defines the packed manager's name */
  128166. name: string;
  128167. /**
  128168. * Creates a new sprite manager from a packed sprite sheet
  128169. * @param name defines the manager's name
  128170. * @param imgUrl defines the sprite sheet url
  128171. * @param capacity defines the maximum allowed number of sprites
  128172. * @param scene defines the hosting scene
  128173. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128174. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128175. * @param samplingMode defines the smapling mode to use with spritesheet
  128176. * @param fromPacked set to true; do not alter
  128177. */
  128178. constructor(
  128179. /** defines the packed manager's name */
  128180. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128181. }
  128182. }
  128183. declare module BABYLON {
  128184. /**
  128185. * Defines the list of states available for a task inside a AssetsManager
  128186. */
  128187. export enum AssetTaskState {
  128188. /**
  128189. * Initialization
  128190. */
  128191. INIT = 0,
  128192. /**
  128193. * Running
  128194. */
  128195. RUNNING = 1,
  128196. /**
  128197. * Done
  128198. */
  128199. DONE = 2,
  128200. /**
  128201. * Error
  128202. */
  128203. ERROR = 3
  128204. }
  128205. /**
  128206. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128207. */
  128208. export abstract class AbstractAssetTask {
  128209. /**
  128210. * Task name
  128211. */ name: string;
  128212. /**
  128213. * Callback called when the task is successful
  128214. */
  128215. onSuccess: (task: any) => void;
  128216. /**
  128217. * Callback called when the task is not successful
  128218. */
  128219. onError: (task: any, message?: string, exception?: any) => void;
  128220. /**
  128221. * Creates a new AssetsManager
  128222. * @param name defines the name of the task
  128223. */
  128224. constructor(
  128225. /**
  128226. * Task name
  128227. */ name: string);
  128228. private _isCompleted;
  128229. private _taskState;
  128230. private _errorObject;
  128231. /**
  128232. * Get if the task is completed
  128233. */
  128234. readonly isCompleted: boolean;
  128235. /**
  128236. * Gets the current state of the task
  128237. */
  128238. readonly taskState: AssetTaskState;
  128239. /**
  128240. * Gets the current error object (if task is in error)
  128241. */
  128242. readonly errorObject: {
  128243. message?: string;
  128244. exception?: any;
  128245. };
  128246. /**
  128247. * Internal only
  128248. * @hidden
  128249. */
  128250. _setErrorObject(message?: string, exception?: any): void;
  128251. /**
  128252. * Execute the current task
  128253. * @param scene defines the scene where you want your assets to be loaded
  128254. * @param onSuccess is a callback called when the task is successfully executed
  128255. * @param onError is a callback called if an error occurs
  128256. */
  128257. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128258. /**
  128259. * Execute the current task
  128260. * @param scene defines the scene where you want your assets to be loaded
  128261. * @param onSuccess is a callback called when the task is successfully executed
  128262. * @param onError is a callback called if an error occurs
  128263. */
  128264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128265. /**
  128266. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128267. * This can be used with failed tasks that have the reason for failure fixed.
  128268. */
  128269. reset(): void;
  128270. private onErrorCallback;
  128271. private onDoneCallback;
  128272. }
  128273. /**
  128274. * Define the interface used by progress events raised during assets loading
  128275. */
  128276. export interface IAssetsProgressEvent {
  128277. /**
  128278. * Defines the number of remaining tasks to process
  128279. */
  128280. remainingCount: number;
  128281. /**
  128282. * Defines the total number of tasks
  128283. */
  128284. totalCount: number;
  128285. /**
  128286. * Defines the task that was just processed
  128287. */
  128288. task: AbstractAssetTask;
  128289. }
  128290. /**
  128291. * Class used to share progress information about assets loading
  128292. */
  128293. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128294. /**
  128295. * Defines the number of remaining tasks to process
  128296. */
  128297. remainingCount: number;
  128298. /**
  128299. * Defines the total number of tasks
  128300. */
  128301. totalCount: number;
  128302. /**
  128303. * Defines the task that was just processed
  128304. */
  128305. task: AbstractAssetTask;
  128306. /**
  128307. * Creates a AssetsProgressEvent
  128308. * @param remainingCount defines the number of remaining tasks to process
  128309. * @param totalCount defines the total number of tasks
  128310. * @param task defines the task that was just processed
  128311. */
  128312. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128313. }
  128314. /**
  128315. * Define a task used by AssetsManager to load meshes
  128316. */
  128317. export class MeshAssetTask extends AbstractAssetTask {
  128318. /**
  128319. * Defines the name of the task
  128320. */
  128321. name: string;
  128322. /**
  128323. * Defines the list of mesh's names you want to load
  128324. */
  128325. meshesNames: any;
  128326. /**
  128327. * Defines the root url to use as a base to load your meshes and associated resources
  128328. */
  128329. rootUrl: string;
  128330. /**
  128331. * Defines the filename of the scene to load from
  128332. */
  128333. sceneFilename: string;
  128334. /**
  128335. * Gets the list of loaded meshes
  128336. */
  128337. loadedMeshes: Array<AbstractMesh>;
  128338. /**
  128339. * Gets the list of loaded particle systems
  128340. */
  128341. loadedParticleSystems: Array<IParticleSystem>;
  128342. /**
  128343. * Gets the list of loaded skeletons
  128344. */
  128345. loadedSkeletons: Array<Skeleton>;
  128346. /**
  128347. * Gets the list of loaded animation groups
  128348. */
  128349. loadedAnimationGroups: Array<AnimationGroup>;
  128350. /**
  128351. * Callback called when the task is successful
  128352. */
  128353. onSuccess: (task: MeshAssetTask) => void;
  128354. /**
  128355. * Callback called when the task is successful
  128356. */
  128357. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128358. /**
  128359. * Creates a new MeshAssetTask
  128360. * @param name defines the name of the task
  128361. * @param meshesNames defines the list of mesh's names you want to load
  128362. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128363. * @param sceneFilename defines the filename of the scene to load from
  128364. */
  128365. constructor(
  128366. /**
  128367. * Defines the name of the task
  128368. */
  128369. name: string,
  128370. /**
  128371. * Defines the list of mesh's names you want to load
  128372. */
  128373. meshesNames: any,
  128374. /**
  128375. * Defines the root url to use as a base to load your meshes and associated resources
  128376. */
  128377. rootUrl: string,
  128378. /**
  128379. * Defines the filename of the scene to load from
  128380. */
  128381. sceneFilename: string);
  128382. /**
  128383. * Execute the current task
  128384. * @param scene defines the scene where you want your assets to be loaded
  128385. * @param onSuccess is a callback called when the task is successfully executed
  128386. * @param onError is a callback called if an error occurs
  128387. */
  128388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128389. }
  128390. /**
  128391. * Define a task used by AssetsManager to load text content
  128392. */
  128393. export class TextFileAssetTask extends AbstractAssetTask {
  128394. /**
  128395. * Defines the name of the task
  128396. */
  128397. name: string;
  128398. /**
  128399. * Defines the location of the file to load
  128400. */
  128401. url: string;
  128402. /**
  128403. * Gets the loaded text string
  128404. */
  128405. text: string;
  128406. /**
  128407. * Callback called when the task is successful
  128408. */
  128409. onSuccess: (task: TextFileAssetTask) => void;
  128410. /**
  128411. * Callback called when the task is successful
  128412. */
  128413. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128414. /**
  128415. * Creates a new TextFileAssetTask object
  128416. * @param name defines the name of the task
  128417. * @param url defines the location of the file to load
  128418. */
  128419. constructor(
  128420. /**
  128421. * Defines the name of the task
  128422. */
  128423. name: string,
  128424. /**
  128425. * Defines the location of the file to load
  128426. */
  128427. url: string);
  128428. /**
  128429. * Execute the current task
  128430. * @param scene defines the scene where you want your assets to be loaded
  128431. * @param onSuccess is a callback called when the task is successfully executed
  128432. * @param onError is a callback called if an error occurs
  128433. */
  128434. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128435. }
  128436. /**
  128437. * Define a task used by AssetsManager to load binary data
  128438. */
  128439. export class BinaryFileAssetTask extends AbstractAssetTask {
  128440. /**
  128441. * Defines the name of the task
  128442. */
  128443. name: string;
  128444. /**
  128445. * Defines the location of the file to load
  128446. */
  128447. url: string;
  128448. /**
  128449. * Gets the lodaded data (as an array buffer)
  128450. */
  128451. data: ArrayBuffer;
  128452. /**
  128453. * Callback called when the task is successful
  128454. */
  128455. onSuccess: (task: BinaryFileAssetTask) => void;
  128456. /**
  128457. * Callback called when the task is successful
  128458. */
  128459. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128460. /**
  128461. * Creates a new BinaryFileAssetTask object
  128462. * @param name defines the name of the new task
  128463. * @param url defines the location of the file to load
  128464. */
  128465. constructor(
  128466. /**
  128467. * Defines the name of the task
  128468. */
  128469. name: string,
  128470. /**
  128471. * Defines the location of the file to load
  128472. */
  128473. url: string);
  128474. /**
  128475. * Execute the current task
  128476. * @param scene defines the scene where you want your assets to be loaded
  128477. * @param onSuccess is a callback called when the task is successfully executed
  128478. * @param onError is a callback called if an error occurs
  128479. */
  128480. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128481. }
  128482. /**
  128483. * Define a task used by AssetsManager to load images
  128484. */
  128485. export class ImageAssetTask extends AbstractAssetTask {
  128486. /**
  128487. * Defines the name of the task
  128488. */
  128489. name: string;
  128490. /**
  128491. * Defines the location of the image to load
  128492. */
  128493. url: string;
  128494. /**
  128495. * Gets the loaded images
  128496. */
  128497. image: HTMLImageElement;
  128498. /**
  128499. * Callback called when the task is successful
  128500. */
  128501. onSuccess: (task: ImageAssetTask) => void;
  128502. /**
  128503. * Callback called when the task is successful
  128504. */
  128505. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128506. /**
  128507. * Creates a new ImageAssetTask
  128508. * @param name defines the name of the task
  128509. * @param url defines the location of the image to load
  128510. */
  128511. constructor(
  128512. /**
  128513. * Defines the name of the task
  128514. */
  128515. name: string,
  128516. /**
  128517. * Defines the location of the image to load
  128518. */
  128519. url: string);
  128520. /**
  128521. * Execute the current task
  128522. * @param scene defines the scene where you want your assets to be loaded
  128523. * @param onSuccess is a callback called when the task is successfully executed
  128524. * @param onError is a callback called if an error occurs
  128525. */
  128526. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128527. }
  128528. /**
  128529. * Defines the interface used by texture loading tasks
  128530. */
  128531. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128532. /**
  128533. * Gets the loaded texture
  128534. */
  128535. texture: TEX;
  128536. }
  128537. /**
  128538. * Define a task used by AssetsManager to load 2D textures
  128539. */
  128540. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128541. /**
  128542. * Defines the name of the task
  128543. */
  128544. name: string;
  128545. /**
  128546. * Defines the location of the file to load
  128547. */
  128548. url: string;
  128549. /**
  128550. * Defines if mipmap should not be generated (default is false)
  128551. */
  128552. noMipmap?: boolean | undefined;
  128553. /**
  128554. * Defines if texture must be inverted on Y axis (default is false)
  128555. */
  128556. invertY?: boolean | undefined;
  128557. /**
  128558. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128559. */
  128560. samplingMode: number;
  128561. /**
  128562. * Gets the loaded texture
  128563. */
  128564. texture: Texture;
  128565. /**
  128566. * Callback called when the task is successful
  128567. */
  128568. onSuccess: (task: TextureAssetTask) => void;
  128569. /**
  128570. * Callback called when the task is successful
  128571. */
  128572. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128573. /**
  128574. * Creates a new TextureAssetTask object
  128575. * @param name defines the name of the task
  128576. * @param url defines the location of the file to load
  128577. * @param noMipmap defines if mipmap should not be generated (default is false)
  128578. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128579. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128580. */
  128581. constructor(
  128582. /**
  128583. * Defines the name of the task
  128584. */
  128585. name: string,
  128586. /**
  128587. * Defines the location of the file to load
  128588. */
  128589. url: string,
  128590. /**
  128591. * Defines if mipmap should not be generated (default is false)
  128592. */
  128593. noMipmap?: boolean | undefined,
  128594. /**
  128595. * Defines if texture must be inverted on Y axis (default is false)
  128596. */
  128597. invertY?: boolean | undefined,
  128598. /**
  128599. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128600. */
  128601. samplingMode?: number);
  128602. /**
  128603. * Execute the current task
  128604. * @param scene defines the scene where you want your assets to be loaded
  128605. * @param onSuccess is a callback called when the task is successfully executed
  128606. * @param onError is a callback called if an error occurs
  128607. */
  128608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128609. }
  128610. /**
  128611. * Define a task used by AssetsManager to load cube textures
  128612. */
  128613. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128614. /**
  128615. * Defines the name of the task
  128616. */
  128617. name: string;
  128618. /**
  128619. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128620. */
  128621. url: string;
  128622. /**
  128623. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128624. */
  128625. extensions?: string[] | undefined;
  128626. /**
  128627. * Defines if mipmaps should not be generated (default is false)
  128628. */
  128629. noMipmap?: boolean | undefined;
  128630. /**
  128631. * Defines the explicit list of files (undefined by default)
  128632. */
  128633. files?: string[] | undefined;
  128634. /**
  128635. * Gets the loaded texture
  128636. */
  128637. texture: CubeTexture;
  128638. /**
  128639. * Callback called when the task is successful
  128640. */
  128641. onSuccess: (task: CubeTextureAssetTask) => void;
  128642. /**
  128643. * Callback called when the task is successful
  128644. */
  128645. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128646. /**
  128647. * Creates a new CubeTextureAssetTask
  128648. * @param name defines the name of the task
  128649. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128650. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128651. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128652. * @param files defines the explicit list of files (undefined by default)
  128653. */
  128654. constructor(
  128655. /**
  128656. * Defines the name of the task
  128657. */
  128658. name: string,
  128659. /**
  128660. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128661. */
  128662. url: string,
  128663. /**
  128664. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128665. */
  128666. extensions?: string[] | undefined,
  128667. /**
  128668. * Defines if mipmaps should not be generated (default is false)
  128669. */
  128670. noMipmap?: boolean | undefined,
  128671. /**
  128672. * Defines the explicit list of files (undefined by default)
  128673. */
  128674. files?: string[] | undefined);
  128675. /**
  128676. * Execute the current task
  128677. * @param scene defines the scene where you want your assets to be loaded
  128678. * @param onSuccess is a callback called when the task is successfully executed
  128679. * @param onError is a callback called if an error occurs
  128680. */
  128681. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128682. }
  128683. /**
  128684. * Define a task used by AssetsManager to load HDR cube textures
  128685. */
  128686. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128687. /**
  128688. * Defines the name of the task
  128689. */
  128690. name: string;
  128691. /**
  128692. * Defines the location of the file to load
  128693. */
  128694. url: string;
  128695. /**
  128696. * Defines the desired size (the more it increases the longer the generation will be)
  128697. */
  128698. size: number;
  128699. /**
  128700. * Defines if mipmaps should not be generated (default is false)
  128701. */
  128702. noMipmap: boolean;
  128703. /**
  128704. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128705. */
  128706. generateHarmonics: boolean;
  128707. /**
  128708. * 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)
  128709. */
  128710. gammaSpace: boolean;
  128711. /**
  128712. * Internal Use Only
  128713. */
  128714. reserved: boolean;
  128715. /**
  128716. * Gets the loaded texture
  128717. */
  128718. texture: HDRCubeTexture;
  128719. /**
  128720. * Callback called when the task is successful
  128721. */
  128722. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128723. /**
  128724. * Callback called when the task is successful
  128725. */
  128726. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128727. /**
  128728. * Creates a new HDRCubeTextureAssetTask object
  128729. * @param name defines the name of the task
  128730. * @param url defines the location of the file to load
  128731. * @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.
  128732. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128733. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128734. * @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)
  128735. * @param reserved Internal use only
  128736. */
  128737. constructor(
  128738. /**
  128739. * Defines the name of the task
  128740. */
  128741. name: string,
  128742. /**
  128743. * Defines the location of the file to load
  128744. */
  128745. url: string,
  128746. /**
  128747. * Defines the desired size (the more it increases the longer the generation will be)
  128748. */
  128749. size: number,
  128750. /**
  128751. * Defines if mipmaps should not be generated (default is false)
  128752. */
  128753. noMipmap?: boolean,
  128754. /**
  128755. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128756. */
  128757. generateHarmonics?: boolean,
  128758. /**
  128759. * 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)
  128760. */
  128761. gammaSpace?: boolean,
  128762. /**
  128763. * Internal Use Only
  128764. */
  128765. reserved?: boolean);
  128766. /**
  128767. * Execute the current task
  128768. * @param scene defines the scene where you want your assets to be loaded
  128769. * @param onSuccess is a callback called when the task is successfully executed
  128770. * @param onError is a callback called if an error occurs
  128771. */
  128772. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128773. }
  128774. /**
  128775. * Define a task used by AssetsManager to load Equirectangular cube textures
  128776. */
  128777. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128778. /**
  128779. * Defines the name of the task
  128780. */
  128781. name: string;
  128782. /**
  128783. * Defines the location of the file to load
  128784. */
  128785. url: string;
  128786. /**
  128787. * Defines the desired size (the more it increases the longer the generation will be)
  128788. */
  128789. size: number;
  128790. /**
  128791. * Defines if mipmaps should not be generated (default is false)
  128792. */
  128793. noMipmap: boolean;
  128794. /**
  128795. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128796. * but the standard material would require them in Gamma space) (default is true)
  128797. */
  128798. gammaSpace: boolean;
  128799. /**
  128800. * Gets the loaded texture
  128801. */
  128802. texture: EquiRectangularCubeTexture;
  128803. /**
  128804. * Callback called when the task is successful
  128805. */
  128806. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128807. /**
  128808. * Callback called when the task is successful
  128809. */
  128810. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128811. /**
  128812. * Creates a new EquiRectangularCubeTextureAssetTask object
  128813. * @param name defines the name of the task
  128814. * @param url defines the location of the file to load
  128815. * @param size defines the desired size (the more it increases the longer the generation will be)
  128816. * If the size is omitted this implies you are using a preprocessed cubemap.
  128817. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128818. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128819. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128820. * (default is true)
  128821. */
  128822. constructor(
  128823. /**
  128824. * Defines the name of the task
  128825. */
  128826. name: string,
  128827. /**
  128828. * Defines the location of the file to load
  128829. */
  128830. url: string,
  128831. /**
  128832. * Defines the desired size (the more it increases the longer the generation will be)
  128833. */
  128834. size: number,
  128835. /**
  128836. * Defines if mipmaps should not be generated (default is false)
  128837. */
  128838. noMipmap?: boolean,
  128839. /**
  128840. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128841. * but the standard material would require them in Gamma space) (default is true)
  128842. */
  128843. gammaSpace?: boolean);
  128844. /**
  128845. * Execute the current task
  128846. * @param scene defines the scene where you want your assets to be loaded
  128847. * @param onSuccess is a callback called when the task is successfully executed
  128848. * @param onError is a callback called if an error occurs
  128849. */
  128850. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128851. }
  128852. /**
  128853. * This class can be used to easily import assets into a scene
  128854. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128855. */
  128856. export class AssetsManager {
  128857. private _scene;
  128858. private _isLoading;
  128859. protected _tasks: AbstractAssetTask[];
  128860. protected _waitingTasksCount: number;
  128861. protected _totalTasksCount: number;
  128862. /**
  128863. * Callback called when all tasks are processed
  128864. */
  128865. onFinish: (tasks: AbstractAssetTask[]) => void;
  128866. /**
  128867. * Callback called when a task is successful
  128868. */
  128869. onTaskSuccess: (task: AbstractAssetTask) => void;
  128870. /**
  128871. * Callback called when a task had an error
  128872. */
  128873. onTaskError: (task: AbstractAssetTask) => void;
  128874. /**
  128875. * Callback called when a task is done (whatever the result is)
  128876. */
  128877. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  128878. /**
  128879. * Observable called when all tasks are processed
  128880. */
  128881. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  128882. /**
  128883. * Observable called when a task had an error
  128884. */
  128885. onTaskErrorObservable: Observable<AbstractAssetTask>;
  128886. /**
  128887. * Observable called when all tasks were executed
  128888. */
  128889. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  128890. /**
  128891. * Observable called when a task is done (whatever the result is)
  128892. */
  128893. onProgressObservable: Observable<IAssetsProgressEvent>;
  128894. /**
  128895. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  128896. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128897. */
  128898. useDefaultLoadingScreen: boolean;
  128899. /**
  128900. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  128901. * when all assets have been downloaded.
  128902. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  128903. */
  128904. autoHideLoadingUI: boolean;
  128905. /**
  128906. * Creates a new AssetsManager
  128907. * @param scene defines the scene to work on
  128908. */
  128909. constructor(scene: Scene);
  128910. /**
  128911. * Add a MeshAssetTask to the list of active tasks
  128912. * @param taskName defines the name of the new task
  128913. * @param meshesNames defines the name of meshes to load
  128914. * @param rootUrl defines the root url to use to locate files
  128915. * @param sceneFilename defines the filename of the scene file
  128916. * @returns a new MeshAssetTask object
  128917. */
  128918. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  128919. /**
  128920. * Add a TextFileAssetTask to the list of active tasks
  128921. * @param taskName defines the name of the new task
  128922. * @param url defines the url of the file to load
  128923. * @returns a new TextFileAssetTask object
  128924. */
  128925. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  128926. /**
  128927. * Add a BinaryFileAssetTask to the list of active tasks
  128928. * @param taskName defines the name of the new task
  128929. * @param url defines the url of the file to load
  128930. * @returns a new BinaryFileAssetTask object
  128931. */
  128932. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  128933. /**
  128934. * Add a ImageAssetTask to the list of active tasks
  128935. * @param taskName defines the name of the new task
  128936. * @param url defines the url of the file to load
  128937. * @returns a new ImageAssetTask object
  128938. */
  128939. addImageTask(taskName: string, url: string): ImageAssetTask;
  128940. /**
  128941. * Add a TextureAssetTask to the list of active tasks
  128942. * @param taskName defines the name of the new task
  128943. * @param url defines the url of the file to load
  128944. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128945. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  128946. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128947. * @returns a new TextureAssetTask object
  128948. */
  128949. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  128950. /**
  128951. * Add a CubeTextureAssetTask to the list of active tasks
  128952. * @param taskName defines the name of the new task
  128953. * @param url defines the url of the file to load
  128954. * @param extensions defines the extension to use to load the cube map (can be null)
  128955. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128956. * @param files defines the list of files to load (can be null)
  128957. * @returns a new CubeTextureAssetTask object
  128958. */
  128959. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  128960. /**
  128961. *
  128962. * Add a HDRCubeTextureAssetTask to the list of active tasks
  128963. * @param taskName defines the name of the new task
  128964. * @param url defines the url of the file to load
  128965. * @param size defines the size you want for the cubemap (can be null)
  128966. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128967. * @param generateHarmonics defines if you want to automatically generate (true by default)
  128968. * @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)
  128969. * @param reserved Internal use only
  128970. * @returns a new HDRCubeTextureAssetTask object
  128971. */
  128972. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  128973. /**
  128974. *
  128975. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  128976. * @param taskName defines the name of the new task
  128977. * @param url defines the url of the file to load
  128978. * @param size defines the size you want for the cubemap (can be null)
  128979. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128980. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128981. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128982. * @returns a new EquiRectangularCubeTextureAssetTask object
  128983. */
  128984. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  128985. /**
  128986. * Remove a task from the assets manager.
  128987. * @param task the task to remove
  128988. */
  128989. removeTask(task: AbstractAssetTask): void;
  128990. private _decreaseWaitingTasksCount;
  128991. private _runTask;
  128992. /**
  128993. * Reset the AssetsManager and remove all tasks
  128994. * @return the current instance of the AssetsManager
  128995. */
  128996. reset(): AssetsManager;
  128997. /**
  128998. * Start the loading process
  128999. * @return the current instance of the AssetsManager
  129000. */
  129001. load(): AssetsManager;
  129002. /**
  129003. * Start the loading process as an async operation
  129004. * @return a promise returning the list of failed tasks
  129005. */
  129006. loadAsync(): Promise<void>;
  129007. }
  129008. }
  129009. declare module BABYLON {
  129010. /**
  129011. * Wrapper class for promise with external resolve and reject.
  129012. */
  129013. export class Deferred<T> {
  129014. /**
  129015. * The promise associated with this deferred object.
  129016. */
  129017. readonly promise: Promise<T>;
  129018. private _resolve;
  129019. private _reject;
  129020. /**
  129021. * The resolve method of the promise associated with this deferred object.
  129022. */
  129023. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129024. /**
  129025. * The reject method of the promise associated with this deferred object.
  129026. */
  129027. readonly reject: (reason?: any) => void;
  129028. /**
  129029. * Constructor for this deferred object.
  129030. */
  129031. constructor();
  129032. }
  129033. }
  129034. declare module BABYLON {
  129035. /**
  129036. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129037. */
  129038. export class MeshExploder {
  129039. private _centerMesh;
  129040. private _meshes;
  129041. private _meshesOrigins;
  129042. private _toCenterVectors;
  129043. private _scaledDirection;
  129044. private _newPosition;
  129045. private _centerPosition;
  129046. /**
  129047. * Explodes meshes from a center mesh.
  129048. * @param meshes The meshes to explode.
  129049. * @param centerMesh The mesh to be center of explosion.
  129050. */
  129051. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129052. private _setCenterMesh;
  129053. /**
  129054. * Get class name
  129055. * @returns "MeshExploder"
  129056. */
  129057. getClassName(): string;
  129058. /**
  129059. * "Exploded meshes"
  129060. * @returns Array of meshes with the centerMesh at index 0.
  129061. */
  129062. getMeshes(): Array<Mesh>;
  129063. /**
  129064. * Explodes meshes giving a specific direction
  129065. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129066. */
  129067. explode(direction?: number): void;
  129068. }
  129069. }
  129070. declare module BABYLON {
  129071. /**
  129072. * Class used to help managing file picking and drag'n'drop
  129073. */
  129074. export class FilesInput {
  129075. /**
  129076. * List of files ready to be loaded
  129077. */
  129078. static readonly FilesToLoad: {
  129079. [key: string]: File;
  129080. };
  129081. /**
  129082. * Callback called when a file is processed
  129083. */
  129084. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129085. private _engine;
  129086. private _currentScene;
  129087. private _sceneLoadedCallback;
  129088. private _progressCallback;
  129089. private _additionalRenderLoopLogicCallback;
  129090. private _textureLoadingCallback;
  129091. private _startingProcessingFilesCallback;
  129092. private _onReloadCallback;
  129093. private _errorCallback;
  129094. private _elementToMonitor;
  129095. private _sceneFileToLoad;
  129096. private _filesToLoad;
  129097. /**
  129098. * Creates a new FilesInput
  129099. * @param engine defines the rendering engine
  129100. * @param scene defines the hosting scene
  129101. * @param sceneLoadedCallback callback called when scene is loaded
  129102. * @param progressCallback callback called to track progress
  129103. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129104. * @param textureLoadingCallback callback called when a texture is loading
  129105. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129106. * @param onReloadCallback callback called when a reload is requested
  129107. * @param errorCallback callback call if an error occurs
  129108. */
  129109. 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);
  129110. private _dragEnterHandler;
  129111. private _dragOverHandler;
  129112. private _dropHandler;
  129113. /**
  129114. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129115. * @param elementToMonitor defines the DOM element to track
  129116. */
  129117. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129118. /**
  129119. * Release all associated resources
  129120. */
  129121. dispose(): void;
  129122. private renderFunction;
  129123. private drag;
  129124. private drop;
  129125. private _traverseFolder;
  129126. private _processFiles;
  129127. /**
  129128. * Load files from a drop event
  129129. * @param event defines the drop event to use as source
  129130. */
  129131. loadFiles(event: any): void;
  129132. private _processReload;
  129133. /**
  129134. * Reload the current scene from the loaded files
  129135. */
  129136. reload(): void;
  129137. }
  129138. }
  129139. declare module BABYLON {
  129140. /**
  129141. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129143. */
  129144. export class SceneOptimization {
  129145. /**
  129146. * Defines the priority of this optimization (0 by default which means first in the list)
  129147. */
  129148. priority: number;
  129149. /**
  129150. * Gets a string describing the action executed by the current optimization
  129151. * @returns description string
  129152. */
  129153. getDescription(): string;
  129154. /**
  129155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129156. * @param scene defines the current scene where to apply this optimization
  129157. * @param optimizer defines the current optimizer
  129158. * @returns true if everything that can be done was applied
  129159. */
  129160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129161. /**
  129162. * Creates the SceneOptimization object
  129163. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129164. * @param desc defines the description associated with the optimization
  129165. */
  129166. constructor(
  129167. /**
  129168. * Defines the priority of this optimization (0 by default which means first in the list)
  129169. */
  129170. priority?: number);
  129171. }
  129172. /**
  129173. * Defines an optimization used to reduce the size of render target textures
  129174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129175. */
  129176. export class TextureOptimization extends SceneOptimization {
  129177. /**
  129178. * Defines the priority of this optimization (0 by default which means first in the list)
  129179. */
  129180. priority: number;
  129181. /**
  129182. * 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
  129183. */
  129184. maximumSize: number;
  129185. /**
  129186. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129187. */
  129188. step: number;
  129189. /**
  129190. * Gets a string describing the action executed by the current optimization
  129191. * @returns description string
  129192. */
  129193. getDescription(): string;
  129194. /**
  129195. * Creates the TextureOptimization object
  129196. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129197. * @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
  129198. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129199. */
  129200. constructor(
  129201. /**
  129202. * Defines the priority of this optimization (0 by default which means first in the list)
  129203. */
  129204. priority?: number,
  129205. /**
  129206. * 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
  129207. */
  129208. maximumSize?: number,
  129209. /**
  129210. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129211. */
  129212. step?: number);
  129213. /**
  129214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129215. * @param scene defines the current scene where to apply this optimization
  129216. * @param optimizer defines the current optimizer
  129217. * @returns true if everything that can be done was applied
  129218. */
  129219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129220. }
  129221. /**
  129222. * Defines an optimization used to increase or decrease the rendering resolution
  129223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129224. */
  129225. export class HardwareScalingOptimization extends SceneOptimization {
  129226. /**
  129227. * Defines the priority of this optimization (0 by default which means first in the list)
  129228. */
  129229. priority: number;
  129230. /**
  129231. * Defines the maximum scale to use (2 by default)
  129232. */
  129233. maximumScale: number;
  129234. /**
  129235. * Defines the step to use between two passes (0.5 by default)
  129236. */
  129237. step: number;
  129238. private _currentScale;
  129239. private _directionOffset;
  129240. /**
  129241. * Gets a string describing the action executed by the current optimization
  129242. * @return description string
  129243. */
  129244. getDescription(): string;
  129245. /**
  129246. * Creates the HardwareScalingOptimization object
  129247. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129248. * @param maximumScale defines the maximum scale to use (2 by default)
  129249. * @param step defines the step to use between two passes (0.5 by default)
  129250. */
  129251. constructor(
  129252. /**
  129253. * Defines the priority of this optimization (0 by default which means first in the list)
  129254. */
  129255. priority?: number,
  129256. /**
  129257. * Defines the maximum scale to use (2 by default)
  129258. */
  129259. maximumScale?: number,
  129260. /**
  129261. * Defines the step to use between two passes (0.5 by default)
  129262. */
  129263. step?: number);
  129264. /**
  129265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129266. * @param scene defines the current scene where to apply this optimization
  129267. * @param optimizer defines the current optimizer
  129268. * @returns true if everything that can be done was applied
  129269. */
  129270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129271. }
  129272. /**
  129273. * Defines an optimization used to remove shadows
  129274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129275. */
  129276. export class ShadowsOptimization extends SceneOptimization {
  129277. /**
  129278. * Gets a string describing the action executed by the current optimization
  129279. * @return description string
  129280. */
  129281. getDescription(): string;
  129282. /**
  129283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129284. * @param scene defines the current scene where to apply this optimization
  129285. * @param optimizer defines the current optimizer
  129286. * @returns true if everything that can be done was applied
  129287. */
  129288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129289. }
  129290. /**
  129291. * Defines an optimization used to turn post-processes off
  129292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129293. */
  129294. export class PostProcessesOptimization extends SceneOptimization {
  129295. /**
  129296. * Gets a string describing the action executed by the current optimization
  129297. * @return description string
  129298. */
  129299. getDescription(): string;
  129300. /**
  129301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129302. * @param scene defines the current scene where to apply this optimization
  129303. * @param optimizer defines the current optimizer
  129304. * @returns true if everything that can be done was applied
  129305. */
  129306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129307. }
  129308. /**
  129309. * Defines an optimization used to turn lens flares off
  129310. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129311. */
  129312. export class LensFlaresOptimization extends SceneOptimization {
  129313. /**
  129314. * Gets a string describing the action executed by the current optimization
  129315. * @return description string
  129316. */
  129317. getDescription(): string;
  129318. /**
  129319. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129320. * @param scene defines the current scene where to apply this optimization
  129321. * @param optimizer defines the current optimizer
  129322. * @returns true if everything that can be done was applied
  129323. */
  129324. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129325. }
  129326. /**
  129327. * Defines an optimization based on user defined callback.
  129328. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129329. */
  129330. export class CustomOptimization extends SceneOptimization {
  129331. /**
  129332. * Callback called to apply the custom optimization.
  129333. */
  129334. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129335. /**
  129336. * Callback called to get custom description
  129337. */
  129338. onGetDescription: () => string;
  129339. /**
  129340. * Gets a string describing the action executed by the current optimization
  129341. * @returns description string
  129342. */
  129343. getDescription(): string;
  129344. /**
  129345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129346. * @param scene defines the current scene where to apply this optimization
  129347. * @param optimizer defines the current optimizer
  129348. * @returns true if everything that can be done was applied
  129349. */
  129350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129351. }
  129352. /**
  129353. * Defines an optimization used to turn particles off
  129354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129355. */
  129356. export class ParticlesOptimization extends SceneOptimization {
  129357. /**
  129358. * Gets a string describing the action executed by the current optimization
  129359. * @return description string
  129360. */
  129361. getDescription(): string;
  129362. /**
  129363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129364. * @param scene defines the current scene where to apply this optimization
  129365. * @param optimizer defines the current optimizer
  129366. * @returns true if everything that can be done was applied
  129367. */
  129368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129369. }
  129370. /**
  129371. * Defines an optimization used to turn render targets off
  129372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129373. */
  129374. export class RenderTargetsOptimization extends SceneOptimization {
  129375. /**
  129376. * Gets a string describing the action executed by the current optimization
  129377. * @return description string
  129378. */
  129379. getDescription(): string;
  129380. /**
  129381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129382. * @param scene defines the current scene where to apply this optimization
  129383. * @param optimizer defines the current optimizer
  129384. * @returns true if everything that can be done was applied
  129385. */
  129386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129387. }
  129388. /**
  129389. * Defines an optimization used to merge meshes with compatible materials
  129390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129391. */
  129392. export class MergeMeshesOptimization extends SceneOptimization {
  129393. private static _UpdateSelectionTree;
  129394. /**
  129395. * Gets or sets a boolean which defines if optimization octree has to be updated
  129396. */
  129397. /**
  129398. * Gets or sets a boolean which defines if optimization octree has to be updated
  129399. */
  129400. static UpdateSelectionTree: boolean;
  129401. /**
  129402. * Gets a string describing the action executed by the current optimization
  129403. * @return description string
  129404. */
  129405. getDescription(): string;
  129406. private _canBeMerged;
  129407. /**
  129408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129409. * @param scene defines the current scene where to apply this optimization
  129410. * @param optimizer defines the current optimizer
  129411. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129412. * @returns true if everything that can be done was applied
  129413. */
  129414. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129415. }
  129416. /**
  129417. * Defines a list of options used by SceneOptimizer
  129418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129419. */
  129420. export class SceneOptimizerOptions {
  129421. /**
  129422. * Defines the target frame rate to reach (60 by default)
  129423. */
  129424. targetFrameRate: number;
  129425. /**
  129426. * Defines the interval between two checkes (2000ms by default)
  129427. */
  129428. trackerDuration: number;
  129429. /**
  129430. * Gets the list of optimizations to apply
  129431. */
  129432. optimizations: SceneOptimization[];
  129433. /**
  129434. * Creates a new list of options used by SceneOptimizer
  129435. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129436. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129437. */
  129438. constructor(
  129439. /**
  129440. * Defines the target frame rate to reach (60 by default)
  129441. */
  129442. targetFrameRate?: number,
  129443. /**
  129444. * Defines the interval between two checkes (2000ms by default)
  129445. */
  129446. trackerDuration?: number);
  129447. /**
  129448. * Add a new optimization
  129449. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129450. * @returns the current SceneOptimizerOptions
  129451. */
  129452. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129453. /**
  129454. * Add a new custom optimization
  129455. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129456. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129457. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129458. * @returns the current SceneOptimizerOptions
  129459. */
  129460. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129461. /**
  129462. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129463. * @param targetFrameRate defines the target frame rate (60 by default)
  129464. * @returns a SceneOptimizerOptions object
  129465. */
  129466. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129467. /**
  129468. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129469. * @param targetFrameRate defines the target frame rate (60 by default)
  129470. * @returns a SceneOptimizerOptions object
  129471. */
  129472. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129473. /**
  129474. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129475. * @param targetFrameRate defines the target frame rate (60 by default)
  129476. * @returns a SceneOptimizerOptions object
  129477. */
  129478. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129479. }
  129480. /**
  129481. * Class used to run optimizations in order to reach a target frame rate
  129482. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129483. */
  129484. export class SceneOptimizer implements IDisposable {
  129485. private _isRunning;
  129486. private _options;
  129487. private _scene;
  129488. private _currentPriorityLevel;
  129489. private _targetFrameRate;
  129490. private _trackerDuration;
  129491. private _currentFrameRate;
  129492. private _sceneDisposeObserver;
  129493. private _improvementMode;
  129494. /**
  129495. * Defines an observable called when the optimizer reaches the target frame rate
  129496. */
  129497. onSuccessObservable: Observable<SceneOptimizer>;
  129498. /**
  129499. * Defines an observable called when the optimizer enables an optimization
  129500. */
  129501. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129502. /**
  129503. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129504. */
  129505. onFailureObservable: Observable<SceneOptimizer>;
  129506. /**
  129507. * Gets a boolean indicating if the optimizer is in improvement mode
  129508. */
  129509. readonly isInImprovementMode: boolean;
  129510. /**
  129511. * Gets the current priority level (0 at start)
  129512. */
  129513. readonly currentPriorityLevel: number;
  129514. /**
  129515. * Gets the current frame rate checked by the SceneOptimizer
  129516. */
  129517. readonly currentFrameRate: number;
  129518. /**
  129519. * Gets or sets the current target frame rate (60 by default)
  129520. */
  129521. /**
  129522. * Gets or sets the current target frame rate (60 by default)
  129523. */
  129524. targetFrameRate: number;
  129525. /**
  129526. * Gets or sets the current interval between two checks (every 2000ms by default)
  129527. */
  129528. /**
  129529. * Gets or sets the current interval between two checks (every 2000ms by default)
  129530. */
  129531. trackerDuration: number;
  129532. /**
  129533. * Gets the list of active optimizations
  129534. */
  129535. readonly optimizations: SceneOptimization[];
  129536. /**
  129537. * Creates a new SceneOptimizer
  129538. * @param scene defines the scene to work on
  129539. * @param options defines the options to use with the SceneOptimizer
  129540. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129541. * @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)
  129542. */
  129543. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129544. /**
  129545. * Stops the current optimizer
  129546. */
  129547. stop(): void;
  129548. /**
  129549. * Reset the optimizer to initial step (current priority level = 0)
  129550. */
  129551. reset(): void;
  129552. /**
  129553. * Start the optimizer. By default it will try to reach a specific framerate
  129554. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129555. */
  129556. start(): void;
  129557. private _checkCurrentState;
  129558. /**
  129559. * Release all resources
  129560. */
  129561. dispose(): void;
  129562. /**
  129563. * Helper function to create a SceneOptimizer with one single line of code
  129564. * @param scene defines the scene to work on
  129565. * @param options defines the options to use with the SceneOptimizer
  129566. * @param onSuccess defines a callback to call on success
  129567. * @param onFailure defines a callback to call on failure
  129568. * @returns the new SceneOptimizer object
  129569. */
  129570. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129571. }
  129572. }
  129573. declare module BABYLON {
  129574. /**
  129575. * Class used to serialize a scene into a string
  129576. */
  129577. export class SceneSerializer {
  129578. /**
  129579. * Clear cache used by a previous serialization
  129580. */
  129581. static ClearCache(): void;
  129582. /**
  129583. * Serialize a scene into a JSON compatible object
  129584. * @param scene defines the scene to serialize
  129585. * @returns a JSON compatible object
  129586. */
  129587. static Serialize(scene: Scene): any;
  129588. /**
  129589. * Serialize a mesh into a JSON compatible object
  129590. * @param toSerialize defines the mesh to serialize
  129591. * @param withParents defines if parents must be serialized as well
  129592. * @param withChildren defines if children must be serialized as well
  129593. * @returns a JSON compatible object
  129594. */
  129595. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129596. }
  129597. }
  129598. declare module BABYLON {
  129599. /**
  129600. * Class used to host texture specific utilities
  129601. */
  129602. export class TextureTools {
  129603. /**
  129604. * Uses the GPU to create a copy texture rescaled at a given size
  129605. * @param texture Texture to copy from
  129606. * @param width defines the desired width
  129607. * @param height defines the desired height
  129608. * @param useBilinearMode defines if bilinear mode has to be used
  129609. * @return the generated texture
  129610. */
  129611. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129612. }
  129613. }
  129614. declare module BABYLON {
  129615. /**
  129616. * This represents the different options available for the video capture.
  129617. */
  129618. export interface VideoRecorderOptions {
  129619. /** Defines the mime type of the video. */
  129620. mimeType: string;
  129621. /** Defines the FPS the video should be recorded at. */
  129622. fps: number;
  129623. /** Defines the chunk size for the recording data. */
  129624. recordChunckSize: number;
  129625. /** The audio tracks to attach to the recording. */
  129626. audioTracks?: MediaStreamTrack[];
  129627. }
  129628. /**
  129629. * This can help with recording videos from BabylonJS.
  129630. * This is based on the available WebRTC functionalities of the browser.
  129631. *
  129632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129633. */
  129634. export class VideoRecorder {
  129635. private static readonly _defaultOptions;
  129636. /**
  129637. * Returns whether or not the VideoRecorder is available in your browser.
  129638. * @param engine Defines the Babylon Engine.
  129639. * @returns true if supported otherwise false.
  129640. */
  129641. static IsSupported(engine: Engine): boolean;
  129642. private readonly _options;
  129643. private _canvas;
  129644. private _mediaRecorder;
  129645. private _recordedChunks;
  129646. private _fileName;
  129647. private _resolve;
  129648. private _reject;
  129649. /**
  129650. * True when a recording is already in progress.
  129651. */
  129652. readonly isRecording: boolean;
  129653. /**
  129654. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129655. * @param engine Defines the BabylonJS Engine you wish to record.
  129656. * @param options Defines options that can be used to customize the capture.
  129657. */
  129658. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129659. /**
  129660. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129661. */
  129662. stopRecording(): void;
  129663. /**
  129664. * Starts recording the canvas for a max duration specified in parameters.
  129665. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129666. * If null no automatic download will start and you can rely on the promise to get the data back.
  129667. * @param maxDuration Defines the maximum recording time in seconds.
  129668. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129669. * @return A promise callback at the end of the recording with the video data in Blob.
  129670. */
  129671. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129672. /**
  129673. * Releases internal resources used during the recording.
  129674. */
  129675. dispose(): void;
  129676. private _handleDataAvailable;
  129677. private _handleError;
  129678. private _handleStop;
  129679. }
  129680. }
  129681. declare module BABYLON {
  129682. /**
  129683. * Class containing a set of static utilities functions for screenshots
  129684. */
  129685. export class ScreenshotTools {
  129686. /**
  129687. * Captures a screenshot of the current rendering
  129688. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129689. * @param engine defines the rendering engine
  129690. * @param camera defines the source camera
  129691. * @param size This parameter can be set to a single number or to an object with the
  129692. * following (optional) properties: precision, width, height. If a single number is passed,
  129693. * it will be used for both width and height. If an object is passed, the screenshot size
  129694. * will be derived from the parameters. The precision property is a multiplier allowing
  129695. * rendering at a higher or lower resolution
  129696. * @param successCallback defines the callback receives a single parameter which contains the
  129697. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129698. * src parameter of an <img> to display it
  129699. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129700. * Check your browser for supported MIME types
  129701. */
  129702. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129703. /**
  129704. * Captures a screenshot of the current rendering
  129705. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129706. * @param engine defines the rendering engine
  129707. * @param camera defines the source camera
  129708. * @param size This parameter can be set to a single number or to an object with the
  129709. * following (optional) properties: precision, width, height. If a single number is passed,
  129710. * it will be used for both width and height. If an object is passed, the screenshot size
  129711. * will be derived from the parameters. The precision property is a multiplier allowing
  129712. * rendering at a higher or lower resolution
  129713. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129714. * Check your browser for supported MIME types
  129715. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129716. * to the src parameter of an <img> to display it
  129717. */
  129718. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129719. /**
  129720. * Generates an image screenshot from the specified camera.
  129721. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129722. * @param engine The engine to use for rendering
  129723. * @param camera The camera to use for rendering
  129724. * @param size This parameter can be set to a single number or to an object with the
  129725. * following (optional) properties: precision, width, height. If a single number is passed,
  129726. * it will be used for both width and height. If an object is passed, the screenshot size
  129727. * will be derived from the parameters. The precision property is a multiplier allowing
  129728. * rendering at a higher or lower resolution
  129729. * @param successCallback The callback receives a single parameter which contains the
  129730. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129731. * src parameter of an <img> to display it
  129732. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129733. * Check your browser for supported MIME types
  129734. * @param samples Texture samples (default: 1)
  129735. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129736. * @param fileName A name for for the downloaded file.
  129737. */
  129738. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129739. /**
  129740. * Generates an image screenshot from the specified camera.
  129741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129742. * @param engine The engine to use for rendering
  129743. * @param camera The camera to use for rendering
  129744. * @param size This parameter can be set to a single number or to an object with the
  129745. * following (optional) properties: precision, width, height. If a single number is passed,
  129746. * it will be used for both width and height. If an object is passed, the screenshot size
  129747. * will be derived from the parameters. The precision property is a multiplier allowing
  129748. * rendering at a higher or lower resolution
  129749. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129750. * Check your browser for supported MIME types
  129751. * @param samples Texture samples (default: 1)
  129752. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129753. * @param fileName A name for for the downloaded file.
  129754. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129755. * to the src parameter of an <img> to display it
  129756. */
  129757. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129758. /**
  129759. * Gets height and width for screenshot size
  129760. * @private
  129761. */
  129762. private static _getScreenshotSize;
  129763. }
  129764. }
  129765. declare module BABYLON {
  129766. /**
  129767. * A cursor which tracks a point on a path
  129768. */
  129769. export class PathCursor {
  129770. private path;
  129771. /**
  129772. * Stores path cursor callbacks for when an onchange event is triggered
  129773. */
  129774. private _onchange;
  129775. /**
  129776. * The value of the path cursor
  129777. */
  129778. value: number;
  129779. /**
  129780. * The animation array of the path cursor
  129781. */
  129782. animations: Animation[];
  129783. /**
  129784. * Initializes the path cursor
  129785. * @param path The path to track
  129786. */
  129787. constructor(path: Path2);
  129788. /**
  129789. * Gets the cursor point on the path
  129790. * @returns A point on the path cursor at the cursor location
  129791. */
  129792. getPoint(): Vector3;
  129793. /**
  129794. * Moves the cursor ahead by the step amount
  129795. * @param step The amount to move the cursor forward
  129796. * @returns This path cursor
  129797. */
  129798. moveAhead(step?: number): PathCursor;
  129799. /**
  129800. * Moves the cursor behind by the step amount
  129801. * @param step The amount to move the cursor back
  129802. * @returns This path cursor
  129803. */
  129804. moveBack(step?: number): PathCursor;
  129805. /**
  129806. * Moves the cursor by the step amount
  129807. * If the step amount is greater than one, an exception is thrown
  129808. * @param step The amount to move the cursor
  129809. * @returns This path cursor
  129810. */
  129811. move(step: number): PathCursor;
  129812. /**
  129813. * Ensures that the value is limited between zero and one
  129814. * @returns This path cursor
  129815. */
  129816. private ensureLimits;
  129817. /**
  129818. * Runs onchange callbacks on change (used by the animation engine)
  129819. * @returns This path cursor
  129820. */
  129821. private raiseOnChange;
  129822. /**
  129823. * Executes a function on change
  129824. * @param f A path cursor onchange callback
  129825. * @returns This path cursor
  129826. */
  129827. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129828. }
  129829. }
  129830. declare module BABYLON {
  129831. /** @hidden */
  129832. export var blurPixelShader: {
  129833. name: string;
  129834. shader: string;
  129835. };
  129836. }
  129837. declare module BABYLON {
  129838. /** @hidden */
  129839. export var pointCloudVertexDeclaration: {
  129840. name: string;
  129841. shader: string;
  129842. };
  129843. }
  129844. // Mixins
  129845. interface Window {
  129846. mozIndexedDB: IDBFactory;
  129847. webkitIndexedDB: IDBFactory;
  129848. msIndexedDB: IDBFactory;
  129849. webkitURL: typeof URL;
  129850. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129851. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129852. WebGLRenderingContext: WebGLRenderingContext;
  129853. MSGesture: MSGesture;
  129854. CANNON: any;
  129855. AudioContext: AudioContext;
  129856. webkitAudioContext: AudioContext;
  129857. PointerEvent: any;
  129858. Math: Math;
  129859. Uint8Array: Uint8ArrayConstructor;
  129860. Float32Array: Float32ArrayConstructor;
  129861. mozURL: typeof URL;
  129862. msURL: typeof URL;
  129863. VRFrameData: any; // WebVR, from specs 1.1
  129864. DracoDecoderModule: any;
  129865. setImmediate(handler: (...args: any[]) => void): number;
  129866. }
  129867. interface HTMLCanvasElement {
  129868. requestPointerLock(): void;
  129869. msRequestPointerLock?(): void;
  129870. mozRequestPointerLock?(): void;
  129871. webkitRequestPointerLock?(): void;
  129872. /** Track wether a record is in progress */
  129873. isRecording: boolean;
  129874. /** Capture Stream method defined by some browsers */
  129875. captureStream(fps?: number): MediaStream;
  129876. }
  129877. interface CanvasRenderingContext2D {
  129878. msImageSmoothingEnabled: boolean;
  129879. }
  129880. interface MouseEvent {
  129881. mozMovementX: number;
  129882. mozMovementY: number;
  129883. webkitMovementX: number;
  129884. webkitMovementY: number;
  129885. msMovementX: number;
  129886. msMovementY: number;
  129887. }
  129888. interface Navigator {
  129889. mozGetVRDevices: (any: any) => any;
  129890. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129891. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129892. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129893. webkitGetGamepads(): Gamepad[];
  129894. msGetGamepads(): Gamepad[];
  129895. webkitGamepads(): Gamepad[];
  129896. }
  129897. interface HTMLVideoElement {
  129898. mozSrcObject: any;
  129899. }
  129900. interface Math {
  129901. fround(x: number): number;
  129902. imul(a: number, b: number): number;
  129903. }
  129904. interface WebGLRenderingContext {
  129905. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  129906. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  129907. vertexAttribDivisor(index: number, divisor: number): void;
  129908. createVertexArray(): any;
  129909. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  129910. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  129911. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  129912. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  129913. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  129914. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  129915. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  129916. // Queries
  129917. createQuery(): WebGLQuery;
  129918. deleteQuery(query: WebGLQuery): void;
  129919. beginQuery(target: number, query: WebGLQuery): void;
  129920. endQuery(target: number): void;
  129921. getQueryParameter(query: WebGLQuery, pname: number): any;
  129922. getQuery(target: number, pname: number): any;
  129923. MAX_SAMPLES: number;
  129924. RGBA8: number;
  129925. READ_FRAMEBUFFER: number;
  129926. DRAW_FRAMEBUFFER: number;
  129927. UNIFORM_BUFFER: number;
  129928. HALF_FLOAT_OES: number;
  129929. RGBA16F: number;
  129930. RGBA32F: number;
  129931. R32F: number;
  129932. RG32F: number;
  129933. RGB32F: number;
  129934. R16F: number;
  129935. RG16F: number;
  129936. RGB16F: number;
  129937. RED: number;
  129938. RG: number;
  129939. R8: number;
  129940. RG8: number;
  129941. UNSIGNED_INT_24_8: number;
  129942. DEPTH24_STENCIL8: number;
  129943. MIN: number;
  129944. MAX: number;
  129945. /* Multiple Render Targets */
  129946. drawBuffers(buffers: number[]): void;
  129947. readBuffer(src: number): void;
  129948. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  129949. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  129950. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  129951. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  129952. // Occlusion Query
  129953. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  129954. ANY_SAMPLES_PASSED: number;
  129955. QUERY_RESULT_AVAILABLE: number;
  129956. QUERY_RESULT: number;
  129957. }
  129958. interface WebGLProgram {
  129959. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  129960. }
  129961. interface EXT_disjoint_timer_query {
  129962. QUERY_COUNTER_BITS_EXT: number;
  129963. TIME_ELAPSED_EXT: number;
  129964. TIMESTAMP_EXT: number;
  129965. GPU_DISJOINT_EXT: number;
  129966. QUERY_RESULT_EXT: number;
  129967. QUERY_RESULT_AVAILABLE_EXT: number;
  129968. queryCounterEXT(query: WebGLQuery, target: number): void;
  129969. createQueryEXT(): WebGLQuery;
  129970. beginQueryEXT(target: number, query: WebGLQuery): void;
  129971. endQueryEXT(target: number): void;
  129972. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  129973. deleteQueryEXT(query: WebGLQuery): void;
  129974. }
  129975. interface WebGLUniformLocation {
  129976. _currentState: any;
  129977. }
  129978. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  129979. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  129980. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  129981. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129982. interface WebGLRenderingContext {
  129983. readonly RASTERIZER_DISCARD: number;
  129984. readonly DEPTH_COMPONENT24: number;
  129985. readonly TEXTURE_3D: number;
  129986. readonly TEXTURE_2D_ARRAY: number;
  129987. readonly TEXTURE_COMPARE_FUNC: number;
  129988. readonly TEXTURE_COMPARE_MODE: number;
  129989. readonly COMPARE_REF_TO_TEXTURE: number;
  129990. readonly TEXTURE_WRAP_R: number;
  129991. readonly HALF_FLOAT: number;
  129992. readonly RGB8: number;
  129993. readonly RED_INTEGER: number;
  129994. readonly RG_INTEGER: number;
  129995. readonly RGB_INTEGER: number;
  129996. readonly RGBA_INTEGER: number;
  129997. readonly R8_SNORM: number;
  129998. readonly RG8_SNORM: number;
  129999. readonly RGB8_SNORM: number;
  130000. readonly RGBA8_SNORM: number;
  130001. readonly R8I: number;
  130002. readonly RG8I: number;
  130003. readonly RGB8I: number;
  130004. readonly RGBA8I: number;
  130005. readonly R8UI: number;
  130006. readonly RG8UI: number;
  130007. readonly RGB8UI: number;
  130008. readonly RGBA8UI: number;
  130009. readonly R16I: number;
  130010. readonly RG16I: number;
  130011. readonly RGB16I: number;
  130012. readonly RGBA16I: number;
  130013. readonly R16UI: number;
  130014. readonly RG16UI: number;
  130015. readonly RGB16UI: number;
  130016. readonly RGBA16UI: number;
  130017. readonly R32I: number;
  130018. readonly RG32I: number;
  130019. readonly RGB32I: number;
  130020. readonly RGBA32I: number;
  130021. readonly R32UI: number;
  130022. readonly RG32UI: number;
  130023. readonly RGB32UI: number;
  130024. readonly RGBA32UI: number;
  130025. readonly RGB10_A2UI: number;
  130026. readonly R11F_G11F_B10F: number;
  130027. readonly RGB9_E5: number;
  130028. readonly RGB10_A2: number;
  130029. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130030. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130031. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130032. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130033. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130034. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130035. 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;
  130036. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130037. readonly TRANSFORM_FEEDBACK: number;
  130038. readonly INTERLEAVED_ATTRIBS: number;
  130039. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130040. createTransformFeedback(): WebGLTransformFeedback;
  130041. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130042. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130043. beginTransformFeedback(primitiveMode: number): void;
  130044. endTransformFeedback(): void;
  130045. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130046. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130047. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130048. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130049. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130050. }
  130051. interface ImageBitmap {
  130052. readonly width: number;
  130053. readonly height: number;
  130054. close(): void;
  130055. }
  130056. interface WebGLQuery extends WebGLObject {
  130057. }
  130058. declare var WebGLQuery: {
  130059. prototype: WebGLQuery;
  130060. new(): WebGLQuery;
  130061. };
  130062. interface WebGLSampler extends WebGLObject {
  130063. }
  130064. declare var WebGLSampler: {
  130065. prototype: WebGLSampler;
  130066. new(): WebGLSampler;
  130067. };
  130068. interface WebGLSync extends WebGLObject {
  130069. }
  130070. declare var WebGLSync: {
  130071. prototype: WebGLSync;
  130072. new(): WebGLSync;
  130073. };
  130074. interface WebGLTransformFeedback extends WebGLObject {
  130075. }
  130076. declare var WebGLTransformFeedback: {
  130077. prototype: WebGLTransformFeedback;
  130078. new(): WebGLTransformFeedback;
  130079. };
  130080. interface WebGLVertexArrayObject extends WebGLObject {
  130081. }
  130082. declare var WebGLVertexArrayObject: {
  130083. prototype: WebGLVertexArrayObject;
  130084. new(): WebGLVertexArrayObject;
  130085. };
  130086. // Type definitions for WebVR API
  130087. // Project: https://w3c.github.io/webvr/
  130088. // Definitions by: six a <https://github.com/lostfictions>
  130089. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130090. interface VRDisplay extends EventTarget {
  130091. /**
  130092. * Dictionary of capabilities describing the VRDisplay.
  130093. */
  130094. readonly capabilities: VRDisplayCapabilities;
  130095. /**
  130096. * z-depth defining the far plane of the eye view frustum
  130097. * enables mapping of values in the render target depth
  130098. * attachment to scene coordinates. Initially set to 10000.0.
  130099. */
  130100. depthFar: number;
  130101. /**
  130102. * z-depth defining the near plane of the eye view frustum
  130103. * enables mapping of values in the render target depth
  130104. * attachment to scene coordinates. Initially set to 0.01.
  130105. */
  130106. depthNear: number;
  130107. /**
  130108. * An identifier for this distinct VRDisplay. Used as an
  130109. * association point in the Gamepad API.
  130110. */
  130111. readonly displayId: number;
  130112. /**
  130113. * A display name, a user-readable name identifying it.
  130114. */
  130115. readonly displayName: string;
  130116. readonly isConnected: boolean;
  130117. readonly isPresenting: boolean;
  130118. /**
  130119. * If this VRDisplay supports room-scale experiences, the optional
  130120. * stage attribute contains details on the room-scale parameters.
  130121. */
  130122. readonly stageParameters: VRStageParameters | null;
  130123. /**
  130124. * Passing the value returned by `requestAnimationFrame` to
  130125. * `cancelAnimationFrame` will unregister the callback.
  130126. * @param handle Define the hanle of the request to cancel
  130127. */
  130128. cancelAnimationFrame(handle: number): void;
  130129. /**
  130130. * Stops presenting to the VRDisplay.
  130131. * @returns a promise to know when it stopped
  130132. */
  130133. exitPresent(): Promise<void>;
  130134. /**
  130135. * Return the current VREyeParameters for the given eye.
  130136. * @param whichEye Define the eye we want the parameter for
  130137. * @returns the eye parameters
  130138. */
  130139. getEyeParameters(whichEye: string): VREyeParameters;
  130140. /**
  130141. * Populates the passed VRFrameData with the information required to render
  130142. * the current frame.
  130143. * @param frameData Define the data structure to populate
  130144. * @returns true if ok otherwise false
  130145. */
  130146. getFrameData(frameData: VRFrameData): boolean;
  130147. /**
  130148. * Get the layers currently being presented.
  130149. * @returns the list of VR layers
  130150. */
  130151. getLayers(): VRLayer[];
  130152. /**
  130153. * Return a VRPose containing the future predicted pose of the VRDisplay
  130154. * when the current frame will be presented. The value returned will not
  130155. * change until JavaScript has returned control to the browser.
  130156. *
  130157. * The VRPose will contain the position, orientation, velocity,
  130158. * and acceleration of each of these properties.
  130159. * @returns the pose object
  130160. */
  130161. getPose(): VRPose;
  130162. /**
  130163. * Return the current instantaneous pose of the VRDisplay, with no
  130164. * prediction applied.
  130165. * @returns the current instantaneous pose
  130166. */
  130167. getImmediatePose(): VRPose;
  130168. /**
  130169. * The callback passed to `requestAnimationFrame` will be called
  130170. * any time a new frame should be rendered. When the VRDisplay is
  130171. * presenting the callback will be called at the native refresh
  130172. * rate of the HMD. When not presenting this function acts
  130173. * identically to how window.requestAnimationFrame acts. Content should
  130174. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130175. * asynchronously from other displays and at differing refresh rates.
  130176. * @param callback Define the eaction to run next frame
  130177. * @returns the request handle it
  130178. */
  130179. requestAnimationFrame(callback: FrameRequestCallback): number;
  130180. /**
  130181. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130182. * Repeat calls while already presenting will update the VRLayers being displayed.
  130183. * @param layers Define the list of layer to present
  130184. * @returns a promise to know when the request has been fulfilled
  130185. */
  130186. requestPresent(layers: VRLayer[]): Promise<void>;
  130187. /**
  130188. * Reset the pose for this display, treating its current position and
  130189. * orientation as the "origin/zero" values. VRPose.position,
  130190. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130191. * updated when calling resetPose(). This should be called in only
  130192. * sitting-space experiences.
  130193. */
  130194. resetPose(): void;
  130195. /**
  130196. * The VRLayer provided to the VRDisplay will be captured and presented
  130197. * in the HMD. Calling this function has the same effect on the source
  130198. * canvas as any other operation that uses its source image, and canvases
  130199. * created without preserveDrawingBuffer set to true will be cleared.
  130200. * @param pose Define the pose to submit
  130201. */
  130202. submitFrame(pose?: VRPose): void;
  130203. }
  130204. declare var VRDisplay: {
  130205. prototype: VRDisplay;
  130206. new(): VRDisplay;
  130207. };
  130208. interface VRLayer {
  130209. leftBounds?: number[] | Float32Array | null;
  130210. rightBounds?: number[] | Float32Array | null;
  130211. source?: HTMLCanvasElement | null;
  130212. }
  130213. interface VRDisplayCapabilities {
  130214. readonly canPresent: boolean;
  130215. readonly hasExternalDisplay: boolean;
  130216. readonly hasOrientation: boolean;
  130217. readonly hasPosition: boolean;
  130218. readonly maxLayers: number;
  130219. }
  130220. interface VREyeParameters {
  130221. /** @deprecated */
  130222. readonly fieldOfView: VRFieldOfView;
  130223. readonly offset: Float32Array;
  130224. readonly renderHeight: number;
  130225. readonly renderWidth: number;
  130226. }
  130227. interface VRFieldOfView {
  130228. readonly downDegrees: number;
  130229. readonly leftDegrees: number;
  130230. readonly rightDegrees: number;
  130231. readonly upDegrees: number;
  130232. }
  130233. interface VRFrameData {
  130234. readonly leftProjectionMatrix: Float32Array;
  130235. readonly leftViewMatrix: Float32Array;
  130236. readonly pose: VRPose;
  130237. readonly rightProjectionMatrix: Float32Array;
  130238. readonly rightViewMatrix: Float32Array;
  130239. readonly timestamp: number;
  130240. }
  130241. interface VRPose {
  130242. readonly angularAcceleration: Float32Array | null;
  130243. readonly angularVelocity: Float32Array | null;
  130244. readonly linearAcceleration: Float32Array | null;
  130245. readonly linearVelocity: Float32Array | null;
  130246. readonly orientation: Float32Array | null;
  130247. readonly position: Float32Array | null;
  130248. readonly timestamp: number;
  130249. }
  130250. interface VRStageParameters {
  130251. sittingToStandingTransform?: Float32Array;
  130252. sizeX?: number;
  130253. sizeY?: number;
  130254. }
  130255. interface Navigator {
  130256. getVRDisplays(): Promise<VRDisplay[]>;
  130257. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130258. }
  130259. interface Window {
  130260. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130261. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130262. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130263. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130264. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130265. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130266. }
  130267. interface Gamepad {
  130268. readonly displayId: number;
  130269. }
  130270. type XRSessionMode =
  130271. | "inline"
  130272. | "immersive-vr"
  130273. | "immersive-ar";
  130274. type XRReferenceSpaceType =
  130275. | "viewer"
  130276. | "local"
  130277. | "local-floor"
  130278. | "bounded-floor"
  130279. | "unbounded";
  130280. type XREnvironmentBlendMode =
  130281. | "opaque"
  130282. | "additive"
  130283. | "alpha-blend";
  130284. type XRVisibilityState =
  130285. | "visible"
  130286. | "visible-blurred"
  130287. | "hidden";
  130288. type XRHandedness =
  130289. | "none"
  130290. | "left"
  130291. | "right";
  130292. type XRTargetRayMode =
  130293. | "gaze"
  130294. | "tracked-pointer"
  130295. | "screen";
  130296. type XREye =
  130297. | "none"
  130298. | "left"
  130299. | "right";
  130300. interface XRSpace extends EventTarget {
  130301. }
  130302. interface XRRenderState {
  130303. depthNear?: number;
  130304. depthFar?: number;
  130305. inlineVerticalFieldOfView?: number;
  130306. baseLayer?: XRWebGLLayer;
  130307. }
  130308. interface XRInputSource {
  130309. handedness: XRHandedness;
  130310. targetRayMode: XRTargetRayMode;
  130311. targetRaySpace: XRSpace;
  130312. gripSpace: XRSpace | undefined;
  130313. gamepad: Gamepad | undefined;
  130314. profiles: Array<string>;
  130315. }
  130316. interface XRSession {
  130317. addEventListener: Function;
  130318. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130319. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130320. requestAnimationFrame: Function;
  130321. end(): Promise<void>;
  130322. renderState: XRRenderState;
  130323. inputSources: Array<XRInputSource>;
  130324. }
  130325. interface XRReferenceSpace extends XRSpace {
  130326. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130327. onreset: any;
  130328. }
  130329. interface XRFrame {
  130330. session: XRSession;
  130331. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130332. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130333. }
  130334. interface XRViewerPose extends XRPose {
  130335. views: Array<XRView>;
  130336. }
  130337. interface XRPose {
  130338. transform: XRRigidTransform;
  130339. emulatedPosition: boolean;
  130340. }
  130341. declare var XRWebGLLayer: {
  130342. prototype: XRWebGLLayer;
  130343. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130344. };
  130345. interface XRWebGLLayer {
  130346. framebuffer: WebGLFramebuffer;
  130347. framebufferWidth: number;
  130348. framebufferHeight: number;
  130349. getViewport: Function;
  130350. }
  130351. interface XRRigidTransform {
  130352. position: DOMPointReadOnly;
  130353. orientation: DOMPointReadOnly;
  130354. matrix: Float32Array;
  130355. inverse: XRRigidTransform;
  130356. }
  130357. interface XRView {
  130358. eye: XREye;
  130359. projectionMatrix: Float32Array;
  130360. transform: XRRigidTransform;
  130361. }
  130362. interface XRInputSourceChangeEvent {
  130363. session: XRSession;
  130364. removed: Array<XRInputSource>;
  130365. added: Array<XRInputSource>;
  130366. }